link up PriorityPickers on read channels
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 3 Jun 2020 21:45:12 +0000 (22:45 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 3 Jun 2020 21:45:12 +0000 (22:45 +0100)
src/soc/simple/core.py

index d34dfef282ec2cfc35586306cd1d6984e68d505f..a8b3b33ef1178fa9bd7d2b68ea042941105a76ce 100644 (file)
@@ -7,6 +7,8 @@ Function Unit to be operational.
 from nmigen import Elaboratable, Module, Signal
 from nmigen.cli import rtlil
 
+from nmutil.picker import PriorityPicker
+
 from soc.fu.compunits.compunits import AllFunctionUnits
 from soc.regfile.regfiles import RegFiles
 from soc.decoder.power_decoder import create_pdecode
@@ -31,6 +33,12 @@ class NonProductionCore(Elaboratable):
         regs = self.regs
         fus = self.fus.fus
 
+        # enable-signals for each FU, get one bit for each FU (by name)
+        fu_enable = Signal(len(fus), reset_less=True)
+        fu_bitdict = {}
+        for i, funame in enumerate(fus.keys()):
+            fu_bitdict[funame] = fu_enable[i]
+
         # dictionary of lists of regfile read ports
         byregfiles_rd = {}
         byregfiles_rdspec = {}
@@ -57,9 +65,23 @@ class NonProductionCore(Elaboratable):
                 (regname, rdflag, read, wid) = byregfiles_rdspec[regfile]
                 print ("  %s" % regname, wid, read, rdflag)
                 for (funame, fu) in fuspec:
-                    print ("    ", funame, fu)
+                    print ("    ", funame, fu, fu.src_i[idx])
                     print ()
 
+        # okaay, now we need a PriorityPicker per regfile per regfile port
+        # loootta pickers... peter piper picked a pack of pickled peppers...
+        rdpickers = {}
+        for regfile, spec in byregfiles_rd.items():
+            rdpickers[regfile] = {}
+            for idx, fuspec in spec.items():
+                rdpickers[regfile][idx] = rdpick = PriorityPicker(len(fuspec))
+                setattr(m.submodules, "rdpick_%s_%d" % (regfile, idx), rdpick)
+                for pi, (funame, fu) in enumerate(fuspec):
+                    # connect request-read to picker input, and output to go-rd
+                    fu_active = fu_bitdict[funame]
+                    comb += rdpick.i[pi].eq(fu.rd_rel_o[idx] & fu_active)
+                    comb += fu.go_rd_i[idx].eq(rdpick.o[pi])
+
         return m
 
     def __iter__(self):