decoding) which read-register ports are to be requested. this is not
ideal (it could be a lot neater) but works for now.
"""
- def __init__(self, speckls, pipekls):
+ 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
- super().__init__(regspec, alu, opsubset) # pass to MultiCompUnit
+ super().__init__(regspec, alu, opsubset, name=alu_name) # MultiCompUnit
##############################################################
class ALUFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.ALU
- def __init__(self): super().__init__(ALUPipeSpec, ALUBasePipe)
+ def __init__(self, idx):
+ super().__init__(ALUPipeSpec, ALUBasePipe, idx)
class LogicalFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.LOGICAL
- def __init__(self): super().__init__(LogicalPipeSpec, LogicalBasePipe)
+ def __init__(self, idx):
+ super().__init__(LogicalPipeSpec, LogicalBasePipe, idx)
class CRFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.CR
- def __init__(self): super().__init__(CRPipeSpec, CRBasePipe)
+ def __init__(self, idx):
+ super().__init__(CRPipeSpec, CRBasePipe, idx)
class BranchFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.BRANCH
- def __init__(self): super().__init__(BranchPipeSpec, BranchBasePipe)
+ def __init__(self, idx):
+ super().__init__(BranchPipeSpec, BranchBasePipe, idx)
class ShiftRotFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.SHIFT_ROT
- def __init__(self): super().__init__(ShiftRotPipeSpec, ShiftRotBasePipe)
+ def __init__(self, idx):
+ super().__init__(ShiftRotPipeSpec, ShiftRotBasePipe, idx)
class DIVFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.DIV
- def __init__(self): super().__init__(DIVPipeSpec, DIVBasePipe)
+ def __init__(self, idx):
+ super().__init__(DIVPipeSpec, DIVBasePipe, idx)
class TrapFunctionUnit(FunctionUnitBaseSingle):
fnunit = Function.TRAP
- def __init__(self): super().__init__(TrapPipeSpec, TrapBasePipe)
+ def __init__(self, idx):
+ super().__init__(TrapPipeSpec, TrapBasePipe, idx)
# special-case
class LDSTFunctionUnit(LDSTCompUnit):
fnunit = Function.LDST
- def __init__(self, pi, awid):
+ def __init__(self, pi, awid, idx):
pspec = LDSTPipeSpec(id_wid=2) # spec (NNNPipeSpec instance)
opsubset = pspec.opsubsetkls # get the operand subset class
regspec = pspec.regspec # get the regspec
* type of FU required
"""
- def __init__(self, pilist=None, addrwid=6):
+ def __init__(self, pspec, pilist=None):
+ addrwid = pspec.addr_wid
+ units = pspec.units
+ if not isinstance(units, dict):
+ units = {'alu': 1, 'cr': 1, 'branch': 1, 'trap': 1, 'logical': 1,
+ 'div': 1, 'shiftrot': 1}
+ alus = {'alu': ALUFunctionUnit,
+ 'cr': CRFunctionUnit,
+ 'branch': BranchFunctionUnit,
+ 'trap': TrapFunctionUnit,
+ 'div': DIVFunctionUnit,
+ 'logical': LogicalFunctionUnit,
+ 'shiftrot': ShiftRotFunctionUnit,
+ }
self.fus = {}
- for (name, qty, kls) in (('alu', 1, ALUFunctionUnit),
- ('cr', 1, CRFunctionUnit),
- ('branch', 1, BranchFunctionUnit),
- ('trap', 1, TrapFunctionUnit),
- # far too large at the moment
- #('div', 1, DIVFunctionUnit),
- ('logical', 1, LogicalFunctionUnit),
- ('shiftrot', 1, ShiftRotFunctionUnit),
- ):
+ for name, qty in units.items():
+ kls = alus[name]
for i in range(qty):
- self.fus["%s%d" % (name, i)] = kls()
+ self.fus["%s%d" % (name, i)] = kls(i)
if pilist is None:
return
for i, pi in enumerate(pilist):
- self.fus["ldst%d" % (i)] = LDSTFunctionUnit(pi, addrwid)
+ self.fus["ldst%d" % (i)] = LDSTFunctionUnit(pi, addrwid, i)
def elaborate(self, platform):
m = Module()
('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)