DOC PREVIEW
U of I CS 231 - Addition and multiplication

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

September 29, 2003 Addition and multiplication 1Addition and multiplication• 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.September 29, 2003 Addition and multiplication 2Binary 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!1110 Carry in1011 Augend+ 1110 Addend1 1 0 0 1 SumThe initial carryin is implicitly 0most significantbit, or MSBleast significantbit, or LSBSeptember 29, 2003 Addition and multiplication 3Adding 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.X Y C S000 0010 1100 111100+ 0 = 00+ 1 = 11+ 0= 11+ 1 = 10C= XYS = X’ Y + X Y’= X ⊕ YBe careful! Now we’re using +for both arithmetic addition and the logical OR operation.September 29, 2003 Addition and multiplication 4Adding three bits• But what we really need to do is add threebits: the augend and addend, and the carry infrom the right.0+ 0+ 0= 000+ 0+ 0= 010+ 1 + 0= 010 + 1 + 1 = 101+ 0+ 0= 011 + 0 + 1 = 101 + 1 + 0 = 101 + 1 + 1 = 11X Y CinCoutS00 0 0 000 1 0 101 0 0 101 1 1 010 0 0 110 1 1 011 0 1 011 1 1 1(These are the same functions from the decoder and mux examples.)11101011+ 111011001September 29, 2003 Addition and multiplication 5Full 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.S= Σm(1,2,4,7)= X’ Y’ Cin+ X’ Y Cin’ + X Y’ Cin’ + X Y Cin= X’ (Y’ Cin+ Y Cin’) + X (Y’ Cin’ + Y Cin)= X’ (Y ⊕ Cin) + X (Y ⊕ Cin)’= X ⊕ Y ⊕ CinCout= Σm(3,5,6,7)= X’ Y Cin+ X Y’ Cin+ X Y Cin’ + X Y Cin= (X’ Y + X Y’) Cin+ XY(Cin’ + Cin)= (X ⊕ Y) Cin+ XYX Y CinCoutS00 0 0 000 1 0 101 0 0 101 1 1 010 0 0 110 1 1 011 0 1 011 1 1 1September 29, 2003 Addition and multiplication 6Full adder circuit• These things are called half adders and full adders because you can build a full adder by putting together two half adders!S= X ⊕ Y ⊕ CinCout= (X ⊕ Y) Cin+ XYSeptember 29, 2003 Addition and multiplication 7A 4-bit adder• Four full adders together make a 4-bit adder.• There are nine total inputs:– Two 4-bit numbers, A3 A2 A1 A0 and B3 B2 B1 B0– An initial carry in, CI• The five outputs are:– A 4-bit sum, S3 S2 S1 S0– A carry out, CO• Imagine designing a nine-input adder without this hierarchical structure—you’d have a 512-row truth table with five outputs!September 29, 2003 Addition and multiplication 8An example of 4-bit addition• Let’s try our initial example: A=1011 (eleven), B=1110 (fourteen).11 10 11 0101. Fill in all the inputs, including CI=0115. Use C3 to compute CO and S3 (1 + 1 + 1 = 11)02. The circuit produces C1 and S0 (1 + 0 + 0 = 01)113. Use C1 to find C2 and S1 (1 + 1 + 0 = 10)014. Use C2 to compute C3 and S2 (0 + 1 + 1 = 10)0Woohoo! The final answer is 11001 (twenty-five).September 29, 2003 Addition and multiplication 9Overflow• 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.September 29, 2003 Addition and multiplication 10Hierarchical 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.• CI is also useful for subtraction, as we’ll see next week.September 29, 2003 Addition and multiplication 11Gate delays• Every gate takes some small fraction of a second between the time inputs are presented and the time the correct answer appears on the outputs. This little fraction of a second is called a gate delay.• There are actually detailed ways of calculating gate delays that can get quite complicated, but for this class, let’s just assume that there’s some small constant delay that’s the same for all gates.• We can use a timing diagram to show gate delays graphically.xx’10gate delaysSeptember 29, 2003 Addition and multiplication 12Delays in the ripple carry adder• The diagram below shows a 4-bit adder completely drawn out.• This is called a ripple carry adder, because the inputs A0, B0and CI “ripple” leftwards until CO and S3are produced.• Ripple carry adders are slow!– Our example addition with 4-bit inputs required 5 “steps.”– There is a very long path from A0, B0and CI to CO and S3.– For an n-bit ripple carry adder, the longest path has 2n+1 gates.– Imagine a 64-bit adder. The longest path would have 129 gates!123456789September 29, 2003 Addition and multiplication 13A faster way to compute carry outs• Instead of waiting for the carry out from all the previous stages, we could compute it directly with a two-level circuit, thus minimizing the delay.• First we define two functions.– The “generate” function giproduces 1 when there mustbe a carry out from position i (i.e., when Aiand Biare both 1).gi= AiBi– The “propagate” function piis true when, if there is an incoming carry, it is propagated (i.e, when Ai=1 or Bi=1, but not both).pi= Ai⊕ Bi• Then we can rewrite the carry out function:ci+1= gi+ picigipiAiBiCiCi+100 0 000 1 001 0 001 1 1100 010 1 1110 111 1 1September 29, 2003 Addition and multiplication 14A Note On Propagation• We could have defined propagation as A + B instead of A ⊕ B–


View Full Document

U of I CS 231 - Addition and multiplication

Documents in this Course
Counters

Counters

23 pages

Latches

Latches

22 pages

Lecture

Lecture

33 pages

Lecture

Lecture

16 pages

Lecture

Lecture

4 pages

Datapaths

Datapaths

30 pages

Lecture

Lecture

6 pages

Registers

Registers

17 pages

Datapaths

Datapaths

28 pages

Decoders

Decoders

20 pages

Load more
Download Addition and multiplication
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Addition and multiplication and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Addition and multiplication 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?