def MOpDecoder(): return GenDecoderFixed( OpClass.OP_CLASS_MUL, 'm_msg', MMsg(), {'opcode': Opcode.OP}, ['funct7', 'funct3'], { (0b0000001, 0b000): m_msg(MFunc.M_FUNC_MUL, MVariant.M_VARIANT_N, 0), (0b0000001, 0b001): m_msg(MFunc.M_FUNC_MUL, MVariant.M_VARIANT_H, 0), (0b0000001, 0b010): m_msg(MFunc.M_FUNC_MUL, MVariant.M_VARIANT_HSU, 0), (0b0000001, 0b011): m_msg(MFunc.M_FUNC_MUL, MVariant.M_VARIANT_HU, 0), (0b0000001, 0b100): m_msg(MFunc.M_FUNC_DIV, MVariant.M_VARIANT_N, 0), (0b0000001, 0b101): m_msg(MFunc.M_FUNC_DIV, MVariant.M_VARIANT_U, 0), (0b0000001, 0b110): m_msg(MFunc.M_FUNC_REM, MVariant.M_VARIANT_N, 0), (0b0000001, 0b111): m_msg(MFunc.M_FUNC_REM, MVariant.M_VARIANT_U, 0), }, rs1_val=1, rs2_val=1, rd_val=1, )
def JALDecoder(): return GenDecoderFixed( OpClass.OP_CLASS_JUMP, 'jump_msg', JumpMsg(), {'opcode': Opcode.JAL}, [], 0, speculative=1, rd_val=1, imm_type=ImmType.IMM_TYPE_J, imm_val=1, )
def MiscDecoder(): return GenDecoderFixed( OpClass.OP_CLASS_ALU, 'alu_msg', AluMsg(), {}, ['opcode'], { Opcode.LUI: alu_msg(AluFunc.ALU_FUNC_LUI, 0, 0), Opcode.AUIPC: alu_msg(AluFunc.ALU_FUNC_AUIPC, 0, 0), }, rd_val=1, imm_type=ImmType.IMM_TYPE_U, imm_val=1, )
def OpImm32Decoder(): return GenDecoderFixed( OpClass.OP_CLASS_ALU, 'alu_msg', AluMsg(), {'opcode': Opcode.OP_IMM_32}, ['funct3'], { 0b000: alu_msg(AluFunc.ALU_FUNC_ADD, 0, 1), }, rs1_val=1, rd_val=1, imm_type=ImmType.IMM_TYPE_I, imm_val=1, )
def FenceDecoder(): return GenDecoderFixed( OpClass.OP_CLASS_SYSTEM, 'system_msg', SystemMsg(), { 'opcode': Opcode.MISC_MEM, 'rd': 0, 'funct3': 0, 'rs1': 0, 'fence_upper': 0, }, [], system_msg(SystemFunc.SYSTEM_FUNC_FENCE), )
def OpImmShiftDecoder(): return GenDecoderFixed( OpClass.OP_CLASS_ALU, 'alu_msg', AluMsg(), {'opcode': Opcode.OP_IMM}, ['funct7_shft64', 'funct3'], { (0b000000, 0b001): alu_msg(AluFunc.ALU_FUNC_SLL, 0), (0b000000, 0b101): alu_msg(AluFunc.ALU_FUNC_SRL, 0), (0b010000, 0b101): alu_msg(AluFunc.ALU_FUNC_SRA, 0), }, rs1_val=1, rd_val=1, imm_type=ImmType.IMM_TYPE_SHAMT64, imm_val=1, )
def Op32Decoder(): return GenDecoderFixed( OpClass.OP_CLASS_ALU, 'alu_msg', AluMsg(), {'opcode': Opcode.OP_32}, ['funct7', 'funct3'], { (0b0000000, 0b000): alu_msg(AluFunc.ALU_FUNC_ADD, 0, 1), (0b0100000, 0b000): alu_msg(AluFunc.ALU_FUNC_SUB, 0, 1), (0b0000000, 0b001): alu_msg(AluFunc.ALU_FUNC_SLL, 0, 1), (0b0000000, 0b101): alu_msg(AluFunc.ALU_FUNC_SRL, 0, 1), (0b0100000, 0b101): alu_msg(AluFunc.ALU_FUNC_SRA, 0, 1), }, rs1_val=1, rs2_val=1, rd_val=1, )
def SystemCallDecoder(): return GenDecoderFixed( OpClass.OP_CLASS_SYSTEM, 'system_msg', SystemMsg(), { 'opcode': Opcode.SYSTEM, 'rd': 0, 'funct3': 0, 'rs1': 0, 'funct7': 0, }, ['rs2'], { 0: system_msg(SystemFunc.SYSTEM_FUNC_ECALL), 1: system_msg(SystemFunc.SYSTEM_FUNC_EBREAK), }, )
def OpImmDecoder(): return GenDecoderFixed( OpClass.OP_CLASS_ALU, 'alu_msg', AluMsg(), {'opcode': Opcode.OP_IMM}, ['funct3'], { 0b000: alu_msg(AluFunc.ALU_FUNC_ADD, 0), 0b010: alu_msg(AluFunc.ALU_FUNC_SLT, 0), 0b011: alu_msg(AluFunc.ALU_FUNC_SLT, 1), 0b100: alu_msg(AluFunc.ALU_FUNC_XOR, 0), 0b110: alu_msg(AluFunc.ALU_FUNC_OR, 0), 0b111: alu_msg(AluFunc.ALU_FUNC_AND, 0), }, rs1_val=1, rd_val=1, imm_type=ImmType.IMM_TYPE_I, imm_val=1, )