Recall that when you add two numbers (in base 10), you find the sum of each column including any carried value from the previous column.
The same procedure is used to add two numbers in base 2.
Boolean Operators each take two Boolean values (true
or false
) as input and report a single bit (a single Boolean value) as output. This is unlike the basic operations used in math. For example in addition, the sum of two single-bit values can have a two-bit result: 1 + 1 = 10 in binary. So things like arithmetic circuitry are built out of Boolean circuitry.
A half-adder adds two binary digits (with no carry in) and reports the sum and the carry out value. If you look at the "SUM" column you will notice that it is identical to the output column of XOR and if you look at the "CARRY" column you will notice that it is identical to the output column of AND.
A full-adder uses two half-adders to perform a full addition of binary digits accomodating a carry in value. It reports the sum and carry out value.
CARRY IN
, A
and B
, have been written for you. For the sprites SUM1
, CARRY1
, SUM OUT
, CARRY2
, CARRY OUT
, assemble some code blocks to emulate a full-adder.Binary addition: I think this is kind of backwards. It introduces "carry out" and "carry in" as technical terms before indicating why they're important, namely, adding more than one-bit-wide numbers. 1. Do a base 10 addition that involves carrying, and introduce the idea that, e.g., the "carry out" from the tens column is the "carry in" to the hundreds column. 2. Do the same thing in binary, with the difference that the carry signals are just a single wire wide. 3. Show a single-bit slice of the addition to show that the + circuit needs /three/ inputs and /two/ outputs. 4. Draw a ripple adder, to show how the Carry Out from one bit slice becomes the Carry In for the next-left bit slice. 5. Now you're ready to say that the traditional way to build a one-bit-wide adder is to start with a circuit called a half-adder that has a carry out but no carry in. 6. Draw this picture: +----------+ A ----->| |-----> Sum |half adder| B ----->| |-----> Carry Out +----------+ and then /have the students build it!/ No leading them by the nose ring. If you must, have a /hidden/ hint that just says "Draw a truth table for Sum and another truth table for Carry Out." 7. Show the figure with two half adders cascaded, but leaving out the OR gate and the three output labels. Have the students draw the rest of the circuit, after reminding them that they're supposed to produce two outputs, Sum and Carry Out. Also remind them that /each half-adder/ has outputs called Sum and Carry Out, and that the full adder has its own outputs with the same name, and all three are distinct. I think it should say someplace that computers today don't really use these simple ripple carry circuits because they're too slow; each bit has to wait for the bit to its right before it can figure out its own output. So, TIF A: How do computers /really/ add binary integers? TIF B has two parts, each with pitfalls. To do subtraction, you really have to first understand twos complement. As for multiplication, as I said earlier, there's the simple way (shift and add), and then there's the real way (much more complicated, involving, I think, table lookup for slices of four or eight bits).
A half-adder adds two binary digits and reports the sum and the carry over value. If you look at the "SUM" column you will notice that it is identical to the output column of XOR and if you look at the "CARRY" column you will notice that it is identical to the output column of AND.
A full-adder uses two half-adders to perform a full addition of binary digits with a carry in value. It reports the sum and carry out value.
CARRY IN
, A
and B
, have been written for you. For the sprites SUM1
, CARRY1
, SUM OUT
, CARRY2
, CARRY OUT
, assemble some code blocks to emulate a full-adder.