allow flexible selection of the types of ALUs
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 2 Jul 2020 23:22:00 +0000 (00:22 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 2 Jul 2020 23:22:00 +0000 (00:22 +0100)
src/soc/fu/compunits/compunits.py
src/soc/simple/core.py
src/soc/simple/issuer.py

index bec55b833e693e19435f804f16fe2d1b145d58b7..6de63d059dff17e07058c0493547af6897212448 100644 (file)
@@ -178,17 +178,23 @@ class AllFunctionUnits(Elaboratable):
      * type of FU required
 
     """
-    def __init__(self, pspec, 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(i)
         if pilist is None:
index a158e19977b4096c885efd7ea72dcd65ab828513..8e4ff93fd281867f23ad46f2414d32b534f2098d 100644 (file)
@@ -55,13 +55,12 @@ def sort_fuspecs(fuspecs):
 
 class NonProductionCore(Elaboratable):
     def __init__(self, pspec):
-        addrwid = pspec.addr_wid
         # single LD/ST funnel for memory access
         self.l0 = TstL0CacheBuffer(pspec, n_units=1)
         pi = self.l0.l0.dports[0]
 
         # function units (only one each)
-        self.fus = AllFunctionUnits(pilist=[pi], addrwid=addrwid)
+        self.fus = AllFunctionUnits(pspec, pilist=[pi])
 
         # register files (yes plural)
         self.regs = RegFiles()
index a610f60dccd689fcfcc9aab09d51ea404fd66de2..0ba749970e089fb0e82a9782b31fd33674b70967 100644 (file)
@@ -161,11 +161,14 @@ class TestIssuer(Elaboratable):
 
 
 if __name__ == '__main__':
+    units = {'alu': 1, 'cr': 1, 'branch': 1, 'trap': 1, 'logical': 1,
+             'shiftrot': 1}
     pspec = TestMemPspec(ldst_ifacetype='bare_wb',
                          imem_ifacetype='bare_wb',
                          addr_wid=48,
                          mask_wid=8,
-                         reg_wid=64)
+                         reg_wid=64,
+                         units=units)
     dut = TestIssuer(pspec)
     vl = rtlil.convert(dut, ports=dut.ports(), name="test_issuer")
     with open("test_issuer.il", "w") as f: