class ALUInputData(FUBaseData):
- regspec = [('INT', 'ra', '0:63'), # RA
- ('INT', 'rb', '0:63'), # RB/immediate
- ('XER', 'xer_so', '32'), # XER bit 32: SO
- ('XER', 'xer_ca', '34,45')] # XER bit 34/45: CA/CA32
-
def __init__(self, pspec):
super().__init__(pspec, False)
# convenience
self.a, self.b = self.ra, self.rb
+ @property
+ def regspec(self):
+ return [('INT', 'ra', self.intrange), # RA
+ ('INT', 'rb', self.intrange), # RB/immediate
+ ('XER', 'xer_so', '32'), # XER bit 32: SO
+ ('XER', 'xer_ca', '34,45')] # XER bit 34/45: CA/CA32
+
+
class ALUOutputData(FUBaseData):
- regspec = [('INT', 'o', '0:63'),
+ def __init__(self, pspec):
+ super().__init__(pspec, True)
+ # convenience
+ self.cr0 = self.cr_a
+
+ @property
+ def regspec(self):
+ return [('INT', 'o', self.intrange),
('CR', 'cr_a', '0:3'),
('XER', 'xer_ca', '34,45'), # bit0: ca, bit1: ca32
('XER', 'xer_ov', '33,44'), # bit0: ov, bit1: ov32
('XER', 'xer_so', '32')]
- def __init__(self, pspec):
- super().__init__(pspec, True)
- # convenience
- self.cr0 = self.cr_a
class ALUPipeSpec(CommonPipeSpec):
- regspec = (ALUInputData.regspec, ALUOutputData.regspec)
opsubsetkls = CompALUOpSubset
+ regspecklses = (ALUInputData, ALUOutputData)
class BranchPipeSpec(CommonPipeSpec):
- regspec = (BranchInputData.regspec, BranchOutputData.regspec)
+ regspecklses = (BranchInputData, BranchOutputData)
opsubsetkls = CompBROpSubset
# spec (NNNPipeSpec instance)
pspec = speckls(id_wid=2, parent_pspec=parent_pspec)
opsubset = pspec.opsubsetkls # get the operand subset class
- regspec = pspec.regspec # get the regspec
+ rsk = pspec.regspecklses # get the regspec classes
+ regspec = []
+ for kls in rsk:
+ regspec.append(kls(pspec).regspec)
+ print ("regspecs", regspec)
alu = pipekls(pspec) # create actual NNNBasePipe
self.pspec = pspec
super().__init__(regspec, alu, opsubset, name=alu_name) # MultiCompUnit
# spec (NNNPipeSpec instance)
pspec = speckls(id_wid=id_wid, parent_pspec=parent_pspec)
- opsubset = pspec.opsubsetkls # get the operand subset class
- regspec = pspec.regspec # get the regspec
- alu = pipekls(pspec) # create actual NNNBasePipe
self.pspec = pspec
+ opsubset = pspec.opsubsetkls # get the operand subset class
+ rsk = pspec.regspecklses # get the regspec classes
+ regspec = []
+ for kls in rsk:
+ regspec.append(kls(pspec).regspec)
+ print ("regspecs", regspec)
+ alu = pipekls(pspec) # create actual NNNBasePipe
alu_name = self.fnunit.name.lower()
super().__init__(alu, num_rows, alu_name) # initialise fan-in/fan-out
self.cu = []
# spec (NNNPipeSpec instance)
pspec = LDSTPipeSpec(id_wid=2, parent_pspec=parent_pspec)
opsubset = pspec.opsubsetkls # get the operand subset class
- regspec = pspec.regspec # get the regspec
+ rsk = pspec.regspecklses # get the regspec classes
+ regspec = []
+ for kls in rsk:
+ regspec.append(kls(pspec).regspec)
+ print ("regspecs", regspec)
self.opsubsetkls = opsubset
super().__init__(pi, regspec, awid, opsubset, name=alu_name)
class CRPipeSpec(CommonPipeSpec):
- regspec = (CRInputData.regspec, CROutputData.regspec)
+ regspecklses = (CRInputData, CROutputData)
opsubsetkls = CompCROpSubset
self.div_pipe_kind = div_pipe_kind
self.core_config = div_pipe_kind.config.core_config
- regspec = (DivInputData.regspec, DivMulOutputData.regspec)
+ regspecklses = (DivInputData, DivMulOutputData)
opsubsetkls = CompLogicalOpSubset
class LDSTPipeSpec(CommonPipeSpec):
- regspec = (LDSTInputData.regspec, LDSTOutputData.regspec)
+ regspecklses = (LDSTInputData, LDSTOutputData)
opsubsetkls = CompLDSTOpSubset
class LogicalPipeSpec(CommonPipeSpec):
- regspec = (LogicalInputData.regspec, LogicalOutputDataFinal.regspec)
+ regspecklses = (LogicalInputData, LogicalOutputDataFinal)
opsubsetkls = CompLogicalOpSubset
class MMUPipeSpec(CommonPipeSpec):
- regspec = (MMUInputData.regspec, MMUOutputData.regspec)
+ regspecklses = (MMUInputData, MMUOutputData)
opsubsetkls = CompMMUOpSubset
class MulPipeSpec(CommonPipeSpec):
- regspec = (DivInputData.regspec, DivMulOutputData.regspec)
+ regspecklses = (DivInputData, DivMulOutputData)
opsubsetkls = CompMULOpSubset
"""
def __init__(self, pspec, output, exc_kls=None):
+ self.pspec = pspec
self.ctx = PipeContext(pspec) # context for ReservationStation usage
self.muxid = self.ctx.muxid
self.data = []
self.is_output = output
# take regspec and create data attributes (in or out)
# TODO: use widspec to create reduced bit mapping.
+ print (self.regspec)
for i, (regfile, regname, widspec) in enumerate(self.regspec):
wid = get_regspec_bitwidth([self.regspec], 0, i)
if output:
if hasattr(self, "exception"):
yield from self.exception.ports()
+ # convenience function to return 0:63 if XLEN=64, 0:31 if XLEN=32 etc.
+ @property
+ def intrange(self):
+ return "0:%d" % (self.pspec.XLEN-1)
+
def eq(self, i):
eqs = [self.ctx.eq(i.ctx)]
assert len(self.data) == len(i.data), \
class RegSpec:
def __init__(self, rwid, n_src=None, n_dst=None, name=None):
self._rwid = rwid
+ print ("RegSpec", rwid)
if isinstance(rwid, int):
# rwid: integer (covers all registers)
self._n_src, self._n_dst = n_src, n_dst
class ShiftRotPipeSpec(CommonPipeSpec):
- regspec = (ShiftRotInputData.regspec, ShiftRotOutputDataFinal.regspec)
+ regspecklses = (ShiftRotInputData, ShiftRotOutputDataFinal)
opsubsetkls = CompSROpSubset
class SPRPipeSpec(CommonPipeSpec):
- regspec = (SPRInputData.regspec, SPROutputData.regspec)
+ regspecklses = (SPRInputData, SPROutputData)
opsubsetkls = CompSPROpSubset
class TrapPipeSpec(CommonPipeSpec):
- regspec = (TrapInputData.regspec, TrapOutputData.regspec)
+ regspecklses = (TrapInputData, TrapOutputData)
opsubsetkls = CompTrapOpSubset