Beruflich Dokumente
Kultur Dokumente
Binary
Name code IDLE 000
(a) State box (b) Example of state box (c) Decision box
IDLE
R→0
0 1
START
From decision box
Register operation
or output PC → 0
(d) Conditional output box (e) Example of decision and condition output box
AVAIL
Exit 0 1
START
A→0
0 1
Q0
Exit Exit
MUL0 MUL1
Clock
START
Q0
AVAIL
A 0034 0000
23 10111 Multiplicand
19 10011 Multiplier
10111
10111
00000
00000
101110000
437 110110101 Product
23 10111 Multiplicand
19 10011 Multiplier
00000 Initial partial product
10111 Add multiplicand, since multiplier bit is 1
10111 Partial product after add and before shift
010111 Partial product after shift
10111 Add multiplicand, since multiplier bit is 1
a
1000101 Partial product after add and before shift
1000101 Partial product after shift
01000101 Partial product after shift
001000101 Partial product after shift
10111 Add multiplicand, since multiplier bit is 1
110110101 Partial product after add and before shift
437 0110110101 Product after final shift
n–1 IN
n
Multiplicand
Counter P Register B
log2n n
Zero detect
Z n n
Control Qo Multiplier
unit
0 C Shift register A Shift register Q
4
n
Product
Control signals
OUT
IDLE
0 1
G
C → 0, A → 0
P→ n – 1
MUL0
0 1
Q0
A → A + B,
C → Cout
MUL1
C → 0, C || A || Q → sr C || A || Q,
P→P–1
0 1
Z
TABLE 8-1
Control Signals for Binary Multiplier
IDLE 00
0 1
G
MUL0 01
MUL1 10
0 1
Z
Fig. 8-8 Sequencing Part of ASM Chart for the Binary Multiplier
TABLE 8-2
State Table for Sequence Register and Decoder Part
of Multiplier Control Unit
Present Next
state Inputs state Decoder Outputs
IDLE 0 0 0 ⫻ 0 0 1 0 0
0 0 1 ⫻ 0 1 1 0 0
MUL0 0 1 ⫻ ⫻ 1 0 0 1 0
MUL1 1 0 ⫻ 0 0 1 0 0 1
1 0 ⫻ 1 0 0 0 0 1
— 1 1 ⫻ ⫻ ⫻ ⫻ ⫻ ⫻ ⫻
G
• • Initialize
M0
D Clear_C
Z • C DECODER IDLE
A0 0 • MUL0
1 • MUL1
2 • Shift_dec
A1 3
M1
D
• C
Load
Q0
Clock
Fig. 8-9 Control Unit for Binary Multiplier Using a Sequence Register and a Decoder
Exit
Exit
(a) State box
Entry X
Entry
•
0 1
•
X
•
Exit 0
Exit 1
Exit 0 Exit 1
Exit Exit
(c) Junction
Entry Entry
X
1
X
•
Exit 1
Control
Exit 1
Fig. 8-10 Transformation Rules for Control Unit with One Flip-Flop per State
IDLE 1
D
C
G
•
•
•
2
4
• Initialize
3
4
Clear _C
MUL0 1 Q0
Load
D •
• C
MUL1 1 4
D • • Shift_dec
• C
Clock Z
•
•
•
Fig. 8-11 Control Unit with One Flip-Flop per State for the Binary Multiplier
assign Z = ~| P;
assign MULT_OUT = {A,Q};
//state register
always@(posedge CLK or posedge RESET)
begin
if (RESET == 1)
state <= IDLE;
else
state <= next_state;
end
//datapath function
always@(posedge CLK)
begin
if (LOADB == 1)
B <= MULT_IN;
if (LOADQ == 1)
Q <= MULT_IN;
case (state)
IDLE:
if (G == 1)
begin
C <= 0;
A <= 4’b0000;
P <= 2’b11;
end
MUL0:
if (Q[0] == 1)
{C, A} = A + B;
MUL1:
begin
C <= 1’b0;
A <= {C, A[3:1]};
Q <= {A[0], Q[3:1]};
P <= P - 2’b01;
end
endcase
end
endmodule
Control
inputs Status signals from datapath
Next-address
generator
Sequencer
Control address
register
Control address
Address
Control
memory
(ROM)
Data
Control data register
(optional)
Microinstruction
0 1
G
INIT 001
A → 0, C → 0
P→ n – 1
MUL0 010
0 Q0 1
ADD 011
A → A + B,
C → Cout
MUL1 100
C → 0, C || A || Q → sr C || A || Q,
P→P–1
0 1
Z
Fig. 8-17 ASM Chart for Microprogrammed Binary Multiplier Control Unit
11 9 8 6 5 4 3 0
TABLE 8-3
Control Signals for Microprogrammed Multiplier Control
States in
Which Micro-
Control Signal is instruction Symbolic
Signal Register Transfers Active Bit Position Notation
Initialize A ← 0, P ← n – 1 INIT 0 IT
Load A ← A + B, C ← Cout ADD 1 LD
Clear_C C←0 INIT, MUL1 2 CC
Shift_dec C A Q ← sr C A Q , P ← P – 1 MUL1 3 SD
TABLE 8-4
SEL Field Definition for Binary Multiplier
Control Sequencing
SEL
IN
n
2 4
Datapath
OUT
MUX1
2–to–1 DATAPATH
MUX
5 x 12 SEL
0 3 3 Control
MUX2 CAR Memory NXTADD0
4–to–1 (ROM)
MUX 1
NXTADD1
0 0 S
G 1
Q0 2 3
Z 3
3
S1 S0
2
TABLE 8-5
Register Transfer Description of Binary Multiplier Microprogram
TABLE 8-6
Symbolic Microprogram and Binary Microprogram for Multiplier
Address NXTADD1 NXTADD0 SEL DATAPATH Address NXTADD1 NXTADD0 SEL DATAPATH
15 9 8 6 5 3 2 0
(a) Register
15 9 8 6 5 3 2 0
(b) Immediate
15 9 8 6 5 3 2 0
Address (AD) Source reg- Address (AD)
Opcode (Left) (Right)
ister A (SA)
70 0000000 011 000 000 Data = 192. After execution of instruction in 35, Data = 80.
Program counter
(PC)
Instruction
memory
215 x 16
Register file
8 x 16
Data
memory
215 x 16
P J B Address
L B C
Instruction
memory RW D
DA Register
Instruction file
AA A B BA
Zero fill
IR(2:0) Constant
in
Instruction decoder
1 0
MUX B MB
Address out
Bus A
Bus B
Data out
MW
D B A M F M R M P J B
A A A B S D W W L B C
A B Data in Address
FS
CONTROL
V Data
Function memory
C unit
N
Data out
Z
F
Data in
0 1
MD
MUX D
Bus D
DATAPATH
Instruction
Opcode DR SA SB
15 14 13 12 11 10 9 8-6 5-3 2-0
3 3 3
•
•
•
• • •
• •
• •
•
•
•
•
•
5
•
•
22 - 20 19 - 17 16 - 14 13 12 - 8 7 6 5 4 3 2-0
DA AA BA MB FS MD RW MW PL JB BC
Control word
TABLE 8-7
Truth Table for Instruction Decoder Logic
TABLE 8-8
Six Instructions for the Single-Cycle Computer
Operation Symbolic
code name Format Description Function MB MD RW MW PL JB
1 ns
PC
Instruction
memory 4 ns
Register file 3 ns
(Read)
MUX B 1 ns
Function
unit or 4 ns
Data memory
MUX D 1 ns
Register file 3 ns
(Write)
PL PC
PI
2
•
2
Z CNZ V C1 0 D
RW
9 x 16
TD || DR DA
76543210 4 Register
3
MUX S MS 16 file
TD || SA AA BA TB || SB
4 A B 4
IR
IL
Opcode DR SA SB
8 1 7 3 3 3 Zero fill
0
0 1 1 0
MC MUX C MB
MUX B
CAR Bus B
Bus A 0 1
8 MM
MUX M
Data MW Address
Control out out
memory A B
256 x 28 FS Data in Address
V
C Function Memory
unit M
N
Z
N M M I P P T T T M F M R M M Data out
F
A S C L I L D A B B S D WM W Data in
Sequence Datapath
control control
0 1
MD
4 Bus D MUX D
27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NA MS M I P P T T T M FS M R M M
C L I L D A B B D W M W
TABLE 8-9
Control Word Information for Datapath
TD TA TB MB FS MD RW MM MW
Select Select Select Select Code Function Code Select Function Select Function Code
R[DR] R[SA] R[SB] Register 0 F=A 00000 FnUt No write (NW) Address No write (NW) 0
R8 R8 R8 Constant 1 F = A +1 00001 Data In Write (WR) PC Write (WR) 1
F = A +B 00010
F = A +B +1 00011
F = A +B 00100
F = A +B +1 00101
F = A –1 00110
F =A 00111
F = A ∧B 01000
F = A ∨B 01010
F = A ⊕B 01100
F =A 01110
F =B 10000
F = sr B 10100
F = sl B 11000
TABLE 8-10
Control Information for Sequence Control Fields
MS MC IL PI PL
Increment CAR CNT 000 NA NXA No load NLI No load NLP No load NLP 0
Load CAR NXT 001 Opcode OPC Load instr. LDI Increment PC INP Load PC LDP 1
If C ⫽ 1, load CAR; BC 010
else increment CAR
If V ⫽ 1, load CAR; BV 011
else increment CAR
If Z ⫽ 1, load CAR; BZ 100
else increment CAR
If N ⫽ 1, load CAR; BN 101
else increment CAR
If C ⫽ 0, load CAR; BNC 110
else increment CAR
If Z ⫽ 0, load CAR, BNZ 111
else increment CAR
0 1
IR = 0000000?
ADl 00000000
R [DR] → R [SA] + zf IR [2:0]
0 1
IR = 0000001?
LD 00000001
R [DR] → M [R [SA] ]
0 1
IR = 0000010?
ST 00000010
M [R [SA] ] → R [SB]
0 1
IR = 0000011?
INC 00000011
R [DR] → R [SA] + 1
0 1
IR = 0000100?
NOT 00000100
R [DR] → R [SA]
0 1
IR = 0000101?
ADD 00000101
R [DR] → R [SA] + R [SB]
0 1
IR = 0000110?
0 1
IR = 0000111?
TABLE 8-11
Symbolic Microprogram for Fetch and Execution of Six Instructions
NXT
Address ADD MS MC IL PI PL TD TA TB MB FS MD RW MM MW
Table 8-11 Symbolic Microprogram for Fetch and Execution of Six Instructions
TABLE 8-12
Binary Microprogram for Fetch and Execution of Six Instructions
NXT
Address ADD MS MC IL PI PL TD TA TB MB FS MD RW MM MW
Table 8-12 Binary Microprogram for Fetch and Execution of Six Instructions
0 1
IR = 0000110?
LRI0 00000110
…
R8 → M [R [ SA] ]
LRI1 10000110
R [DR] → M [R8]
To IF
0 1
IR = 0000111?
SRM1 00000111
…
R8 → zf IR [2:0]
1
zf IR [2:0] = 0? T0 IF
SRM2 10000111
NOTE: SA = DR
R [DR] → sr R [SA],
SRM3 10001000
R8 → R8 – 1
1
R8 = 0? T0 IF
0 1 (ADl)
IR = 0000000?
0 1 (LD)
IR = 0000001?
R [DR] → M [R [SA] ]
0 1 (ST)
IR = 0000010?
M [R [SA] ] → R [SB]
0 1 (INC)
IR = 0000011?
R [DR] → R [SA] + 1
0 1 (NOT)
IR = 0000100?
R [DR] → R [SA]
0 1 (ADD)
IR = 0000101?
0 1 (LRI)
IR = 0000110?
R8 → M [R [SA] ]
EX1 10
R [DR] → M [R8]
Counter
CR Syn. reset
IL
Decoder
0 1 2
I E E
F X X
0 1
I
R ADI
0
LD
1
9 ST
2
10 Decoder INC Control logic
3
11 NOT
4
ADD
5
LRI
6
C I P T T T M F M R M M
R L I D A B B S D W M W
Fig. 8-32 Block Diagram of Hardwired Counter and Decoder-Based, Multiple-Cycle Control Unit
WAREHOUSE
Address
Stage Instruction
1 memory
Instruction
IF
IR
DOF Register
file
AA A data B data BA
AA BA MB
DOF Data A Data B
EX
Address out
FS MW
5 A B
FS Address
C Function
Stage V unit Data
memory
3 N
Z F Data out
Data in
Data out MW
EX Data F Data I
Data in Address
WB
Stage DA MD RW
Data
MD MUX D memory
4 (same as
above)
WB RW D data
D register
file (same
CONTROL DATAPATH as above)
Clock cycle
1 2 3 4 5 6 7 8 9 10
1 IF DOF EX WB
2 IF DOF EX WB
3 IF DOF EX WB
4 IF DOF EX WB
5 IF DOF EX WB
6 IF DOF EX WB
7 IF DOF EX WB
Instruction
00, 01
S0
00
10, 11 01, 11
S1 01, 10, 11 S2
00 01 10
00, 10