1 # This stage is the setup stage that converts the inputs
2 # into the values expected by DivPipeCore
4 from nmigen
import (Module
, Signal
, Cat
, Repl
, Mux
, Const
, Array
)
5 from nmutil
.pipemodbase
import PipeModBase
6 from ieee754
.part
.partsig
import PartitionedSignal
7 from openpower
.decoder
.power_enums
import MicrOp
9 from openpower
.decoder
.power_fields
import DecodeFields
10 from openpower
.decoder
.power_fieldsn
import SignalBitRange
11 from soc
.fu
.div
.pipe_data
import (CoreInputData
,
14 from ieee754
.div_rem_sqrt_rsqrt
.core
import (DivPipeCoreSetupStage
,
15 DivPipeCoreCalculateStage
,
16 DivPipeCoreFinalStage
)
18 __all__
= ["DivCoreBaseStage", "DivCoreSetupStage",
19 "DivCoreCalculateStage", "DivCoreFinalStage"]
22 class DivCoreBaseStage(PipeModBase
):
23 def __init__(self
, pspec
, modname
, core_class
, *args
, **kwargs
):
24 super().__init
__(pspec
, modname
)
25 self
.core
= core_class(pspec
.core_config
, *args
, **kwargs
)
27 def elaborate(self
, platform
):
30 # pass-through on non-core parameters
31 m
.d
.comb
+= self
.o
.eq_without_core(self
.i
)
33 m
.submodules
.core
= self
.core
35 # copy parameters to/from divremsqrt core into the Base, here.
36 m
.d
.comb
+= self
.core
.i
.eq(self
.i
.core
)
37 m
.d
.comb
+= self
.o
.core
.eq(self
.core
.o
)
42 class DivCoreSetupStage(DivCoreBaseStage
):
43 def __init__(self
, pspec
):
44 super().__init
__(pspec
, "core_setup_stage",
45 pspec
.div_pipe_kind
.config
.core_setup_stage_class
)
48 return CoreInputData(self
.pspec
)
51 return CoreInterstageData(self
.pspec
)
54 class DivCoreCalculateStage(DivCoreBaseStage
):
55 def __init__(self
, pspec
, stage_index
):
56 stage
= pspec
.div_pipe_kind
.config
.core_calculate_stage_class
57 super().__init
__(pspec
, f
"core_calculate_stage_{stage_index}",
61 return CoreInterstageData(self
.pspec
)
64 return CoreInterstageData(self
.pspec
)
67 class DivCoreFinalStage(DivCoreBaseStage
):
68 def __init__(self
, pspec
):
69 super().__init
__(pspec
, "core_final_stage",
70 pspec
.div_pipe_kind
.config
.core_final_stage_class
)
73 return CoreInterstageData(self
.pspec
)
76 return CoreOutputData(self
.pspec
)