move flexible ports fn to MultiOutControlBase
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 28 Mar 2019 14:07:44 +0000 (14:07 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 28 Mar 2019 14:07:44 +0000 (14:07 +0000)
src/add/multipipe.py
src/add/nmigen_add_experiment.py
src/add/test_inout_mux_pipe.py
src/add/test_outmux_pipe.py

index 0518cfeb978c4d50722f18c5aebce14e9a153f15..8abdc172d405cd8039a79625825ec9f5da06c1f9 100644 (file)
@@ -126,16 +126,22 @@ class MultiOutControlBase:
         return eq(self.p.i_data, i)
 
     def ports(self):
-        res = []
-        res += [self.p.i_valid, self.p.o_ready,
-                self.p.i_data] # XXX need flattening!
+        res = [self.p.i_valid, self.p.o_ready]
+        if hasattr(self.p.i_data, "ports"):
+            res += self.p.i_data.ports()
+        else:
+            res += self.p.i_data
+
         for i in range(len(self.n)):
-            res += [self.n[i].i_ready, self.n[i].o_valid,
-                    self.n[i].o_data]   # XXX need flattening!
+            n = self.n[i]
+            res += [n.i_ready, n.o_valid]
+            if hasattr(n.o_data, "ports"):
+                res += n.o_data.ports()
+            else:
+                res += n.o_data
         return res
 
 
-
 class CombMultiOutPipeline(MultiOutControlBase):
     """ A multi-input Combinatorial block conforming to the Pipeline API
 
@@ -275,8 +281,6 @@ class CombMuxOutPipe(CombMultiOutPipeline):
         # HACK: n-mux is also the stage... so set the muxid equal to input mid
         stage.m_id = self.p.i_data.mid
 
-    def ports(self):
-        return self.p_mux.ports()
 
 
 class InputPriorityArbiter:
index 54b69f83683b35ed01df0e0ddbed10088772b783..62880a41a34997e437155e52e54e617d0c7d4fa9 100644 (file)
@@ -1897,14 +1897,6 @@ class FPADDMuxOutPipe(CombMuxOutPipe):
         stage = PassThroughStage(iospec)
         CombMuxOutPipe.__init__(self, stage, n_len=self.num_rows)
 
-    def ports(self):
-        res = [self.p.i_valid, self.p.o_ready] + \
-                self.p.i_data.ports()
-        for i in range(len(self.n)):
-            res += [self.n[i].i_ready, self.n[i].o_valid] + \
-                    self.n[i].o_data.ports()
-        return res
-
 
 class FPADDMuxInOut:
     """ Reservation-Station version of FPADD pipeline.
index ada5e1cb3f7553929d97967da7dc3f138d3ce47d..1bfc8dfe6a1caa5ef47f9370d197be6a8534eed0 100644 (file)
@@ -198,14 +198,6 @@ class TestMuxOutPipe(CombMuxOutPipe):
         stage = PassThroughStage()
         CombMuxOutPipe.__init__(self, stage, n_len=self.num_rows)
 
-    def ports(self):
-        res = [self.p.i_valid, self.p.o_ready] + \
-                self.p.i_data.ports()
-        for i in range(len(self.n)):
-            res += [self.n[i].i_ready, self.n[i].o_valid] + \
-                    self.n[i].o_data.ports()
-        return res
-
 
 class TestInOutPipe:
     def __init__(self, num_rows=4):
index 3e8a5559d17a28a30dd54de187e5a664e06d5e3a..67b0313240d428ad1e4863b850a030561138dc1d 100644 (file)
@@ -221,15 +221,6 @@ class TestPriorityMuxPipe(CombMuxOutPipe):
         stage = PassThroughStage()
         CombMuxOutPipe.__init__(self, stage, n_len=self.num_rows)
 
-    def ports(self):
-        res = [self.p.i_valid, self.p.o_ready] + \
-                self.p.i_data.ports()
-        for i in range(len(self.n)):
-            res += [self.n[i].i_ready, self.n[i].o_valid] + \
-                    [self.n[i].o_data]
-                    #self.n[i].o_data.ports()
-        return res
-
 
 class TestSyncToPriorityPipe:
     def __init__(self):