455a2040fb869ff8fb5c97770da938d6566b9400
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
20 def __init__(self
, pspec
, modname
):
21 self
.modname
= modname
# use this to give a name to this module
29 def setup(self
, m
, i
):
30 """ links module to inputs and outputs
32 setattr(m
.submodules
, self
.modname
, self
)
33 m
.d
.comb
+= self
.i
.eq(i
)
36 class PipeModBaseChain(DynamicPipe
):
37 """PipeModBaseChain: common code between stage-chained pipes
39 Links a set of combinatorial modules (get_chain) together
40 and uses pspec.pipekls to dynamically select the pipeline type
41 Also conforms to the Pipeline Stage API
44 def __init__(self
, pspec
):
46 self
.chain
= self
.get_chain()
47 super().__init
__(pspec
)
50 """ returns the input spec of the first module in the chain
52 return self
.chain
[0].ispec()
55 """ returns the output spec of the last module in the chain
57 return self
.chain
[-1].ospec()
60 return self
.o
# ... returned here (see setup comment below)
62 def setup(self
, m
, i
):
63 """ links module to inputs and outputs
65 StageChain(self
.chain
).setup(m
, i
) # input linked here, through chain
66 self
.o
= self
.chain
[-1].o
# output is the last thing in the chain...