14-08-2012, 04:53 PM
Addition and multiplication
09-AdditionMultiplication.ppt (Size: 357 KB / Downloads: 49)
Arithmetic is the most basic thing you can do with a computer, but it’s not as easy as you might expect!
These next few lectures focus on addition, subtraction, multiplication and arithmetic-logic units, or ALUs, which are the “heart” of CPUs.
ALUs are a good example of many of the issues we’ve seen so far, including Boolean algebra, circuit analysis, data representation, and hierarchical, modular design.
Binary addition by hand
You can add two binary numbers one column at a time starting from the right, just as you add two decimal numbers.
But remember that it’s binary. For example, 1 + 1 = 10 and you have to carry!
Adding two bits
We’ll make a hardware adder by copying the human addition algorithm.
We start with a half adder, which adds two bits and produces a two-bit result: a sum (the right bit) and a carry out (the left bit).
Here are truth tables, equations, circuit and block symbol.
Full adder equations
A full adder circuit takes three bits of input, and produces a two-bit output consisting of a sum and a carry out.
Using Boolean algebra, we get the equations shown here.
XOR operations simplify the equations a bit.
We used algebra because you can’t easily derive XORs from K-maps.
Overflow
In this case, note that the answer (11001) is five bits long, while the inputs were each only four bits (1011 and 1110). This is called overflow.
Although the answer 11001 is correct, we cannot use that answer in any subsequent computations with this 4-bit adder.
For unsigned addition, overflow occurs when the carry out is 1.
Hierarchical adder design
When you add two 4-bit numbers the carry in is always 0, so why does the 4-bit adder have a CI input?
One reason is so we can put 4-bit adders together to make even larger adders! This is just like how we put four full adders together to make the 4-bit adder in the first place.
Here is an 8-bit adder, for example.