a147b068d5c2099145e00d54c1beb3056d0ab50b
1 """IEEE754 Floating Point pipelined Divider
3 Relevant bugreport: http://bugs.libre-riscv.org/show_bug.cgi?id=99
7 from nmutil
.pipemodbase
import FPModBaseChain
8 from ieee754
.div_rem_sqrt_rsqrt
.div_pipe
import (DivPipeInterstageData
,
10 DivPipeCalculateStage
,
13 from ieee754
.fpdiv
.div0
import FPDivStage0Mod
14 from ieee754
.fpdiv
.div2
import FPDivStage2Mod
17 class FPDivStagesSetup(FPModBaseChain
):
19 def __init__(self
, pspec
, n_stages
, stage_offs
):
20 self
.n_stages
= n_stages
# number of combinatorial stages
21 self
.stage_offs
= stage_offs
# each CalcStage needs *absolute* idx
22 super().__init
__(pspec
)
27 note: this is a pure *combinatorial* module (StageChain).
28 therefore each sub-module must also be combinatorial
33 # Converts from FPSCData into DivPipeInputData
34 divstages
.append(FPDivStage0Mod(self
.pspec
))
36 # does 1 "convert" (actual processing) from DivPipeInputData
37 # into "intermediate" output (DivPipeInterstageData)
38 divstages
.append(DivPipeSetupStage(self
.pspec
))
40 # here is where the intermediary stages are added.
41 # n_stages is adjusted (by pipeline.py), reduced to take
42 # into account extra processing that FPDivStage0Mod and DivPipeSetup
44 for count
in range(self
.n_stages
): # number of combinatorial stages
45 idx
= count
+ self
.stage_offs
46 divstages
.append(DivPipeCalculateStage(self
.pspec
, idx
))
51 class FPDivStagesIntermediate(FPModBaseChain
):
53 def __init__(self
, pspec
, n_stages
, stage_offs
):
54 self
.n_stages
= n_stages
# number of combinatorial stages
55 self
.stage_offs
= stage_offs
# each CalcStage needs *absolute* idx
56 super().__init
__(pspec
)
61 note: this is a pure *combinatorial* module (StageChain).
62 therefore each sub-module must also be combinatorial
67 # here is where the intermediary stages are added.
68 # n_stages is adjusted (in pipeline.py), reduced to take
69 # into account the extra processing that self.begin and self.end
71 for count
in range(self
.n_stages
): # number of combinatorial stages
72 idx
= count
+ self
.stage_offs
73 divstages
.append(DivPipeCalculateStage(self
.pspec
, idx
))
78 class FPDivStagesFinal(FPModBaseChain
):
80 def __init__(self
, pspec
, n_stages
, stage_offs
):
81 self
.n_stages
= n_stages
# number of combinatorial stages
82 self
.stage_offs
= stage_offs
# each CalcStage needs *absolute* idx
83 super().__init
__(pspec
)
88 note: this is a pure *combinatorial* module (StageChain).
89 therefore each sub-module must also be combinatorial
92 # takes the DIV pipeline/chain data and munges it
93 # into the format that the normalisation can accept.
97 # here is where the intermediary stages are added.
98 # n_stages is adjusted (in pipeline.py), reduced to take
99 # into account the extra processing that self.begin and self.end
101 for count
in range(self
.n_stages
): # number of combinatorial stages
102 idx
= count
+ self
.stage_offs
103 divstages
.append(DivPipeCalculateStage(self
.pspec
, idx
))
105 # does the final conversion from intermediary to output data
106 divstages
.append(DivPipeFinalStage(self
.pspec
))
108 # does conversion from DivPipeOutputData into
109 # FPAddStage1Data format (bad name, TODO, doesn't matter),
110 # so that post-normalisation and corrections can take over
111 divstages
.append(FPDivStage2Mod(self
.pspec
))