From: Luke Kenneth Casson Leighton Date: Thu, 13 Aug 2020 23:25:36 +0000 (+0100) Subject: divide alu pipeline into 2 (simple last) X-Git-Tag: semi_working_ecp5~359 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f340bf7df1f95b71c996806801a6475fe1b15454;p=soc.git divide alu pipeline into 2 (simple last) --- diff --git a/src/soc/fu/alu/pipeline.py b/src/soc/fu/alu/pipeline.py index a84efe1e..87ca1356 100644 --- a/src/soc/fu/alu/pipeline.py +++ b/src/soc/fu/alu/pipeline.py @@ -8,8 +8,13 @@ class ALUStages(PipeModBaseChain): def get_chain(self): inp = ALUInputStage(self.pspec) main = ALUMainStage(self.pspec) + return [inp, main] + + +class ALUStageEnd(PipeModBaseChain): + def get_chain(self): out = ALUOutputStage(self.pspec) - return [inp, main, out] + return [out] class ALUBasePipe(ControlBase): @@ -17,10 +22,12 @@ class ALUBasePipe(ControlBase): ControlBase.__init__(self) self.pspec = pspec self.pipe1 = ALUStages(pspec) - self._eqs = self.connect([self.pipe1]) + self.pipe2 = ALUStageEnd(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.pipe1 = self.pipe1 + m.submodules.pipe2 = self.pipe2 m.d.comb += self._eqs return m diff --git a/src/soc/fu/alu/test/test_pipe_caller.py b/src/soc/fu/alu/test/test_pipe_caller.py index 842ce2db..aea6cb9d 100644 --- a/src/soc/fu/alu/test/test_pipe_caller.py +++ b/src/soc/fu/alu/test/test_pipe_caller.py @@ -187,7 +187,12 @@ class TestRunner(unittest.TestCase): fn_unit = yield pdecode2.e.do.fn_unit self.assertEqual(fn_unit, Function.ALU.value) yield from set_alu_inputs(alu, pdecode2, sim) + + # 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 sim.call(opname) index = sim.pc.CIA.value//4 @@ -199,6 +204,7 @@ class TestRunner(unittest.TestCase): yield yield from self.check_alu_outputs(alu, pdecode2, sim, code) + yield Settle() def test_it(self): test_data = ALUTestCase().test_data @@ -214,8 +220,7 @@ class TestRunner(unittest.TestCase): m.submodules.alu = alu = ALUBasePipe(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) # XXX ONLY works because ALU is 1 stage pipe + comb += alu.n.ready_i.eq(1) comb += pdecode2.dec.raw_opcode_in.eq(instruction) sim = Simulator(m)