Cs2100 12 Basic Datapath
Cs2100 12 Basic Datapath
Basic Datapath
CS2100
Basic Datapath
CS2100
Basic Datapath
All instructions
execute in a single
cycle of the clock
(negative edge to
negative edge)
Not used in reality! Only for teaching purposes.
CS2100
Basic Datapath
CS2100
Basic Datapath
INSTRUCTION FETCH
Obtain
CS2100
Basic Datapath
INSTRUCTION DECODE
Decode instruction to find out what to do
Input: the instruction to be executed
Output: the control signals to the other parts of
the processor telling various units what to do so
that together they execute this instruction
CS2100
Basic Datapath
OPERAND FETCH
Get the operands needed by the instruction to
compute on
Read from the registers
CS2100
Basic Datapath
EXECUTE
CS2100
Do it!
Basic Datapath
RESULT STORE
Write
CS2100
Basic Datapath
10
CS2100
Basic Datapath
11
Generic implementation
use the program counter (PC) to supply the
instruction address and fetch the instruction
from memory (and update the PC)
decode the instruction (and read registers)
execute the instruction
Fetch
PC = PC+4
Exec
Decode
Basic Datapath
12
CLOCKING METHODOLOGIES
Typical execution
read contents of state elements
send values through combinational logic
write results to one or more state elements
CS2100
Basic Datapath
13
CLOCKING METHODOLOGIES
State
element
1
Combinational
logic
State
element
2
clock
CS2100
Basic Datapath
14
FETCHING INSTRUCTIONS
CS2100
Basic Datapath
15
FETCHING INSTRUCTIONS
Add
4
Instruction
Memory
PC
Read
Address
Instruction
Basic Datapath
16
SEQUENTIAL LOGIC
Add
4
Instruction
Memory
PC
Read
Instruction
Address
CLK
CS2100
Basic Datapath
17
SEQUENTIAL LOGIC
Add
4
Instruction
Memory
PC
Read
Instruction
Address
CLK
CS2100
Basic Datapath
18
SEQUENTIAL LOGIC
Add
4
Instruction
Memory
PC
Read
Instruction
Address
CLK
CS2100
Basic Datapath
19
CS2100
Basic Datapath
20
CLK
CS2100
Basic Datapath
21
DECODING INSTRUCTIONS
Control
Unit
Instruction
Read Addr 1
Read
Register
Read Addr 2 Data 1
File
Write Addr
Read
Write Data
CS2100
Data 2
Basic Datapath
22
DECODING INSTRUCTIONS
CS2100
Basic Datapath
23
CS2100
Basic Datapath
24
REGISTER FILE
sel(rs1)
CLK
R0 the constant 0
sel(ws)
EN
R1
.
.
.
32
WE
D
E
M
U
X
EN
R2
D
32
wd
M
U
X
32
rd1
.
.
.
EN
32
sel(rs2)
5
32
R31
.
.
.
32
M
U
X
32
rd2
25
rs
20
15
rt
rd
10
shamt funct
CS2100
Basic Datapath
26
RegWrite
Instruction
ALU control
Read Addr 1
Read
Register
Read Addr 2 Data 1
File
Write Addr
Read
Write Data
ALU
overflow
zero
Data 2
The Register File is not written every cycle (e.g. sw), so we need
an explicit write control signal for the Register File
CS2100
Basic Datapath
27
THE ALU
Additional outputs
Is it zero?
Did an overflow occur?
Typically the flags:
CS2100
Zero
Carry
Overflow
Negative
Basic Datapath
28
Basic Datapath
29
CS2100
Basic Datapath
30
Instruction
16
Address
ALU
Data
Memory Read Data
Write Data
Data 2
Sign
Extend
MemWrite
overflow
zero
Read Addr 1
Register Read
Read Addr 2 Data 1
File
Write Addr
Read
Write Data
CS2100
ALU control
MemRead
32
Basic Datapath
31
Instruction
Fetch
Instruction
Decode
Instruction
Decode
Operand
Fetch
Operand
Fetch
Execute
Execute
Memory
Read/Write
Result
Store
CS2100
Result
Store
Basic Datapath
32
CS2100
Basic Datapath
33
Add
Shift
left 2
Branch
target
address
ALU control
PC
Instruction
Read Addr 1
Register Read
Read Addr 2 Data 1
File
Write Addr
Read
Write Data
16
CS2100
ALU
Data 2
Sign
Extend
Basic Datapath
32
34
Add
4
4
Instruction
Memory
PC
CS2100
Read
Address
Instruction
Basic Datapath
Shift
left 2
Jump
address
28
26
35
CS2100
Basic Datapath
36
RegWrite
4
Instruction
Memory
PC
Read
Address
Instruction
CS2100
Address
ALU
Data
Memory Read Data
Write Data
Data 2
Sign
Extend
16
MemtoReg
ovf
zero
Read Addr 1
Register Read
Read Addr 2 Data 1
File
Write Addr
Read
Write Data
MemWrite
MemRead
32
Basic Datapath
37
CS2100
Basic Datapath
38
Observations
R-type: op
31
25
rs
25
20
15
rt
rd
20
10
shamt funct
15
Basic Datapath
39
Shift
PCSrc
left 2
ALUOp
Branch
MemRead
Control
Unit
Instr[31-26]
MemtoReg
MemWrite
ALUSrc
RegWrite
RegDst
ovf
Instruction
Memory
PC
Read
Address
Instr[31-0]
Instr[25-21]
Read Addr 1
Instr[20-16]
Register
Read Addr 2
File
0
1
Instr[15
-11]
Write Addr
Read
Data 1
Address
zero
0
Read
Data 2
Write Data
Write Data
Sign
Extend
Instr[15-0]
16
ALU
Data
Memory
32
Instr[5-0]
ALU
control
Read Data
1
0
R-TYPE INSTRUCTION
DATA/CONTROL FLOW
CS2100
Basic Datapath
41
CS2100
Basic Datapath
42
BRANCH INSTRUCTION
DATA/CONTROL FLOW
CS2100
Basic Datapath
43
Controls
RegDst
ALUSrc
MemtoReg
RegWrite
MemRead
MemWrite
Branch
ALUOp1
ALUOp2
Jump
R-type
000000
lw
100011
sw
101011
beq
000100
j
000010
Instruction [31-26]
CS2100
Basic Datapath
45
ALU operations
Assume
0000 AND
0001 OR
0010 add
0110 subtract
0111 set less than
1100 NOR
CS2100
Basic Datapath
46
ALUop
Operation
Funct field
Desired op
ALU control
lw
00
load word
XXXXXX
add
0010
sw
00
store word
XXXXXX
add
0010
beq
01
branch eq
XXXXXX
subtract
0110
R-type
10
add
100000
add
0010
R-type
10
subtract
100010
subtract
0110
R-type
10
AND
100100
and
0000
R-type
10
OR
100101
or
0001
R-type
10
slt
101010
slt
0111
CS2100
Basic Datapath
47
ALUOp0
Funct
Operation (output)
XXXXXX
0010
XXXXXX
0110
XX0000
0010
XX0010
0110
XX0100
0000
XX0101
0001
XX1010
0111
CS2100
Basic Datapath
48
READING ASSIGNMENT
The
CS2100
Basic Datapath
49
END
CS2100
Basic Datapath
50