2 * see https://libre-soc.org/3d_gpu/architecture/regfile/ section on regspecs
6 from nmigen
.cli
import rtlil
7 from soc
.experiment
.compalu_multi
import MultiCompUnit
9 from soc
.fu
.alu
.pipeline
import ALUBasePipe
10 from soc
.fu
.alu
.pipe_data
import ALUPipeSpec
12 from soc
.fu
.cr
.pipeline
import CRBasePipe
13 from soc
.fu
.cr
.pipe_data
import CRPipeSpec
16 class FunctionUnitBaseSingle(MultiCompUnit
):
17 """FunctionUnitBaseSingle
19 main "glue" class that brings everything together.
20 ONLY use this class for single-stage pipelines.
22 * :speckls: - the specification. contains regspec and op subset info,
23 and contains common "stuff" like the pipeline ctx,
24 what type of nmutil pipeline base is to be used (etc)
25 * :pipekls: - the type of pipeline. actually connects things together
27 note that it is through MultiCompUnit.get_in/out that we *actually*
28 connect up the association between regspec variable names (defined
31 def __init__(self
, speckls
, pipekls
):
32 pspec
= speckls(id_wid
=2) # spec (NNNPipeSpec instance)
33 opsubset
= pspec
.opsubsetkls
# get the operand subset class
34 regspec
= pspec
.regspec
# get the regspec
35 alu
= pipekls(pspec
) # create actual NNNBasePipe
36 super().__init
__(regspec
, alu
, opsubset
) # pass to MultiCompUnit
39 ######################################################################
40 ###### actual Function Units: these are "single" stage pipelines #####
42 class ALUFunctionUnit(FunctionUnitBaseSingle
):
43 def __init__(self
): super().__init
__(ALUPipeSpec
, ALUBasePipe
)
45 class CRFunctionUnit(FunctionUnitBaseSingle
):
46 def __init__(self
): super().__init
__(CRPipeSpec
, CRBasePipe
)
48 #####################################################################
49 ###### actual Function Units: these are "multi" stage pipelines #####
51 # TODO: ReservationStations-based.
54 def tst_single_fus_il():
55 for (name
, kls
) in (('alu', ALUFunctionUnit
),
56 ('cr', CRFunctionUnit
)):
58 vl
= rtlil
.convert(fu
, ports
=fu
.ports())
59 with
open("fu_%s.il" % name
, "w") as f
:
62 if __name__
== '__main__':