Skip to content

CS214 Principles of Computer Organization

NOTE

Contributors:

  1. Yicheng Xiao
  2. Shengli Zhou
  3. Haibin Lai

We have designed a pipelined RISC-V CPU with the following structure: Pipeline Structure

We have realized the following instructions:

InstructionEncodingData FlowUsage
R-Type InstructionOpcode: 0110011
addfunct7: 0x00 funct3: 0x0Register(rs1, rs2) -> ALU -> WB -> Register(rd)add rd, rs1, rs2
xorfunct7: 0x00 funct3: 0x4Register(rs1, rs2) -> ALU -> WB -> Register(rd)xor rd, rs1, rs2
andfunct7: 0x00 funct3: 0x7Register(rs1, rs2) -> ALU -> WB -> Register(rd)and rd, rs1, rs2
I-Type-Immediate InstructionOpcode: 0010011
addifunct3: 0x0Register(rs1) \ ID(Imm) -> ALU -> WB -> Register(rd)addi rd, rs1, Imm
xorifunct3: 0x4Register(rs1) \ ID(Imm) -> ALU -> WB -> Register(rd)xori rd, rs1, Imm
andifunct3: 0x7Register(rs1) \ ID(Imm) -> ALU -> WB -> Register(rd)andi rd, rs1, Imm
sllifunct3: 0x1Register(rs1) \ ID(Imm) -> ALU -> WB -> Register(rd)slli rd, rs1, Imm
srlifunct3: 0x5Register(rs1) \ ID(Imm) -> ALU -> WB -> Register(rd)srli rd, rs1, Imm
I-Type-Load InstructionOpcode: 0000011
lbfunct3: 0x0Register(rs1) \ ID(Imm) -> ALU -> DMem -> WB -> Register(rd)lb rd, Imm(rs1)
lbufunct3: 0x4Register(rs1) \ ID(Imm) -> ALU -> DMem -> WB -> Register(rd)lbu rd, Imm(rs1)
lwfunct3: 0x2Register(rs1) \ ID(Imm) -> ALU -> DMem -> WB -> Register(rd)lw rd, Imm(rs1)
I-Type-Jump InstructionOpcode: 1100111
jalrfunct3: 0x01. Register(rs1) \ ID(Imm) -> ALU -> IFjalr rd, Imm(rs1)
2. IF(PC) -> ID -> ALU -> WB -> Register(rd)
I-Type-Ecall InstructionOpcode: 1110011
S-Type InstructionOpcode:0100011
swfunct3: 0x2Register(rs1) \ ID(Imm) -> ALU -> DMem(Mem[rs1 + Imm] = rs2)sw rs2, Imm(rs1)
B-Type InstructionOpcode: 1100011
beqfunct3: 0x0Register(rs1, rs2) -> ALU -> IFbeq rs1, rs2, Label
bnefunct3: 0x1Register(rs1, rs2) -> ALU -> IFbne rs1, rs2, Label
bltfunct3: 0x4Register(rs1, rs2) -> ALU -> IFblt rs1, rs2, Label
bgefunct3: 0x5Register(rs1, rs2) -> ALU -> IFbge rs1, rs2, Label
bltufunct3: 0x6Register(rs1, rs2) -> ALU -> IFbltu rs1, rs2, Label
bgeufunct3: 0x7Register(rs1, rs2) -> ALU -> IFbgeu rs1, rs2, Label
J-Type InstructionOpcode: 1101111
jalID(Imm) -> ALU -> PC \ ID(PC) -> ALU -> WB -> Register(rd)jal rd, Label
U-Type InstructionOpcode: 0110111
luiID(Imm) -> ALU -> WB -> Register(rd)lui rd, Imm

The github repository: Pipeline CPU