riscv-formal-nmigen/insns/InsnSra.py

16 lines
777 B
Python
Raw Normal View History

2020-08-07 15:51:21 +08:00
from InsnRV32IRType import *
2020-08-07 16:06:15 +08:00
"""
SRA instruction
"""
2020-08-07 15:51:21 +08:00
class InsnSra(InsnRV32IRType):
def __init__(self, RISCV_FORMAL_ILEN, RISCV_FORMAL_XLEN, RISCV_FORMAL_CSR_MISA):
super().__init__(RISCV_FORMAL_ILEN, RISCV_FORMAL_XLEN, RISCV_FORMAL_CSR_MISA, 0b0100000, 0b101, 0b0110011)
2020-08-07 15:51:21 +08:00
def elaborate(self, platform):
2020-08-10 11:15:05 +08:00
m = super().elaborate(platform)
2020-08-07 15:51:21 +08:00
2020-08-10 12:46:09 +08:00
m.d.comb += self.spec_rd_wdata.eq(Mux(self.spec_rd_addr, (Value.as_signed(self.rvfi_rs1_rdata) >> Mux(self.RISCV_FORMAL_XLEN == 64, self.rvfi_rs2_rdata[:6], self.rvfi_rs2_rdata[:5])) | (-(Value.as_signed(self.rvfi_rs1_rdata) < 0) << (self.RISCV_FORMAL_XLEN - Mux(self.RISCV_FORMAL_XLEN == 64, self.rvfi_rs2_rdata[:6], self.rvfi_rs2_rdata[:5]))), 0)) # https://stackoverflow.com/a/25207042
2020-08-07 15:51:21 +08:00
return m