1706e97c076d6abecb61251d167faa26d16722af
2 This work is funded through NLnet under Grant 2019-02-012
7 * https://bugs.libre-soc.org/show_bug.cgi?id=538
11 from nmigen
import Elaboratable
12 from ieee754
.pipeline
import DynamicPipe
13 from nmutil
.singlepipe
import StageChain
16 class PipeModBase(Elaboratable
):
17 """PipeModBase: common code between nearly every pipeline module
19 def __init__(self
, pspec
, modname
):
20 self
.modname
= modname
# use this to give a name to this module
28 def setup(self
, m
, i
):
29 """ links module to inputs and outputs
31 setattr(m
.submodules
, self
.modname
, self
)
32 m
.d
.comb
+= self
.i
.eq(i
)
35 class PipeModBaseChain(DynamicPipe
):
36 """PipeModBaseChain: common code between stage-chained pipes
38 Links a set of combinatorial modules (get_chain) together
39 and uses pspec.pipekls to dynamically select the pipeline type
40 Also conforms to the Pipeline Stage API
42 def __init__(self
, pspec
):
44 self
.chain
= self
.get_chain()
45 super().__init
__(pspec
)
48 """ returns the input spec of the first module in the chain
50 return self
.chain
[0].ispec()
53 """ returns the output spec of the last module in the chain
55 return self
.chain
[-1].ospec()
58 return self
.o
# ... returned here (see setup comment below)
60 def setup(self
, m
, i
):
61 """ links module to inputs and outputs
63 StageChain(self
.chain
).setup(m
, i
) # input linked here, through chain
64 self
.o
= self
.chain
[-1].o
# output is the last thing in the chain...