Lesson 4 of 4
A full adder and the processor.
Three bits in a column: the full adder, eight of them in a row in a processor's arithmetic unit, binary addition with carries, and what happens when the sum does not fit in a byte.
Step 1 of 5 · A full adder
Step 1 of 5
A full adder
A full adder adds three bits: , , and a carry in from the column to its right. Their sum is between and , so it always fits in two bits: a sum digit and a carry out. It is built from two half adders: the first adds and , the second adds the carry in to the result, and an OR gate joins the two carries.
This is a toy eight-bit processor. Its program adds the First number and the Second number, , and it is now decoding the add instruction. Predict, and then Zoom into the chip will raise a loupe over bit 3 of the arithmetic unit, one full adder, transistor by transistor.
Step 2 of 5
Column addition
Binary addition is the same column addition as at school, only with two digits: from right to left, column by column, and whenever a column reaches 2, write the sum digit and carry 1 to the left. Here is :
Fill in the bottom row.
Step 3 of 5
Eight adders
The arithmetic unit, the ALU, is eight full adders in a row, one per bit. The carry out of each is the carry in of the one to its left. The loupe shows one of them: a CMOS full adder is 28 transistors, and a real processor holds millions of copies of circuits like it.
Step 4 of 5
Overflow
Eight adders hold eight bits, so a result over 255 does not fit. The carry out of the leftmost bit is not lost: the processor keeps it in the carry flag, which a program can test. The numbers here are and . Move Clock tick to run the program, and see what is stored in cell 13.
Step 5 of 5
A byte in memory
The processor’s memory shows each cell as eight bits. The First number is stored in cell 14, and the second in cell 15. When you change the number, you write a new byte into memory.
Loading the interactive version…
Loading the interactive version…
Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.
Practice · Predict, then look
The processor is about to add . The Zoom into the chip loupe will hold bit 3 of the arithmetic unit: a full adder receiving , and a carry in of 1 from the bit to its right. What will it give?
Practice · Predict, then look
The processor is about to add . The Zoom into the chip loupe will hold bit 3 of the arithmetic unit: a full adder receiving , and a carry in of 1 from the bit to its right. What will it give?
Practice · Calculate
The first number is and the second . Add them in base 2, column by column with carries, as the arithmetic unit does. What is the result in base ten?
Practice · Calculate
The first number is and the second . Add them in base 2, column by column with carries, as the arithmetic unit does. What is the result in base ten?
Practice · Choose
This processor’s arithmetic unit adds two bytes. How is it built?
Practice · Choose
This processor’s arithmetic unit adds two bytes. How is it built?
Practice · Calculate
The first number is and the second . The result has to fit in one byte, in cell 13. Which number will be stored there?
Practice · Calculate
The first number is and the second . The result has to fit in one byte, in cell 13. Which number will be stored there?
Practice · Reach the target
Set the First number so that cell 14 holds the byte , and press Check.
Practice · Reach the target
Set the First number so that cell 14 holds the byte , and press Check.
Lesson complete. Every practice question here is done.
