Datapath & Control Subsystems
Datapath & Control Subsystems
k j i
i k j i
c b a p
1
The ith product term p
i
can be expressed as
Alternate view of multiplication process
a
3
a
2
a
1
a
0
b
3
b
2
b
1
b
0
a
0
) a
1
a
2
(a
3
p
3
p
2
p
1
p
0
p
7
p
6
p
5
p
4
xb
0
a
0
) a
1
a
2
(a
3
xb
1
a
0
) a
1
a
2
(a
3
xb
2
a
0
) a
1
a
2
(a
3
xb
3
(axb
0
)2
0
(axb
1
)2
1
(axb
2
)2
2
(axb
3
)2
3
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 33
Datapath Multipliers
(axb
0
)2
0
(axb
1
)2
1
(axb
2
)2
2
(axb
3
)2
3
7
6 5 4 3 2 1 0 Product register
Using a product register for multiplication
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 34
Datapath Multipliers
add (axb
0
)
shift right
a
3
b
0
Shift-right multiplication sequence
a
2
b
0
a
1
b
0
a
0
b
0
a
3
b
0
a
2
b
0
a
1
b
0
a
0
b
0
a
3
b
0
a
2
b
0
a
1
b
0
a
0
b
0
a
3
b
1
a
2
b
1
a
1
b
1
a
0
b
1
a
3
b
0
a
2
b
0
a
1
b
0
a
0
b
0
a
3
b
1
a
2
b
1
a
1
b
1
a
0
b
1
c
x
c
x
a
3
b
0
a
2
b
0
a
1
b
0
a
0
b
0
a
3
b
1
a
2
b
1
a
1
b
1
a
0
b
1
a
3
b
2
a
2
b
2
a
1
b
2
a
0
b
2
c
y
a
3
b
0
a
2
b
0
a
1
b
0
a
0
b
0
a
3
b
1
a
2
b
1
a
1
b
1
a
0
b
1
a
3
b
2
a
2
b
2
a
1
b
2
a
0
b
2
c
y
a
3
b
0
a
2
b
0
a
1
b
0
a
0
b
0
a
3
b
1
a
2
b
1
a
1
b
1
a
0
b
1
a
2
b
2
a
1
b
2
a
0
b
2
a
3
b
2
a
2
b
3
a
1
b
3
a
0
b
3
a
3
b
3
p
7
add (axb
1
)
shift right
add (axb
2
)
shift right
add (axb
3
)
shift right
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 35
Datapath Register-Based Multiplier
Multiplicand
MUX
n-bit adder
Multiplier
Product register (2n)
n n
n
n
n
clk
shr
0
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 36
Datapath Array Multipliers
1
0
2
n
i
i
i
X X
1
0
2
n
j
j
j
Y Y
1
0
1
0
2 2
n
i
n
j
j
j
i
i
Y X Y X P
Consider two unsigned binary integers X and Y
1
0
1
0
1
0
2
2 ) (
n n
k
k
k
n
j
j i
j i
n
i
P
Y X
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 37
Datapath Array Multipliers
X
3
Y
0
P
0
P
1
P
2
P
3
P
4
P
5
P
6
P
7
X
2
Y
0
X
1
Y
0
X
0
Y
0
X
3
Y
1
X
2
Y
1
X
1
Y
1
X
0
Y
1
X
3
Y
2
X
2
Y
2
X
1
Y
2
X
0
Y
2
X
3
Y
3
X
2
Y
3
X
1
Y
3
X
0
Y
3
0 0 0
0
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 38
Datapath Array Multipliers
X
3
X
2
X
1
X
0
Y
0
Y
1
Y
2
Y
3
P
0
P
1
P
2
P
3
P
4
P
5
P
6
P
7
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 39
Booths algorithm takes advantages of the fact that an
adder-substractor is nearly as fast and small as a simple
adder
Consider the twos complement representation of the
multiplier y
2
2
1
1
2 2 2
n
n
n
n
n
n
y y y y
) ( 2 ) ( 2 ) ( 2
2 3
2
1 2
1
1 n n
n
n n
n
n n
n
y y y y y y y
) ( 2 ) ( 2
1 2
1
1
n n
n
n n
n
y y y y y
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 40
Datapath Booth Multiplier
2 1 i i i
y y y
Operation
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Add 0
Add x
Add x
Add 2x
Sub 2x
Sub x
Sub x
Add 0
Actions during Booth multiplication
For example, x=011001 (25
10
), y=101110 (-18
10
)
1. y
1
y
0
y
-1
=100, so P
1
=P
0
-2x.1=11111001110
2. y
3
y
2
y
1
=111, so P
2
=P
1
+0.4=11111001110
3. y
5
y
4
y
3
=101, so P
3
=P
2
-x.16=11000111110
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 41
Datapath Booth Multiplier
Structure of a Booth multiplier
left shift 2
code
Mux sel
Adder/substractor
P
j+2
P
j+1
y
i+4
y
i+3
y
i+2
Stage j+1 2x x
0
left shift 2
code
Mux sel
Adder/substractor
P
j+1
P
j
y
i+2
y
i+1
y
i
Stage j 2x x
0
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 42
Datapath Wallace Tree Multiplier
A Wallace tree is a full adder tree structured
specially for a quick addition of the partial products
Example
A 16x16 Booth multiplier
8 partial products are generated
Assume that all partial products are negative so all sign
extension bits are 1s
Sign extension correction vector is 1010101010101011
1111111111111111
11111111111111
111111111111
1111111111
11111111
111111
1111
11
1010101010101011
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 43
Datapath Wallace Tree Multiplier
Wallace tree multiplication
1st stage
4-2 compression
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1
2nd stage
4-2 compression
Sign Extension
Correction
Final Addition
Partial
Products
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 44
Datapath Wallace Tree Multiplier
4-2 compressor Carry-save adder
FA
FA
c s
FA FA
Inputs
Outputs
FA
c s
FA
c s
FA
c s
C
out
C
in
C
out
C
in
Inputs
Outputs
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 45
Datapath Serial Multiplication
X
Y
reset
serial register
Serial multiplier
1. Require MN clock cycles to produce a product for an N-bit
multiplier and a M-bit multiplicand
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 46
Datapath Serial Multiplication
X
Y
0
Serial/parallel multiplier
D D D
D D D
Y
1
Y
2
Y
3
S
0
S
1
S
2
1. Require M+N clock cycles to produce a product for an N-bit
multiplier and a M-bit multiplicand
2. The critical path consists of the adders
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 47
Control FSM
output
clk
input
output
clk
input
Moore
Mealy
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 48
Control FSM
FSM design procedure
Draw the state-transition diagram
Check the state diagram
Write state equations (Write HDL)
An example of state-transition diagram
IDLE
WAIT
EXIT
A
IDLE: (S1,S0)=(00)
WAIT: (S1,S0)=(01)
EXIT: (S1,S0)=(10)
A: car-in
C: change-ok
R: rst
R
-A
A
-A
C
-C
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 49
Control FSM
Check the state-transition diagram
Ensure all states are represented, including the IDLE
state
Check that the OR of all transitions leaving a state is
TRUE. This is a simple method of determining that
there is a way out of a state once entered.
Verify that the pairwise XOR of all exit transitions is
TRUE. This ensures that there are not conflicting
conditions that would lead to more than one exit-
transition becoming active at any time.
Insert loops into any state if it is not guaranteed to
otherwise change on each cycle.
Formal FSM verification method
Perform conformance checking
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 50
Control Verilog Coding Style for FSMs
module
toll_booth(clk,rst,car_in,change_ok,green);
input clk,rst,car_in,change_ok;
output green;
reg[1:0] state_reg, next_state;
parameter IDLE =2b00;
parameter WAIT =2b01;
parameter EXIT =2b11;
always @(posedge clk or posedge rst) begin
If (rst==1b1) state_reg<=IDLE;
else state_reg<=next_state;
end
always @(state_reg or car_in or change_ok)
begin
case(state_reg):
IDLE: if (car_in==11) begin
next_state=WAIT;
green=1b0;
end else begin
next_state=IDEL;
end
WAIT: if (change==1b1) begin
next_state=EXIT;
green=1b1;
end else begin
next_state=WAIT;
green=1b0;
end
EXIT: if (car_in==11) begin
next_state=EXIT;
green=1b1;
end else begin
next_state=IDEL;
green=1b0;
end
default: begin
next_state=IDLE;
green=1b0;
end
endcase
end
endmodule
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 51
Control PLA
i
i i
d c b a m f ) , , , (
Structure of a PLA
AND array OR array
a b c d f
0
f
1
f
2
f
3
Minterms
d c b a d c b a d c b a f
1
A PLA represents an expression of sum-of-product (SOP)
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 52
Control PLA
a b c d f
0
f
1
f
2
f
3
Fuse-programmable PLA
Fuse
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 53
Control PLA
a b c d f
0
f
1
f
2
f
3
Logic gate diagram of a PLA