Add cordic stages to fp cordic pipeline
authorMichael Nolan <mtnolan2640@gmail.com>
Tue, 28 Apr 2020 17:55:53 +0000 (13:55 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Mon, 4 May 2020 18:55:10 +0000 (14:55 -0400)
src/ieee754/cordic/fp_pipeline.py
src/ieee754/cordic/test/test_fp_pipe.py

index 9ceaaea46d77c5f0b4bf6fc997ddc4474cf197fa..2b0b8287dccf7540ff6753cc38803b1eb3a1c727 100644 (file)
@@ -4,6 +4,8 @@ from nmutil.pipemodbase import PipeModBaseChain
 from ieee754.fpcommon.denorm import FPAddDeNormMod
 from ieee754.cordic.fp_pipe_init_stages import (FPCordicInitStage,
                                                 FPCordicConvertFixed)
+from ieee754.cordic.sin_cos_pipe_stage import (CordicStage,
+                                               CordicInitialStage)
 
 
 class CordicPipeChain(PipeModBaseChain):
@@ -25,7 +27,18 @@ class FPCordicBasePipe(ControlBase):
                                        FPAddDeNormMod(self.pspec, False),
                                        FPCordicConvertFixed(self.pspec)])
 
-        self._eqs = self.connect([self.denorm])
+        self.cordicstages = []
+
+        initstage = CordicInitialStage(pspec)
+        stages = []
+        for i in range(pspec.iterations):
+            stages.append(CordicStage(pspec, i))
+        chunks = self.chunkify(initstage, stages)
+        for chunk in chunks:
+            chain = CordicPipeChain(pspec, chunk)
+            self.cordicstages.append(chain)
+
+        self._eqs = self.connect([self.denorm] + self.cordicstages)
 
     def chunkify(self, initstage, stages):
         chunks = []
@@ -39,5 +52,8 @@ class FPCordicBasePipe(ControlBase):
     def elaborate(self, platform):
         m = ControlBase.elaborate(self, platform)
         m.submodules.denorm = self.denorm
+        for i, stage in enumerate(self.cordicstages):
+            setattr(m.submodules, "cordic%d" % i,
+                    stage)
         m.d.comb += self._eqs
         return m
index 1b2ead125381d366065fd0c943f85e9c3dd51c96..295c3c4f3c42c3596a441750c6eefc467a652768 100644 (file)
@@ -47,7 +47,7 @@ class SinCosTestCase(FHDLTestCase):
 
         sim.add_sync_process(writer_process)
         with sim.write_vcd("fp_pipeline.vcd", "fp_pipeline.gtkw", traces=[
-                z, dut.n.data_o.z0]):
+                z]):
             sim.run()
 
     def test_rand(self):