move o_valid and o_ready (underscore them) and replace with properties
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 5 Apr 2019 08:06:20 +0000 (09:06 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 5 Apr 2019 08:06:36 +0000 (09:06 +0100)
o_ready now redirects to self._o_ready if stage_ctl is False
likewise o_valid in NextControl redirects to self._o_valid

src/add/singlepipe.py

index 50eba9dc67167aae04355ebc78237c7275ef3706..ef037fb95d2091dab1207835b055b0018dc891b7 100644 (file)
@@ -171,11 +171,17 @@ class PrevControl:
     def __init__(self, i_width=1, stage_ctl=False):
         self.stage_ctl = stage_ctl
         self.i_valid = Signal(i_width, name="p_i_valid") # prev   >>in  self
-        self.o_ready = Signal(name="p_o_ready") # prev   <<out self
+        self._o_ready = Signal(name="p_o_ready") # prev   <<out self
         self.i_data = None # XXX MUST BE ADDED BY USER
         if stage_ctl:
             self.s_o_ready = Signal(name="p_s_o_rdy") # prev   <<out self
 
+    @property
+    def o_ready(self):
+        if self.stage_ctl:
+            return self.s_o_ready
+        return self._o_ready
+
     def _connect_in(self, prev):
         """ internal helper function to connect stage to an input source.
             do not use to connect stage-to-stage!
@@ -202,12 +208,18 @@ class NextControl:
     """
     def __init__(self, stage_ctl=False):
         self.stage_ctl = stage_ctl
-        self.o_valid = Signal(name="n_o_valid") # self out>>  next
+        self._o_valid = Signal(name="n_o_valid") # self out>>  next
         self.i_ready = Signal(name="n_i_ready") # self <<in   next
         self.o_data = None # XXX MUST BE ADDED BY USER
         if stage_ctl:
             self.s_o_valid = Signal(name="n_s_o_vld") # self out>>  next
 
+    @property
+    def o_valid(self):
+        if self.stage_ctl:
+            return self.s_o_valid
+        return self._o_valid
+
     def connect_to_next(self, nxt):
         """ helper function to connect to the next stage data/valid/ready.
             data/valid is passed *TO* nxt, and ready comes *IN* from nxt.