div pipe completed except for tests
authorJacob Lifshay <programmerjake@gmail.com>
Thu, 18 Jun 2020 23:11:10 +0000 (16:11 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Thu, 18 Jun 2020 23:11:10 +0000 (16:11 -0700)
src/soc/fu/div/core_stages.py
src/soc/fu/div/pipeline.py

index cc4e6f7e52d618454192bf2b25d132d84332b3d4..3bbde7dba509721545a51a6d223974091db3fc28 100644 (file)
@@ -15,6 +15,9 @@ from ieee754.div_rem_sqrt_rsqrt.core import (DivPipeCoreSetupStage,
                                              DivPipeCoreCalculateStage,
                                              DivPipeCoreFinalStage)
 
+__all__ = ["DivCoreBaseStage", "DivCoreSetupStage",
+           "DivCoreCalculateStage", "DivCoreFinalStage"]
+
 
 class DivCoreBaseStage(PipeModBase):
     def __init__(self, pspec, modname, core_class, *args, **kwargs):
index 3bde19bd17ccee0db87481c2bd8c0ab3979c33a8..fb510ff04394b8212414111b94cbd19db2fb706b 100644 (file)
@@ -1,33 +1,61 @@
 from nmutil.singlepipe import ControlBase
 from nmutil.pipemodbase import PipeModBaseChain
 from soc.fu.alu.input_stage import ALUInputStage
-from soc.fu.logical.main_stage import LogicalMainStage
 from soc.fu.alu.output_stage import ALUOutputStage
+from soc.fu.div.setup_stage import DivSetupStage
+from soc.fu.div.core_stages import DivCoreSetupStage, DivCoreCalculateStage, DivCoreFinalStage
+from soc.fu.div.output_stage import DivOutputStage
 
 
 class DivStagesStart(PipeModBaseChain):
     def get_chain(self):
-        inp = ALUInputStage(self.pspec)
-        main = DivMainStage1(self.pspec)
-        return [inp, main, out]
+        alu_input = ALUInputStage(self.pspec)
+        div_setup = DivSetupStage(self.pspec)
+        core_setup = DivCoreSetupStage(self.pspec)
+        return [alu_input, div_setup, core_setup]
+
+
+class DivStagesMiddle(PipeModBaseChain):
+    def __init__(self, pspec, stage_start_index, stage_end_index):
+        self.stage_start_index = stage_start_index
+        self.stage_end_index = stage_end_index
+        super().__init__(pspec)
+
+    def get_chain(self):
+        stages = []
+        for index in range(self.stage_start_index, self.stage_end_index):
+            stages.append(DivCoreCalculateStage(self.pspec, index))
+        return stages
+
 
 class DivStagesEnd(PipeModBaseChain):
     def get_chain(self):
-        main = DivMainStage2(self.pspec)
-        out = ALUOutputStage(self.pspec)
-        return [inp, main, out]
+        core_final = DivCoreFinalStage(self.pspec)
+        div_out = DivOutputStage(self.pspec)
+        alu_out = ALUOutputStage(self.pspec)
+        return [core_final, div_out, alu_out]
 
 
-class LogicalBasePipe(ControlBase):
-    def __init__(self, pspec):
+class DivPipe(ControlBase):
+    def __init__(self, pspec, compute_steps_per_stage=2):
         ControlBase.__init__(self)
-        self.pipe1 = DivStagesStart(pspec)
-        self.pipe5 = DivStagesEnd(pspec)
-        self._eqs = self.connect([self.pipe1, self.pipe5])
+        self.pipe_start = DivStagesStart(pspec)
+        compute_steps = pspec.core_config.n_stages
+        self.pipe_middles = []
+        for start in range(0, compute_steps, compute_steps_per_stage):
+            end = min(start + compute_steps_per_stage, compute_steps)
+            self.pipe_middles.append(DivStagesMiddle(pspec, start, end))
+        self.pipe_end = DivStagesEnd(pspec)
+        self._eqs = self.connect([self.pipe_start,
+                                  *self.pipe_middles,
+                                  self.pipe_end])
 
     def elaborate(self, platform):
         m = ControlBase.elaborate(self, platform)
-        m.submodules.pipe1 = self.pipe1
-        m.submodules.pipe5 = self.pipe5
+        m.submodules.pipe_start = self.pipe_start
+        for i in self.pipe_middles:
+            name = f"pipe_{i.stage_start_index}_to_{i.stage_end_index}"
+            setattr(m.submodules, name, i)
+        m.submodules.pipe_end = self.pipe_end
         m.d.comb += self._eqs
         return m