Professional Documents
Culture Documents
N. B. Dodge 9/15
Control Unit
Instruction Fetch/Decode
N. B. Dodge 9/15
0 1000
0 1001
0 1010
$t0
$t1
$t2
0 0000
10 0000
N. B. Dodge 9/15
10 0000
0 0000
01010
Bit 31
To function code
decoder
0 1001
Bit 0
0 1000
As mentioned before,
the control unit is a
collection of decoders
and multiplexers.
The decoded
instruction fields tell
(1) the ALU what
function to perform,
(2) what operands to
use.
00 0000
To operation code
decoder
N. B. Dodge 9/15
Current Architecture
The ALU control uses instruction bits 0-5 to obtain
information about the ALU operation in register-toregister instructions.
Note in the following diagram that some of the
decoding is done in the register block, which has the
decoding mechanism (as discussed in lecture 8, slides 8
and 9) that identifies source and destination registers in
load/store and register/register operations.
The ALU control also has input control lines from the
operation code decoder which decodes bits 26-31, and
which will be shown later.
5
N. B. Dodge 9/15
+4
ADD
Inst.
0-31
Instruction
Address
Instruction
Memory
M
32
U
X
ADD
Left
shift
2
P
C
32
32
5
5
32
Rs
Rt
M 5
U
Rd
X
Write
Data
32
Read
Data 2
32
Reg. Block
16 (Bits 0-15)
Read
Data 1
Sign 32
Extend
ALU
M
32
U
X
ALU
6 (Bits 0-5) Control
32
Data
Address
Write
Data
Read 32
Data
32
M 32
U
X
Data
Memory
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Unit Design and Multicycle Implementation
ALU Control
Block Detail
N. B. Dodge 9/15
32
32
ADD
+4
Instruction
Address
P
C
6 (Bits 26-31)
Inst.
0-31
Instruction
Memory
5
5
Control
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
M
32
U
X
32
ADD
Left
shift
2
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
Write
ALU
32
Reg. Block
16 (Bits 0-15)
32
Sign 32
Extend
M
32
U
X
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
ALU
6 (Bits 0-5) Control
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Unit Design and Multicycle Implementation
Op code
decode/
control
block
N. B. Dodge 9/15
10
When Signal = 1
When Signal = 0
RegDst
Branch
No branch activated
MemRead
MemtoReg
ALUOp
MemWrite
ALUSrc
RegWrite
N. B. Dodge 9/15
Instruction
bits 26-31
0
23
2a 04
TO ALU
control block
11
Lecture # 19:
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Control Unit Design and Multicycle Implementation
Register Block
Registers
$rt
decode
$rs
decode
01010
$rd
decode
0 1001
12
0 1000
Bit 31
ALU
Control
Block
00 0000
0 0000
Bit 0
10 0000
Op
Code
Control
Block
N. B. Dodge 9/15
13
N. B. Dodge 9/15
32
32
ADD
+4
Instruction
is fetched
P
C
Instruction
Address
Inst.
0-31
Instruction
Memory
14
6 (Bits 26-31)
5
5
Control
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
M
32
U
X
32
ADD
Left
shift
2
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
Write
ALU
32
Reg. Block
16 (Bits 0-15)
32
Sign 32
Extend
M
32
U
X
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
ALU
Control
6 (Bits 0-5)
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Unit Design and Multicycle Implementation
32
32
ADD
+4
Instruction
Address
P
C
6 (Bits 26-31)
Inst.
0-31
Instruction
Memory
5
5
Control
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
M
32
U
X
32
ADD
Left
shift
2
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
32
ALU
32
Reg. Block
16 (Bits 0-15)
Write
Sign 32
Extend
M
32
U
X
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
ALU
Registers are identified and
Control
6 (Bits 0-5)
needed operands are routed to
the ALU and the PC update
circuit.
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Lecture # 19: Control Unit Design and Multicycle Implementation
15
32
32
ADD
+4
Instruction
Address
P
C
6 (Bits 26-31)
5
5
Inst.
0-31
Instruction
Memory
Control
M
32
U
X
32
ADD
Left
shift
2
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
32
16 (Bits 0-15)
Write
ALU
32
Reg. Block
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
Sign 32
Extend
M
32
U
X
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
ALU
Control
6 (Bits 0-5)
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Unit Design and Multicycle Implementation
32
32
ADD
+4
Instruction
Address
P
C
6 (Bits 26-31)
5
5
Inst.
0-31
Instruction
Memory
Control
M
32
U
X
32
ADD
Left
shift
2
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
32
Write
ALU
32
Reg. Block
16 (Bits 0-15)
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
Sign 32
Extend
M
32
U
X
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
ALU
6 (Bits 0-5) Control
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Unit Design and Multicycle Implementation
Load Instruction
Reg. Dest.
32
32
ADD
+4
6 (Bits 26-31)
Control
Instr. lines
Instruction bits 0-31
P
C
Instruction
Address
Inst.
0-31
Read
Data 1
Rt
M 5
U
Rd
X
Instruction
Memory
Write
Data
Read
Data 2
ADD
Left
shift
2
32
32
16 (Bits 0-15)
Write
ALU
32
Reg. Block
18
M
32
U
X
32
Rs
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
Sign 32
Extend
M
32
U
X
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
ALU
6 (Bits 0-5) Control
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Unit Design and Multicycle Implementation
Branch Instruction
Reg. Dest.
32
32
ADD
+4
PC+4
Addr.
Immediate
New PC address
Instruction
lines
P
C
Instruction
Address
Inst.
0-31
Instruction
Memory
6 (Bits 26-31)
5
5
Control
M
32
U
X
32
ADD
Left
shift
2
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
32
Write
ALU
32
Reg. Block
16 (Bits 0-15)
Active
control lines
Register data
19
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
Sign 32
Extend
M
32
U
X
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
ALU
6 (Bits 0-5) Control
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Unit Design and Multicycle Implementation
32
Jump
Reg. Dest.
+4
ADD
Instruction
Address
6 (Bits 26-31)
P
C
Inst.
0-31
Instruction
Memory
5
5
Control
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
M
32
U
X
32
32
ADD
Left
shift
2
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
32
Write
32
M
32
U
X
Reg. Block
16 (Bits 0-15)
Sign 32
Extend
6 (Bits 0-5)
20
M
U
X
32
ALU
ALU
Control
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
N. B. Dodge 9/15
32
Jump
Reg. Dest.
+4
ADD
6 (Bits 26-31)
Control
PC+4 data
PC jump data
PC update
Jump control
P
C
Instruction
Address
Inst.
0-31
Instruction
Memory
5
5
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
32
ADD
Left
shift
2
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
32
Write
32
M
32
U
X
Reg. Block
16 (Bits 0-15)
Sign 32
Extend
6 (Bits 0-5)
21
M
32
U
X
32
M
U
X
ALU
ALU
Control
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
N. B. Dodge 9/15
Exercise 1
On the next slide is a diagram of the complete
single-cycle preliminary MIPS architecture.
On a copy of that diagram:
1. Circle every element that contains a decoder.
2. Highlight the line that controls the content of the
data written back to the destination register.
3. Circle the device that allows a 16-bit number to be
successfully added to a 32-bit number.
22
N. B. Dodge 9/15
32
Jump
Reg. Dest.
+4
ADD
Instruction
Address
6 (Bits 26-31)
P
C
M
U
X
32
Inst.
0-31
Instruction
Memory
5
5
Control
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
M
32
U
X
32
32
ADD
Left
shift
2
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
32
Write
32
M
32
U
X
Reg. Block
16 (Bits 0-15)
Sign 32
Extend
6 (Bits 0-5)
ALU
ALU
Control
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
N. B. Dodge 9/15
26
N. B. Dodge 9/15
Multicycle Implementation
A solution to the single-cycle problem is stated as
follows:
Each instruction has several phases, such as fetch/decode,
register selection, ALU processing, etc.
Instead of using a single clock cycle for the whole instruction,
run the clock much faster, and have a single clock cycle for
each of the elements or phases of the instruction process.
Many instructions take fewer phases (for example, jump,
branch [the fewest phases], register-register or store
instructions), so these instructions execute much faster.
As most instructions execute faster than the longest
instructions (such as lw), the average instruction time will be
reduced substantially.
27
N. B. Dodge 9/15
N. B. Dodge 9/15
Multicycle Implementation
P
C
Instruction
Fetch
Instruction
Decode/
Register
Fetch
Instruction
Memory
Register
Block
ALU
Execution
ALU
Memory
Access
(if
required)
Data
Memory
Data
Writeback
Register
Block
Op/Fn
1 clock
cycle
29
Skipped for
reg.-reg. inst.
1 clock
1 clock
1 clock
cycle
cycle
cycle
All five segments (five clock cycles) required only for load instructions
Skipped for
store inst.
1 clock
cycle
N. B. Dodge 9/15
30
RType
Memory
Reference
Branches
Jumps
Instruction
Fetch
Instruction
Decode /Register
Fetch
Instruction
Execution
ALU output is
mem. address for
load/store
If condition met,
[PC]address
output of ALU
PC address is instr.
[0-25] (shifted 2
places) + [PC 28-31]
Memory Access or
ALU Data
Writeback
Logical/shift/math
operation result
written to dest. reg.
---
---
Memory Data
Writeback
---
Data written to
destination register
---
---
N. B. Dodge 9/15
Multicycle Advantages
For most instructions, we save 20-40% in clock cycles
and our processor is much faster, as mentioned earlier.
Since different parts of the circuit are active only for
one cycle at a time, we can use less circuitry because
parts of the computer can be reused in different cycles.
The CPU now needs only one ALU, since it can do the PC
update functions prior to the ALU processing.
Since we access memory for data and instructions in different
clock cycles, we only need one path to memory.
31
N. B. Dodge 9/15
N. B. Dodge 9/15
32
32
ADD
+4
Instruction
Address
P
C
6 (Bits 26-31)
Inst.
0-31
Instruction
Memory
Need instruction
storage here
33
5
5
Control
Branch
Mem. Read
Mem. To Reg.
ALU Op.
Mem. Write
ALU Srce.
Reg. Write
M
32
U
X
32
ADD
Left
shift
2
Need
read
data
storage
here
32
Rs
Read
Data 1
Rt
M 5
U
Rd
X
Write
Data
Read
Data 2
32
Write
ALU
32
M
32
U
X
Reg. Block
16 (Bits 0-15)
Sign 32
Extend
ALU
6 (Bits 0-5) Control
32
Data
Address
Write
Data
Read
Mem./Reg.
Select
Read 32
Data
32
M 32
U
X
Data
Memory
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Unit Design and Multicycle Implementation
Memory
Out
Write
Data
Memory
Memory
Data
Register
Instr.
21-25
Instr.
16-20
Instruction 0-31
Memory
Address
Instruction Register
Inst.
11-15
Rd
Read
Data 1
Read
Data 2
ALU
ALU
Out
Write Data
Reg. Block
Instr. 0-15
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
34
N. B. Dodge 9/15
Memory
Out
Write
Data
Memory
Note memory
data path
simplified
Memory
Data
Register
Instr.
21-25
Instr.
16-20
Instruction 0-31
Memory
Address
Instruction Register
Ins.
1115
M
U
X
Rs
Rt
Rd
Read
Data 1
Read
Data 2
B
4
Write Data
M
U
X
Reg. Block
Sign
Extend
Instr. 0-15
ALU
Left
shift
2
M
U
X
ALU
Out
Instr. 0-5
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
M
U
X
Memory
Address
Memory
Out
Write
Data
Memory
Memory
Data
Register
Instr.
21-25
Instr.
16-20
Instruction 0-31
P
C
Instruction Register
PC 0-31
Ins.
1115
M
U
X
M
U
X
Rs
Rt
Rd
Read
Data 1
Read
Data 2
B
4
Write Data
M
U
X
ALU
M
U
X
Reg. Block
Sign
Instr. 0-15 Extend
ALU
Out
ALU
Control
Left
shift
2
Instr. 0-5
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
36
N. B. Dodge 9/15
PC Write Cond.
PC Write
ALU Op.
Inst. / Data
Mem. Read
ALU Srce. B
Mem. Write
Mem. To. Reg.
Control
Reg. Write
Memory
Out
Write
Data
Memory
PC 0-31
Instruction 0-31
Memory
Address
Instruction Register
M
U
X
Instr. 0-25
Reg. Dest.
Instr. 26-31
P
C
PC 28-31
ALU Srce. A
Instr.
21-25
Instr.
16-20
Ins.
1115
Memory
Data
Register
M
U
X
M
U
X
Rs
Rt
Rd
Read
Data 1
Read
Data 2
Reg. Block
Sign
Instr. 0-15 Extend
ALU
4
Write Data
M
U
X
Left
shift
2
M
U
X
M
U
X
ALU
Out
ALU
Control
Left
shift
2
Instr. 0-5
37
After David A. Patterson and John L. Hennessy, Computer Organization and Design, 2nd Edition
N. B. Dodge 9/15
Design and Multicycle Implementation
Multicycle Summary
Cont.
P
C
Reg.
Memory
ALU
B
ALU
Op.
N. B. Dodge 9/15
Exercise 2
On the Complete Multicycle Design Diagram
on the next page, do the following:
1. Summarize the inputs into the lower MUX to the
ALU.
2. Why is the 16-bit sign-extender input directly to the
ALU in one case and left-shifted two places in the
other?
3. Why is the output of the ALU sent directly to the
MUX that inputs an instruction address into the
PC?
39
N. B. Dodge 9/15
PC Write Cond.
PC Write
ALU Op.
Inst. / Data
Mem. Read
ALU Srce. B
Mem. Write
Mem. To. Reg.
Control
Reg. Write
Memory
Out
Write
Data
Memory
Memory
Data
Register
PC 0-31
Instruction 0-31
Memory
Address
Instruction Register
M
U
X
Instr. 0-25
Reg. Dest.
Instr. 26-31
P
C
PC 28-31
ALU Srce. A
Instr.
21-25
Instr.
16-20
Ins.
1115
M
U
X
M
U
X
Rs
Rt
Rd
Read
Data 1
Read
Data 2
Reg. Block
Sign
Instr. 0-15 Extend
ALU
4
Write Data
M
U
X
Left
shift
2
M
U
X
ALU
Control
Left
shift
2
Instr. 0-5
M
U
X
ALU
Out