move stage test of setup function to ControlBase
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 8 Apr 2019 10:56:15 +0000 (11:56 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 8 Apr 2019 10:56:15 +0000 (11:56 +0100)
src/add/singlepipe.py

index d72ac134778ea6a64f5fc90208fb72a1af456db0..99974e29e2169efefd037729e41603d348cabc27 100644 (file)
@@ -552,6 +552,10 @@ class ControlBase:
         """ handles case where stage has dynamic ready/valid functions
         """
         m = Module()
+
+        if self.stage is not None and hasattr(self.stage, "setup"):
+            self.stage.setup(m, self.p.i_data)
+
         if not self.p.stage_ctl:
             return m
 
@@ -596,13 +600,10 @@ class BufferedHandshake(ControlBase):
     """
 
     def elaborate(self, platform):
-
         self.m = ControlBase._elaborate(self, platform)
 
         result = self.stage.ospec()
         r_data = self.stage.ospec()
-        if hasattr(self.stage, "setup"):
-            self.stage.setup(self.m, self.p.i_data)
 
         # establish some combinatorial temporaries
         o_n_validn = Signal(reset_less=True)
@@ -669,8 +670,6 @@ class SimpleHandshake(ControlBase):
 
         r_busy = Signal()
         result = self.stage.ospec()
-        if hasattr(self.stage, "setup"):
-            self.stage.setup(m, self.p.i_data)
 
         # establish some combinatorial temporaries
         n_i_ready = Signal(reset_less=True, name="n_i_rdy_data")
@@ -745,8 +744,6 @@ class UnbufferedPipeline(ControlBase):
 
         data_valid = Signal() # is data valid or not
         r_data = self.stage.ospec() # output type
-        if hasattr(self.stage, "setup"):
-            self.stage.setup(m, self.p.i_data)
 
         # some temporaries
         p_i_valid = Signal(reset_less=True)
@@ -801,8 +798,6 @@ class UnbufferedPipeline2(ControlBase):
 
         buf_full = Signal() # is data valid or not
         buf = self.stage.ospec() # output type
-        if hasattr(self.stage, "setup"):
-            self.stage.setup(m, self.p.i_data)
 
         # some temporaries
         p_i_valid = Signal(reset_less=True)
@@ -837,9 +832,6 @@ class PassThroughHandshake(ControlBase):
     def elaborate(self, platform):
         self.m = m = ControlBase._elaborate(self, platform)
 
-        if hasattr(self.stage, "setup"):
-            self.stage.setup(m, self.p.i_data)
-
         # temporaries
         p_i_valid = Signal(reset_less=True)
         pvr = Signal(reset_less=True)