CS61C: Great Ideas in Computer Architecture (aka Machine Structures)
Lecture 15: Single-Cycle Datapath II
Instructor: Ariana Abel
Slides Credit: Justin Yokota
CS 61C
Summer 2025
Agenda
2
CS 61C
Summer 2025
Agenda
3
CS 61C
Summer 2025
Datapath so far: R, I, S, J types
4
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
PC Sel
ALUSel
ASel
MEMRW
WBSel
RegWEn
BSel
ImmSel
CS 61C
Summer 2025
Implementing branch instructions
5
CS 61C
Summer 2025
Datapath so far
6
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
PC Sel
ALUSel
ASel
MEMRW
WBSel
RegWEn
BSel
ImmSel
CS 61C
Summer 2025
Datapath running beq x5 x6 16
7
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
0x00628863
16
5
6
16
16
PC Sel?
ADD
1
Read
*
0
1
B
*
16
0
CS 61C
Summer 2025
The Branch Comparator
The Branch Comparator will handle all our branch instructions:
Input:
Output:
8
Eq
Branch Comp
32
32
BrUn
Lt
CS 61C
Summer 2025
Datapath running beq x5 x6 16 (equality holds)
9
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
0x00628863
16
5
6
Branch Comp
16
16
3
3
PC Sel
ADD
1
Read
*
0
1
B
*
PCSel depends on the result of Branch Comparator; either the pink or the orange path gets used, though both get computed
16
0
CS 61C
Summer 2025
Datapath running beq x5 x6 16 (equality does not hold)
10
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
0x00628863
16
5
6
Branch Comp
16
16
3
2
PC Sel
ADD
1
Read
*
0
1
*
RegWEn and MEMRW need to disable writes, since we don't want to change anything except PC.
0
4
B
CS 61C
Summer 2025
Agenda
11
CS 61C
Summer 2025
Implementing lui
12
CS 61C
Summer 2025
Implementing auipc
13
CS 61C
Summer 2025
Datapath So Far
14
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
Branch Comp
PC Sel
ALUSel
ASel
MEMRW
WBSel
RegWEn
BSel
ImmSel
BrUn
BrLt
BrEq
CS 61C
Summer 2025
Datapath running lui x5 0x12345
15
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
Branch Comp
0
B
*
Read
1
1
1
U
*
lui doesn't need many changes! All we need is a new ImmGen format and a new ALU operation: return value of B.
5
0x1234 5000
0x1234 5000
0x123452B7
CS 61C
Summer 2025
Datapath running auipc x5 0x12345
16
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
Branch Comp
0
ADD
1
Read
1
1
1
U
*
auipc also gets implemented with no changes, by using the PC input we set for jal instructions!
5
0x1234 5000
0x1234 5000
0x12345297
CS 61C
Summer 2025
Complete RISC-V Datapath!!!
17
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
Branch Comp
PC Sel
ALUSel
ASel
MEMRW
WBSel
RegWEn
BSel
ImmSel
BrUn
BrLt
BrEq
CS 61C
Summer 2025
Agenda
18
CS 61C
Summer 2025
What's Left?
With the datapath we have, we've reduced the problem of making a CPU to a few small subcircuits:
19
CS 61C
Summer 2025
How to make the ImmGen
Option 1:
Option 2:
20
CS 61C
Summer 2025
Instruction Formats
21
CS 61C
Summer 2025
Tracking all Immediate Bits in each format
22
I | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | | | | | | | | | | | | | | | | | | |
S | 11 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 0 | | | | | | | |
B | 12 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 11 | | | | | | | |
U | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
J | 20 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 11 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
Imm | 31 | 30 | 29 | 28 | 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 |
CS 61C
Summer 2025
Tracking all Immediate Bits in each format
23
I | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | | | | | | | | | | | | | | | | | | |
S | 11 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 0 | | | | | | | |
B | 12 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 11 | | | | | | | |
U | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
J | 20 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 11 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
Imm | 31 | 30 | 29 | 28 | 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 |
Bit 0 of imm: Bit 20 of inst if I type, Bit 7 of inst if S type, always 0 if B/U/J type
CS 61C
Summer 2025
Tracking all Immediate Bits in each format
24
I | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | | | | | | | | | | | | | | | | | | |
S | 11 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 0 | | | | | | | |
B | 12 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 11 | | | | | | | |
U | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
J | 20 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 11 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
Imm | 31 | 30 | 29 | 28 | 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 |
Bits 4-1 of imm: Bits 24-21 of inst if I/J type, Bits 11-8 of inst if S/B type, always 0 if U type. Only found in two parts of the instruction, and these 4 bits are always together.
CS 61C
Summer 2025
Tracking all Immediate Bits in each format
25
I | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | | | | | | | | | | | | | | | | | | |
S | 11 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 0 | | | | | | | |
B | 12 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 11 | | | | | | | |
U | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
J | 20 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 11 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
Imm | 31 | 30 | 29 | 28 | 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 |
Bits 10-5 of imm: Bits 30-25 of inst if I/S/B/J type, always 0 if U type. Only found in one part of the instruction, even though 4 different instruction formats use it!
CS 61C
Summer 2025
Tracking all Immediate Bits in each format
26
I | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | | | | | | | | | | | | | | | | | | |
S | 11 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 0 | | | | | | | |
B | 12 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 11 | | | | | | | |
U | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
J | 20 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 11 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
Imm | 31 | 30 | 29 | 28 | 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 |
MSB of instruction is ALWAYS the MSB of the immediate. Sign-extending is just copying the MSB, and almost all RISC-V immediates sign-extend. To sign-extend, we just take the MSB of the instruction.
CS 61C
Summer 2025
Tracking all Immediate Bits in each format
27
I | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | | | | | | | | | | | | | | | | | | |
S | 11 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 0 | | | | | | | |
B | 12 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 11 | | | | | | | |
U | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
J | 20 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 11 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
Imm | 31 | 30 | 29 | 28 | 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 |
Bits 31-21 and 19-12 of immediate: Always the corresponding bit in the instruction if part of the format, and bit 31 otherwise. Only two options for these bits as well
CS 61C
Summer 2025
Tracking all Immediate Bits in each format
28
I | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | | | | | | | | | | | | | | | | | | |
S | 11 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 0 | | | | | | | |
B | 12 | 10 | 9 | 8 | 7 | 6 | 5 | | | | | | | | | | | | | | 4 | 3 | 2 | 1 | 11 | | | | | | | |
U | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
J | 20 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 11 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | | | | | | | | | | | | |
Imm | 31 | 30 | 29 | 28 | 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 |
Bits 20 and 11 of immediate: Kind of put in random spots where there's space. Bit 20 needs a 2-way mux, and bit 11 needs a 4-way mux
CS 61C
Summer 2025
How to make the ImmGen
Because of how all instruction formats were chosen, there are a lot of underlying patterns in how immediates are stored.
By looking for these patterns, the ImmGen can be greatly simplified (in terms of total number of logic gates)
29
CS 61C
Summer 2025
Complete RISC-V Datapath!
30
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
Branch Comp
PC Sel
ALUSel
ASel
MEMRW
WBSel
RegWEn
BSel
ImmSel
BrUn
BrLt
BrEq
CS 61C
Summer 2025
Agenda
31
CS 61C
Summer 2025
Complete RISC-V Datapath
32
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
Branch Comp
PC Sel
ALUSel
ASel
MEMRW
WBSel
RegWEn
BSel
ImmSel
BrUn
BrLt
BrEq
CS 61C
Summer 2025
[Practice] RV32I Datapath and Control
For each instruction below:
33
CS 61C
Summer 2025
34
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
Branch Comp
PC Sel
ALUSel
ASel
MEMRW
WBSel
RegWEn
BSel
ImmSel
BrUn
BrLt
BrEq
CS 61C
Summer 2025
Scratch Work:
CS 61C
Summer 2025
Control Logic Truth Table (Partial)
36
inst[31:0] | BrEq | BrLT | PCSel | ImmSel | BrUn | ASel | BSel | ALUSel | MemRW | RegWEn | WBSel |
R-Type | * | * | +4 | * | * | Reg | Reg | (Op) | Read | 1 | ALU |
add | | | | | | | | Add | | | |
sub | | | | | | | | Sub | | | |
addi | * | * | +4 | I | * | Reg | Imm | Add | Read | 1 | ALU |
lw | * | * | +4 | I | * | Reg | Imm | Add | Read | 1 | Mem |
sw | * | * | +4 | S | * | Reg | Imm | Add | Write | 0 | * |
beq | | | | B | * | PC | Imm | Add | Read | 0 | * |
not taken | 0 | * | +4 | | | | | | | | |
taken | 1 | * | ALU | | | | | | | | |
bne | | | | B | * | PC | Imm | Add | Read | 0 | * |
taken | 0 | * | ALU | | | | | | | | |
not taken | 1 | * | +4 | | | | | | | | |
blt taken | * | 1 | ALU | B | 0 | PC | Imm | Add | Read | 0 | * |
bltu taken | * | 1 | ALU | B | 1 | PC | Imm | Add | Read | 0 | * |
jalr | * | * | ALU | I | * | Reg | Imm | Add | Read | 1 | PC+4 |
jal | * | * | ALU | J | * | PC | Imm | Add | Read | 1 | PC+4 |
auipc | * | * | +4 | U | * | PC | Imm | Add | Read | 1 | ALU |
Do Project 3!
CS 61C
Summer 2025
Agenda
37
CS 61C
Summer 2025
Two Options for Control Realization
38
CS 61C
Summer 2025
RV32I ROM-based Control
39
1. What is the minimum set of instruction bits needed for input (RV32I)?
2. Why might PCSel not be known at this time?
A. 32
B. 17
C. 11
D. 9
E. Something else
(address)
?
decoder
ROM
control signals
RegWEn
ImmSel[2:0]
BrUn
BSel
ASel
ALUSel[3:0]
MemRW
WBSel[1:0]
control word
14
CS 61C
Summer 2025
RV32I is a “9-bit ISA”
40
CS 61C
Summer 2025
RV32I ROM-based Control
41
9
inst[30,� 14:12,
6:2]
decoder
ROM
RegWEn
ImmSel[2:0]
BrUn
BSel
ASel
ALUSel[3:0]
MemRW
WBSel[1:0]
14
BrEq
Datapath
BrLT
Datapath
Control Logic Part 1
Take branch?
PCSel
Control Logic Part 2
PCSel cannot be encoded in our ROM because it depends on subsequent datapath output (branch comparator).
CS 61C
Summer 2025
ROM Controller Implementation
Under the hood, the ROM controller can be implemented as combinational logic gates. Use Sum of Products on logic table.
42
ROM
Control Word for add |
Control Word for sub |
Control Word for or |
… |
… |
decoder
add
or
jal
9
inst[30,� 14:12,
6:2]
14
control word
AND
OR
sub
CS 61C
Summer 2025
Agenda
43
CS 61C
Summer 2025
Combinational Logic-based Control Logic
44
CS 61C
Summer 2025
[Practice] Combinational Logic-based Control Logic
45
CS 61C
Summer 2025
[Practice] Write a Boolean Expression for BrUn
46
Instruction | Opcode | Funct3 |
beq rs1 rs2 label | 110 0011 | 000 |
bne rs1 rs2 label | 110 0011 | 001 |
blt rs1 rs2 label | 110 0011 | 100 |
bltu rs1 rs2 label | 110 0011 | 110 |
bge rs1 rs2 label | 110 0011 | 101 |
bgeu rs1 rs2 label | 110 0011 | 111 |
31 25 24 20 19 15 14 12 11 7 6 0 | ||||||
B | imm[12|10:5] | rs2 | rs1 | funct3 | imm[4:1|11] | opcode |
BrUn = !inst[2]&!inst[3]&!inst[4]&inst[5]&inst[6]&inst[13]
CS 61C
Summer 2025
[Practice] Write a Boolean Expression for BrUn
47
Instruction | Opcode | Funct3 |
beq rs1 rs2 label | 110 0011 | 000 |
bne rs1 rs2 label | 110 0011 | 001 |
blt rs1 rs2 label | 110 0011 | 100 |
bltu rs1 rs2 label | 110 0011 | 110 |
bge rs1 rs2 label | 110 0011 | 101 |
bgeu rs1 rs2 label | 110 0011 | 111 |
31 25 24 20 19 15 14 12 11 7 6 0 | ||||||
B | imm[12|10:5] | rs2 | rs1 | funct3 | imm[4:1|11] | opcode |
BrUn = inst[13]
For non-Branch instructions, BrUn is *, not 0. So we don't actually need to check the opcode bits!
CS 61C
Summer 2025
Combinational Logic-based Control Logic
48
CS 61C
Summer 2025
Agenda
49
CS 61C
Summer 2025
Instructions' Critical Path
For each of the below instructions, what is the delay along the critical path?
1. add rd rs1 rs2
2. lw rd imm(rs1)
50
A. tclk_q + tAdd + tIMEM + tReg� + tBrComp + tALU + tDMEM + tmux + tSetup
B. tclk_q + tIMEM + tReg + tmux� + tALU + tmux + tsetup
C. tclk_q + tIMEM + max{tReg, tImm}� + tALU + 2*tmux + tDMEM + tSetup
D. tclk_q + tIMEM + max{tReg, tImm}� + tALU + 3*tmux + tSetup
E. Something else
CS 61C
Summer 2025
Critical Path for Add: tclk_q + tIMEM + tReg + tmux
+ tALU + tmux + tsetup
51
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
Branch Comp
PC Sel
ALUSel
ASel
MEMRW
WBSel
RegWEn
BSel
ImmSel
BrUn
BrLt
BrEq
CS 61C
Summer 2025
Critical Path for lw: tclk_q + tIMEM + max{tReg, tImm} + tALU + 2*tmux + tDMEM + tSetup
52
PC
dataR
addr
IMEM
dataW
rsW
rs1 data1
rs2
data2�
Reg[]
+
4
Control Logic
A
ALU
B
ImmGen
1
0
dataR
addr
DMEM
dataW
1
0
0
1
1
0
2
Branch Comp
PC Sel
ALUSel
ASel
MEMRW
WBSel
RegWEn
BSel
ImmSel
BrUn
BrLt
BrEq
CS 61C
Summer 2025
Instruction Timing, Divided by 5 Phases
53
Instruction Decode (IF)
Execute (EX)
Instruction Fetch (IF)
Memory Access (MEM)
Write back to Reg (WB)
200 ps
100 ps
200 ps
200 ps
100 ps
CS 61C
Summer 2025
Compute Clock Period
54
Instruction | IF (200ps) | ID (100ps) | EX (200ps) | MEM (200ps) | WB (100ps) | Total |
add | X | X | X | | X | 600ps |
beq | X | X | X | | | 500ps |
jal | X | X | X | | | 500ps |
lw | X | X | X | X | X | 800ps |
sw | X | X | X | X | | 700ps |
CS 61C
Summer 2025
5-Phase Timing, In Detail
55
PC
clock
Instr. fetch
Instr. decode
Execute
Memory Access
pc
pc+4
old
old
old
old
old
instruction
register out
ALU result
memory data
tIF
tID
tEX
tMEM
tWB
CS 61C
Summer 2025
Agenda
56
CS 61C
Summer 2025
Call home, we’ve made HW/SW contact!
57
High Level Language�Program (e.g., C)
Assembly Language �Program (e.g., RISC-V)
Machine Language Program (RISC-V)
Hardware Architecture Description�(e.g., block diagrams)
Logic Circuit Description�(Circuit Schematic Diagrams)
Compiler
Architecture Implementation
Assembler
temp = v[k];
v[k] = v[k+1];
v[k+1] = temp;
1000 1101 1110 0010 0000 0000 0000 0000
1000 1110 0001 0000 0000 0000 0000 0100
1010 1110 0001 0010 0000 0000 0000 0000
1010 1101 1110 0010 0000 0000 0000 0100
lw x3, 0(x10)
lw x4, 4(x10)
sw x4, 0(x10)
sw x3, 4(x10)
IMEM
ALU
Imm
.
Gen
+4
DMEM
Branch
Comp.
Reg
[]
AddrA
AddrB
DataA
AddrD
DataB
DataD
Addr
DataW
DataR
1
0
0
1
2
1
0
pc
0
1
inst
[11:7]
inst
[19:15]
inst
[24:20]
inst
[31:7]
pc+4
alu
mem
wb
alu
pc+4
Reg
[rs1]
pc
imm
[31:0]
Reg
[rs2]
wb
CS 61C
Summer 2025
“And in conclusion…”
CS 61C
Summer 2025