From: Luke Kenneth Casson Leighton Date: Fri, 29 Mar 2019 11:29:32 +0000 (+0000) Subject: create separate pipeline examples X-Git-Tag: ls180-24jan2020~1407 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=029aac7e4e4abd1d583bda651771dff58e072623;p=ieee754fpu.git create separate pipeline examples --- diff --git a/src/add/pipeline_example.py b/src/add/pipeline_example.py index 44d453da..6474a396 100644 --- a/src/add/pipeline_example.py +++ b/src/add/pipeline_example.py @@ -13,9 +13,36 @@ class SimplePipelineExample(SimplePipeline): def __init__(self, pipe): SimplePipeline.__init__(self, pipe) self._loopback = Signal(4) - self._obj = ObjectProxy(pipe) - self._obj.a = Signal(4) - self._obj.b = Signal(4) + self._setup() + + def stage0(self): + self.n = ~self._loopback + + def stage1(self): + self.n = self.n + 2 + + def stage2(self): + localv = Signal(4) + self._pipe.comb += localv.eq(2) + self.n = self.n << localv + + def stage3(self): + self.n = ~self.n + + def stage4(self): + self._pipe.sync += self._loopback.eq(self.n + 3) + + +class ObjectBasedPipelineExample(SimplePipeline): + """ A very simple pipeline to show how registers are inferred. """ + + def __init__(self, pipe): + ObjectBasedPipeline.__init__(self, pipe) + self._loopback = Signal(4) + o = ObjectProxy(pipe) + o.a = Signal(4) + o.b = Signal(4) + self._obj = o self._setup() def stage0(self): @@ -24,16 +51,18 @@ class SimplePipelineExample(SimplePipeline): def stage1(self): self.n = self.n + self.o.a - self.o = self.o - self.o.a = self.n - self.o.b = self.o.b + o = ObjectProxy(self._pipe) + o.a = self.n + o.b = self.o.b + self.o = o def stage2(self): localv = Signal(4) self._pipe.comb += localv.eq(2) self.n = self.n << localv - self.o = self.o - self.o.b = self.n + self.o.a + self.o.b + o = ObjectProxy(self._pipe) + o.b = self.n + self.o.a + self.o.b + self.o = o def stage3(self): self.n = ~self.n @@ -41,14 +70,14 @@ class SimplePipelineExample(SimplePipeline): self.o.b = self.o.b + self.n def stage4(self): - self.o.b = self.o.b self._pipe.sync += self._loopback.eq(self.n + 3 + self.o.b) + class PipeModule: def __init__(self): self.m = Module() - self.p = SimplePipelineExample(self.m.d) + self.p = ObjectBasedPipelineExample(self.m.d) def get_fragment(self, platform=None): return self.m