class MultiCompUnit(RegSpecALUAPI, Elaboratable):
- def __init__(self, rwid, alu, opsubsetkls, n_src=2, n_dst=1):
+ def __init__(self, rwid, alu, opsubsetkls, n_src=2, n_dst=1, name=None):
"""MultiCompUnit
* :rwid: width of register latches (TODO: allocate per regspec)
* :n_dst: number of destination operands
"""
RegSpecALUAPI.__init__(self, rwid, alu)
+ self.alu_name = name or "alu"
self.opsubsetkls = opsubsetkls
self.cu = cu = CompUnitRecord(opsubsetkls, rwid, n_src, n_dst)
n_src, n_dst = self.n_src, self.n_dst = cu._n_src, cu._n_dst
def elaborate(self, platform):
m = Module()
- m.submodules.alu = self.alu
+ setattr(m.submodules, self.alu_name, self.alu)
m.submodules.src_l = src_l = SRLatch(False, self.n_src, name="src")
m.submodules.opc_l = opc_l = SRLatch(sync=False, name="opc")
m.submodules.req_l = req_l = SRLatch(False, self.n_dst, name="req")
ideal (it could be a lot neater) but works for now.
"""
def __init__(self, speckls, pipekls, idx):
+ alu_name = "alu_%s%d" % (self.fnunit.name.lower(), idx)
pspec = speckls(id_wid=2) # spec (NNNPipeSpec instance)
opsubset = pspec.opsubsetkls # get the operand subset class
regspec = pspec.regspec # get the regspec
alu = pipekls(pspec) # create actual NNNBasePipe
- alu.name = "alu_%s%d" % (self.fnunit.name.lower(), idx)
- super().__init__(regspec, alu, opsubset) # pass to MultiCompUnit
+ super().__init__(regspec, alu, opsubset, name=alu_name) # MultiCompUnit
##############################################################
('trap', TrapFunctionUnit),
('logical', LogicalFunctionUnit),
('shiftrot', ShiftRotFunctionUnit)):
- fu = kls()
+ fu = kls(0)
vl = rtlil.convert(fu, ports=fu.ports())
with open("fu_%s.il" % name, "w") as f:
f.write(vl)