09-AdditionMultiplic - Addition and multiplication Arithmetic is the most basic thing you can do with a computer but its not as easy as you might

This preview shows pages 1–7. Sign up to view the full content.

Addition and multiplication 1 Addition 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.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Addition and multiplication 2 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! 1 1 1 0 Carry in 1 0 1 1 Augend + 1 1 1 0 Addend 1 1 0 0 1 Sum The initial carry in is implicitly 0 most significant bit , or MSB least significant bit , or LSB
Addition and multiplication 3 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. X Y C S 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 C = XY S = X’ Y + X Y’ = X Y Be careful! Now we’re using + for both arithmetic addition and the logical OR operation.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Addition and multiplication 4 Adding 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 = 00 0 + 0 + 0 = 01 0 + 1 + 0 = 01 0 + 1 + 1 = 10 1 + 0 + 0 = 01 1 + 0 + 1 = 10 1 + 1 + 0 = 10 1 + 1 + 1 = 11 X Y C in C out S 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 (These are the same functions from the decoder and mux examples.) 1 1 1 0 1 0 1 1 + 1 1 1 0 1 1 0 0 1
Addition and multiplication 5 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. S = Σ m(1,2,4,7) = X’ Y’ C in + X’ Y C in + X Y’ C in + X Y C in = X’ (Y’ C in + Y C in ’) + X (Y’ C in ’ + Y C in ) = X’ (Y C in ) + X (Y C in )’ = X Y C in C out = Σ m(3,5,6,7) = X’ Y C in + X Y’ C in + X Y C in ’ + X Y C in = (X’ Y + X Y’) C in + XY(C in ’ + C in ) = (X Y) C in + XY X Y C in C out S 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document