# class ALUFunctionUnit(FunctionUnitBaseMulti):
fnunit = Function.ALU
- def __init__(self, idx):
- super().__init__(ALUPipeSpec, ALU, 1)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(ALUPipeSpec, ALU, 1, parent_pspec)
class ALU(Elaboratable):
self.mmu = MMU()
- pipe_spec = MMUPipeSpec(id_wid=2)
+ pipe_spec = MMUPipeSpec(id_wid=2, parent_pspec=None)
self.fsm = FSMMMUStage(pipe_spec)
self.fsm.set_ldst_interface(ldst)
recwidth += width
comb += p.eq(AnyConst(width))
- pspec = ALUPipeSpec(id_wid=2, op_wid=recwidth)
+ pspec = ALUPipeSpec(id_wid=2, op_wid=recwidth, parent_pspec=None)
m.submodules.dut = dut = ALUInputStage(pspec)
a = Signal(64)
width = p.width
comb += p.eq(AnyConst(width))
- pspec = ALUPipeSpec(id_wid=2)
+ pspec = ALUPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.dut = dut = ALUMainStage(pspec)
# convenience variables
recwidth += width
comb += p.eq(AnyConst(width))
- pspec = ALUPipeSpec(id_wid=2)
+ pspec = ALUPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.dut = dut = ALUOutputStage(pspec)
o = Signal(64)
class ALUIAllCases(ALUTestCase):
def case_ilang(self):
- pspec = ALUPipeSpec(id_wid=2)
+ pspec = ALUPipeSpec(id_wid=2, parent_pspec=None)
alu = ALUBasePipe(pspec)
vl = rtlil.convert(alu, ports=alu.ports())
with open("alu_pipeline.il", "w") as f:
pdecode, opkls, fn_name)
pdecode = pdecode2.dec
- pspec = ALUPipeSpec(id_wid=2)
+ pspec = ALUPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.alu = alu = ALUBasePipe(pspec)
comb += alu.p.i_data.ctx.op.eq_from_execute1(pdecode2.do)
recwidth += width
comb += p.eq(AnyConst(width))
- pspec = ALUPipeSpec(id_wid=2, op_wid=recwidth)
+ pspec = ALUPipeSpec(id_wid=2, op_wid=recwidth, parent_pspec=None)
m.submodules.dut = dut = ALUInputStage(pspec)
a = Signal(64)
recwidth += width
comb += p.eq(AnyConst(width))
- pspec = BranchPipeSpec(id_wid=2)
+ pspec = BranchPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.dut = dut = BranchMainStage(pspec)
# convenience aliases
class BranchAllCases(BranchTestCase):
def case_ilang(self):
- pspec = BranchPipeSpec(id_wid=2)
+ pspec = BranchPipeSpec(id_wid=2, parent_pspec=None)
alu = BranchBasePipe(pspec)
vl = rtlil.convert(alu, ports=alu.ports())
with open("branch_pipeline.il", "w") as f:
m.submodules.pdecode2 = pdecode2 = PowerDecode2(None, opkls, fn_name)
pdecode = pdecode2.dec
- pspec = BranchPipeSpec(id_wid=2)
+ pspec = BranchPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.branch = branch = BranchBasePipe(pspec)
comb += branch.p.i_data.ctx.op.eq_from_execute1(pdecode2.do)
to actually read (and write) the correct register number
"""
- def __init__(self, speckls, pipekls, idx):
+ def __init__(self, speckls, pipekls, idx, parent_pspec):
alu_name = "alu_%s%d" % (self.fnunit.name.lower(), idx)
- pspec = speckls(id_wid=2) # spec (NNNPipeSpec instance)
+ # 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
alu = pipekls(pspec) # create actual NNNBasePipe
ideal (it could be a lot neater) but works for now.
"""
- def __init__(self, speckls, pipekls, num_rows):
+ def __init__(self, speckls, pipekls, num_rows, parent_pspec):
id_wid = num_rows.bit_length()
- pspec = speckls(id_wid=id_wid) # spec (NNNPipeSpec instance)
+
+ # 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
class ALUFunctionUnit(FunctionUnitBaseMulti):
fnunit = Function.ALU
- def __init__(self, num_rses):
- super().__init__(ALUPipeSpec, ALUBasePipe, num_rses)
+ def __init__(self, num_rses, parent_pspec):
+ super().__init__(ALUPipeSpec, ALUBasePipe, num_rses, parent_pspec)
# class LogicalFunctionUnit(FunctionUnitBaseSingle):
class LogicalFunctionUnit(FunctionUnitBaseMulti):
fnunit = Function.LOGICAL
- def __init__(self, idx):
- super().__init__(LogicalPipeSpec, LogicalBasePipe, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(LogicalPipeSpec, LogicalBasePipe, idx, parent_pspec)
# class CRFunctionUnit(FunctionUnitBaseSingle):
class CRFunctionUnit(FunctionUnitBaseMulti):
fnunit = Function.CR
- def __init__(self, idx):
- super().__init__(CRPipeSpec, CRBasePipe, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(CRPipeSpec, CRBasePipe, idx, parent_pspec)
# class BranchFunctionUnit(FunctionUnitBaseSingle):
class BranchFunctionUnit(FunctionUnitBaseMulti):
fnunit = Function.BRANCH
- def __init__(self, idx):
- super().__init__(BranchPipeSpec, BranchBasePipe, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(BranchPipeSpec, BranchBasePipe, idx, parent_pspec)
# class ShiftRotFunctionUnit(FunctionUnitBaseSingle):
class ShiftRotFunctionUnit(FunctionUnitBaseMulti):
fnunit = Function.SHIFT_ROT
- def __init__(self, idx):
- super().__init__(ShiftRotPipeSpec, ShiftRotBasePipe, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(ShiftRotPipeSpec, ShiftRotBasePipe, idx, parent_pspec)
class DivFSMFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.DIV
- def __init__(self, idx):
- super().__init__(DivPipeSpecFSMDivCore, DivBasePipe, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(DivPipeSpecFSMDivCore, DivBasePipe, idx, parent_pspec)
class MMUFSMFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.MMU
- def __init__(self, idx):
- super().__init__(MMUPipeSpec, FSMMMUStage, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(MMUPipeSpec, FSMMMUStage, idx, parent_pspec)
class DivPipeFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.DIV
- def __init__(self, idx):
- super().__init__(DivPipeSpecDivPipeCore, DivBasePipe, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(DivPipeSpecDivPipeCore, DivBasePipe, idx, parent_pspec)
# class MulFunctionUnit(FunctionUnitBaseSingle):
class MulFunctionUnit(FunctionUnitBaseMulti):
fnunit = Function.MUL
- def __init__(self, idx):
- super().__init__(MulPipeSpec, MulBasePipe, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(MulPipeSpec, MulBasePipe, idx, parent_pspec)
class TrapFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.TRAP
- def __init__(self, idx):
- super().__init__(TrapPipeSpec, TrapBasePipe, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(TrapPipeSpec, TrapBasePipe, idx, parent_pspec)
class SPRFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.SPR
- def __init__(self, idx):
- super().__init__(SPRPipeSpec, SPRBasePipe, idx)
+ def __init__(self, idx, parent_pspec):
+ super().__init__(SPRPipeSpec, SPRBasePipe, idx, parent_pspec)
# special-case: LD/ST conforms to the CompUnit API but is not a pipeline
class LDSTFunctionUnit(LDSTCompUnit):
fnunit = Function.LDST
- def __init__(self, pi, awid, idx):
+ def __init__(self, pi, awid, idx, parent_pspec):
alu_name = "ldst_%s%d" % (self.fnunit.name.lower(), idx)
- pspec = LDSTPipeSpec(id_wid=2) # spec (NNNPipeSpec instance)
+ # 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
self.opsubsetkls = opsubset
for name, qty in units.items():
kls = alus[name]
if issubclass(kls, FunctionUnitBaseMulti):
- fu = kls(qty) # create just the one ALU but many "fronts"
+ # create just the one ALU but many "fronts"
+ fu = kls(qty, parent_pspec=pspec)
self.actual_alus[name] = fu # to be made a module of AllFUs
for i in range(qty):
self.fus["%s%d" % (name, i)] = fu.cu[i]
else:
for i in range(qty):
- self.fus["%s%d" % (name, i)] = kls(i)
+ self.fus["%s%d" % (name, i)] = kls(i, parent_pspec=pspec)
# debug print for MMU ALU
if microwatt_mmu:
return
print("pilist", pilist)
for i, pi in enumerate(pilist):
- self.fus["ldst%d" % (i)] = LDSTFunctionUnit(pi, addrwid, i)
+ self.fus["ldst%d" % (i)] = LDSTFunctionUnit(pi, addrwid, i, pspec)
# extract exceptions from any FunctionUnits for easy access
self.excs = {}
recwidth += width
comb += p.eq(AnyConst(width))
- pspec = ALUPipeSpec(id_wid=2)
+ pspec = ALUPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.dut = dut = CRMainStage(pspec)
full_cr_in = Signal(32)
class CRIlangCase(TestAccumulatorBase):
def case_ilang(self):
- pspec = CRPipeSpec(id_wid=2)
+ pspec = CRPipeSpec(id_wid=2, parent_pspec=None)
alu = CRBasePipe(pspec)
vl = rtlil.convert(alu, ports=alu.ports())
with open("cr_pipeline.il", "w") as f:
m.submodules.pdecode2 = pdecode2 = PowerDecode2(None, opkls, fn_name)
pdecode = pdecode2.dec
- pspec = CRPipeSpec(id_wid=2)
+ pspec = CRPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.alu = alu = CRBasePipe(pspec)
comb += alu.p.i_data.ctx.op.eq_from_execute1(pdecode2.do)
class DivPipeSpec(CommonPipeSpec):
- def __init__(self, id_wid, div_pipe_kind):
- super().__init__(id_wid=id_wid)
+ def __init__(self, id_wid, parent_pspec, div_pipe_kind):
+ super().__init__(id_wid=id_wid, parent_pspec=parent_pspec)
self.div_pipe_kind = div_pipe_kind
self.core_config = div_pipe_kind.config.core_config
class DivPipeSpecDivPipeCore(DivPipeSpec):
- def __init__(self, id_wid):
- super().__init__(id_wid=id_wid, div_pipe_kind=DivPipeKind.DivPipeCore)
+ def __init__(self, id_wid, parent_pspec):
+ super().__init__(id_wid=id_wid,
+ parent_pspec=parent_pspec,
+ div_pipe_kind=DivPipeKind.DivPipeCore)
class DivPipeSpecFSMDivCore(DivPipeSpec):
- def __init__(self, id_wid):
- super().__init__(id_wid=id_wid, div_pipe_kind=DivPipeKind.FSMDivCore)
+ def __init__(self, id_wid, parent_pspec):
+ super().__init__(id_wid=id_wid,
+ parent_pspec=parent_pspec,
+ div_pipe_kind=DivPipeKind.FSMDivCore)
class DivPipeSpecSimOnly(DivPipeSpec):
- def __init__(self, id_wid):
- super().__init__(id_wid=id_wid, div_pipe_kind=DivPipeKind.SimOnly)
+ def __init__(self, id_wid, parent_pspec):
+ super().__init__(id_wid=id_wid,
+ parent_pspec=parent_pspec,
+ div_pipe_kind=DivPipeKind.SimOnly)
class CoreBaseData(DivInputData):
m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode)
- pspec = DivPipeSpec(id_wid=2, div_pipe_kind=div_pipe_kind)
+ pspec = DivPipeSpec(
+ id_wid=2, div_pipe_kind=div_pipe_kind, parent_pspec=None)
m.submodules.alu = alu = DivBasePipe(pspec)
comb += alu.p.i_data.ctx.op.eq_from_execute1(pdecode2.do)
class TestPipeIlang(unittest.TestCase):
def write_ilang(self, div_pipe_kind):
- pspec = DivPipeSpec(id_wid=2, div_pipe_kind=div_pipe_kind)
+ pspec = DivPipeSpec(
+ id_wid=2, div_pipe_kind=div_pipe_kind, parent_pspec=None)
alu = DivBasePipe(pspec)
vl = rtlil.convert(alu, ports=alu.ports())
with open(f"div_pipeline_{div_pipe_kind.name}.il", "w") as f:
recwidth += width
comb += p.eq(AnyConst(width))
- pspec = ALUPipeSpec(id_wid=2)
+ pspec = ALUPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.dut = dut = ALUInputStage(pspec)
a = Signal(64)
width = p.width
comb += p.eq(AnyConst(width))
- pspec = ALUPipeSpec(id_wid=2)
+ pspec = ALUPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.dut = dut = LogicalMainStage(pspec)
# convenience variables
class LogicalIlangCase(TestAccumulatorBase):
def case_ilang(self):
- pspec = LogicalPipeSpec(id_wid=2)
+ pspec = LogicalPipeSpec(id_wid=2, parent_pspec=None)
alu = LogicalBasePipe(pspec)
vl = rtlil.convert(alu, ports=alu.ports())
with open("logical_pipeline.il", "w") as f:
m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode)
- pspec = LogicalPipeSpec(id_wid=2)
+ pspec = LogicalPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.alu = alu = LogicalBasePipe(pspec)
comb += alu.p.i_data.ctx.op.eq_from_execute1(pdecode2.do)
initial_regs, initial_sprs)
# def case_ilang(self):
- # pspec = SPRPipeSpec(id_wid=2)
+ # pspec = SPRPipeSpec(id_wid=2, parent_pspec=None)
# alu = SPRBasePipe(pspec)
# vl = rtlil.convert(alu, ports=alu.ports())
# with open("trap_pipeline.il", "w") as f:
class MMUIlangCase(TestAccumulatorBase):
# def case_ilang(self):
- # pspec = SPRPipeSpec(id_wid=2)
+ # pspec = SPRPipeSpec(id_wid=2, parent_pspec=None)
# alu = SPRBasePipe(pspec)
# vl = rtlil.convert(alu, ports=alu.ports())
# with open("trap_pipeline.il", "w") as f:
m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode)
- pipe_spec = MMUPipeSpec(id_wid=2)
+ pipe_spec = MMUPipeSpec(id_wid=2, parent_pspec=None)
ldst = LoadStore1(pspec)
fsm = FSMMMUStage(pipe_spec)
fsm.set_ldst_interface(ldst)
# set up the mul stages. do not add them to m.submodules, this
# is handled by StageChain.setup().
- pspec = MulPipeSpec(id_wid=2)
+ pspec = MulPipeSpec(id_wid=2, parent_pspec=None)
pipe1 = MulMainStage1(pspec)
pipe2 = MulMainStage2(pspec)
pipe3 = MulMainStage3(pspec)
m.submodules.pdecode2 = pdecode2 = PowerDecode2(None, opkls, fn_name)
pdecode = pdecode2.dec
- pspec = MulPipeSpec(id_wid=2)
+ pspec = MulPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.alu = alu = MulBasePipe(pspec)
comb += alu.p.i_data.ctx.op.eq_from_execute1(pdecode2.do)
class TestPipeIlang(unittest.TestCase):
def write_ilang(self):
- pspec = MulPipeSpec(id_wid=2)
+ pspec = MulPipeSpec(id_wid=2, parent_pspec=None)
alu = MulBasePipe(pspec)
vl = rtlil.convert(alu, ports=alu.ports())
with open("mul_pipeline.il", "w") as f:
see README.md for explanation of members.
"""
- def __init__(self, id_wid):
+ def __init__(self, id_wid, parent_pspec):
self.pipekls = SimpleHandshakeRedir
self.id_wid = id_wid
self.opkls = lambda _: self.opsubsetkls()
self.op_wid = get_rec_width(self.opkls(None)) # hmm..
self.stage = None
self.draft_bitmanip = False
+ self.parent_pspec = parent_pspec
def get_pspec_draft_bitmanip(pspec):
comb += rec.is_signed.eq(AnyConst(rec.is_signed.width))
comb += rec.insn.eq(AnyConst(rec.insn.width))
- pspec = ShiftRotPipeSpec(id_wid=2)
+ pspec = ShiftRotPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.dut = dut = ShiftRotMainStage(pspec)
# convenience variables
class ShiftRotIlangCase(TestAccumulatorBase):
def case_ilang(self):
- pspec = ShiftRotPipeSpec(id_wid=2)
+ pspec = ShiftRotPipeSpec(id_wid=2, parent_pspec=None)
pspec.draft_bitmanip = True
alu = ShiftRotBasePipe(pspec)
vl = rtlil.convert(alu, ports=alu.ports())
m.submodules.pdecode2 = pdecode2 = PowerDecode2(None, opkls, fn_name)
pdecode = pdecode2.dec
- pspec = ShiftRotPipeSpec(id_wid=2)
+ pspec = ShiftRotPipeSpec(id_wid=2, parent_pspec=None)
pspec.draft_bitmanip = True
m.submodules.alu = alu = ShiftRotBasePipe(pspec)
width = p.width
comb += p.eq(AnyConst(width))
- pspec = SPRPipeSpec(id_wid=2)
+ pspec = SPRPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.dut = dut = SPRMainStage(pspec)
# frequently used aliases
class SPRIlangCase(TestAccumulatorBase):
def case_ilang(self):
- pspec = SPRPipeSpec(id_wid=2)
+ pspec = SPRPipeSpec(id_wid=2, parent_pspec=None)
alu = SPRBasePipe(pspec)
vl = rtlil.convert(alu, ports=alu.ports())
with open("trap_pipeline.il", "w") as f:
m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode)
- pspec = SPRPipeSpec(id_wid=2)
+ pspec = SPRPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.alu = alu = SPRBasePipe(pspec)
comb += alu.p.i_data.ctx.op.eq_from_execute1(pdecode2.do)
comb = m.d.comb
rec = CompTrapOpSubset()
- pspec = TrapPipeSpec(id_wid=2)
+ pspec = TrapPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.dut = dut = TrapMainStage(pspec)
class TrapIlangCase(TestAccumulatorBase):
def case_ilang(self):
- pspec = TrapPipeSpec(id_wid=2)
+ pspec = TrapPipeSpec(id_wid=2, parent_pspec=None)
alu = TrapBasePipe(pspec)
vl = rtlil.convert(alu, ports=alu.ports())
with open("trap_pipeline.il", "w") as f:
m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode)
- pspec = TrapPipeSpec(id_wid=2)
+ pspec = TrapPipeSpec(id_wid=2, parent_pspec=None)
m.submodules.alu = alu = TrapBasePipe(pspec)
comb += alu.p.i_data.ctx.op.eq_from_execute1(pdecode2.do)