Add SRAW instruction

This commit is contained in:
Donald Sebastian Leung 2020-08-27 16:04:00 +08:00
parent d188b9cdac
commit e7066b8c89
1 changed files with 17 additions and 0 deletions

17
rvfi/insns/insn_sraw.py Normal file
View File

@ -0,0 +1,17 @@
from .insn_rv64i_r_type import *
"""
SRAW instruction
"""
class InsnSraw(InsnRV64IRType):
def __init__(self, params):
super().__init__(params, 0b0100000, 0b101)
def elaborate(self, platform):
m = super().elaborate(platform)
result = Signal(32)
m.d.comb += result.eq((Value.as_signed(self.rvfi_rs1_rdata[:32]) >> self.rvfi_rs2_rdata[:5]) | (-(Value.as_signed(self.rvfi_rs1_rdata[:32]) < 0) << (32 - self.rvfi_rs2_rdata[:5]))) # https://stackoverflow.com/a/25207042
m.d.comb += spec_rd_wdata.eq(Mux(self.spec_rd_addr, (Mux(result[31], 2 ** (self.params.xlen - 32) - 1, 0) << 32) | result, 0))
return m