Control signals

SignalWidthDescriptionUsed By
1RegWrite1 bitWrite enable for register fileRegFile
2MemRead1 bitEnable memory readData Memory
3MemWrite1 bitEnable memory writeData Memory
4MemtoReg1 bitSelect memory data or ALU result to RegFileWrite-back Mux
5ALUSrc1 bitSelect immediate or register as ALU inputALU input Mux
6PCSrc1 bitSelect next PC (sequential or branch)PC input Mux
7Branch1 bitIndicates branch instructionBranch Comparator, PC logic
8Jump1 bitIndicates jump instructionPC logic
9ALUOp2-3 bitsEncodes ALU operation typeALU Control
10(Optional) ImmSrc2-3 bitsSelect immediate extractionImmediate Generator
11(Optional) LoadType2 bitsSelect load sizeData Memory or extension logic
12(Optional) StoreType2 bitsSelect store sizeData Memory

Before diving into the tables, note that some control signals are not simple single bits but multi‑bit buses that let your datapath select among multiple options:

  • ImmSrc [2:0]: selects which immediate format your imm_gen.v uses:

    • 3'b000 = I‑type

    • 3'b001 = S‑type

    • 3'b010 = B‑type

    • 3'b011 = U‑type

    • 3'b100 = J‑type

  • LoadType [2:0]: tells data_mem.v the width and signedness of a load:

    • 3'b000 = Byte, Signed

    • 3'b001 = Half, Signed

    • 3'b010 = Word (no sign extension)

    • 3'b011 = Byte, Unsigned

    • 3'b100 = Half, Unsigned

  • StoreType [1:0]: tells data_mem.v the width of a store:

    • 2'b00 = Byte

    • 2'b01 = Half

    • 2'b10 = Word

PCSrc is high whenever the next‐PC comes from a target adder (branches or jumps):
$PCSrc=Branch \lor Jump$

ImmSrc selects which immediate‐generation format to use:

> I : I‐type (loads, ALU‐imm, JALR)
> S : S‐type (stores)
> B : B‐type (branches)
> U : U‐type (LUI/AUIPC)
> J : J‐type (JAL)

LoadType / StoreType encode access width & signedness.


R-Type ALU Ops (opcode = 0110011; ALUSrc=0; ALUOp=10; ImmSrc=–)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
ADD011001100000000001000000010
SUB011001100001000001000000010
SLL011001100100000001000000010
SLT011001101000000001000000010
SLTU011001101100000001000000010
XOR011001110000000001000000010
SRL011001110100000001000000010
SRA011001110101000001000000010
OR011001111000000001000000010
AND011001111100000001000000010

I-Type ALU Ops (opcode = 0010011; ALUSrc=1; ALUOp=10; ImmSrc=I)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
ADDI00100110001100000010I
SLLI001001100100000001100000010I
SLTI00100110101100000010I
SLTIU00100110111100000010I
XORI00100111001100000010I
SRLI001001110100000001100000010I
SRAI001001110101000001100000010I
ORI00100111101100000010I
ANDI00100111111100000010I

Loads (opcode = 0000011; ALUSrc=1; ALUOp=00; MemRead=1; MemtoReg=1; ImmSrc=I)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
LB00000110001110100000IByte_Signed
LH00000110011110100000IHalf_Signed
LW00000110101110100000IWord
LBU00000111001110100000IByte_Unsigned
LHU00000111011110100000IHalf_Unsigned

Stores (opcode = 0100011; ALUSrc=1; ALUOp=00; MemWrite=1; ImmSrc=S)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
SB0100011000010100000SByte
SH0100011001010100000SHalf
SW0100011010010100000SWord

Branches (opcode = 1100011; ALUSrc=0; ALUOp=01; Branch=1; ImmSrc=B)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
BEQ1100011000000011001B
BNE1100011001000011001B
BLT1100011100000011001B
BGE1100011101000011001B
BLTU1100011110000011001B
BGEU1100011111000011001B

Jumps (opcode = 1101111 & 1100111; ImmSrc=J for JAL, I for JALR)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
JAL11011111100010100J
JALR11001110001100010100I

U-Type (opcode = 0110111 & 0010111; ALUSrc=1; ImmSrc=U)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
LUI01101111100000011U
AUIPC00101111100000000U

See more: ALU Control