check.insn: use DUT parameters to configure the spec pfv.Interface.

main
Jean-François Nguyen 2 years ago
parent c16e678c49
commit 2e29794b7d

@ -134,7 +134,7 @@ class MicrowattWrapper(Elaboratable):
""") """)


def __init__(self, **kwargs): def __init__(self, **kwargs):
self.pfv = pfv.Interface() self.pfv = pfv.Interface(mem_aligned=False)
self.wb_insn = wishbone.Interface(addr_width=29, data_width=64, granularity=8, self.wb_insn = wishbone.Interface(addr_width=29, data_width=64, granularity=8,
features=("stall",)) features=("stall",))
self.wb_data = wishbone.Interface(addr_width=29, data_width=64, granularity=8, self.wb_data = wishbone.Interface(addr_width=29, data_width=64, granularity=8,

@ -28,7 +28,7 @@ class InsnCheck(PowerFVCheck, metaclass=InsnCheckMeta):
def __init__(self, *, depth, skip, core, **kwargs): def __init__(self, *, depth, skip, core, **kwargs):
super().__init__(depth=depth, skip=skip, core=core, **kwargs) super().__init__(depth=depth, skip=skip, core=core, **kwargs)
self.insn = self.insn_cls() self.insn = self.insn_cls()
self.spec = self.spec_cls(self.insn) self.spec = self.spec_cls(self.insn, mem_aligned=self.dut.pfv.mem_aligned)


def testbench(self): def testbench(self):
return InsnTestbench(self) return InsnTestbench(self)

@ -1,5 +1,6 @@
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod


from power_fv import pfv
from power_fv.insn import WordInsn from power_fv.insn import WordInsn




@ -7,20 +8,13 @@ __all__ = ["InsnSpec"]




class InsnSpec(metaclass=ABCMeta): class InsnSpec(metaclass=ABCMeta):
def __init__(self, insn): def __init__(self, insn, **kwargs):
self.pfv = pfv.Interface()
self.insn = insn

@property
def insn(self):
return self._insn

@insn.setter
def insn(self, insn):
if not isinstance(insn, WordInsn): if not isinstance(insn, WordInsn):
raise TypeError("Instruction must be an instance of WordInsn, not {!r}" raise TypeError("Instruction must be an instance of WordInsn, not {!r}"
.format(insn)) .format(insn))
self._insn = insn
self.insn = insn
self.pfv = pfv.Interface(**kwargs)


@abstractmethod @abstractmethod
def elaborate(self, platform): def elaborate(self, platform):

@ -11,10 +11,6 @@ __all__ = ["AddSubSpec"]




class AddSubSpec(InsnSpec, Elaboratable): class AddSubSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -11,10 +11,6 @@ __all__ = ["BCDAssistSpec"]




class BCDAssistSpec(InsnSpec, Elaboratable): class BCDAssistSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -11,10 +11,6 @@ __all__ = ["BranchSpec"]




class BranchSpec(InsnSpec, Elaboratable): class BranchSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -11,10 +11,6 @@ __all__ = ["ByteReverseSpec"]




class ByteReverseSpec(InsnSpec, Elaboratable): class ByteReverseSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -11,10 +11,6 @@ __all__ = ["CompareSpec"]




class CompareSpec(InsnSpec, Elaboratable): class CompareSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -14,10 +14,6 @@ __all__ = ["CRLogicalSpec", "CRMoveSpec"]




class CRLogicalSpec(InsnSpec, Elaboratable): class CRLogicalSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -12,11 +12,6 @@ __all__ = ["LoadStoreSpec"]




class LoadStoreSpec(InsnSpec, Elaboratable): class LoadStoreSpec(InsnSpec, Elaboratable):
def __init__(self, insn, *, dword_aligned=False):
self.pfv = pfv.Interface()
self.insn = insn
self.dword_aligned = dword_aligned

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()


@ -79,8 +74,8 @@ class LoadStoreSpec(InsnSpec, Elaboratable):


m.d.comb += ea.eq(iea(ea_base + ea_offset, self.pfv.msr.r_data.sf)) m.d.comb += ea.eq(iea(ea_base + ea_offset, self.pfv.msr.r_data.sf))


# If `dword_aligned` is set, `pfv.mem.addr` points to the dword containing EA. # If `pfv.mem_aligned` is set, `pfv.mem.addr` points to the dword containing EA.
# If `dword_aligned` is unset, `pfv.mem.addr` is equal to EA. # If `pfv.mem_aligned` is unset, `pfv.mem.addr` is equal to EA.


byte_offset = Signal(3) byte_offset = Signal(3)
half_offset = Signal(2) half_offset = Signal(2)
@ -88,7 +83,7 @@ class LoadStoreSpec(InsnSpec, Elaboratable):


m.d.comb += self.pfv.mem.addr[3:].eq(ea[3:]) m.d.comb += self.pfv.mem.addr[3:].eq(ea[3:])


if self.dword_aligned: if self.pfv.mem_aligned:
m.d.comb += [ m.d.comb += [
self.pfv.mem.addr[:3].eq(0), self.pfv.mem.addr[:3].eq(0),
byte_offset.eq(ea[:3]), byte_offset.eq(ea[:3]),

@ -28,10 +28,6 @@ class _CountTrailingZeros(Elaboratable):




class LogicalSpec(InsnSpec, Elaboratable): class LogicalSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -12,10 +12,6 @@ __all__ = ["MSRMoveSpec"]




class MSRMoveSpec(InsnSpec, Elaboratable): class MSRMoveSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -11,10 +11,6 @@ __all__ = ["RotateShiftSpec"]




class RotateShiftSpec(InsnSpec, Elaboratable): class RotateShiftSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -12,10 +12,6 @@ __all__ = ["SPRMoveSpec"]




class SPRMoveSpec(InsnSpec, Elaboratable): class SPRMoveSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -11,10 +11,6 @@ __all__ = ["SystemCallSpec"]




class SystemCallSpec(InsnSpec, Elaboratable): class SystemCallSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -11,10 +11,6 @@ __all__ = ["TrapSpec"]




class TrapSpec(InsnSpec, Elaboratable): class TrapSpec(InsnSpec, Elaboratable):
def __init__(self, insn):
self.pfv = pfv.Interface()
self.insn = insn

def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()



@ -51,7 +51,9 @@ class Interface(Record):
Instruction strobe. Asserted when the processor retires an instruction. Other signals are Instruction strobe. Asserted when the processor retires an instruction. Other signals are
only valid when ``stb`` is asserted. only valid when ``stb`` is asserted.
""" """
def __init__(self, *, name=None, src_loc_at=0): def __init__(self, *, mem_aligned=False, name=None, src_loc_at=0):
self.mem_aligned = bool(mem_aligned)

layout = [ layout = [
("stb" , unsigned( 1)), ("stb" , unsigned( 1)),
("insn" , unsigned(64)), ("insn" , unsigned(64)),

Loading…
Cancel
Save