CODE
The Hidden Language of Computer Hardware and Software
2nd Edition

Chapter 14. Adding with Logic Gates

Addition is the most basic arithmetic operation. This chapter demonstrates how logic gates can add binary numbers. In all these circuits, you select the digits to be added using the square buttons. You can toggle these buttons with mouse clicks or finger taps. The output is shown in the circles.

All the gates in these animations have their propagation times set to 100 milliseconds (1/10th second). When you toggle one of the switches, you can see the bits propagating from left to right.

One-Bit Sum (pages 174)

The journey of a complex adder begins with a single bit sum:

Your browser does not support the canvas element.

One-Bit Half Adder (page 176)

That sum must be supplemented with a Carry bit. Although the sum part of this circuit is shown in the book as an Exclusive-OR (XOR) gate, the individual gates are shown here:

Your browser does not support the canvas element.

One-Bit Full Adder (pages 177)

Two adders are required to accomodate a Carry In bit. In the book, this is shown with a pair of half-adders encapsulated in a box, but here all the separate gates are shown.

Your browser does not support the canvas element.

Eight-Bit Adder (pages 180)

Finally, entire bytes can be added by cascading eight one-bit adders. The diagram in the book shows the encapsulated full adders but this animation shows all the individual logic gates.

Select the two binary values to be added by clicking or tapping the square buttons at the top. The values in hexadecimal and decimal are shown at the far right. The binary result is shown in the circles at the bottom, and the hexadecimal and decimal equivalents are shown at the far right.

Your browser does not support the canvas element.

This circuit implements a ripple carry. The Carry Out from each bit must be calculated for the Carry In of the next most significant digit. To see the full propagation delay, try setting the entire row of top buttons to 1, and then use the buttons in the second row to add 1 to that.