ECE 501 - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

ECE 501

Description:

... to algorithm used to multiply by hand. Multiplying two n-bit numbers can result ... Exponent is the power of 2 to multiply the fraction by to get the number ... – PowerPoint PPT presentation

Number of Views:71
Avg rating:3.0/5.0
Slides: 20
Provided by: johngwe
Category:
Tags: ece | multiply

less

Transcript and Presenter's Notes

Title: ECE 501


1
ECE 501
  • Session 9
  • Dr. John G. Weber
  • KL-241E
  • 229-3182
  • John.Weber_at_notes.udayton.edu
  • jweber-1_at_woh.rr.com
  • http//academic.udayton.edu/JohnWeber

2
Multiplication
  • Fixed Point
  • Unsigned
  • Signed
  • Floating Point

3
Fixed Point Unsigned Multiplication
  • Similar to algorithm used to multiply by hand
  • Multiplying two n-bit numbers can result in a
    2n-bit product

4
Combinatorial Multiplier
B1 B0 A1 A0
A0B1 A0B0 A1B1
A1B0 _____________________________ S3
S2 S1 S0
NOTE S0 A0B0 S1 A0B1
A1B0 S2 A1B1A0B1
A1B0 S3 A1B1A0B1
A1B0
5
Combinatorial Multiplier
6
Sequential MultiplierHardware Implementation of
Unsigned Multiply
7
Multiply Process
  • Clear A and C
  • Put multiplicand in M and multiplier in Q
  • If q0 is one, add multiplicand to A, then shift
    C,A,Q to right (fill C with a zero from the left)
  • Continue process until n steps (four in example)
    have been completed
  • n is the number of bits in the multiplier

Multiplicand 1101 Initial Value
C A Q 0
0000 1011 Initial
Value n 4 0 1101
1011 Add M to A 0
0110 1101 Shift Right one
position n 3 1 0011
1101 Add M to A 0 1001
1110 Shift Right one position n 2
0 0100 1111 Shift Right one
position (No Add) n 1 1
0001 1111 Add M to A 0
1000 1111 Shift Right one position (A,Q
contains product) n 0
8
Verilog (Note This code is not fully debugged)
//mul_4_u.v //unsigned 4 bit multiplier module
mul_4_u(Min, Qin,Prod,strt, clk) parameter
width 4, count4 input strt, clk input
width-10 Min, Qin output 2width-10
Prod reg width-10 M,A,Q,Cnt reg
2width-10 Prod reg C
9
Verilog (cont)
always _at_(posedge clk or posedge strt) if
(strt) begin M Min //note use of
blocking operators A 4'b0000 Q
Qin Cnt 4'b0100 C 0
end else if (Cnt ! 0) case
(Q0) 0 begin
Awidth-10,Qwidth-10C,Awidth-10,Qwid
th-11 C0 Cnt Cnt-1
end 1 begin C,A M
A Awidth-10,Qwidth-10C,Awidth-10
,Qwidth-11 C0 Cnt Cnt-1
end endcase else Prod
Awidth-10,Qwidth-10 endmodule
10
Simulation
11
Signed Multiplication
  • Approach 1
  • Use unsigned multiplier
  • Sign of answer is XOR of signs of multiplicand
    and multiplier
  • Complement negative numbers and multiply as
    unsigned
  • Add sign bit at end
  • Approach 2
  • Extend multiplier to work with twos complement
    numbers directly
  • Extend sign of negative numbers to full width
  • Multiply as before
  • Retain rightmost n bits

12
Example
1111 (-1)10 0001 (1)10 1111
0000 0000 0000 00001111
(15)10
11111111 (-1)10 0001 (1)10 11111111 00000
00 000000 00000 11111111 (-1)10
13
Using the previous hardware
Multiplicand 1111 Initial Value
C A Q 1
0000 0001 Initial Value
1 1111 0001 Add M to
A 1 1111
1000 Shift Right one position 1
1111 1100 Shift Right one position
1 1111 1110 Shift Right one
position (No Add) 1 1111
1111 Shift Right one position (A,Q contains
product)
Works by shifting in sign bit of multiplicand
14
Timing
  • This algorithm requires a maximum of n shifts and
    n adds or 2n total operations
  • Speed up by parallel multiplier or rework
    algorithm
  • Rework Approaches
  • Booth
  • Shifts over ones
  • String of ones in the multiplier from bit u to
    bit v
  • Equivalent to 2u1 2v
  • booth algorithm recodes the multiplier to this
    form

15
Example
010101 (21)10 Multiplicand 001110 (14)10
Multiplier 010010 Booth Recoded
Multiplier 111111010110 (-21x2)10 00010101000
0 (21x16)10 000100100110 (294)10
Shift
Add
Subtract
16
Booths Algorithm
  • Works for twos complement numbers
  • Does not always reduce the number of operations
  • Can compensate by encoding multiple bits
  • Worst case n shifts and n/2 adds/subtracts or 1.5
    n operations

17
Floating Point Numbers
S
Exponent
Fraction
  • S is the sign of the number
  • Exponent is the power of 2 to multiply the
    fraction by to get the number
  • Fraction contains the significant bits of the
    number, normalized to have a non-zero leading bit

18
Exponents
  • Exponents may be positive of negative
  • Offset notation is most widely used
  • e.g. An 8-bit exponent field may contain numbers
    between 0 and 255
  • IEEE Single Precision Format

19
Floating Point Operations
  • Addition and Subtraction
  • Adjust fractions and exponents so that exponents
    are equal
  • Add or subtract fractions
  • Normalize result
  • Multiplication
  • Compute sign of result, multiply fractions and
    add exponents
  • Normalize result
  • Division
  • Compute sign of result, divide fractions,
    subtract exponents
  • Normalize result
Write a Comment
User Comments (0)
About PowerShow.com