1 """IEEE754 Floating Point pipelined Divider
3 This module simply constructs register-based pipeline(s) out of
4 appropriate combinatorial blocks: setup, intermediary and final
5 single-clock pipelines.
7 "actual" processing is carried out by the DivPipeCalculateStage
8 combinatorial block: everything else is chaining and pre- and post-
11 there's no "actual" work done here: it's just a "joining-together" job.
12 see pipeline.py for an ASCII diagram showing how everything fits together
14 Relevant bugreport: http://bugs.libre-riscv.org/show_bug.cgi?id=99
18 from nmutil
.pipemodbase
import PipeModBaseChain
19 from ieee754
.div_rem_sqrt_rsqrt
.div_pipe
import (DivPipeInterstageData
,
21 DivPipeCalculateStage
,
24 from ieee754
.fpdiv
.div0
import FPDivPreFPAdjust
25 from ieee754
.fpdiv
.div2
import FPDivPostToFPFormat
28 class FPDivStagesSetup(PipeModBaseChain
):
30 def __init__(self
, pspec
, n_stages
, stage_offs
):
31 self
.n_stages
= n_stages
# number of combinatorial stages
32 self
.stage_offs
= stage_offs
# each CalcStage needs *absolute* idx
33 super().__init
__(pspec
)
38 note: this is a pure *combinatorial* module (StageChain).
39 therefore each sub-module must also be combinatorial
42 # chain to be returned
45 # Converts from FPSCData into DivPipeInputData
46 divstages
.append(FPDivPreFPAdjust(self
.pspec
))
48 # does 1 "convert" (actual processing) from DivPipeInputData
49 # into "intermediate" output (DivPipeInterstageData)
50 divstages
.append(DivPipeSetupStage(self
.pspec
))
52 # here is where the intermediary stages are added.
53 for count
in range(self
.n_stages
): # number of combinatorial stages
54 idx
= count
+ self
.stage_offs
55 divstages
.append(DivPipeCalculateStage(self
.pspec
, idx
))
60 class FPDivStagesIntermediate(PipeModBaseChain
):
62 def __init__(self
, pspec
, n_stages
, stage_offs
):
63 self
.n_stages
= n_stages
# number of combinatorial stages
64 self
.stage_offs
= stage_offs
# each CalcStage needs *absolute* idx
65 super().__init
__(pspec
)
70 note: this is a pure *combinatorial* module (StageChain).
71 therefore each sub-module must also be combinatorial
74 # chain to be returned
77 # here is where the intermediary stages are added.
78 for count
in range(self
.n_stages
): # number of combinatorial stages
79 idx
= count
+ self
.stage_offs
80 divstages
.append(DivPipeCalculateStage(self
.pspec
, idx
))
85 class FPDivStagesFinal(PipeModBaseChain
):
87 def __init__(self
, pspec
, n_stages
, stage_offs
):
88 self
.n_stages
= n_stages
# number of combinatorial stages
89 self
.stage_offs
= stage_offs
# each CalcStage needs *absolute* idx
90 super().__init
__(pspec
)
95 note: this is a pure *combinatorial* module (StageChain).
96 therefore each sub-module must also be combinatorial
99 # chain to be returned
102 # here is where the last intermediary stages are added.
103 for count
in range(self
.n_stages
): # number of combinatorial stages
104 idx
= count
+ self
.stage_offs
105 divstages
.append(DivPipeCalculateStage(self
.pspec
, idx
))
107 # does the final conversion from intermediary to output data
108 divstages
.append(DivPipeFinalStage(self
.pspec
))
110 # does conversion from DivPipeOutputData into FPPostCalcData format
111 # so that post-normalisation and corrections can take over
112 divstages
.append(FPDivPostToFPFormat(self
.pspec
))