Created
February 6, 2019 20:34
-
-
Save thoughtpolice/dd6d071b1fccbc8ae2989eafd9da343f to your computer and use it in GitHub Desktop.
RV32IM Sail Decoder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -------------------------------------------------------------------------- */ | |
/* -- LUI encoding ---------------------------------------------------------- */ | |
union clause ast = LUI : Utype | |
mapping clause encdec_base = LUI(imm, rd) <-> imm @ rd @ 0b0110111 | |
function clause print_insn LUI(imm, rd) = "lui " ^ rd ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- AUIPC encoding -------------------------------------------------------- */ | |
union clause ast = AUIPC : Utype | |
mapping clause encdec_base = AUIPC(imm, rd) <-> imm @ rd @ 0b0010111 | |
function clause print_insn AUIPC(imm, rd) = "auipc " ^ rd ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- JAL encoding ---------------------------------------------------------- */ | |
union clause ast = JAL : Jtype | |
mapping clause encdec_base = JAL(imm, rd) <-> uj_imm(imm) @ rd @ 0b1101111 | |
function clause print_insn JAL(imm, 0b00000) = "j " ^ bits_str(extz(imm) : bits(32)) | |
function clause print_insn JAL(imm, rd) = "jal " ^ rd ^ ", " ^ bits_str(extz(imm) : bits(32)) | |
/* -------------------------------------------------------------------------- */ | |
/* -- JALR encoding --------------------------------------------------------- */ | |
union clause ast = JALR : Itype | |
mapping clause encdec_base = JALR(imm, rs1, rd) <-> imm @ rs1 @ 0b000 @ rd @ 0b1100111 | |
function clause print_insn JALR(0b000000000000, 0b00001, 0b00000) = "ret" | |
function clause print_insn JALR(imm, rs1, rd) = "jalr " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- BEQ encoding ---------------------------------------------------------- */ | |
union clause ast = BEQ : Btype | |
mapping clause encdec_base = BEQ(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b000 @ imm0 @ 0b1100011 | |
function clause print_insn BEQ(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "beq " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- BNE encoding ---------------------------------------------------------- */ | |
union clause ast = BNE : Btype | |
mapping clause encdec_base = BNE(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b001 @ imm0 @ 0b1100011 | |
function clause print_insn BNE(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "bne " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- BLT encoding ---------------------------------------------------------- */ | |
union clause ast = BLT : Btype | |
mapping clause encdec_base = BLT(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b100 @ imm0 @ 0b1100011 | |
function clause print_insn BLT(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "blt " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- BGE encoding ---------------------------------------------------------- */ | |
union clause ast = BGE : Btype | |
mapping clause encdec_base = BGE(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b101 @ imm0 @ 0b1100011 | |
function clause print_insn BGE(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "bge " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- BLTU encoding --------------------------------------------------------- */ | |
union clause ast = BLTU : Btype | |
mapping clause encdec_base = BLTU(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b110 @ imm0 @ 0b1100011 | |
function clause print_insn BLTU(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "bltu " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- BGEU encoding --------------------------------------------------------- */ | |
union clause ast = BGEU : Btype | |
mapping clause encdec_base = BGEU(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b111 @ imm0 @ 0b1100011 | |
function clause print_insn BGEU(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "bgeu " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- LB encoding ----------------------------------------------------------- */ | |
union clause ast = LB : Itype | |
mapping clause encdec_base = LB(imm, rs1, rd) <-> imm @ rs1 @ 0b000 @ rd @ 0b0000011 | |
function clause print_insn LB(imm, rs1, rd) = "lb " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- LH encoding ----------------------------------------------------------- */ | |
union clause ast = LH : Itype | |
mapping clause encdec_base = LH(imm, rs1, rd) <-> imm @ rs1 @ 0b001 @ rd @ 0b0000011 | |
function clause print_insn LH(imm, rs1, rd) = "lh " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- LW encoding ----------------------------------------------------------- */ | |
union clause ast = LW : Itype | |
mapping clause encdec_base = LW(imm, rs1, rd) <-> imm @ rs1 @ 0b010 @ rd @ 0b0000011 | |
function clause print_insn LW(imm, rs1, rd) = "lw " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- LBU encoding ---------------------------------------------------------- */ | |
union clause ast = LBU : Itype | |
mapping clause encdec_base = LBU(imm, rs1, rd) <-> imm @ rs1 @ 0b100 @ rd @ 0b0000011 | |
function clause print_insn LBU(imm, rs1, rd) = "lbu " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- LHU encoding ---------------------------------------------------------- */ | |
union clause ast = LHU : Itype | |
mapping clause encdec_base = LHU(imm, rs1, rd) <-> imm @ rs1 @ 0b101 @ rd @ 0b0000011 | |
function clause print_insn LHU(imm, rs1, rd) = "lhu " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- SB encoding ----------------------------------------------------------- */ | |
union clause ast = SB : Stype | |
mapping clause encdec_base = SB(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b000 @ imm0 @ 0b0100011 | |
function clause print_insn SB(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "sb " ^ rs2 ^ ", " ^ bits_str(append(imm1,imm0)) ^ "(" ^ rs1 ^ ")" | |
/* -------------------------------------------------------------------------- */ | |
/* -- SH encoding ----------------------------------------------------------- */ | |
union clause ast = SH : Stype | |
mapping clause encdec_base = SH(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b001 @ imm0 @ 0b0100011 | |
function clause print_insn SH(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "sh " ^ rs2 ^ ", " ^ bits_str(append(imm1,imm0)) ^ "(" ^ rs1 ^ ")" | |
/* -------------------------------------------------------------------------- */ | |
/* -- SW encoding ----------------------------------------------------------- */ | |
union clause ast = SW : Stype | |
mapping clause encdec_base = SW(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b010 @ imm0 @ 0b0100011 | |
function clause print_insn SW(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "sw " ^ rs2 ^ ", " ^ bits_str(append(imm1,imm0)) ^ "(" ^ rs1 ^ ")" | |
/* -------------------------------------------------------------------------- */ | |
/* -- ADDI encoding --------------------------------------------------------- */ | |
union clause ast = ADDI : Itype | |
mapping clause encdec_base = ADDI(imm, rs1, rd) <-> imm @ rs1 @ 0b000 @ rd @ 0b0010011 | |
function clause print_insn ADDI(0b000000000000, 0b00000, 0b00000) = "nop" | |
function clause print_insn ADDI(imm, 0b00000, rd) = "li " ^ rd ^ ", " ^ bits_str(imm) | |
function clause print_insn ADDI(0b000000000000, rs1, rd) = "mv " ^ rd ^ ", " ^ rs1 | |
function clause print_insn ADDI(imm, rs1, rd) = "addi " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- SLTI encoding --------------------------------------------------------- */ | |
union clause ast = SLTI : Itype | |
mapping clause encdec_base = SLTI(imm, rs1, rd) <-> imm @ rs1 @ 0b010 @ rd @ 0b0010011 | |
function clause print_insn SLTI(imm, rs1, rd) = "slti " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- SLTIU encoding -------------------------------------------------------- */ | |
union clause ast = SLTIU : Itype | |
mapping clause encdec_base = SLTIU(imm, rs1, rd) <-> imm @ rs1 @ 0b011 @ rd @ 0b0010011 | |
function clause print_insn SLTIU(0b000000000001, rs, rd) = "seqz " ^ rd ^ ", " ^ rs | |
function clause print_insn SLTIU(imm, rs1, rd) = "sltiu " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- XORI encoding --------------------------------------------------------- */ | |
union clause ast = XORI : Itype | |
mapping clause encdec_base = XORI(imm, rs1, rd) <-> imm @ rs1 @ 0b100 @ rd @ 0b0010011 | |
function clause print_insn XORI(imm, rs1, rd) = "xori " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- ORI encoding ---------------------------------------------------------- */ | |
union clause ast = ORI : Itype | |
mapping clause encdec_base = ORI(imm, rs1, rd) <-> imm @ rs1 @ 0b110 @ rd @ 0b0010011 | |
function clause print_insn ORI(imm, rs1, rd) = "ori " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- ANDI encoding --------------------------------------------------------- */ | |
union clause ast = ANDI : Itype | |
mapping clause encdec_base = ANDI(imm, rs1, rd) <-> imm @ rs1 @ 0b111 @ rd @ 0b0010011 | |
function clause print_insn ANDI(imm, rs1, rd) = "andi " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- SLLI encoding --------------------------------------------------------- */ | |
union clause ast = SLLI : Rtype | |
mapping clause encdec_base = SLLI(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b001 @ rd @ 0b0010011 | |
function clause print_insn SLLI(rs2, rs1, rd) = "slli " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- SRLI encoding --------------------------------------------------------- */ | |
union clause ast = SRLI : Rtype | |
mapping clause encdec_base = SRLI(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b101 @ rd @ 0b0010011 | |
function clause print_insn SRLI(rs2, rs1, rd) = "srli " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- SRAI encoding --------------------------------------------------------- */ | |
union clause ast = SRAI : Rtype | |
mapping clause encdec_base = SRAI(rs2, rs1, rd) <-> 0b0100000 @ rs2 @ rs1 @ 0b101 @ rd @ 0b0010011 | |
function clause print_insn SRAI(rs2, rs1, rd) = "srai " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- ADD encoding ---------------------------------------------------------- */ | |
union clause ast = ADD : Rtype | |
mapping clause encdec_base = ADD(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b000 @ rd @ 0b0110011 | |
function clause print_insn ADD(rs2, rs1, rd) = "add " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- SUB encoding ---------------------------------------------------------- */ | |
union clause ast = SUB : Rtype | |
mapping clause encdec_base = SUB(rs2, rs1, rd) <-> 0b0100000 @ rs2 @ rs1 @ 0b000 @ rd @ 0b0110011 | |
function clause print_insn SUB(rs2, rs1, rd) = "sub " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- SLL encoding ---------------------------------------------------------- */ | |
union clause ast = SLL : Rtype | |
mapping clause encdec_base = SLL(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b001 @ rd @ 0b0110011 | |
function clause print_insn SLL(rs2, rs1, rd) = "sll " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- SLT encoding ---------------------------------------------------------- */ | |
union clause ast = SLT : Rtype | |
mapping clause encdec_base = SLT(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b010 @ rd @ 0b0110011 | |
function clause print_insn SLT(rs2, rs1, rd) = "slt " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- SLTU encoding --------------------------------------------------------- */ | |
union clause ast = SLTU : Rtype | |
mapping clause encdec_base = SLTU(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b011 @ rd @ 0b0110011 | |
function clause print_insn SLTU(rs, 0b00000, rd) = "snez " ^ rd ^ ", " ^ rs | |
function clause print_insn SLTU(rs2, rs1, rd) = "sltu " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- XOR encoding ---------------------------------------------------------- */ | |
union clause ast = XOR : Rtype | |
mapping clause encdec_base = XOR(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b100 @ rd @ 0b0110011 | |
function clause print_insn XOR(rs2, rs1, rd) = "xor " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- SRL encoding ---------------------------------------------------------- */ | |
union clause ast = SRL : Rtype | |
mapping clause encdec_base = SRL(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b101 @ rd @ 0b0110011 | |
function clause print_insn SRL(rs2, rs1, rd) = "srl " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- SRA encoding ---------------------------------------------------------- */ | |
union clause ast = SRA : Rtype | |
mapping clause encdec_base = SRA(rs2, rs1, rd) <-> 0b0100000 @ rs2 @ rs1 @ 0b101 @ rd @ 0b0110011 | |
function clause print_insn SRA(rs2, rs1, rd) = "sra " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- OR encoding ----------------------------------------------------------- */ | |
union clause ast = OR : Rtype | |
mapping clause encdec_base = OR(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b110 @ rd @ 0b0110011 | |
function clause print_insn OR(rs2, rs1, rd) = "or " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- AND encoding ---------------------------------------------------------- */ | |
union clause ast = AND : Rtype | |
mapping clause encdec_base = AND(rs2, rs1, rd) <-> 0b0000000 @ rs2 @ rs1 @ 0b111 @ rd @ 0b0110011 | |
function clause print_insn AND(rs2, rs1, rd) = "and " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- FENCE encoding -------------------------------------------------------- */ | |
union clause ast = FENCE : Mtype | |
mapping clause encdec_base = FENCE(p, s) <-> 0b0000 @ p @ s @ 0b00000 @ 0b000 @ 0b00000 @ 0b0001111 | |
function clause print_insn FENCE(p, s) = "fence " ^ bits_str(p) ^ ", " ^ bits_str(s) | |
/* -------------------------------------------------------------------------- */ | |
/* -- FENCE.I encoding ------------------------------------------------------ */ | |
union clause ast = FENCE_I : unit | |
mapping clause encdec_base = FENCE_I() <-> 0b00000000000000000001000000001111 | |
function clause print_insn FENCE_I() = "fence.i " ^ " " | |
/* -------------------------------------------------------------------------- */ | |
/* -- ECALL encoding -------------------------------------------------------- */ | |
union clause ast = ECALL : unit | |
mapping clause encdec_base = ECALL() <-> 0b00000000000000000000000001110011 | |
function clause print_insn ECALL() = "ecall " ^ " " | |
/* -------------------------------------------------------------------------- */ | |
/* -- EBREAK encoding ------------------------------------------------------- */ | |
union clause ast = EBREAK : unit | |
mapping clause encdec_base = EBREAK() <-> 0b00000000000100000000000001110011 | |
function clause print_insn EBREAK() = "ebreak " ^ " " | |
/* -------------------------------------------------------------------------- */ | |
/* -- CSRRW encoding -------------------------------------------------------- */ | |
union clause ast = CSRRW : Itype | |
mapping clause encdec_base = CSRRW(imm, rs1, rd) <-> imm @ rs1 @ 0b001 @ rd @ 0b1110011 | |
function clause print_insn CSRRW(csr, rs1, rd) = "csrrw " ^ rd ^ ", " ^ rs1 ^ ", " ^ csr_name(csr) | |
function clause print_insn CSRRW(imm, rs1, rd) = "csrrw " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- CSRRS encoding -------------------------------------------------------- */ | |
union clause ast = CSRRS : Itype | |
mapping clause encdec_base = CSRRS(imm, rs1, rd) <-> imm @ rs1 @ 0b010 @ rd @ 0b1110011 | |
function clause print_insn CSRRS(csr, rs1, rd) = "csrrs " ^ rd ^ ", " ^ rs1 ^ ", " ^ csr_name(csr) | |
function clause print_insn CSRRS(imm, rs1, rd) = "csrrs " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- CSRRC encoding -------------------------------------------------------- */ | |
union clause ast = CSRRC : Itype | |
mapping clause encdec_base = CSRRC(imm, rs1, rd) <-> imm @ rs1 @ 0b011 @ rd @ 0b1110011 | |
function clause print_insn CSRRC(csr, rs1, rd) = "csrrc " ^ rd ^ ", " ^ rs1 ^ ", " ^ csr_name(csr) | |
function clause print_insn CSRRC(imm, rs1, rd) = "csrrc " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- CSRRWI encoding ------------------------------------------------------- */ | |
union clause ast = CSRRWI : Itype | |
mapping clause encdec_base = CSRRWI(imm, rs1, rd) <-> imm @ rs1 @ 0b101 @ rd @ 0b1110011 | |
function clause print_insn CSRRWI(csr, imm, rd) = "csrrwi " ^ rd ^ ", " ^ bits_str(imm) ^ ", " ^ csr_name(csr) | |
function clause print_insn CSRRWI(imm, rs1, rd) = "csrrwi " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- CSRRSI encoding ------------------------------------------------------- */ | |
union clause ast = CSRRSI : Itype | |
mapping clause encdec_base = CSRRSI(imm, rs1, rd) <-> imm @ rs1 @ 0b110 @ rd @ 0b1110011 | |
function clause print_insn CSRRSI(csr, imm, rd) = "csrrsi " ^ rd ^ ", " ^ bits_str(imm) ^ ", " ^ csr_name(csr) | |
function clause print_insn CSRRSI(imm, rs1, rd) = "csrrsi " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- CSRRCI encoding ------------------------------------------------------- */ | |
union clause ast = CSRRCI : Itype | |
mapping clause encdec_base = CSRRCI(imm, rs1, rd) <-> imm @ rs1 @ 0b111 @ rd @ 0b1110011 | |
function clause print_insn CSRRCI(csr, imm, rd) = "csrrci " ^ rd ^ ", " ^ bits_str(imm) ^ ", " ^ csr_name(csr) | |
function clause print_insn CSRRCI(imm, rs1, rd) = "csrrci " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- MUL encoding ---------------------------------------------------------- */ | |
union clause ast = MUL : Rtype | |
mapping clause encdec_base = MUL(rs2, rs1, rd) <-> 0b0000001 @ rs2 @ rs1 @ 0b000 @ rd @ 0b0110011 | |
function clause print_insn MUL(rs2, rs1, rd) = "mul " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- MULH encoding --------------------------------------------------------- */ | |
union clause ast = MULH : Rtype | |
mapping clause encdec_base = MULH(rs2, rs1, rd) <-> 0b0000001 @ rs2 @ rs1 @ 0b001 @ rd @ 0b0110011 | |
function clause print_insn MULH(rs2, rs1, rd) = "mulh " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- MULHSU encoding ------------------------------------------------------- */ | |
union clause ast = MULHSU : Rtype | |
mapping clause encdec_base = MULHSU(rs2, rs1, rd) <-> 0b0000001 @ rs2 @ rs1 @ 0b010 @ rd @ 0b0110011 | |
function clause print_insn MULHSU(rs2, rs1, rd) = "mulhsu " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- MULHU encoding -------------------------------------------------------- */ | |
union clause ast = MULHU : Rtype | |
mapping clause encdec_base = MULHU(rs2, rs1, rd) <-> 0b0000001 @ rs2 @ rs1 @ 0b011 @ rd @ 0b0110011 | |
function clause print_insn MULHU(rs2, rs1, rd) = "mulhu " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- DIV encoding ---------------------------------------------------------- */ | |
union clause ast = DIV : Rtype | |
mapping clause encdec_base = DIV(rs2, rs1, rd) <-> 0b0000001 @ rs2 @ rs1 @ 0b100 @ rd @ 0b0110011 | |
function clause print_insn DIV(rs2, rs1, rd) = "div " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- DIVU encoding --------------------------------------------------------- */ | |
union clause ast = DIVU : Rtype | |
mapping clause encdec_base = DIVU(rs2, rs1, rd) <-> 0b0000001 @ rs2 @ rs1 @ 0b101 @ rd @ 0b0110011 | |
function clause print_insn DIVU(rs2, rs1, rd) = "divu " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- REM encoding ---------------------------------------------------------- */ | |
union clause ast = REM : Rtype | |
mapping clause encdec_base = REM(rs2, rs1, rd) <-> 0b0000001 @ rs2 @ rs1 @ 0b110 @ rd @ 0b0110011 | |
function clause print_insn REM(rs2, rs1, rd) = "rem " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- REMU encoding --------------------------------------------------------- */ | |
union clause ast = REMU : Rtype | |
mapping clause encdec_base = REMU(rs2, rs1, rd) <-> 0b0000001 @ rs2 @ rs1 @ 0b111 @ rd @ 0b0110011 | |
function clause print_insn REMU(rs2, rs1, rd) = "remu " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 | |
/* -------------------------------------------------------------------------- */ | |
/* -- LR.W encoding --------------------------------------------------------- */ | |
union clause ast = LR_W : A0type | |
mapping clause encdec_base = LR_W(aq, rl, rs1, rd) <-> 0b00010 @ aq @ rl @ 0b00000 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn LR_W(aq, rl, rs1, rd) = "lr.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- SC.W encoding --------------------------------------------------------- */ | |
union clause ast = SC_W : A1type | |
mapping clause encdec_base = SC_W(aq, rl, rs2, rs1, rd) <-> 0b00011 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn SC_W(aq, rl, rs2, rs1, rd) = "sc.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- AMOSWAP.W encoding ---------------------------------------------------- */ | |
union clause ast = AMOSWAP_W : A1type | |
mapping clause encdec_base = AMOSWAP_W(aq, rl, rs2, rs1, rd) <-> 0b00011 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn AMOSWAP_W(aq, rl, rs2, rs1, rd) = "amoswap.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- AMOADD.W encoding ----------------------------------------------------- */ | |
union clause ast = AMOADD_W : A1type | |
mapping clause encdec_base = AMOADD_W(aq, rl, rs2, rs1, rd) <-> 0b00001 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn AMOADD_W(aq, rl, rs2, rs1, rd) = "amoadd.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- AMOXOR.W encoding ----------------------------------------------------- */ | |
union clause ast = AMOXOR_W : A1type | |
mapping clause encdec_base = AMOXOR_W(aq, rl, rs2, rs1, rd) <-> 0b00000 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn AMOXOR_W(aq, rl, rs2, rs1, rd) = "amoxor.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- AMOAND.W encoding ----------------------------------------------------- */ | |
union clause ast = AMOAND_W : A1type | |
mapping clause encdec_base = AMOAND_W(aq, rl, rs2, rs1, rd) <-> 0b00100 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn AMOAND_W(aq, rl, rs2, rs1, rd) = "amoand.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- AMOOR.W encoding ------------------------------------------------------ */ | |
union clause ast = AMOOR_W : A1type | |
mapping clause encdec_base = AMOOR_W(aq, rl, rs2, rs1, rd) <-> 0b01100 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn AMOOR_W(aq, rl, rs2, rs1, rd) = "amoor.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- AMOMIN.W encoding ----------------------------------------------------- */ | |
union clause ast = AMOMIN_W : A1type | |
mapping clause encdec_base = AMOMIN_W(aq, rl, rs2, rs1, rd) <-> 0b01000 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn AMOMIN_W(aq, rl, rs2, rs1, rd) = "amomin.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- AMOMAX.W encoding ----------------------------------------------------- */ | |
union clause ast = AMOMAX_W : A1type | |
mapping clause encdec_base = AMOMAX_W(aq, rl, rs2, rs1, rd) <-> 0b10000 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn AMOMAX_W(aq, rl, rs2, rs1, rd) = "amomax.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- AMOMINU.W encoding ---------------------------------------------------- */ | |
union clause ast = AMOMINU_W : A1type | |
mapping clause encdec_base = AMOMINU_W(aq, rl, rs2, rs1, rd) <-> 0b11000 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn AMOMINU_W(aq, rl, rs2, rs1, rd) = "amominu.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- AMOMAXU.W encoding ---------------------------------------------------- */ | |
union clause ast = AMOMAXU_W : A1type | |
mapping clause encdec_base = AMOMAXU_W(aq, rl, rs2, rs1, rd) <-> 0b11100 @ aq @ rl @ rs2 @ rs1 @ 0b010 @ rd @ 0b0101111 | |
function clause print_insn AMOMAXU_W(aq, rl, rs2, rs1, rd) = "amomaxu.w " ^ "" | |
/* -------------------------------------------------------------------------- */ | |
/* -- FLW encoding ---------------------------------------------------------- */ | |
union clause ast = FLW : Itype | |
mapping clause encdec_base = FLW(imm, rs1, rd) <-> imm @ rs1 @ 0b010 @ rd @ 0b0000111 | |
function clause print_insn FLW(imm, rs1, rd) = "flw " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- FSW encoding ---------------------------------------------------------- */ | |
union clause ast = FSW : Stype | |
mapping clause encdec_base = FSW(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b010 @ imm0 @ 0b0100111 | |
function clause print_insn FSW(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "fsw " ^ rs2 ^ ", " ^ bits_str(append(imm1,imm0)) ^ "(" ^ rs1 ^ ")" | |
/* -------------------------------------------------------------------------- */ | |
/* -- FMADD.S encoding ------------------------------------------------------ */ | |
union clause ast = FMADD_S : R4type | |
mapping clause encdec_base = FMADD_S(rs3, rs2, rs1, frm, rd) <-> rs3 @ 0b00 @ rs2 @ rs1 @ frm @ rd @ 0b1000011 | |
function clause print_insn FMADD_S(rs3, rs2, rs1, frm, rd) = "fmadd.s " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 ^ ", " ^ rs3 | |
/* -------------------------------------------------------------------------- */ | |
/* -- FMSUB.S encoding ------------------------------------------------------ */ | |
union clause ast = FMSUB_S : R4type | |
mapping clause encdec_base = FMSUB_S(rs3, rs2, rs1, frm, rd) <-> rs3 @ 0b00 @ rs2 @ rs1 @ frm @ rd @ 0b1000111 | |
function clause print_insn FMSUB_S(rs3, rs2, rs1, frm, rd) = "fmsub.s " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 ^ ", " ^ rs3 | |
/* -------------------------------------------------------------------------- */ | |
/* -- FNMSUB.S encoding ----------------------------------------------------- */ | |
union clause ast = FNMSUB_S : R4type | |
mapping clause encdec_base = FNMSUB_S(rs3, rs2, rs1, frm, rd) <-> rs3 @ 0b00 @ rs2 @ rs1 @ frm @ rd @ 0b1001011 | |
function clause print_insn FNMSUB_S(rs3, rs2, rs1, frm, rd) = "fnmsub.s " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 ^ ", " ^ rs3 | |
/* -------------------------------------------------------------------------- */ | |
/* -- FNMADD.S encoding ----------------------------------------------------- */ | |
union clause ast = FNMADD_S : R4type | |
mapping clause encdec_base = FNMADD_S(rs3, rs2, rs1, frm, rd) <-> rs3 @ 0b00 @ rs2 @ rs1 @ frm @ rd @ 0b1001111 | |
function clause print_insn FNMADD_S(rs3, rs2, rs1, frm, rd) = "fnmadd.s " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 ^ ", " ^ rs3 | |
/* -------------------------------------------------------------------------- */ | |
/* -- FLD encoding ---------------------------------------------------------- */ | |
union clause ast = FLD : Itype | |
mapping clause encdec_base = FLD(imm, rs1, rd) <-> imm @ rs1 @ 0b011 @ rd @ 0b0000111 | |
function clause print_insn FLD(imm, rs1, rd) = "fld " ^ rd ^ ", " ^ rs1 ^ ", " ^ bits_str(imm) | |
/* -------------------------------------------------------------------------- */ | |
/* -- FSD encoding ---------------------------------------------------------- */ | |
union clause ast = FSD : Stype | |
mapping clause encdec_base = FSD(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) <-> imm1 @ rs2 @ rs1 @ 0b011 @ imm0 @ 0b0100111 | |
function clause print_insn FSD(imm1 : bits(7) @ imm0 : bits(5), rs2, rs1) = "fsd " ^ rs2 ^ ", " ^ bits_str(append(imm1,imm0)) ^ "(" ^ rs1 ^ ")" | |
/* -------------------------------------------------------------------------- */ | |
/* -- FMADD.D encoding ------------------------------------------------------ */ | |
union clause ast = FMADD_D : R4type | |
mapping clause encdec_base = FMADD_D(rs3, rs2, rs1, frm, rd) <-> rs3 @ 0b01 @ rs2 @ rs1 @ frm @ rd @ 0b1000011 | |
function clause print_insn FMADD_D(rs3, rs2, rs1, frm, rd) = "fmadd.d " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 ^ ", " ^ rs3 | |
/* -------------------------------------------------------------------------- */ | |
/* -- FMSUB.D encoding ------------------------------------------------------ */ | |
union clause ast = FMSUB_D : R4type | |
mapping clause encdec_base = FMSUB_D(rs3, rs2, rs1, frm, rd) <-> rs3 @ 0b01 @ rs2 @ rs1 @ frm @ rd @ 0b1000111 | |
function clause print_insn FMSUB_D(rs3, rs2, rs1, frm, rd) = "fmsub.d " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 ^ ", " ^ rs3 | |
/* -------------------------------------------------------------------------- */ | |
/* -- FNMSUB.D encoding ----------------------------------------------------- */ | |
union clause ast = FNMSUB_D : R4type | |
mapping clause encdec_base = FNMSUB_D(rs3, rs2, rs1, frm, rd) <-> rs3 @ 0b01 @ rs2 @ rs1 @ frm @ rd @ 0b1001011 | |
function clause print_insn FNMSUB_D(rs3, rs2, rs1, frm, rd) = "fnmsub.d " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 ^ ", " ^ rs3 | |
/* -------------------------------------------------------------------------- */ | |
/* -- FNMADD.D encoding ----------------------------------------------------- */ | |
union clause ast = FNMADD_D : R4type | |
mapping clause encdec_base = FNMADD_D(rs3, rs2, rs1, frm, rd) <-> rs3 @ 0b01 @ rs2 @ rs1 @ frm @ rd @ 0b1001111 | |
function clause print_insn FNMADD_D(rs3, rs2, rs1, frm, rd) = "fnmadd.d " ^ rd ^ ", " ^ rs1 ^ ", " ^ rs2 ^ ", " ^ rs3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment