1 # SPDX-License-Identifier: LGPL-3-or-later
3 This work is funded through NLnet under Grant 2019-02-012
8 * https://bugs.libre-soc.org/show_bug.cgi?id=538
12 from nmigen
import Elaboratable
13 from ieee754
.pipeline
import DynamicPipe
14 from nmutil
.singlepipe
import StageChain
17 class PipeModBase(Elaboratable
):
18 """PipeModBase: common code between nearly every pipeline module
21 def __init__(self
, pspec
, modname
):
22 self
.modname
= modname
# use this to give a name to this module
30 def setup(self
, m
, i
):
31 """ links module to inputs and outputs
33 setattr(m
.submodules
, self
.modname
, self
)
34 m
.d
.comb
+= self
.i
.eq(i
)
37 class PipeModBaseChain(DynamicPipe
):
38 """PipeModBaseChain: common code between stage-chained pipes
40 Links a set of combinatorial modules (get_chain) together
41 and uses pspec.pipekls to dynamically select the pipeline type
42 Also conforms to the Pipeline Stage API
45 def __init__(self
, pspec
):
47 self
.chain
= self
.get_chain()
48 super().__init
__(pspec
)
51 """ returns the input spec of the first module in the chain
53 return self
.chain
[0].ispec()
56 """ returns the output spec of the last module in the chain
58 return self
.chain
[-1].ospec()
61 return self
.o
# ... returned here (see setup comment below)
63 def setup(self
, m
, i
):
64 """ links module to inputs and outputs
66 StageChain(self
.chain
).setup(m
, i
) # input linked here, through chain
67 self
.o
= self
.chain
[-1].o
# output is the last thing in the chain...