Chaining the columns takes about a minute. What falls off the end of the chain is what nineteen hours of this course have been walking towards.
Collect the send off first: 255 plus 1 in eight bits, and what the last carry did.
Last session you built one column. Here is the rest of the arc.
today, in one line
Line thirty two full adders up and join each carry out to the next carry in. That is the whole construction.
Then feed it two numbers whose answer does not fit, and find out where the missing bit goes.
Everything is drawn with eight columns so it fits on a slide. Real machines use thirty two or sixty four, and none of the argument changes.
Say the eight versus thirty two thing once, clearly, so nobody leaves thinking eight bits is the real machine.
press add a column, and watch what each one needs
Each column makes a carry. Each column also needs one. Join them.
The rightmost carry in has nothing to its right, so it is tied to zero. Somebody always asks.
THAT IS AN ADDER
click any a or b bit, or load one of the presets below
Eight full adders, forty eight gates, one wire between each pair.
IF YOU MEANT UNSIGNED
IF YOU MEANT SIGNED
CARRY OUTthe ninth bit
OVERFLOWthe sign is wrong
TRY
Leave it on 7 + 3. Both readings agree, both lamps dark. That is the boring case, and it will not last.
go back a slide and press 255 + 1 if you want to watch it happen
The largest number it can hold, plus one, comes back as zero.
Not an error. Not a warning. A confident, calm, wrong zero, delivered as fast as any other answer.
And here is the part worth sitting with: every single column got its own column right. Not one full adder made a mistake.
The ninth bit of the answer was computed correctly and then had nowhere to go.
so where did it actually end up
On the carry out wire at the far left, where it has been sitting the whole time.
There were eight sum wires and the answer needed nine digits. The hardware did its job and the container was too small.
That distinction matters. Nothing here is broken, and something has still gone badly wrong.
The hardware is not broken. Say it plainly. Everything after this depends on them accepting it.
HOUR ONE, FINALLY CLOSED
press store to write it into eight bits
A phone that would not boot, and a colour value of 271.
Then go back two slides and run 255 + 16 live. Watching 15 come out of a circuit they built is the payoff.
SO GIVE IT A NAME
The wire has a name, and reading it is somebody else's job.
remember
An adder of fixed width cannot hand you an answer that needs more width. All it can do is tell you it happened.
That one bit becomes an output of the machine alongside the answer, and it is called the carry flag.
Hardware raising a flag and software never looking at it is the single most common shape of arithmetic bug there is.
In C, unsigned overflow is defined to wrap quietly. The flag is right there. The language just does not make you check.
A flag is a notification, not a fix. Notifications get ignored, and this one usually is.
predict the carry lamp before you look · most people get this wrong
Now try 127 plus 1, and watch the flag you just built do nothing.
In two's complement, 127 is the biggest positive number eight bits will hold. Add one and you get the pattern 10000000, which a signed reader calls -128.
Wrong by two hundred and fifty six. And the carry flag stays dark.
Nothing fell off the end. As unsigned, 127 + 1 is 128, and 128 fits perfectly well.
the same eight wires, at the same instant
An unsigned reader looks at that result and is completely satisfied.
A signed reader looks at the same wires and has been lied to.
So the disagreement is not in the hardware. It is in what the two of them thought the bits meant.
Take a show of hands on the carry lamp first. Almost everybody says it lights.
back to the circle from class five · press show the cuts
Two readers, one ring, and they disagree about where it ends.
Two hundred and fifty six patterns in a ring, and counting up walks you round it. Nothing new since Class 5.
But the two readers put the end of the number line in different places on that ring.
so there are two ways to fall off
Step over the unsigned cut and the unsigned answer is wrong.
Step over the signed cut and the signed answer is wrong.
They sit on opposite sides, so crossing one tells you nothing about the other.
Draw the ring on the board and mark both cuts before showing this. Two ends is the idea of the hour.
before hunting for a detector, throw away half the cases
Adding a positive to a negative can never overflow. Ever.
the whole argument, in three lines
If one input is positive and the other is negative, the true answer lies somewhere between them.
Both inputs are representable, and the representable numbers run in one unbroken stretch from -128 to 127.
So anything between two of them is representable too. There is nothing to fall off.
This is not a fact about two's complement. It is true of adding inside any contiguous range at all.
Half of the eight sign combinations die on this slide, which is what makes the next one short.
so it comes down to three bits · filter the rows and look
Same sign in, other sign out. That, and only that, is overflow.
SHOW
Filter to "differ" first: four rows, none of them overflow. Then "agree", and the two failures stand out.
Matching input signs is the condition to check. It is not the answer.
If the two top bits differ, stop looking. There is no overflow, and there cannot be, whatever the result turns out to be.
If they match, then and only then does the result's top bit decide it. Matching means the sign survived. Differing means it was pushed over the cut.
All three bits are needed. Any two of them leave the answer undecided.
written out
V = (sa equals sb) AND (ss differs from sa)
Every one of the eight sign combinations really happens in eight bit arithmetic. None of them is a curiosity.
So a machine could check those three bits on every addition. It turns out it does not have to.
Precondition, not verdict. That phrasing heads off the usual mistake of thinking matching signs alone means overflow.
A CHEAPER PLACE TO LOOK
press next · three rows, and they all end the same way
The sign column is a full adder like any other. Ask what it does to a carry.
Every wire in this table exists in the machine. Nothing here is hypothetical, which is the point.
SAME FLAG, CHEAPER WIRING
Six gates and a long walk, or one gate on wires already there.
The sign rule tells you what overflow means. The sign column tells you the same thing without being asked.
click any box to load it into the adder
Two things can go wrong, independently, so all four combinations occur.
remember
The bits leaving the adder are the same in all four. Only the question being asked of them is different.
The circuit has no way to know which you meant, so it does not try to guess.
It works out both verdicts, raises both flags, and leaves the choice to whoever wrote the program.
All four quadrants hold real eight bit examples. Worth saying: this is not a theoretical taxonomy.
WHAT THE ADDER ACTUALLY OUTPUTS
Eight sum bits, and two separate pieces of bad news.
what this hour taught
Carry says the unsigned answer needed a ninth bit. Overflow says the signed answer came out with the wrong sign.
They are independent, and you have now seen all four combinations of them in ordinary eight bit arithmetic.
This is Class 5 arriving in copper. The bits never carried a meaning, so the hardware works for both meanings at once and lets the software pick.
Every processor you will ever meet has both flags. Now you know why there are two of them.
Class 5 said the machine does not know what its bits mean. This is what that costs: two flags instead of one.
Two down, six to go.
what you are carrying into next session
An adder that is correct on all 65,536 inputs, and honest about both ways it can fail you.
And one thing nobody has looked at yet: how long it takes for the carry to get from the right hand end to the left.
You already own the tool for measuring that. It was the last thing Class 18 gave you.
Set up the measurement now so the send off feels like an obvious next step rather than homework.
The wallpaper crash was never a broken circuit.
It was a correct circuit, raising a flag that nothing downstream was reading. Nineteen hours to explain a bug, and the explanation turned out to be a wire that nobody looked at.
Next session: it is also far too slow to use, and you already have everything you need to prove it.
Stop here. Send off: measure this adder with Class 18's method. Longest path from any input to any output, counted in gates. Bring a number.