93
RISC-V Processor Datapath

RISC-V Processor Datapath - bt.nitk.ac.in · RISC-V datapath implementation – Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational

  • Upload
    others

  • View
    26

  • Download
    0

Embed Size (px)

Citation preview

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.