Intro to Arithmetic Circuits

- The second major category of circuits found inside the CPU are
circuits that do computations: addition, subtraction,
multiplication and division.
We will not look at every single circuit....

- I will discuss the addition circuit in class
and project 2
( click here)
will let you design a multiply circuit.
Subtraction can be do via addition, since

- a - b = a + (-b)
- -b can be obtained by flipping the bits of b and then add 1 to the result (this method was/should have been explained in CS255, if you forgot it, check this out: click here
- Conclusion: a subtract circuit can be constructed using an addition circuit...

Finally, division circuits are hard to construct and not worth the time to study them because we don't use them in the course. It will be be productive to use the time to study other issues of computer architecture, like pipeline and caching.

After the treatise, you will be able to construct circuits that do addition, subtraction and multiplication... 3 out of 4 ain't bad...

- The adder digital circuit
- An adder circuit has 2N inputs and N+1 outputs.
- The inputs of an adder circuit are two N-bit (binary) numbers
- N outputs will represent the sum of the two input numbers
- 1 output wiill represent the carry output

The following figure shows a 4-bit adder circuit and an example of its operation:

- The inputs b
_{3}b_{2}b_{1}b_{0}represents the first (4 bit) binary number - the inputs a
_{3}a_{2}a_{1}a_{0}represent the second number. - The outputs s
_{3}s_{2}s_{1}s_{0}is the sum and the output**c**is the carry. - The figure on the left should the operation of the adder circuit.

The circuit is adding the two 4-bit numbers 1010 + 1011.

- Let us try to design this circuit naively using the circuit design
method that we learned
a week ago ( click here):
- We would have a table consisting of 8 input columns and the table will have 256 (!!!) rows.
- There will be 5 output columns, with a total number of 5x256 = 1280 entries
- For every non-empty entry in the right hand size columns,
you need an
**and**gate with 8 inputs. With a total of 1280 entries, we can estimate that about half of them are 1 (since each entry can be 0 or 1, it's reasonable to assume you have half of each), you will need 640 and gates... - In other words: it's a pretty ugly business making this circuit....

- So what's the alternative ?
- We can get some idea on how to construct adder circuits by
looking at what homo sapiens do:
**staged addition** - When homo sapiens add two binary numbers, they add
**two bits**at a time, starting from the right... - At each stage, a
**carry**may be generated that can affect the outcome of the bit-addition in the next stage: - Let's design a "staged adder" circuit....

- We can get some idea on how to construct adder circuits by
looking at what homo sapiens do: