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 soc
.fu
.logical
.pipe_data
import LogicalInputData
7 from soc
.fu
.alu
.pipe_data
import ALUOutputData
8 from ieee754
.part
.partsig
import PartitionedSignal
9 from soc
.decoder
.power_enums
import InternalOp
11 from soc
.decoder
.power_fields
import DecodeFields
12 from soc
.decoder
.power_fieldsn
import SignalBitRange
13 from soc
.fu
.div
.pipe_data
import CoreInputData
, CoreInterstageData
, CoreOutputData
14 from ieee754
.div_rem_sqrt_rsqrt
.core
import (DivPipeCoreSetupStage
,
15 DivPipeCoreCalculateStage
,
16 DivPipeCoreFinalStage
)
19 class DivCoreBaseStage(PipeModBase
):
20 def __init__(self
, pspec
, modname
, core_class
, *args
, **kwargs
):
21 super().__init
__(pspec
, modname
)
22 self
.core
= core_class(pspec
.core_config
, *args
, **kwargs
)
24 def elaborate(self
, platform
):
27 m
.d
.comb
+= self
.o
.eq_without_core(self
.i
)
29 m
.submodules
.core
= self
.core
31 m
.d
.comb
+= self
.core
.i
.eq(self
.i
.core
)
32 m
.d
.comb
+= self
.o
.core
.eq(self
.core
.o
)
37 class DivCoreSetupStage(DivCoreBaseStage
):
38 def __init__(self
, pspec
):
39 super().__init
__(pspec
, "core_setup_stage", DivPipeCoreSetupStage
)
42 return CoreInputData(self
.pspec
)
45 return CoreInterstageData(self
.pspec
)
48 class DivCoreCalculateStage(DivCoreBaseStage
):
49 def __init__(self
, pspec
, stage_index
):
50 super().__init
__(pspec
, f
"core_calculate_stage_{stage_index}",
51 DivPipeCoreCalculateStage
, stage_index
)
54 return CoreInterstageData(self
.pspec
)
57 return CoreInterstageData(self
.pspec
)
60 class DivCoreFinalStage(DivCoreBaseStage
):
61 def __init__(self
, pspec
):
62 super().__init
__(pspec
, "core_final_stage", DivPipeCoreFinalStage
)
65 return CoreInterstageData(self
.pspec
)
68 return CoreOutputData(self
.pspec
)