Register each pipeline stage
authorMichael Nolan <mtnolan2640@gmail.com>
Wed, 1 Apr 2020 17:17:27 +0000 (13:17 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Wed, 1 Apr 2020 17:20:22 +0000 (13:20 -0400)
src/ieee754/cordic/sin_cos_pipeline.py

index 65ac952566575f6c2e8298dd18d31eb7ab99f61d..e8b3a6be767ec08cdd320f9fe68e36e98943e58d 100644 (file)
@@ -8,23 +8,32 @@ from ieee754.cordic.pipe_data import (CordicPipeSpec, CordicData,
                                       CordicInitialData)
 
 class CordicPipeChain(PipeModBaseChain):
+    def __init__(self, pspec, stages):
+        self.stages = stages
+        super().__init__(pspec)
+
     def get_chain(self):
-        initstage = CordicInitialStage(self.pspec)
-        cordicstages = []
-        for i in range(self.pspec.iterations):
-            stage = CordicStage(self.pspec, i)
-            cordicstages.append(stage)
-        return [initstage] + cordicstages
+        return self.stages
         
 
 class CordicBasePipe(ControlBase):
     def __init__(self, pspec):
         ControlBase.__init__(self)
-        self.chain = CordicPipeChain(pspec)
-        self._eqs = self.connect([self.chain])
+        self.initstage = CordicPipeChain(pspec,
+                                         [CordicInitialStage(pspec)])
+        self.cordicstages = []
+        for i in range(pspec.iterations):
+            stage = CordicPipeChain(pspec,
+                                    [CordicStage(pspec, i)])
+            self.cordicstages.append(stage)
+
+        self._eqs = self.connect([self.initstage] + self.cordicstages)
         
     def elaborate(self, platform):
         m = ControlBase.elaborate(self, platform)
-        m.submodules.chain = self.chain
+        m.submodules.init = self.initstage
+        for i, stage in enumerate(self.cordicstages):
+            setattr(m.submodules, "cordic%d" % i,
+                    stage)
         m.d.comb += self._eqs
         return m