DOC PREVIEW
U of I CS 231 - Addition and multiplication

This preview shows page 1-2-3-24-25-26-27-48-49-50 out of 50 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 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 50 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 50 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 50 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 50 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 50 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 50 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 50 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 50 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 50 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Addition and multiplicationBinary addition by handAdding two bitsAdding three bitsFull adder equationsFull adder circuitA 4-bit adderAn example of 4-bit additionOverflowHierarchical adder designGate delaysDelays in the ripple carry adderA faster way to compute carry outsA Note On PropagationAlgebraic carry out hocus-pocusA 4-bit carry lookahead adder circuitCarry lookahead addersAddition summaryMultiplicationBinary multiplication exampleA 2x2 binary multiplierA 4x4 multiplier circuitMore on multipliersMultiplication: a special caseAddition and multiplication summaryNegative Numbers and SubtractionSigned magnitude representationSigned magnitude operationsOne’s complement representationWhy is it called “one’s complement?”One’s complement additionWhy does this work (roughly)?Two’s complementMore about two’s complementTwo’s complement additionAnother two’s complement exampleWhy does this work?Comparing the signed number systemsRanges of the signed number systemsConverting signed numbers to decimalExample solutionSigned Numbers are Sign-Extended to Infinity!Making a subtraction circuitA two’s complement subtraction circuitSmall differencesAn adder-subtractor circuitSigned overflowDetecting signed overflowSign extensionSubtraction summaryBinary Arithmetic 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.Binary Arithmetic 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!1 1 1 0 Carry in1 0 1 1 Augend+ 1 1 1 0 Addend1 1 0 0 1 SumThe initial carryin is implicitly 0most significantbit, or MSBleast significantbit, or LSBBinary Arithmetic 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 S0 0 0 00 1 0 11 0 0 11 1 1 00 + 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.Binary Arithmetic 4Adding three bits•But what we really need to do is add three bits: the augend and addend, and the carry in from 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 CinCoutS0 0 0 0 00 0 1 0 10 1 0 0 10 1 1 1 01 0 0 0 11 0 1 1 01 1 0 1 01 1 1 1 1(These are the same functions from the decoder and mux examples.)1 1 1 01 0 1 1+ 1 1 1 01 1 0 0 1Binary Arithmetic 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 CinCoutS0 0 0 0 00 0 1 0 10 1 0 0 10 1 1 1 01 0 0 0 11 0 1 1 01 1 0 1 01 1 1 1 1Binary Arithmetic 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 + XYBinary Arithmetic 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!Binary Arithmetic 8An example of 4-bit addition•Let’s try our initial example: A=1011 (eleven), B=1110 (fourteen).1 1 1 0 1 1 0 101. Fill in all the inputs, including CI=01 15. 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).Binary Arithmetic 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.Binary Arithmetic 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.Binary Arithmetic 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 delaysBinary Arithmetic 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, B0 and CI “ripple” leftwards until CO and S3 are produced.•Ripple carry adders are slow!–Our example addition with 4-bit inputs required 5 “steps.”–There is a very long path from A0,


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?