![Page 1: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/1.jpg)
RISC-V Processor Datapath
![Page 2: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/2.jpg)
Module Outline
● RISC-V datapath implementation– Register File, Instruction memory, Data memory
● Instruction interpretation and execution. ● Combinational control● Assignment: Datapath design and Control Unit
design using a HDL.
![Page 3: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/3.jpg)
Sequential Elements● Register: stores data in a circuit
– Uses a clock signal to determine when to update the stored value
– Edge-triggered: update when Clk changes from 0 to 1
D
Clk
Q
Clk
D
Q
![Page 4: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/4.jpg)
Sequential Elements● Register with write control
– Only updates on clock edge when write control input is 1
– Used when stored value is required later
![Page 5: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/5.jpg)
Sequential Elements● Register with write control
– Only updates on clock edge when write control input is 1
– Used when stored value is required later
D
Clk
Q
Write
Write
D
Q
Clk
![Page 6: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/6.jpg)
Clocking Methodology● Combinational logic transforms data during
clock cycles–
![Page 7: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/7.jpg)
Clocking Methodology● Combinational logic transforms data during
clock cycles– Between clock edges– Input from state elements, output to state element–
![Page 8: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/8.jpg)
Clocking Methodology● Combinational logic transforms data during
clock cycles– Between clock edges– Input from state elements, output to state element–
![Page 9: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/9.jpg)
Clocking Methodology● Combinational logic transforms data during
clock cycles– Between clock edges– Input from state elements, output to state element– Longest delay determines clock period
![Page 10: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/10.jpg)
Building a Datapath
● Datapath–
![Page 11: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/11.jpg)
Building a Datapath
● Datapath– Elements that process data and addresses
in the CPU●
●
![Page 12: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/12.jpg)
Building a Datapath
● Datapath– Elements that process data and addresses
in the CPU● Registers, ALUs, muxes, memories, …
●
![Page 13: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/13.jpg)
Building a Datapath
● Datapath– Elements that process data and addresses
in the CPU● Registers, ALUs, muxes, memories, …
● We will build a RISC-V datapath incrementally
![Page 14: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/14.jpg)
A Basic RISC-V Implementation
● Memory-reference instructions – Load doubleword (ld) and Store doubleword (sd)
● ALU instructions – add, addi, sub, and, or● Branch on equal (beq)
![Page 15: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/15.jpg)
Instruction Execution – Steps
![Page 16: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/16.jpg)
Instruction Execution – Steps
● Instruction Fetch
![Page 17: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/17.jpg)
Instruction Execution – Steps
● Instruction Fetch● Instruction Decode/Register Fetch
![Page 18: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/18.jpg)
Instruction Execution – Steps
● Instruction Fetch● Instruction Decode/Register Fetch● Execute
– ALU
– Effective Address Calculation
![Page 19: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/19.jpg)
Instruction Execution – Steps
● Instruction Fetch● Instruction Decode/Register Fetch● Execute
– ALU
– Effective Address Calculation
● Memory Access
![Page 20: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/20.jpg)
Instruction Execution – Steps
● Instruction Fetch● Instruction Decode/Register Fetch● Execute
– ALU
– Effective Address Calculation
● Memory Access● Write back (Update RF)
![Page 21: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/21.jpg)
Instruction Fetch – Actions
![Page 22: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/22.jpg)
Instruction Fetch – Actions
● Read Program Counter
![Page 23: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/23.jpg)
Instruction Fetch – Actions
● Read Program Counter● Fetch instruction from Instruction memory
pointed to by the PC
![Page 24: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/24.jpg)
Instruction Fetch – Actions
● Send Program Counter to Instruction Memory● Fetch instruction from IM● Increment PC
![Page 25: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/25.jpg)
Instruction Fetch – Elements
![Page 26: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/26.jpg)
Instruction Fetch – Elements
![Page 27: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/27.jpg)
Instruction Fetch
![Page 28: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/28.jpg)
ALU Instructions – Operations
ADD x5, x6, x7
![Page 29: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/29.jpg)
ALU Instructions – Operations
● Read x6 and x7 from Register file– Send 6 and 7 to RF
– RF reads contents of x6 and x7
ADD x5, x6, x7
![Page 30: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/30.jpg)
ALU Instructions – Operations
● Read x6 and x7 from Register file– Send register numbers (6 and 7) to RF
– RF reads contents of x6 and x7
● Add contents of x6 and x7 in the ALU
ADD x5, x6, x7
![Page 31: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/31.jpg)
ALU Instructions – Operations
● Read x6 and x7 from Register file– Send 6 and 7 to RF
– RF reads contents of x6 and x7
● Add contents of x6 and x7 in the ALU● Feed the sum to the RF; Ask it to write into x5
ADD x5, x6, x7
![Page 32: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/32.jpg)
ALU Operations – Elements
ADD x5, x6, x7
![Page 33: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/33.jpg)
ALU Operations – Elements
ADD x5, x6, x7
REGISTERFILE
REGISTERFILE
Addr
Data
Data
Write
![Page 34: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/34.jpg)
ALU Operations – Elements
ADD x5, x6, x7
![Page 35: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/35.jpg)
ALU Operations – Elements
ADD x5, x6, x7
![Page 36: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/36.jpg)
ALU Operations – Datapath
ADD x5, x6, x7
![Page 37: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/37.jpg)
ALU Operations – Datapath
ADDI x5, x6, -13
● How will the design change for ADDI?
![Page 38: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/38.jpg)
ALU Operations – Datapath
ADDI x5, x6, -13
● How will the design change for ADDI?● How is the immediate value treated?
![Page 39: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/39.jpg)
ALU Operations – Datapath
ADDI x5, x6, -13
● How will the design change for ADDI?● How is the immediate value treated?
32 64
![Page 40: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/40.jpg)
ALU Operations – Datapath
ADDI x5, x6, -13
32 64
REGISTERFILE
REGISTERFILE
![Page 41: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/41.jpg)
ALU Operations – Datapath
ADDI x5, x6, -13
32 64
![Page 42: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/42.jpg)
Loads and Stores – Actions
LW x5, -8(x6)
![Page 43: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/43.jpg)
Loads and Stores – Actions
● Calculate full address– Sum of -8 (offset) and contents of x6 (base)
– Size of offset? Size of contents of x6?
LW x5, -8(x6)
![Page 44: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/44.jpg)
Loads and Stores – Actions
● Calculate full address– Sum of -8 (offset) and contents of x6 (base)
– Size of offset? Size of contents of x6?
● Send the address to Data memory
LW x5, -8(x6)
![Page 45: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/45.jpg)
Loads and Stores – Actions
● Calculate full address– Sum of -8 (offset) and contents of x6 (base)
– Size of offset? Size of contents of x6?
● Send the address to Data memory● DM reads out the contents of Mem[x6+(-8)]
LW x5, -8(x6)
![Page 46: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/46.jpg)
Loads and Stores – Actions
● Calculate full address– Sum of -8 (offset) and contents of x6 (base)
– Size of offset? Size of contents of x6?
● Send the address to Data memory● DM reads out the contents of Mem[x6+(-8)]● Feed the value from memory to the RF; Ask it
to write the value into x5
LW x5, -8(x6)
![Page 47: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/47.jpg)
Loads and Stores – Elements
LW x5, -8(x6)
32 64
![Page 48: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/48.jpg)
Memory and R-type Instructions
32 64
![Page 49: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/49.jpg)
Memory Instruction – Load
LW x5, -8(x6)
32 64
![Page 50: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/50.jpg)
Memory Instruction – Load
LW x5, -8(x6)
32 64
![Page 51: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/51.jpg)
Memory Instruction – Load
LW x5, -8(x6)
32 64
66
55
![Page 52: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/52.jpg)
Memory Instruction – Load
LW x5, -8(x6)
32 64
R[x6]R[x6]
-8 (2s 64b)-8 (2s 64b)
66
55
![Page 53: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/53.jpg)
Memory Instruction – Load
LW x5, -8(x6)
ADD
32 64
R[x6]R[x6]
-8 (2s 64b)-8 (2s 64b)
66
55
![Page 54: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/54.jpg)
Memory Instruction – Load
LW x5, -8(x6)
ADD
32 64
R[x6]R[x6]
-8 (2s 64b)-8 (2s 64b)
R[x6]-8R[x6]-8
66
55
![Page 55: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/55.jpg)
Memory Instruction – Load
LW x5, -8(x6)
ADD
32 64
R[x6]R[x6]
-8 (2s 64b)-8 (2s 64b)
R[x6]-8R[x6]-8
R[x6]-8R[x6]-8
66
55
![Page 56: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/56.jpg)
Memory Instruction – Load
LW x5, -8(x6)
ADD
32 64
R[x6]R[x6]
-8 (2s 64b)-8 (2s 64b)
R[x6]-8R[x6]-8 M[R[x6]-8]M[R[x6]-8]
R[x6]-8R[x6]-8
66
55
![Page 57: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/57.jpg)
Memory Instruction – Load
LW x5, -8(x6)
ADD
32 64
R[x6]R[x6]
-8 (2s 64b)-8 (2s 64b)
R[x6]-8R[x6]-8 M[R[x6]-8]M[R[x6]-8]M[R[x6]-8]M[R[x6]-8]
R[x6]-8R[x6]-8
66
55
![Page 58: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/58.jpg)
Memory Instruction – Load
Control Signals: RegWrite; ALUSrc; ALUoperation;MemRead;MemWrite; MemToReg;Control Signals: RegWrite; ALUSrc; ALUoperation;MemRead;MemWrite; MemToReg;
32 64
![Page 59: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/59.jpg)
Memory Instruction – Load
Control Signals: RegWrite=1; ALUSrc=1; ALUoperation=ADD;MemRead=1;MemWrite=0; MemToReg=1;
Control Signals: RegWrite=1; ALUSrc=1; ALUoperation=ADD;MemRead=1;MemWrite=0; MemToReg=1;
32 64
![Page 60: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/60.jpg)
Memory Instruction – Store
SW x5, -8(x6)
32 64
![Page 61: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/61.jpg)
Memory Instruction – Store
SW x5, -8(x6)
![Page 62: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/62.jpg)
Memory Instruction – Store
Control Signals: Control Signals:
32 64
![Page 63: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/63.jpg)
Memory Instruction – Store
Control Signals: RegWrite=0; ALUSrc=1; ALUoperation=ADD;MemRead=0;MemWrite=1; MemToReg=X;
Control Signals: RegWrite=0; ALUSrc=1; ALUoperation=ADD;MemRead=0;MemWrite=1; MemToReg=X;
32 64
![Page 64: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/64.jpg)
R Type Instruction – ADD
ADD x5, x6, x7
32 64
![Page 65: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/65.jpg)
R Type Instruction – ADD
ADD x5, x6, x7
![Page 66: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/66.jpg)
R Type Instruction – ADD
Control Signals: Control Signals:
32 64
![Page 67: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/67.jpg)
R Type Instruction – ADD
Control Signals: RegWrite=1; ALUSrc=0; ALUoperation=ADD;MemRead=X;MemWrite=0; MemToReg=0;
Control Signals: RegWrite=1; ALUSrc=0; ALUoperation=ADD;MemRead=X;MemWrite=0; MemToReg=0;
32 64
![Page 68: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/68.jpg)
I Type Instruction – ADDI
ADDI x5, x6, 13
32 64
![Page 69: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/69.jpg)
I Type Instruction – ADDI
ADDI x5, x6, 13
![Page 70: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/70.jpg)
I Type Instruction – ADDI
Control Signals: Control Signals:
32 64
![Page 71: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/71.jpg)
I Type Instruction – ADDI
Control Signals: RegWrite=1; ALUSrc=1; ALUoperation=ADD;MemRead=X;MemWrite=0; MemToReg=0;
Control Signals: RegWrite=1; ALUSrc=1; ALUoperation=ADD;MemRead=X;MemWrite=0; MemToReg=0;
32 64
![Page 72: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/72.jpg)
BEQ – Actions
BEQ x5, x6, -16BEQ x5, x6, -16
if(R[x5] = R[x6]); then PC = PC + {-16,1’b0} = PC + {-32} # -16 << 1
![Page 73: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/73.jpg)
BEQ – Actions
BEQ x5, x6, -16BEQ x5, x6, -16
if(R[x5] = R[x6]); then PC = PC + {-16,1’b0} = PC + {-32} # -16 << 1
![Page 74: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/74.jpg)
BEQ – Actions
BEQ x5, x6, -16BEQ x5, x6, -16
if(R[x5] = R[x6]); then PC = PC + {-16,1’b0} = PC + {-32} # -16 << 1
Operations?Operations?
![Page 75: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/75.jpg)
BEQ – Actions
BEQ x5, x6, -16BEQ x5, x6, -16
if(R[x5] = R[x6]); then PC = PC + {-16,1’b0} = PC + {-32} # -16 << 1
ShiftLeft 1
ShiftLeft 1
64 64ImmGen
ImmGen
32 64
![Page 76: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/76.jpg)
BEQ – Actions
● Read x5 and x6 from Register file– Send 5 and 6 to RF
– RF reads contents of x5 and x6
●
BEQ x5, x6, -16
![Page 77: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/77.jpg)
BEQ – Actions
● Read x5 and x6 from Register file– Send 5 and 6 to RF
– RF reads contents of x5 and x6
● Send to ALU to Subtract
BEQ x5, x6, -16
![Page 78: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/78.jpg)
BEQ – Actions
● Read x5 and x6 from Register file– Send 5 and 6 to RF
– RF reads contents of x5 and x6
● Send to ALU to Subtract● Read out Zero flag from ALU
BEQ x5, x6, -16
![Page 79: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/79.jpg)
BEQ – Actions
● Read x5 and x6 from Register file– Send 5 and 6 to RF
– RF reads contents of x5 and x6
● Send to ALU to Subtract● Read out Zero flag from ALU● If Z flag == 0; then PC = (PC + imm<<1)
BEQ x5, x6, -16
![Page 80: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/80.jpg)
BEQ – Actions
● Read x5 and x6 from Register file– Send 5 and 6 to RF
– RF reads contents of x5 and x6
● Send to ALU to Subtract● Read out Zero flag from ALU● If Z flag == 0; then PC = (PC + imm<<1)● Else if Z flag == 1; then PC = PC + 4
BEQ x5, x6, -16
![Page 81: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/81.jpg)
Branches – Elements
BEQ x5, x6, LABEL BEQ x5, x6, -16
![Page 82: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/82.jpg)
Branches – Elements
BEQ x5, x6, LABEL BEQ x5, x6, -16
![Page 83: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/83.jpg)
RISC-V Datapath – BEQ
![Page 84: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/84.jpg)
RISC-V Datapath – BEQ
![Page 85: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/85.jpg)
RISC-V Datapath – BEQ
![Page 86: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/86.jpg)
RISC-V Datapath – BEQ
![Page 87: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/87.jpg)
RISC-V Datapath – BEQ
![Page 88: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/88.jpg)
RISC-V Datapath – BEQ
![Page 89: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/89.jpg)
RISC-V Datapath – BEQ
![Page 90: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/90.jpg)
RISC-V Datapath – BEQ
Control Signals : Control Signals :
![Page 91: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/91.jpg)
RISC-V Datapath – BEQ
Control Signals : RegWrite=0; ALUSrc=0; ALUoperation=SUB; MemRead=X;MemWrite=X; MemToReg=X; PCSrc=Condition
Control Signals : RegWrite=0; ALUSrc=0; ALUoperation=SUB; MemRead=X;MemWrite=X; MemToReg=X; PCSrc=Condition
![Page 92: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/92.jpg)
RISC-V Datapath and Control Lines
![Page 93: RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational](https://reader036.vdocuments.us/reader036/viewer/2022062223/5ecedd0cc06374728112dec9/html5/thumbnails/93.jpg)
Module Outline
● MIPS datapath implementation– Register File, Instruction memory, Data memory
● Instruction interpretation and execution. ● Combinational control● Assignment: Datapath design and Control Unit
design using HDL.