From f42c081ddea8b9982298bc01a7303b44f2b297e9 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 22 Mar 2019 10:12:19 +0000 Subject: [PATCH] add an example of a stage that is itself a module --- src/add/test_buf_pipe.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/add/test_buf_pipe.py b/src/add/test_buf_pipe.py index e38043ec..be472c43 100644 --- a/src/add/test_buf_pipe.py +++ b/src/add/test_buf_pipe.py @@ -342,6 +342,28 @@ class LTStage: return self.o +class LTStageDerived(SetLessThan): + + def __init__(self): + SetLessThan.__init__(self, 16, True) + + def ispec(self): + return (Signal(16), Signal(16)) + + def ospec(self): + return Signal(16) + + def setup(self, m, i): + self.o = Signal(16) + m.submodules.slt = self + m.d.comb += self.src1.eq(i[0]) + m.d.comb += self.src2.eq(i[1]) + m.d.comb += self.o.eq(self.output) + + def process(self, i): + return self.o + + class ExampleLTCombPipe(CombPipe): """ an example of how to use the combinatorial pipeline. """ @@ -351,6 +373,15 @@ class ExampleLTCombPipe(CombPipe): CombPipe.__init__(self, stage) +class ExampleLTBufferedPipeDerived(CombPipe): + """ an example of how to use the combinatorial pipeline. + """ + + def __init__(self): + stage = LTStageDerived() + CombPipe.__init__(self, stage) + + def test6_resultfn(o_data, expected, i, o): res = 1 if expected[0] < expected[1] else 0 assert o_data == res, \ @@ -537,3 +568,8 @@ if __name__ == '__main__': run_simulation(dut, [test.send, test.rcv], vcd_name="test_bufpipechain2.vcd") + print ("test 10") + dut = ExampleLTBufferedPipeDerived() + test = Test5(dut, test6_resultfn) + run_simulation(dut, [test.send, test.rcv], vcd_name="test_ltbufpipe10.vcd") + -- 2.30.2