Beruflich Dokumente
Kultur Dokumente
21510
Multiplier
0 0 0 1 0 1 1 1
2310
Shift copies of
the multiplicand
1 1 0 1 0 1 1 1
1 1 0 1 0 1 1 1
1 1 0 1 0 1 1 1
1 1 0 1 0 1 1 1
Double shift
1 0 0 1 1 0 1 0 1 0 0 0 1
494510
24/12/2010
21510
Multiplier
2310
0 0 0 1 0 1 1 1
Accumulated
Partial Products
1 1 0 1 0 1 1 1
Shift copies of
the multiplicand
1 1 0 1 0 1 1 1
1 0 1 0 0 0 0 1 0 1
1 1 0 1 0 1 1 1
1 0 1 1 1 1 0 0 0 0 1
Double shift
1 1 0 1 0 1 1 1
1 0 0 1 1 0 1 0 1 0 0 0 1
494510
24/12/2010
Word2
[-:0]
7
15
Start
Clock
Reset
Sequential
Binary
Multiplier
Ready
Products
[-:0]
16
15
product
multiplier
multiplicand
24/12/2010
Register transfers
product
multiplier
7
15
0
7
multiplicand
0
0
Shift Multiplicant
Shift Multiplicant
0
Shift Multiplicant
Not add
...
Multiplier Algorithms and Architectures
24/12/2010
Structural Units
Top-level module: Multiplier_STG_0
m0: LSB of Multiplier, used to control state transaction
word1 word2
Load_words
Start
Shift
m0
Add
Controller
Datapath
Clock
Reset
m0
Ready
Multiplier Algorithms and Architectures
24/12/2010
Product
Pham Quoc Cuong
6
!Reset/
Ready
Reset
S_Idle
Start/Load_word,
Ready
S_1
[0]/Add
S_8
Ready
![0]
Start/Load_word,
Ready
S_2
![0]/shift
[0]/Add
S_7
Start/Load_word,
Ready
S_1
[0]/Add
S_8
Ready
![0]
-/Shift
Reset
S_Idle
S_2
![0]/shift
[0]/Add
-/Shift
S_7
S_3
-/Shift
![0]/Shift
![0]/Shift
S_3
-/Shift
![0]/Shift
![0]/Shift
[0]/Add
S_6
S_4
[0]/Add
[0]/Add
S_6
S_5
[0]/Add
-/Shift
S_4
24/12/2010
S_5
-/Shift
Module Decleration
module Multiplier_STG_0 (product, Ready, word1, word2, Start, clock, reset);
parameter
L_word = 4;
// Datapath size
output [2*L_word -1: 0] product;
output
Ready;
input [L_word -1: 0]
word1, word2;
input
Start, clock, reset;
wire
m0, Load_words, Shift;
Datapath M1 (product, m0, word1, word2, Load_words, Shift, Add, clock, reset);
Controller M2 (Load_words, Shift, Add, Ready, m0, Start, clock, reset);
endmodule
24/12/2010
Controller (1)
module Controller (Load_words, Shift, Add, Ready, m0, Start, clock, reset);
parameter
L_word = 4;
// Datapath size
parameter
L_state = 4;
// State size
output
Load_words, Shift, Add, Ready;
input
m0, Start, clock, reset;
reg
[L_state -1: 0]
state, next_state;
parameter
S_idle = 0, S_1 = 1, S_2 = 2;
parameter
S_3 = 3, S_4 = 4, S_5 = 5, S_6 = 6;
parameter
S_7 = 7, S_8 = 8;
reg
Load_words, Shift, Add;
wire
24/12/2010
Controller (2)
always @ (state or Start or m0) begin
// Next state and control logic
Load_words = 0; Shift = 0; Add = 0;
case (state)
S_idle: if (Start)
begin Load_words = 1; next_state = S_1; end
else next_state = S_idle;
S_1:
if (m0)
begin Add = 1; next_state = S_2; end
else
begin Shift = 1; next_state = S_3; end
S_2:
begin Shift = 1; next_state = S_3; end
S_3:
if (m0)
begin Add = 1; next_state = S_4; end
else
begin Shift = 1; next_state = S_5; end
S_4:
begin Shift = 1; next_state = S_5; end
S_5:
if (m0)
begin Add = 1; next_state = S_6; end
else
begin Shift = 1; next_state = S_7; end
S_6:
begin Shift = 1; next_state = S_7; end
S_7:
if (m0)
begin Add = 1; next_state = S_8; end
else
begin next_state = S_8; end
S_8:
if (Start)
begin Load_words = 1; next_state = S_1; end
else
next_state = S_8;
default:
next_state = S_idle;
endcase
end
endmodule
24/12/2010
Datapath (1)
module Datapath (product, m0, word1, word2, Load_words, Shift, Add, clock, reset);
parameter
L_word = 4;
output
[2*L_word -1: 0]
product;
output
m0;
input
[L_word -1: 0]
word1, word2;
input
Load_words, Shift, Add, clock, reset;
reg
[2*L_word -1: 0]
product, multiplicand;
reg
[L_word -1: 0]
multiplier;
wire
m0 = multiplier[0];
24/12/2010
Datapath (2)
always @ (posedge clock or posedge reset) begin
if (reset) begin multiplier <= 0; multiplicand <= 0; product <= 0; end
else if (Load_words) begin
multiplicand <= word1;
multiplier <= word2; product <= 0;
end
else if (Shift) begin
multiplier <= multiplier >> 1;
multiplicand <= multiplicand << 1;
end
else if (Add) product <= product + multiplicand;
end
endmodule
24/12/2010
24/12/2010
24/12/2010
24/12/2010
mi-1
BRCi
Value
Status
String of 0s
+1
End of String of 1s
-1
Begin strings of 1s
Midstring of 1s
24/12/2010
Booth recoding
mi
mi-1
BRCi
Value
Status
String of 0s
+1
End of String of 1s
-1
Begin strings of 1s
Midstring of 1s
-6510 =
1 0 1 1 1 1 1 1
2s complement Notation
1 0 1 1 1 1 1 1 0
Additional bit
1 1 0 0 0 0 0 1
Booth Recoded
Signed Digit Notation
24/12/2010
Example
0 0 0 0 1 1 1 1
-6510 =
1 1 0 0 0 0 0 1
-
0 0 0 0 1 1 1 1
Booth Recoded
Signed Digit Notation
0 0 0 0 1 1 1 1
-
0 0 0 0 1 1 1 1
1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 1
2s Complement Notation
0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1
24/12/2010
Reset
S_Idle
Start/Load_word,
Ready
S_1
1/Add
S_8
Ready
0,3/Shift
1/Add
S_7
2/Sub
BRC
S_2
0,3/shift
-/Shift
2/Sub
S_3
-/Shift
S_6
0,3/Shift
1/Add
2/Sub
2/Sub
1/Add
0,3/Shift
S_4
S_5
-/Shift
24/12/2010
Structural Units
Top-level module: Multiplier_Booth_STG_0
m0: LSB of Multiplier, used to control state transaction
word1 word2
Load_words
Start
Shift
m0
Add
Controller
Datapath
Sub
Clock
Reset
m0
Ready
Multiplier Algorithms and Architectures
24/12/2010
Product
Pham Quoc Cuong
20
Module Declarations
module Multiplier_Booth_STG_0 (product, Ready, word1, word2, Start, clock, reset);
parameter
L_word = 4;
parameter
L_BRC = 2;
parameter
All_Ones = {L_word {1'b1}};
parameter
All_Zeros = {L_word {1'b0}};
output
[2*L_word -1: 0]
product;
output
Ready;
input
[L_word -1: 0]
word1, word2;
input
Start, clock, reset;
wire
m0, Load_words, Shift, Add, Sub, Ready;
wire
[L_BRC -1: 0]
BRC;
Datapath_Booth_STG_0 M1 (product, m0, word1, word2, Load_words, Shift, Add, Sub,
clock, reset);
Controller_Booth_STG_0 M2 (Load_words, Shift, Add, Sub, Ready, m0, Start, clock, reset);
endmodule
24/12/2010
Controller (1)
module Controller_Booth_STG_0 (Load_words, Shift, Add, Sub, Ready, m0, Start, clock, reset);
parameter
L_word = 4;
parameter
L_state = 4;
parameter
L_BRC = 2;
output
Load_words, Shift, Add, Sub, Ready;
input
Start, clock, reset;
input
m0;
reg
[L_state -1: 0]
state, next_state;
parameter
S_idle = 0, S_1 = 1, S_2 = 2, S_3 = 3;
parameter
S_4 = 4, S_5 = 5, S_6 = 6, S_7 = 7, S_8 = 8;
reg
Load_words, Shift, Add, Sub;
wire
Ready = (state == S_8);
reg
m0_del;
wire
[L_BRC -1: 0]
BRC = {m0, m0_del}; // Booth recoding bits
always @ (posedge clock or posedge reset)
if (reset) m0_del <= 0; else if (Load_words) m0_del <= 0; else m0_del <= m0;
always @ (posedge clock or posedge reset)
if (reset) state <= S_idle; else state <= next_state;
Multiplier Algorithms and Architectures
24/12/2010
Controller (2)
always @ (state or Start or BRC) begin // Next state and control logic
Load_words = 0; Shift = 0; Add = 0; Sub = 0;
case (state)
S_idle:
if (Start) begin Load_words = 1; next_state = S_1; end
else next_state = S_idle;
S_1: if ((BRC == 0) || (BRC == 3)) begin Shift = 1; next_state = S_3; end
else if (BRC == 1)
begin Add = 1; next_state = S_2; end
else if (BRC == 2)
begin Sub = 1; next_state = S_2; end
S_3: if ((BRC == 0) || (BRC == 3)) begin Shift = 1; next_state = S_5; end
else if (BRC == 1)
begin Add = 1; next_state = S_4; end
else if (BRC == 2)
begin Sub = 1; next_state = S_4; end
24/12/2010
Controller (3)
S_2:
S_4:
S_6:
S_8: if (Start)
else
default:
endcase
end
endmodule
next_state = S_idle;
24/12/2010
Datapath (1)
module Datapath_Booth_STG_0 (product, m0, word1, word2, Load_words,
Shift, Add, Sub, clock, reset);
parameter
L_word = 4;
output
[2*L_word -1: 0] product;
output
m0;
input
[L_word -1: 0]
word1, word2;
input
Load_words, Shift, Add, Sub, clock, reset;
reg
[2*L_word -1: 0] product, multiplicand;
reg
[L_word -1: 0]
multiplier;
wire
m0 = multiplier[0];
parameter
All_Ones = {L_word {1'b1}};
parameter
All_Zeros = {L_word {1'b0}};
24/12/2010
Datapath (2)
always @ (posedge clock or posedge reset) begin
if (reset) begin multiplier <= 0; multiplicand <= 0; product <= 0; end
else if (Load_words) begin
if (word1[L_word -1] == 0) multiplicand <= word1;
// Check sign bit
else multiplicand <= {All_Ones, word1[L_word -1:0]};
multiplier <= word2;
product <= 0;
end
else if (Shift) begin
multiplier <= multiplier >> 1;
multiplicand <= multiplicand << 1;
end
else if (Add) begin product <= product + multiplicand;
end
else if (Sub) begin product <= product - multiplicand;
end
end
endmodule
Multiplier Algorithms and Architectures
24/12/2010