From 0281c8fdcdf064a1a300836ace47d8b46d18307e Mon Sep 17 00:00:00 2001 From: Jiuyang Liu Date: Wed, 24 Nov 2021 09:27:42 +0800 Subject: [PATCH 1/8] switch to decoder, recode InstructionType uop to OneHot, improve dispatch timing by removing useless Mux. --- src/main/scala/Constants.scala | 10 +- src/main/scala/Decoder.scala | 191 ++++++++++++++++----------------- 2 files changed, 102 insertions(+), 99 deletions(-) diff --git a/src/main/scala/Constants.scala b/src/main/scala/Constants.scala index 3b3116f..2813a44 100644 --- a/src/main/scala/Constants.scala +++ b/src/main/scala/Constants.scala @@ -1,5 +1,6 @@ package chiselv +import chisel3._ import chisel3.experimental.ChiselEnum object Instruction extends ChiselEnum { @@ -21,5 +22,12 @@ object Instruction extends ChiselEnum { } object InstructionType extends ChiselEnum { - val IN_ERR, INST_R, INST_I, INST_S, INST_B, INST_U, INST_J, INST_Z = Value + val INST_I = Value((1 << 0).U) + val INST_S = Value((1 << 1).U) + val INST_B = Value((1 << 2).U) + val INST_U = Value((1 << 3).U) + val INST_J = Value((1 << 4).U) + val INST_Z = Value((1 << 5).U) + val INST_R = Value((1 << 6).U) + val IN_ERR = Value((1 << 7).U) } diff --git a/src/main/scala/Decoder.scala b/src/main/scala/Decoder.scala index b0c3464..1828d7f 100644 --- a/src/main/scala/Decoder.scala +++ b/src/main/scala/Decoder.scala @@ -1,10 +1,9 @@ package chiselv import chisel3._ -import chisel3.util.{BitPat, _} - -import Instruction._ -import InstructionType._ +import chisel3.util._ +import chiselv.Instruction._ +import chiselv.InstructionType._ class DecoderPort(bitWidth: Int = 32) extends Bundle { val op = Input(UInt(bitWidth.W)) // Op is the 32 bit instruction read received for decoding @@ -26,116 +25,112 @@ class Decoder(bitWidth: Int = 32) extends Module { val DecoderPort = new DecoderPort(bitWidth) }) - val signals = - ListLookup( + class DecType extends Bundle { + val inst_type = UInt(InstructionType.getWidth.W) + val inst = UInt(Instruction.getWidth.W) + val to_alu = Bool() + val branch = Bool() + val use_imm = Bool() + val jump = Bool() + val is_load = Bool() + val is_store = Bool() + } + val signals = chisel3.util.experimental.decode + .decoder( io.DecoderPort.op, + chisel3.util.experimental.decode.TruthTable( // format: off - List( IN_ERR, ERR_INST, false.B, false.B, false.B, false.B, false.B, false.B), // Default values Array( - /* inst_type, inst to_alu branch use_imm jump is_load is_store*/ + /* inst_type, inst to_alu branch use_imm jump is_load is_store*/ // Arithmetic - BitPat("b0000000??????????000?????0110011") -> List(INST_R, ADD, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????000?????0010011") -> List(INST_I, ADDI, true.B, false.B, true.B, false.B, false.B, false.B), - BitPat("b0100000??????????000?????0110011") -> List(INST_R, SUB, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????????????0110111") -> List(INST_U, LUI, false.B, false.B, true.B, false.B, false.B, false.B), - BitPat("b?????????????????????????0010111") -> List(INST_U, AUIPC, false.B, false.B, true.B, false.B, false.B, false.B), + BitPat("b0000000??????????000?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADD.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????000?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADDI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????000?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SUB.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????????????0110111") -> BitPat(INST_U.litValue.U(InstructionType.getWidth.W)) ## BitPat(LUI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????????????0010111") -> BitPat(INST_U.litValue.U(InstructionType.getWidth.W)) ## BitPat(AUIPC.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Shifts - BitPat("b0000000??????????001?????0110011") -> List(INST_R, SLL, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b0000000??????????001?????0010011") -> List(INST_I, SLLI, true.B, false.B, true.B, false.B, false.B, false.B), - BitPat("b0100000??????????101?????0110011") -> List(INST_R, SRL, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b0000000??????????101?????0010011") -> List(INST_I, SRLI, true.B, false.B, true.B, false.B, false.B, false.B), - BitPat("b0100000??????????101?????0110011") -> List(INST_R, SRA, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b0100000??????????101?????0010011") -> List(INST_I, SRAI, true.B, false.B, true.B, false.B, false.B, false.B), + BitPat("b0000000??????????001?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????001?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRA.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRAI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Logical - BitPat("b0000000??????????100?????0110011") -> List(INST_R, XOR, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????100?????0010011") -> List(INST_I, XORI, true.B, false.B, true.B, false.B, false.B, false.B), - BitPat("b0000000??????????110?????0110011") -> List(INST_R, OR, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????110?????0010011") -> List(INST_I, ORI, true.B, false.B, true.B, false.B, false.B, false.B), - BitPat("b0000000??????????111?????0110011") -> List(INST_R, AND, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????111?????0010011") -> List(INST_I, ANDI, true.B, false.B, true.B, false.B, false.B, false.B), + BitPat("b0000000??????????100?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(XOR.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????100?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(XORI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????110?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(OR.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????110?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ORI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????111?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(AND.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????111?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ANDI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Compare - BitPat("b0000000??????????010?????0110011") -> List(INST_R, SLT, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????010?????0010011") -> List(INST_I, SLTI, true.B, false.B, true.B, false.B, false.B, false.B), - BitPat("b0000000??????????011?????0110011") -> List(INST_R, SLTU, true.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????011?????0010011") -> List(INST_I, SLTIU, true.B, false.B, true.B, false.B, false.B, false.B), + BitPat("b0000000??????????010?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLT.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????010?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????011?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTU.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????011?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTIU.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Branches - BitPat("b?????????????????000?????1100011") -> List(INST_B, BEQ, false.B, true.B, true.B, false.B, false.B, false.B), - BitPat("b?????????????????001?????1100011") -> List(INST_B, BNE, false.B, true.B, true.B, false.B, false.B, false.B), - BitPat("b?????????????????100?????1100011") -> List(INST_B, BLT, false.B, true.B, true.B, false.B, false.B, false.B), - BitPat("b?????????????????101?????1100011") -> List(INST_B, BGE, false.B, true.B, true.B, false.B, false.B, false.B), - BitPat("b?????????????????110?????1100011") -> List(INST_B, BLTU, false.B, true.B, true.B, false.B, false.B, false.B), - BitPat("b?????????????????111?????1100011") -> List(INST_B, BGEU, false.B, true.B, true.B, false.B, false.B, false.B), + BitPat("b?????????????????000?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BEQ.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????001?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BNE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????100?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BLT.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????101?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BGE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????110?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BLTU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????111?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BGEU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Jump & link - BitPat("b?????????????????????????1101111") -> List(INST_J, JAL, false.B, false.B, true.B, true.B, false.B, false.B), - BitPat("b?????????????????000?????1100111") -> List(INST_I, JALR, false.B, false.B, true.B, true.B, false.B, false.B), + BitPat("b?????????????????????????1101111") -> BitPat(INST_J.litValue.U(InstructionType.getWidth.W)) ## BitPat(JAL.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????000?????1100111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(JALR.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), // Sync - BitPat("b0000????????00000000000000001111") -> List(INST_I, FENCE, false.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b00000000000000000000001000001111") -> List(INST_I, FENCEI, false.B, false.B, true.B, false.B, false.B, false.B), + BitPat("b0000????????00000000000000001111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(FENCE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b00000000000000000000001000001111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(FENCEI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Environment - BitPat("b00000000000000000000000001110011") -> List(INST_I, ECALL, false.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b00000000000100000000000001110011") -> List(INST_I, EBREAK, false.B, false.B, false.B, false.B, false.B, false.B), + BitPat("b00000000000000000000000001110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ECALL.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b00000000000100000000000001110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(EBREAK.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // CSR - BitPat("b?????????????????001?????1110011") -> List(INST_I, CSRRW, false.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????010?????1110011") -> List(INST_I, CSRRS, false.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????011?????1110011") -> List(INST_I, CSRRC, false.B, false.B, false.B, false.B, false.B, false.B), - BitPat("b?????????????????101?????1110011") -> List(INST_I, CSRRWI, false.B, false.B, true.B, false.B, false.B, false.B), - BitPat("b?????????????????110?????1110011") -> List(INST_I, CSRRSI, false.B, false.B, true.B, false.B, false.B, false.B), - BitPat("b?????????????????111?????1110011") -> List(INST_I, CSRRCI, false.B, false.B, true.B, false.B, false.B, false.B), + BitPat("b?????????????????001?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????010?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRS.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????011?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRC.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????101?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRWI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????110?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRSI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????111?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRCI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Loads - BitPat("b?????????????????000?????0000011") -> List(INST_I, LB, false.B, false.B, true.B, false.B, true.B, false.B), - BitPat("b?????????????????001?????0000011") -> List(INST_I, LH, false.B, false.B, true.B, false.B, true.B, false.B), - BitPat("b?????????????????100?????0000011") -> List(INST_I, LBU, false.B, false.B, true.B, false.B, true.B, false.B), - BitPat("b?????????????????101?????0000011") -> List(INST_I, LHU, false.B, false.B, true.B, false.B, true.B, false.B), - BitPat("b?????????????????010?????0000011") -> List(INST_I, LW, false.B, false.B, true.B, false.B, true.B, false.B), + BitPat("b?????????????????000?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LB.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????001?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LH.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????100?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LBU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????101?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LHU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????010?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), // Stores - BitPat("b?????????????????000?????0100011") -> List(INST_S, SB, false.B, false.B, true.B, false.B, false.B, true.B), - BitPat("b?????????????????001?????0100011") -> List(INST_S, SH, false.B, false.B, true.B, false.B, false.B, true.B), - BitPat("b?????????????????010?????0100011") -> List(INST_S, SW, false.B, false.B, true.B, false.B, false.B, true.B), + BitPat("b?????????????????000?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SB.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), + BitPat("b?????????????????001?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SH.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), + BitPat("b?????????????????010?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y() ) - ) // format: on + , + BitPat(IN_ERR.litValue.U(InstructionType.getWidth.W)) ## BitPat(ERR_INST.litValue.U(Instruction.getWidth.W)) ## BitPat.dontCare(6) // Default values + // format: on + ), + ) + .asTypeOf(new DecType) - io.DecoderPort.rd := 0.U - io.DecoderPort.rs1 := 0.U - io.DecoderPort.rs2 := 0.U - io.DecoderPort.imm := 0.S - io.DecoderPort.inst := signals(1) - io.DecoderPort.toALU := signals(2) - io.DecoderPort.branch := signals(3) - io.DecoderPort.use_imm := signals(4) - io.DecoderPort.jump := signals(5) - io.DecoderPort.is_load := signals(6) - io.DecoderPort.is_store := signals(7) - - switch(signals(0)) { - is(INST_R) { - io.DecoderPort.rd := io.DecoderPort.op(11, 7) - io.DecoderPort.rs1 := io.DecoderPort.op(19, 15) - io.DecoderPort.rs2 := io.DecoderPort.op(24, 20) - } - is(INST_I) { - io.DecoderPort.rd := io.DecoderPort.op(11, 7) - io.DecoderPort.rs1 := io.DecoderPort.op(19, 15) - io.DecoderPort.imm := ImmGenerator(INST_I, io.DecoderPort.op) - } - is(INST_S) { - io.DecoderPort.rs1 := io.DecoderPort.op(19, 15) - io.DecoderPort.rs2 := io.DecoderPort.op(24, 20) - io.DecoderPort.imm := ImmGenerator(INST_S, io.DecoderPort.op) - } - is(INST_B) { - io.DecoderPort.rs1 := io.DecoderPort.op(19, 15) - io.DecoderPort.rs2 := io.DecoderPort.op(24, 20) - io.DecoderPort.imm := ImmGenerator(INST_B, io.DecoderPort.op) - } - is(INST_U) { - io.DecoderPort.rd := io.DecoderPort.op(11, 7) - io.DecoderPort.imm := ImmGenerator(INST_U, io.DecoderPort.op) - } - is(INST_J) { - io.DecoderPort.rd := io.DecoderPort.op(11, 7) - io.DecoderPort.imm := ImmGenerator(INST_J, io.DecoderPort.op) - } - } + io.DecoderPort.rd := io.DecoderPort.op(11, 7) + io.DecoderPort.rs1 := io.DecoderPort.op(19, 15) + io.DecoderPort.rs2 := io.DecoderPort.op(24, 20) + io.DecoderPort.imm := Mux1H( + signals.inst_type, + Seq( + ImmGenerator(INST_I, io.DecoderPort.op), + ImmGenerator(INST_S, io.DecoderPort.op), + ImmGenerator(INST_B, io.DecoderPort.op), + ImmGenerator(INST_U, io.DecoderPort.op), + ImmGenerator(INST_J, io.DecoderPort.op), + ImmGenerator(INST_Z, io.DecoderPort.op), + 0.U, // padding for InstructionType + 0.U // padding for InstructionType + ), + ) + io.DecoderPort.inst := signals.inst + io.DecoderPort.toALU := signals.to_alu + io.DecoderPort.branch := signals.branch + io.DecoderPort.use_imm := signals.use_imm + io.DecoderPort.jump := signals.jump + io.DecoderPort.is_load := signals.is_load + io.DecoderPort.is_store := signals.is_store /** ImmGenerator generates the immadiate value depending on the instruction type * From 2d77a8344ea976c95b8253a385238e36622da8e0 Mon Sep 17 00:00:00 2001 From: Jiuyang Liu Date: Tue, 4 Jan 2022 01:08:03 +0800 Subject: [PATCH 2/8] bump --- build.sbt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index f9d96d9..f48854f 100644 --- a/build.sbt +++ b/build.sbt @@ -27,8 +27,7 @@ lazy val chiselv = (project in file(".")) // Default library versions lazy val versions = new { - val chisel3 = "3.5.0-RC2" - // val firrtl = "1.5-SNAPSHOT" + val chisel3 = "3.5.0-RC2" val chiseltest = "0.5.0-RC2" val scalatest = "3.2.10" val organizeimports = "0.5.0" @@ -43,7 +42,6 @@ libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % versions.scalatest % "test", "com.carlosedp" %% "scalautils" % versions.scalautils, "com.lihaoyi" %% "os-lib" % versions.oslib - // "edu.berkeley.cs" %% "firrtl" % versions.firrtl // Force using SNAPSHOT until next RC is cut (memory synth) ) ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % versions.organizeimports addCompilerPlugin(("edu.berkeley.cs" % "chisel3-plugin" % versions.chisel3).cross(CrossVersion.full)) From 5aa9a8ecb5eba66c29c9051bc9dcc8ce00daebe1 Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Mon, 3 Jan 2022 13:25:18 -0300 Subject: [PATCH 3/8] Update libraries, improve buildfiles --- src/main/scala/Decoder.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/Decoder.scala b/src/main/scala/Decoder.scala index 1828d7f..b6cbd87 100644 --- a/src/main/scala/Decoder.scala +++ b/src/main/scala/Decoder.scala @@ -51,7 +51,7 @@ class Decoder(bitWidth: Int = 32) extends Module { // Shifts BitPat("b0000000??????????001?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), BitPat("b0000000??????????001?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0100000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), BitPat("b0000000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), BitPat("b0100000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRA.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), BitPat("b0100000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRAI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), @@ -104,7 +104,7 @@ class Decoder(bitWidth: Int = 32) extends Module { , BitPat(IN_ERR.litValue.U(InstructionType.getWidth.W)) ## BitPat(ERR_INST.litValue.U(Instruction.getWidth.W)) ## BitPat.dontCare(6) // Default values // format: on - ), + ) ) .asTypeOf(new DecType) @@ -120,9 +120,9 @@ class Decoder(bitWidth: Int = 32) extends Module { ImmGenerator(INST_U, io.DecoderPort.op), ImmGenerator(INST_J, io.DecoderPort.op), ImmGenerator(INST_Z, io.DecoderPort.op), - 0.U, // padding for InstructionType - 0.U // padding for InstructionType - ), + 0.S, // padding for InstructionType + 0.S // padding for InstructionType + ) ) io.DecoderPort.inst := signals.inst io.DecoderPort.toALU := signals.to_alu From 3f7d84e5bcafe73838038668e279e8cf9acd78ca Mon Sep 17 00:00:00 2001 From: Jiuyang Liu Date: Tue, 4 Jan 2022 01:08:03 +0800 Subject: [PATCH 4/8] bump --- src/main/scala/MemoryIOManager.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/scala/MemoryIOManager.scala b/src/main/scala/MemoryIOManager.scala index 641a66f..8d92b5b 100644 --- a/src/main/scala/MemoryIOManager.scala +++ b/src/main/scala/MemoryIOManager.scala @@ -91,8 +91,26 @@ class MemoryIOManager(bitWidth: Int = 32, sizeBytes: Long = 1024) extends Module /* --- Syscon --- */ when(readAddress(31, 12) === 0x0000_1L.U && io.MemoryIOPort.readRequest) { +<<<<<<< HEAD io.SysconPort.Address := readAddress(11, 0) dataOut := io.SysconPort.DataOut +======= + // Dummy output - (0x0000_1000) + when(readAddress(11, 0) === 0x0L.U)(dataOut := 0xbaad_cafeL.U) + // Clock frequency - (0x0000_1008) + when(readAddress(11, 0) === 0x8L.U)(dataOut := clockFreq.asUInt) + // Has UART0 - (0x0000_1010) + when(readAddress(11, 0) === 0x10L.U)(dataOut := 1.U) + // Has GPIO0 - (0x0000_1018) + when(readAddress(11, 0) === 0x18L.U)(dataOut := 1.U) + // Has PWM0 - (0x0000_1020) + when(readAddress(11, 0) === 0x20L.U)(dataOut := 0.U) + // Has Timer0 - (0x0000_1024) + when(readAddress(11, 0) === 0x24L.U)(dataOut := 1.U) + // Num GPIOs in GPIO0 - (0x0000_1028) + when(readAddress(11, 0) === 0x28L.U)(dataOut := numGPIO0.asUInt) + +>>>>>>> 5be2cdb (bump) } /* --- UART0 --- */ From 58e9569b4e709f423b14d18eaf7ac7580ae70e37 Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Mon, 3 Jan 2022 16:35:41 -0300 Subject: [PATCH 5/8] Rebase and fix decode pattern --- src/main/scala/MemoryIOManager.scala | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/main/scala/MemoryIOManager.scala b/src/main/scala/MemoryIOManager.scala index 8d92b5b..641a66f 100644 --- a/src/main/scala/MemoryIOManager.scala +++ b/src/main/scala/MemoryIOManager.scala @@ -91,26 +91,8 @@ class MemoryIOManager(bitWidth: Int = 32, sizeBytes: Long = 1024) extends Module /* --- Syscon --- */ when(readAddress(31, 12) === 0x0000_1L.U && io.MemoryIOPort.readRequest) { -<<<<<<< HEAD io.SysconPort.Address := readAddress(11, 0) dataOut := io.SysconPort.DataOut -======= - // Dummy output - (0x0000_1000) - when(readAddress(11, 0) === 0x0L.U)(dataOut := 0xbaad_cafeL.U) - // Clock frequency - (0x0000_1008) - when(readAddress(11, 0) === 0x8L.U)(dataOut := clockFreq.asUInt) - // Has UART0 - (0x0000_1010) - when(readAddress(11, 0) === 0x10L.U)(dataOut := 1.U) - // Has GPIO0 - (0x0000_1018) - when(readAddress(11, 0) === 0x18L.U)(dataOut := 1.U) - // Has PWM0 - (0x0000_1020) - when(readAddress(11, 0) === 0x20L.U)(dataOut := 0.U) - // Has Timer0 - (0x0000_1024) - when(readAddress(11, 0) === 0x24L.U)(dataOut := 1.U) - // Num GPIOs in GPIO0 - (0x0000_1028) - when(readAddress(11, 0) === 0x28L.U)(dataOut := numGPIO0.asUInt) - ->>>>>>> 5be2cdb (bump) } /* --- UART0 --- */ From 9789ee4f9db8675b2e085a322ee02921a59143f5 Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Mon, 3 Jan 2022 19:03:05 -0300 Subject: [PATCH 6/8] Fix type with cast and some test cases --- src/main/scala/Decoder.scala | 2 +- src/test/scala/DecoderSpec.scala | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/scala/Decoder.scala b/src/main/scala/Decoder.scala index b6cbd87..84d6bb2 100644 --- a/src/main/scala/Decoder.scala +++ b/src/main/scala/Decoder.scala @@ -124,7 +124,7 @@ class Decoder(bitWidth: Int = 32) extends Module { 0.S // padding for InstructionType ) ) - io.DecoderPort.inst := signals.inst + io.DecoderPort.inst := signals.inst.asTypeOf(new Instruction.Type) io.DecoderPort.toALU := signals.to_alu io.DecoderPort.branch := signals.branch io.DecoderPort.use_imm := signals.use_imm diff --git a/src/test/scala/DecoderSpec.scala b/src/test/scala/DecoderSpec.scala index ab4baaf..a31f1ea 100644 --- a/src/test/scala/DecoderSpec.scala +++ b/src/test/scala/DecoderSpec.scala @@ -25,7 +25,7 @@ class DecoderSpec extends AnyFlatSpec with ChiselScalatestTester with should.Mat // ?????????????????000?????0010011 c.io.DecoderPort.op.poke(makeBin("andi x7, x24, -1")) c.clock.step() - validateResult(c, ANDI, 7, 24, 0, -1, true.B, false.B) + validateResult(c, ANDI, 7, 24, 31, -1, true.B, false.B) } } it should "Decode an SB instruction (type S)" in { @@ -33,14 +33,14 @@ class DecoderSpec extends AnyFlatSpec with ChiselScalatestTester with should.Mat // Template: b?????????????????000?????0100011 c.io.DecoderPort.op.poke(makeBin("sb x10, -81(x21)")) c.clock.step() - validateResult(c, SB, 0, 21, 10, -81, false.B, false.B) + validateResult(c, SB, 15, 21, 10, -81, false.B, false.B) } } it should "Decode an BEQ instruction (type B)" in { test(new Decoder()) { c => c.io.DecoderPort.op.poke(makeBin("beq x21, x10, -1366")) c.clock.step() - validateResult(c, BEQ, 0, 21, 10, -1366, false.B, true.B) + validateResult(c, BEQ, 11, 21, 10, -1366, false.B, true.B) } } it should "Decode an LUI instruction (type U)" in { @@ -50,8 +50,8 @@ class DecoderSpec extends AnyFlatSpec with ChiselScalatestTester with should.Mat c.clock.step() c.io.DecoderPort.inst.expect(LUI) c.io.DecoderPort.rd.peek().litValue should be(23) - c.io.DecoderPort.rs1.peek().litValue should be(0) - c.io.DecoderPort.rs2.peek().litValue should be(0) + c.io.DecoderPort.rs1.peek().litValue should be(21) + c.io.DecoderPort.rs2.peek().litValue should be(10) c.io.DecoderPort.imm.peek().litValue should be(-1431658496L) c.io.DecoderPort.toALU.expect(false.B) c.io.DecoderPort.branch.expect(false.B) @@ -62,7 +62,7 @@ class DecoderSpec extends AnyFlatSpec with ChiselScalatestTester with should.Mat // Template: b?????????????????????????1101111 c.io.DecoderPort.op.poke(makeBin("jal x21, -699052")) c.clock.step() - validateResult(c, JAL, 21, 0, 0, -699052, false.B, false.B) + validateResult(c, JAL, 21, 10, 20, -699052, false.B, false.B) } } From 753378bb68dc7c389ae07b796fff54266c6b79ca Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Tue, 4 Jan 2022 15:20:09 -0300 Subject: [PATCH 7/8] Improve formatting --- src/main/scala/CPUSingleCycle.scala | 2 +- src/main/scala/Constants.scala | 2 +- src/main/scala/Decoder.scala | 109 ++++++++++++++-------------- 3 files changed, 56 insertions(+), 57 deletions(-) diff --git a/src/main/scala/CPUSingleCycle.scala b/src/main/scala/CPUSingleCycle.scala index a82a02b..f2fa38f 100644 --- a/src/main/scala/CPUSingleCycle.scala +++ b/src/main/scala/CPUSingleCycle.scala @@ -39,7 +39,7 @@ class CPUSingleCycle( // Instantiate and initialize the ALU val ALU = Module(new ALU(bitWidth)) - ALU.io.ALUPort.inst := ERR_INST + ALU.io.ALUPort.inst := ERR ALU.io.ALUPort.a := 0.U ALU.io.ALUPort.b := 0.U diff --git a/src/main/scala/Constants.scala b/src/main/scala/Constants.scala index 2813a44..322feba 100644 --- a/src/main/scala/Constants.scala +++ b/src/main/scala/Constants.scala @@ -4,7 +4,7 @@ import chisel3._ import chisel3.experimental.ChiselEnum object Instruction extends ChiselEnum { - val ERR_INST, + val ERR, // RV32I ADD, ADDI, SUB, LUI, AUIPC, // Arithmetic SLL, SLLI, SRL, SRLI, SRA, SRAI, // Shifts diff --git a/src/main/scala/Decoder.scala b/src/main/scala/Decoder.scala index 84d6bb2..0dd2999 100644 --- a/src/main/scala/Decoder.scala +++ b/src/main/scala/Decoder.scala @@ -2,6 +2,7 @@ package chiselv import chisel3._ import chisel3.util._ +import chisel3.util.experimental.decode import chiselv.Instruction._ import chiselv.InstructionType._ @@ -35,74 +36,72 @@ class Decoder(bitWidth: Int = 32) extends Module { val is_load = Bool() val is_store = Bool() } - val signals = chisel3.util.experimental.decode + val signals = decode .decoder( io.DecoderPort.op, - chisel3.util.experimental.decode.TruthTable( - // format: off - Array( - /* inst_type, inst to_alu branch use_imm jump is_load is_store*/ + decode.TruthTable( + // format: off + Array( + /* inst_type, ## inst ## to_alu ## branch ## use_imm ## jump ## is_load ## is_store */ // Arithmetic - BitPat("b0000000??????????000?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADD.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????000?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADDI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0100000??????????000?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SUB.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????????????0110111") -> BitPat(INST_U.litValue.U(InstructionType.getWidth.W)) ## BitPat(LUI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????????????0010111") -> BitPat(INST_U.litValue.U(InstructionType.getWidth.W)) ## BitPat(AUIPC.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????000?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADD.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????000?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADDI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????000?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SUB.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????????????0110111") -> BitPat(INST_U.litValue.U(InstructionType.getWidth.W)) ## BitPat(LUI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????????????0010111") -> BitPat(INST_U.litValue.U(InstructionType.getWidth.W)) ## BitPat(AUIPC.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Shifts - BitPat("b0000000??????????001?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????001?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0100000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRA.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0100000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRAI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????001?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????001?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRA.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRAI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Logical - BitPat("b0000000??????????100?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(XOR.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????100?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(XORI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????110?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(OR.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????110?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ORI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????111?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(AND.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????111?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ANDI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????100?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(XOR.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????100?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(XORI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????110?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(OR.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????110?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ORI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????111?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(AND.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????111?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ANDI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Compare - BitPat("b0000000??????????010?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLT.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????010?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????011?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTU.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????011?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTIU.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????010?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLT.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????010?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????011?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTU.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????011?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTIU.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Branches - BitPat("b?????????????????000?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BEQ.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????001?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BNE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????100?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BLT.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????101?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BGE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????110?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BLTU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????111?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BGEU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????000?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BEQ.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????001?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BNE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????100?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BLT.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????101?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BGE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????110?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BLTU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????111?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BGEU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Jump & link - BitPat("b?????????????????????????1101111") -> BitPat(INST_J.litValue.U(InstructionType.getWidth.W)) ## BitPat(JAL.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????000?????1100111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(JALR.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????????????1101111") -> BitPat(INST_J.litValue.U(InstructionType.getWidth.W)) ## BitPat(JAL.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????000?????1100111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(JALR.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), // Sync - BitPat("b0000????????00000000000000001111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(FENCE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b00000000000000000000001000001111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(FENCEI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000????????00000000000000001111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(FENCE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b00000000000000000000001000001111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(FENCEI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y()## BitPat.N() ## BitPat.N() ## BitPat.N(), // Environment - BitPat("b00000000000000000000000001110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ECALL.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b00000000000100000000000001110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(EBREAK.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b00000000000000000000000001110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ECALL.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b00000000000100000000000001110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(EBREAK.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // CSR - BitPat("b?????????????????001?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????010?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRS.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????011?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRC.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????101?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRWI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????110?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRSI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????111?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRCI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????001?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????010?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRS.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????011?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRC.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????101?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRWI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????110?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRSI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????111?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRCI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Loads - BitPat("b?????????????????000?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LB.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), - BitPat("b?????????????????001?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LH.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), - BitPat("b?????????????????100?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LBU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), - BitPat("b?????????????????101?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LHU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), - BitPat("b?????????????????010?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????000?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LB.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????001?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LH.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????100?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LBU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????101?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LHU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????010?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), // Stores - BitPat("b?????????????????000?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SB.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), - BitPat("b?????????????????001?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SH.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), - BitPat("b?????????????????010?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y() - ) - , - BitPat(IN_ERR.litValue.U(InstructionType.getWidth.W)) ## BitPat(ERR_INST.litValue.U(Instruction.getWidth.W)) ## BitPat.dontCare(6) // Default values + BitPat("b?????????????????000?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SB.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), + BitPat("b?????????????????001?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SH.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), + BitPat("b?????????????????010?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y() + ), BitPat(IN_ERR.litValue.U(InstructionType.getWidth.W)) ## BitPat(ERR.litValue.U(Instruction.getWidth.W)) ## BitPat.dontCare(6) // Default values // format: on ) ) From d676295d9e6cc16d4df973f2ea13005a775130bb Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Mon, 10 Jan 2022 14:26:20 -0300 Subject: [PATCH 8/8] Improve API using some unmerged PRs --- build.sbt | 2 +- src/main/scala/Constants.scala | 14 +--- src/main/scala/Decoder.scala | 118 +++++++++++++++++---------------- 3 files changed, 64 insertions(+), 70 deletions(-) diff --git a/build.sbt b/build.sbt index f48854f..a915471 100644 --- a/build.sbt +++ b/build.sbt @@ -27,7 +27,7 @@ lazy val chiselv = (project in file(".")) // Default library versions lazy val versions = new { - val chisel3 = "3.5.0-RC2" + val chisel3 = "3.5-SNAPSHOT" val chiseltest = "0.5.0-RC2" val scalatest = "3.2.10" val organizeimports = "0.5.0" diff --git a/src/main/scala/Constants.scala b/src/main/scala/Constants.scala index 322feba..e735b49 100644 --- a/src/main/scala/Constants.scala +++ b/src/main/scala/Constants.scala @@ -1,7 +1,6 @@ package chiselv -import chisel3._ -import chisel3.experimental.ChiselEnum +import chisel3.experimental.{ChiselEnum, ChiselEnum1H} object Instruction extends ChiselEnum { val ERR, @@ -21,13 +20,6 @@ object Instruction extends ChiselEnum { = Value } -object InstructionType extends ChiselEnum { - val INST_I = Value((1 << 0).U) - val INST_S = Value((1 << 1).U) - val INST_B = Value((1 << 2).U) - val INST_U = Value((1 << 3).U) - val INST_J = Value((1 << 4).U) - val INST_Z = Value((1 << 5).U) - val INST_R = Value((1 << 6).U) - val IN_ERR = Value((1 << 7).U) +object InstructionType extends ChiselEnum1H { + val INST_I, INST_S, INST_B, INST_U, INST_J, INST_Z, INST_R, IN_ERR = Value } diff --git a/src/main/scala/Decoder.scala b/src/main/scala/Decoder.scala index 0dd2999..86de69e 100644 --- a/src/main/scala/Decoder.scala +++ b/src/main/scala/Decoder.scala @@ -27,8 +27,8 @@ class Decoder(bitWidth: Int = 32) extends Module { }) class DecType extends Bundle { - val inst_type = UInt(InstructionType.getWidth.W) - val inst = UInt(Instruction.getWidth.W) + val inst_type = InstructionType() + val inst = Instruction() val to_alu = Bool() val branch = Bool() val use_imm = Bool() @@ -36,76 +36,77 @@ class Decoder(bitWidth: Int = 32) extends Module { val is_load = Bool() val is_store = Bool() } - val signals = decode - .decoder( - io.DecoderPort.op, - decode.TruthTable( + + val signals = decode.decodeAs( + (new DecType), + io.DecoderPort.op, + decode.TruthTable( // format: off Array( - /* inst_type, ## inst ## to_alu ## branch ## use_imm ## jump ## is_load ## is_store */ + /* inst_type, ## inst ## to_alu ## branch ## use_imm ## jump ## is_load ## is_store */ // Arithmetic - BitPat("b0000000??????????000?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADD.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????000?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADDI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0100000??????????000?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SUB.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????????????0110111") -> BitPat(INST_U.litValue.U(InstructionType.getWidth.W)) ## BitPat(LUI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????????????0010111") -> BitPat(INST_U.litValue.U(InstructionType.getWidth.W)) ## BitPat(AUIPC.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????000?????0110011") -> BitPat(INST_R) ## BitPat(ADD) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????000?????0010011") -> BitPat(INST_I) ## BitPat(ADDI) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????000?????0110011") -> BitPat(INST_R) ## BitPat(SUB) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????????????0110111") -> BitPat(INST_U) ## BitPat(LUI) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????????????0010111") -> BitPat(INST_U) ## BitPat(AUIPC) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Shifts - BitPat("b0000000??????????001?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????001?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRL.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRLI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0100000??????????101?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRA.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0100000??????????101?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SRAI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????001?????0110011") -> BitPat(INST_R) ## BitPat(SLL) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????001?????0010011") -> BitPat(INST_I) ## BitPat(SLLI) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????101?????0110011") -> BitPat(INST_R) ## BitPat(SRL) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????101?????0010011") -> BitPat(INST_I) ## BitPat(SRLI) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????101?????0110011") -> BitPat(INST_R) ## BitPat(SRA) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0100000??????????101?????0010011") -> BitPat(INST_I) ## BitPat(SRAI) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Logical - BitPat("b0000000??????????100?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(XOR.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????100?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(XORI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????110?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(OR.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????110?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ORI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????111?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(AND.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????111?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ANDI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????100?????0110011") -> BitPat(INST_R) ## BitPat(XOR) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????100?????0010011") -> BitPat(INST_I) ## BitPat(XORI) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????110?????0110011") -> BitPat(INST_R) ## BitPat(OR) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????110?????0010011") -> BitPat(INST_I) ## BitPat(ORI) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????111?????0110011") -> BitPat(INST_R) ## BitPat(AND) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????111?????0010011") -> BitPat(INST_I) ## BitPat(ANDI) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Compare - BitPat("b0000000??????????010?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLT.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????010?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b0000000??????????011?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTU.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????011?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(SLTIU.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????010?????0110011") -> BitPat(INST_R) ## BitPat(SLT) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????010?????0010011") -> BitPat(INST_I) ## BitPat(SLTI) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000000??????????011?????0110011") -> BitPat(INST_R) ## BitPat(SLTU) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????011?????0010011") -> BitPat(INST_I) ## BitPat(SLTIU) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Branches - BitPat("b?????????????????000?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BEQ.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????001?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BNE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????100?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BLT.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????101?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BGE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????110?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BLTU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????111?????1100011") -> BitPat(INST_B.litValue.U(InstructionType.getWidth.W)) ## BitPat(BGEU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????000?????1100011") -> BitPat(INST_B) ## BitPat(BEQ) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????001?????1100011") -> BitPat(INST_B) ## BitPat(BNE) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????100?????1100011") -> BitPat(INST_B) ## BitPat(BLT) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????101?????1100011") -> BitPat(INST_B) ## BitPat(BGE) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????110?????1100011") -> BitPat(INST_B) ## BitPat(BLTU) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????111?????1100011") -> BitPat(INST_B) ## BitPat(BGEU) ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Jump & link - BitPat("b?????????????????????????1101111") -> BitPat(INST_J.litValue.U(InstructionType.getWidth.W)) ## BitPat(JAL.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????000?????1100111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(JALR.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????????????1101111") -> BitPat(INST_J) ## BitPat(JAL) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????000?????1100111") -> BitPat(INST_I) ## BitPat(JALR) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.Y() ## BitPat.N() ## BitPat.N(), // Sync - BitPat("b0000????????00000000000000001111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(FENCE.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b00000000000000000000001000001111") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(FENCEI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y()## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b0000????????00000000000000001111") -> BitPat(INST_I) ## BitPat(FENCE) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b00000000000000000000001000001111") -> BitPat(INST_I) ## BitPat(FENCEI) ## BitPat.N() ## BitPat.N() ## BitPat.Y()## BitPat.N() ## BitPat.N() ## BitPat.N(), // Environment - BitPat("b00000000000000000000000001110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ECALL.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b00000000000100000000000001110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(EBREAK.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b00000000000000000000000001110011") -> BitPat(INST_I) ## BitPat(ECALL) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b00000000000100000000000001110011") -> BitPat(INST_I) ## BitPat(EBREAK) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // CSR - BitPat("b?????????????????001?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????010?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRS.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????011?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRC.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????101?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRWI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????110?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRSI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), - BitPat("b?????????????????111?????1110011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(CSRRCI.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????001?????1110011") -> BitPat(INST_I) ## BitPat(CSRRW) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????010?????1110011") -> BitPat(INST_I) ## BitPat(CSRRS) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????011?????1110011") -> BitPat(INST_I) ## BitPat(CSRRC) ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????101?????1110011") -> BitPat(INST_I) ## BitPat(CSRRWI) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????110?????1110011") -> BitPat(INST_I) ## BitPat(CSRRSI) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), + BitPat("b?????????????????111?????1110011") -> BitPat(INST_I) ## BitPat(CSRRCI) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(), // Loads - BitPat("b?????????????????000?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LB.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), - BitPat("b?????????????????001?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LH.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), - BitPat("b?????????????????100?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LBU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), - BitPat("b?????????????????101?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LHU.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), - BitPat("b?????????????????010?????0000011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(LW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????000?????0000011") -> BitPat(INST_I) ## BitPat(LB) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????001?????0000011") -> BitPat(INST_I) ## BitPat(LH) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????100?????0000011") -> BitPat(INST_I) ## BitPat(LBU) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????101?????0000011") -> BitPat(INST_I) ## BitPat(LHU) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), + BitPat("b?????????????????010?????0000011") -> BitPat(INST_I) ## BitPat(LW) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N(), // Stores - BitPat("b?????????????????000?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SB.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), - BitPat("b?????????????????001?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SH.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), - BitPat("b?????????????????010?????0100011") -> BitPat(INST_S.litValue.U(InstructionType.getWidth.W)) ## BitPat(SW.litValue.U(Instruction.getWidth.W)) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y() - ), BitPat(IN_ERR.litValue.U(InstructionType.getWidth.W)) ## BitPat(ERR.litValue.U(Instruction.getWidth.W)) ## BitPat.dontCare(6) // Default values + BitPat("b?????????????????000?????0100011") -> BitPat(INST_S) ## BitPat(SB) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), + BitPat("b?????????????????001?????0100011") -> BitPat(INST_S) ## BitPat(SH) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y(), + BitPat("b?????????????????010?????0100011") -> BitPat(INST_S) ## BitPat(SW) ## BitPat.N() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.Y() + ), BitPat(IN_ERR) ## BitPat(ERR) ## BitPat.dontCare(6) // Default values // format: on - ) ) - .asTypeOf(new DecType) + ) + // .asTypeOf(new DecType) io.DecoderPort.rd := io.DecoderPort.op(11, 7) io.DecoderPort.rs1 := io.DecoderPort.op(19, 15) @@ -123,7 +124,8 @@ class Decoder(bitWidth: Int = 32) extends Module { 0.S // padding for InstructionType ) ) - io.DecoderPort.inst := signals.inst.asTypeOf(new Instruction.Type) + + io.DecoderPort.inst := signals.inst io.DecoderPort.toALU := signals.to_alu io.DecoderPort.branch := signals.branch io.DecoderPort.use_imm := signals.use_imm