divide logical pipe into 2 (simple phase last)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 13 Aug 2020 23:19:34 +0000 (00:19 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 14 Aug 2020 11:10:23 +0000 (12:10 +0100)
src/soc/fu/logical/pipeline.py
src/soc/fu/logical/test/test_pipe_caller.py

index 41aea1487347eb0d6dacd583f6abb72a76002ba0..a16bd78acab1c6c65702368ddd28b5a2f07f1dc1 100644 (file)
@@ -4,23 +4,31 @@ from soc.fu.logical.input_stage import LogicalInputStage
 from soc.fu.logical.main_stage import LogicalMainStage
 from soc.fu.logical.output_stage import LogicalOutputStage
 
-class LogicalStages(PipeModBaseChain):
+
+class LogicalStages1(PipeModBaseChain):
     def get_chain(self):
         inp = LogicalInputStage(self.pspec)
         main = LogicalMainStage(self.pspec)
+        return [inp, main]
+
+
+class LogicalStages2(PipeModBaseChain):
+    def get_chain(self):
         out = LogicalOutputStage(self.pspec)
-        return [inp, main, out]
+        return [out]
 
 
 class LogicalBasePipe(ControlBase):
     def __init__(self, pspec):
         ControlBase.__init__(self)
         self.pspec = pspec
-        self.pipe1 = LogicalStages(pspec)
-        self._eqs = self.connect([self.pipe1])
+        self.pipe1 = LogicalStages1(pspec)
+        self.pipe2 = LogicalStages2(pspec)
+        self._eqs = self.connect([self.pipe1, self.pipe2])
 
     def elaborate(self, platform):
         m = ControlBase.elaborate(self, platform)
-        m.submodules.pipe = self.pipe1
+        m.submodules.logical_pipe1 = self.pipe1
+        m.submodules.logical_pipe2 = self.pipe2
         m.d.comb += self._eqs
         return m
index 26ef54e6c1e132bda06eaf9a32177e39a72f3f1f..725cf306b11534c6dc2cc5d9a8daecc4ecedfc20 100644 (file)
@@ -161,7 +161,6 @@ class TestRunner(FHDLTestCase):
         m.submodules.alu = alu = LogicalBasePipe(pspec)
 
         comb += alu.p.data_i.ctx.op.eq_from_execute1(pdecode2.e)
-        comb += alu.p.valid_i.eq(1)
         comb += alu.n.ready_i.eq(1)
         comb += pdecode2.dec.raw_opcode_in.eq(instruction)
         sim = Simulator(m)
@@ -193,7 +192,12 @@ class TestRunner(FHDLTestCase):
                     fn_unit = yield pdecode2.e.do.fn_unit
                     self.assertEqual(fn_unit, Function.LOGICAL.value, code)
                     yield from set_alu_inputs(alu, pdecode2, simulator)
+
+                    # set valid for one cycle, propagate through pipeline...
+                    yield alu.p.valid_i.eq(1)
                     yield
+                    yield alu.p.valid_i.eq(0)
+
                     opname = code.split(' ')[0]
                     yield from simulator.call(opname)
                     index = simulator.pc.CIA.value//4
@@ -206,6 +210,8 @@ class TestRunner(FHDLTestCase):
 
                     yield from self.check_alu_outputs(alu, pdecode2,
                                                       simulator, code)
+                    yield Settle()
+
 
         sim.add_sync_process(process)
         with sim.write_vcd("logical_simulator.vcd", "logical_simulator.gtkw",