Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor: Alexander Stoytchev CprE 281: Digital Logic.

Similar presentations


Presentation on theme: "Instructor: Alexander Stoytchev CprE 281: Digital Logic."— Presentation transcript:

1 Instructor: Alexander Stoytchev http://www.ece.iastate.edu/~alexs/classes/ CprE 281: Digital Logic

2 Multiplication CprE 281: Digital Logic Iowa State University, Ames, IA Copyright © Alexander Stoytchev

3 Administrative Stuff HW 6 is out It is due next Monday (Oct 14) Wednesday (Oct 16)

4 Quick Review

5 The story with floats is more complicated IEEE 754-1985 Standard [http://en.wikipedia.org/wiki/IEEE_754]

6 In the example shown above, the sign is zero so s is +1, the exponent is 124 so e is −3, and the significand m is 1.01 (in binary, which is 1.25 in decimal). The represented number is therefore +1.25 × 2 −3, which is +0.15625. [http://en.wikipedia.org/wiki/IEEE_754]

7 Figure 3.37. IEEE Standard floating-point formats. Sign 32 bits 23 bits of mantissa excess-127 exponent 8-bit 52 bits of mantissa11-bit excess-1023 exponent 64 bits Sign SM SM (a) Single precision (b) Double precision E + E 0 denotes – 1 denotes

8 On-line IEEE 754 Converters http://www.h-schmidt.net/FloatApplet/IEEE754.html http://babbage.cs.qc.edu/IEEE-754/Decimal.html

9

10 Decimal Multiplication What happens when we multiply a number by 10? 4 x 10 = ? 542 x 10 = ? 1245 x 10 = ?

11 Decimal Division What happens when we divide a number by 10? 14 / 10 = ? 540 / 10 = ? 1240 x 10 = ?

12 Decimal Division What happens when we divide a number by 10? 14 / 10 = ? 540 / 10 = ? 1240 x 10 = ?

13 Binary Multiplication by 2 What happens when we multiply a number by 2? 011 times 2 = ? 101 times 2 = ? 110011 times 2 = ?

14 Binary Multiplication by 2 What happens when we multiply a number by 2? 011 times 2 = 0110 101 times 2 = 1010 110011 times 2 = 1100110 You simply add a zero as the rightmost number

15 Binary Multiplication by 4 What happens when we multiply a number by 4? 011 times 4 = ? 101 times 4 = ? 110011 times 4 = ?

16 Binary Multiplication by 4 What happens when we multiply a number by 4? 011 times 4 = 01100 101 times 4 = 10100 110011 times 4 = 11001100 add two zeros in the last two bits and shift everything else to the left

17 Binary Multiplication by 2 N What happens when we multiply a number by 2 N ? 011 times 2 N = 01100…0 // add N zeros 101 times 4 = 10100…0 // add N zeros 110011 times 4 = 11001100…0 // add N zeros

18 Binary Division by 2 What happens when we divide a number by 2? 0110 divided 2 = ? 101 times 2 = ? 110011 times 2 = ?

19 Decimal Multiplication By Hand [http://www.ducksters.com/kidsmath/long_multiplication.php]

20 Binary Multiplication By Hand [Figure 3.34a from the textbook]

21 Binary Multiplication By Hand [Figure 3.34b from the textbook]

22 Binary Multiplication By Hand [Figure 3.34c from the textbook]

23 Figure 3.34. Multiplication of unsigned numbers.

24 Figure 3.35. A 4x4 multiplier circuit.

25 Positive Multiplicand Example 0 0 1 1 1 0 0 1 0 1 1 0 0 1 1 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 Multiplicand M Multiplier Q Product P (+14) (+11) (+154) + + 00 0 1 0 1 0 0 0 1 1 1 0+ 00 1 0 0 1 1 0 0 0 0 0 0+ 0 0 1 0 0 1 1 0 1 0 Partial product 0 Partial product 1 Partial product 2 Partial product 3 x [Figure 3.36a in the textbook]

26 Negative Multiplicand Example  1 1 0 0 1 0 0 1 0 1 1 11 0 0 1 0 11 0 1 0 1 1 00 0 0 0 0 Multiplicand M Multiplier Q Product P ( 14) (+11) ( 154) + + 11 1 0 1 0 1 11 0 0 1 0+ 11 0 1 1 0 0 0 0 0 0 0 0+ 1 1 0 1 1 0 0 1 1 0 Partial product 0 Partial product 1 Partial product 2 Partial product 3 – – [Figure 3.36b in the textbook]

27 Binary Coded Decimal

28 Table 3.3. Binary-coded decimal digits.

29 Figure 3.38. Addition of BCD digits.

30 Figure 3.39. Block diagram for a one-digit BCD adder.

31 modulebcdadd(Cin,X,Y,S, Cout); inputCin; input[3:0] X,Y; outputreg [3:0] S; outputreg Cout; reg[4:0] Z; always@ (X,Y,Cin) begin Z=X+Y+Cin; if(Z<10) {Cout,S}=Z; else {Cout,S}=Z+6; end endmodule Figure 3.40. Verilog code for a one-digit BCD adder.

32 Figure 3.41. Circuit for a one-digit BCD adder.

33 Questions?

34 THE END


Download ppt "Instructor: Alexander Stoytchev CprE 281: Digital Logic."

Similar presentations


Ads by Google