add ALUProxy to ReservationStations class
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 1 Nov 2021 20:15:34 +0000 (20:15 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 1 Nov 2021 20:15:34 +0000 (20:15 +0000)
src/nmutil/concurrentunit.py

index 6d2ff3d56b814b4bf50b3890e58a5678d3160b5d..9f3432a1fe9e23f47e8b6242ad86fe4d21019cc2 100644 (file)
@@ -93,6 +93,17 @@ class MuxOutPipe(CombMuxOutPipe):
                                 maskwid=maskwid)
 
 
+class ALUProxy:
+    """ALUProxy: create a series of ALUs that look like the ALU being
+    sandwiched in between the fan-in and fan-out.  One ALU looks like
+    it is multiple concurrent ALUs
+    """
+    def __init__(self, alu, p, n):
+        self.alu = alu
+        self.p = p
+        self.n = n
+
+
 class ReservationStations(Elaboratable):
     """ Reservation-Station pipeline
 
@@ -117,6 +128,14 @@ class ReservationStations(Elaboratable):
         self.n = self.outpipe.n # use pipe in/out as this class in/out
         self._ports = self.inpipe.ports() + self.outpipe.ports()
 
+    def set_alu(self, alu):
+        """set_alu: sets self.alu and also establishes a suite of pseudo-alus
+        that look to all pipeline-intents-and-purposes just like the original
+        """
+        self.alu, self.pseudoalus = alu, []
+        for i in range(num_rows):
+            self.pseudoalus.append(ALUProxy(alu, self.p[i], self.n[i]))
+
     def elaborate(self, platform):
         m = Module()
         m.submodules.inpipe = self.inpipe