Pooja Vashisth
Pooja Vashisth
Pooja Vashisth
Pooja Vashisth
CSC 258
Pooja Vashisth
This Week’s Learning Goals
Describe a computer as a state machine that interprets instructions.
4
Introduction
We will examine two RISC-V implementations
A simplified version (this week)
A more realistic pipelined version (next week)
5
Instruction Execution
PC → instruction memory, fetch instruction
6
Datapath Overview
7
Composing the Elements
The single-cycle data path does an instruction in one clock cycle
Each datapath element can only do one function at a time
Hence, we need separate instruction and data memories
Use multiplexers where alternate data sources are used for different
instructions
8
Multiplexers
Can’t just join
wires together
Use multiplexers
9
Breaking Down Instructions
Next, we’ll look at individual steps
10
Instruction Fetch
Increment by
4 for next
64-bit instruction
register
11
R-Format Instructions
Read two register operands
Perform arithmetic/logical operation
Write register result
12
Load/Store Instructions
Read register operands
Calculate address using 12-bit offset
Use ALU, but sign-extend offset
Load: Read memory and update register
Store: Write register value to memory
13
Branch Instructions
1. Read register operands
2. Compare operands
1. Use ALU, subtract and check Zero output
3. Calculate target address
1. Sign-extend displacement
2. Shift left 1 place (halfword displacement)
3. Add to PC value
14
Branch Instructions
Just
re-routes
wires
Sign-bit wire
replicated
15
R-Type/Load/Store Datapath
16
Full Datapath
17
Activity time!
5 minutes
18
Latencies and clock period
19
Full Datapath to Annotate
20
Processor Control and
the Processor as State Machine
21
Control
22
ALU Control
ALU used for
Load/Store: F = add
Branch: F = subtract
R-type: F depends on opcode
23
ALU Control
Assume 2-bit ALUOp derived from opcode
Combinational logic derives ALU control
ALU
opcode ALUOp Operation Opcode field ALU function control
ld 00 load register XXXXXXXXXXX add 0010
sd 00 store register XXXXXXXXXXX add 0010
beq 01 branch on equal XXXXXXXXXXX subtract 0110
24
The Main Control Unit
Control signals derived from instruction
25
Datapath With Control
26
R-Type Instruction
27
Load Instruction
28
BEQ Instruction
29
Performance Issues
1. Longest delay determines clock period
1. Critical path: load instruction
2. Instruction memory → register file → ALU → data
memory → register file
2. Not feasible to vary period for different instructions
3. Violates design principle
1. Making the common case fast
4. We will improve performance by pipelining
30
Demonstration
Let’s go to RIPES!
1. Demonstrate how an instruction is executed
on an implementation of a classical von
Neumann machine.
31
Activity time!
5 minutes
32
Tasks
33
Extra Exercises
34
Let’s do this together!
35
Coming Up
36
Don’t Forget!
37
Don’t Forget!
38
In the next week …
39
See you next
week!
40