Comparch 05
Comparch 05
Pipelining
2
Readings for Today
P&P, Revised Appendix C
Microarchitecture of the LC-3b
Appendix A (LC-3b ISA) will be useful in following this
P&H, Appendix D
Mapping Control to Hardware
3
Last Lecture
Intro to Microarchitecture: Single-cycle Microarchitectures
Single-cycle vs. multi-cycle
Instruction processing “cycle”
Datapath vs. control logic
Hardwired vs. microprogrammed control
Performance analysis: Execution time equation
4
Review: A Key System Design Principle
Keep it simple
Balanced design
Balance instruction/data flow through hardware components
Design to eliminate bottlenecks: balance the hardware for the
work
6
Review: Single-Cycle Design vs. Design Principles
Critical path design
Balanced design
7
Multi-Cycle Microarchitectures
8
Multi-Cycle Microarchitectures
Goal: Let each instruction take (close to) only as much time
it really needs
Idea
Determine clock cycle time independently of instruction
processing time
Each instruction takes as many clock cycles as it needs to take
Multiple state transitions per instruction
The states followed by each instruction is different
9
Benefits of Multi-Cycle Design
Critical path design
Can keep reducing the critical path independently of the worst-
case processing time of any instruction
Balanced design
No need to provide more capability or resources than really
needed
An instruction that needs resource X multiple times does not require
multiple X’s to be implemented
Leads to more efficient hardware: Can reuse hardware components
needed multiple times for an instruction
10
Remember: Performance Analysis
Execution time of an instruction
{CPI} x {clock cycle time}
Execution time of a program
Sum over all instructions [{CPI} x {clock cycle time}]
{# of instructions} x {Average CPI} x {clock cycle time}
12
Microprogrammed Multi-Cycle uArch
Key Idea for Realization
13
The Instruction Processing Cycle
Fetch
Decode
Evaluate Address
Fetch Operands
Execute
Store Result
14
A Basic Multi-Cycle Microarchitecture
Instruction processing cycle divided into “states”
A stage in the instruction processing cycle can take multiple states
15
Microprogrammed Control Terminology
Control signals associated with the current state
Microinstruction
18
A Bad Clock Cycle!
19
LC-3b Instructions set
20
A Simple LC-3b Control and Datapath
More information:Read Appendix C
(P&P)
21
What Determines Next-State Control Signals?
What is happening in the current clock cycle
See the 9 control signals coming from “Control” block
What are these for?
23
C.2. THE STATE MACHINE 5
uniquely specified 33
MDR <! M
32
1011
RTI
BEN<! IR[11] & N + IR[10] & Z + IR[9] & P To 11
1010
To 8
[IR[15:12]]
variables
set CC
9 12
To 18
DR<! SR1 XOR OP2* To 18
PC<! BaseR
set CC
To 18 15 4
0 1
instruction processing
PC<! MDR R7<! PC
To 18 PC<! PC+LSHF(off11,1
cycle
13
To 18
DR<! SHF(SR,A,D,amt4)
set CC To 18
19 state 33 state To 18
35
29 25 23 24
NOTES MDR<! M[MAR[15:1]’0] MDR<! M[MAR] MDR<! SR MDR<! SR[7:0]
B+off6 : Base + SEXT[offset6]
M[MAR]<! MDR
16
M[MAR]<! MDR**
17
set CC set CC
MAR[0]
R R R R
To 18 To 18 To 18 To 19
25
LC-3b Datapath
Patt and Patel, Appendix C, Figure C.3
26
C.4. THE CONTROL STRUCTURE 11
IR[11:9] IR[11:9]
DR SR1
111 IR[8:6]
DRMUX SR1MUX
(a) (b)
Remember the MIPS datapath
IR[11:9]
N Logic BEN
Z
P
(c)
30
LC-3b Microprogrammed Control Structure
Patt and Patel, Appendix C, Figure C.4
Three components:
Microinstruction, control store, microsequencer
Microsequencer
Control Store
2 6 x 35
35
Microinstruction
9 26
COND1 COND0
BEN R IR[11]
0,0,IR[15:12]
6
IRD
LC-3b Microsequencer
Figure C.5: The microsequencer of the LC-3b base machine
UX
UX
E
Ga ARM
UX
LS .SIZ
1M
2M
Ga DR
AD U X
Ga L U
LD A R
LD D R
SR X
LD N
LD G
R. W N
RM
Ga C
MU
1
. CC
. BE
. RE
MU
DR
DR
E
.PC
UK
TA
t eM
t eM
1M
t eA
. IR
.M
.M
t eP
t eS
HF
O.
nd
D
MA
AD
DA
DR
LD
LD
LD
AL
PC
MI
Co
Ga
IR
J
000000 (State 0)
000001 (State 1)
000010 (State 2)
000011 (State 3)
000100 (State 4)
000101 (State 5)
000110 (State 6)
000111 (State 7)
001000 (State 8)
001001 (State 9)
001010 (State 10)
001011 (State 11)
001100 (State 12)
001101 (State 13)
001110 (State 14)
001111 (State 15)
010000 (State 16)
010001 (State 17)
010010 (State 18)
010011 (State 19)
010100 (State 20)
010101 (State 21)
010110 (State 22)
010111 (State 23)
011000 (State 24)
011001 (State 25)
011010 (State 26)
011011 (State 27)
011100 (State 28)
011101 (State 29)
011110 (State 30)
011111 (State 31)
100000 (State 32)
100001 (State 33)
100010 (State 34)
100011 (State 35)
100100 (State 36)
100101 (State 37)
100110 (State 38)
100111 (State 39)
101000 (State 40)
101001 (State 41)
101010 (State 42)
101011 (State 43)
101100 (State 44)
101101 (State 45)
101110 (State 46)
101111 (State 47)
110000 (State 48)
110001 (State 49)
110010 (State 50)
110011 (State 51)
110100 (State 52)
110101 (State 53)
110110 (State 54)
110111 (State 55)
111000 (State 56)
111001 (State 57)
111010 (State 58)
111011 (State 59)
111100 (State 60)
111101 (State 61)
111110 (State 62)
111111 (State 63)
35
10APPENDIX C. THE MICROARCHITECTURE OF THE LC-3B, BASIC MACHINE
COND1 COND0
BEN R IR[11]
0,0,IR[15:12]
6
IRD
37
An Exercise in
Microprogramming
38
10APPENDIX C. THE MICROARCHITECTURE OF THE LC-3B, BASIC MACHINE
State Machine for LDW Microsequencer COND1 COND0
BEN R IR[11]
0,0,IR[15:12]
6
IRD
40
The Control Store: Some Questions
What control signals can be stored in the control store?
vs.
42
The Microsequencer: Advanced Questions
What happens if the machine is interrupted?
43
Advantages of Microprogrammed Control
Allows a very simple design to do powerful computation by
controlling the datapath (using a sequencer)
High-level ISA translated into microcode (sequence of microinstructions)
Microcode (ucode) enables a minimal datapath to emulate an ISA
Microinstructions can be thought of as a user-invisible ISA (micro ISA)
44
Update of Machine Behavior
The ability to update/patch microcode in the field (after a
processor is shipped) enables
Ability to add new instructions without changing the processor!
Ability to “fix” buggy hardware implementations
Examples
IBM 370 Model 145: microcode stored in main memory, can be
updated after a reboot
IBM System z: Similar to 370/145.
Heller and Farrell, “Millicode in an IBM zSeries processor,” IBM
JR&D, May/Jul 2004.
B1700 microcode can be updated while the processor is running
User-microprogrammable machine!
45
The Power of Abstraction
The concept of a control store of microinstructions enables
the hardware designer with a new abstraction:
microprogramming
46
Aside: Alignment Correction in Memory
Remember unaligned accesses
LC-3b has byte load and byte store instructions that move
data not aligned at the word-address boundary
Convenience to the programmer/compiler
47
Aside: Memory Mapped I/O
Address control logic determines whether the specified
address of LDx and STx are to memory or I/O devices
48