Title: Processor: Datapath and Control
1Processor Datapath and Control
- Shivkumar Kalyanaraman
- Rensselaer Polytechnic Institute
- shivkuma_at_ecse.rpi.edu
- http//www.ecse.rpi.edu/Homepages/shivkuma
2Overview
- Datapath components and their interconnections
used to implement the instruction set
architecture - Control implementation of signals used to
control the information flow through the data
path - A single-cycle and multi-cycle implementation of
a subset of the MIPS instruction set
3The Processor Datapath Control
- We're ready to look at an implementation of the
MIPS - Simplified to contain only
- memory-reference instructions lw, sw
- arithmetic-logical instructions add, sub, and,
or, slt - control flow instructions beq, j
- Generic Implementation
- use the program counter (PC) to supply
instruction address - get the instruction from memory
- read registers
- use the instruction to decide exactly what to do
- All instructions use the ALU after reading the
registers
4Implementation Details
- Abstract / Simplified View
- Two types of functional units
- elements that operate on data values
(combinational) - elements that contain state (sequential)
5Building blocks combinatorial and sequential
logic
- An edge triggered methodology
- Typical execution
- read contents of some state elements,
- send values through some combinational logic
- write results to one or more state elements
6Building Blocks Register File
7Building blocks Register File (contd)
- We still use the real clock to determine when to
write
8Simple Implementation
- The functional units we need...
For instruction fetch
For lw and sw
9For arithmetic/logic operations
For beq
10Building the Datapath
- Use multiplexors to stitch them together
P
C
S
r
c
M
A
d
d
u
x
A
L
U
A
d
d
4
r
e
s
u
l
t
S
h
i
f
t
l
e
f
t
2
R
e
g
i
s
t
e
r
s
A
L
U
o
p
e
r
a
t
i
o
n
3
R
e
a
d
M
e
m
W
r
i
t
e
A
L
U
S
r
c
R
e
a
d
r
e
g
i
s
t
e
r
1
P
C
R
e
a
d
a
d
d
r
e
s
s
R
e
a
d
d
a
t
a
1
M
e
m
t
o
R
e
g
Z
e
r
o
r
e
g
i
s
t
e
r
2
I
n
s
t
r
u
c
t
i
o
n
A
L
U
A
L
U
R
e
a
d
W
r
i
t
e
R
e
a
d
A
d
d
r
e
s
s
r
e
s
u
l
t
M
r
e
g
i
s
t
e
r
d
a
t
a
d
a
t
a
2
M
u
I
n
s
t
r
u
c
t
i
o
n
u
x
W
r
i
t
e
m
e
m
o
r
y
D
a
t
a
x
d
a
t
a
m
e
m
o
r
y
W
r
i
t
e
R
e
g
W
r
i
t
e
d
a
t
a
3
2
1
6
S
i
g
n
M
e
m
R
e
a
d
e
x
t
e
n
d
11Control
- Selecting the operations to perform (ALU,
read/write, etc.) - Controlling the flow of data (multiplexor inputs)
- Information comes from the 32 bits of the
instruction - Example add t0, s1, s2 add 8, 17, 18
- Instruction Format 000000 10001 10010
01000 00000 100000 -
- op rs rt rd shamt funct
- ALU's operation based on instruction type and
function code
12Control
- Example lw 1, 100(2)
-
- 35 2 1 100 op
rs rt 16 bit offset - ALU hardware control input 000
AND 001 OR 010 add 110 subtract 111 set-on-le
ss-than
13Control
- Need hardware to compute 3-bit ALU control input
- given instruction type compute ALUOp 00 lw,
sw 01 beq, 11 arithmetic - function code determines arithmetic signals
- Describe it using a truth table (can turn into
gates)
14 15Control implementation
- Simple combinational logic (truth tables)
16Single Cycle Implementation
- Calculate cycle time assuming negligible delays
except - memory (2ns), ALU adders (2ns), register file
(1ns)
17Where we are headed
- Single Cycle Problems
- what if we had more complicated things like
floating point? - wasteful of area, and cycle time that of
slowest instruction - One Solution
- Use a smaller cycle time
- Have different instructions take different
numbers of cycles - A multicycle datapath
18Multicycle Approach
- We will be reusing functional units
- Single ALU used to compute address and to
increment PC - Single memory used for instruction and data
- Control signals not determined solely by
instruction - It also will depend upon the current cycle of
execution - Well use a finite state machine for control
19Review finite state machines
- Finite state machines
- a set of states and
- next state function (determined by current state
and the input) - output function (determined by current state and
possibly input) - Well use a Moore machine (output based only on
current state)
20Multicycle Approach
- Break up the instructions into steps, each step
takes a cycle - restrict each cycle to use only one major
functional unit - At the end of a cycle
- store values for use in later cycles (easiest
thing to do) - introduce additional internal registers
21Multicycle Approach
22Five Execution Steps
- Instruction Fetch
- Instruction Decode and Register Fetch
- Execution, Memory Address Computation, or Branch
Completion - Memory Access or R-type instruction completion
- Write-back step INSTRUCTIONS TAKE FROM 3 - 5
CYCLES!
23Step 1 Instruction Fetch
- Use PC to get instruction and put it in the
Instruction Register. - Increment the PC by 4 and put the result back in
the PC. - Can be described succinctly using RTL
"Register-Transfer Language" IR
MemoryPC PC PC 4What is the advantage
of updating the PC now?
24Step 2 Instruction Decode and Register Fetch
- Read registers rs and rt in case we need them
- Compute the branch address in case the
instruction is a branch - RTL A RegIR25-21 B
RegIR20-16ALUOut PC (sign-extend(IR15-0
) ltlt2) - We aren't setting any control lines based on the
instruction type. We are busy "decoding" it in
our control logic.
25Step 3 (instruction dependent)
- ALU is performing one of three functions, based
on instruction type - Memory Reference ALUOut A
sign-extend(IR15-0) - R-type ALUOut A op B
- Branch if (AB) PC ALUOut
26Step 4 (R-type or memory-access)
- Loads and stores access memory MDR
MemoryALUOut or MemoryALUOut B - R-type instructions finish RegIR15-11
ALUOutThe write actually takes place at the
end of the cycle on the edge
27Write-back step
- RegIR20-16 MDR
- What about all the other instructions?
28Summary
29Simple Questions
- How many cycles will it take to execute this
code? lw t2, 0(t3) lw t3, 4(t3) beq
t2, t3, Label assume not equal add t5, t2,
t3 sw t5, 8(t3)Label ... - In what cycle does the actual addition of t2 and
t3 takes place?
30Implementing the Control
- Value of control signals is dependent upon
- what instruction is being executed
- which step is being performed
- Use the information weve accumulated to specify
a finite state machine - specify the finite state machine graphically, or
- use microprogramming(specify control information
as a program) - Implementation can be derived from specification
31Graphical Specification of FSM
-
-
- How many state bits will we need?
32Finite State Machine for Control
33PLA Implementation
- If I picked a horizontal or vertical line could
you explain it?
34Microprogramming
- A specification methodology
- appropriate if hundreds of opcodes, modes,
cycles, etc. - signals specified symbolically using
microinstructions - Will two implementations of the same architecture
have the same microcode? - What would a microassembler do?
35Microinstruction format
36Microprogram Implementation
- The "next state" is often current state 1
- Dispatch tables used if explicit jump needed
37The Big Picture for control
38Summary
- Datapath components, single- and multi-cycle
implementation for MIPS subset - Single cycle CPI 1, clock cycle large
- Multi-cycle CPI variable, clock cycle small
- Control Simple for single-cycle, complex (need
FSM or microprogram) for multi-cycle
implementation