1 from nmutil
.singlepipe
import ControlBase
2 from nmutil
.pipemodbase
import PipeModBaseChain
4 from ieee754
.fpcommon
.denorm
import FPAddDeNormMod
5 from ieee754
.cordic
.fp_pipe_init_stages
import (FPCordicInitStage
,
7 from ieee754
.cordic
.sin_cos_pipe_stage
import (CordicStage
,
11 class CordicPipeChain(PipeModBaseChain
):
12 def __init__(self
, pspec
, stages
):
14 super().__init
__(pspec
)
20 class FPCordicBasePipe(ControlBase
):
21 def __init__(self
, pspec
):
22 ControlBase
.__init
__(self
)
25 self
.denorm
= CordicPipeChain(pspec
,
26 [FPCordicInitStage(self
.pspec
),
27 FPAddDeNormMod(self
.pspec
, False),
28 FPCordicConvertFixed(self
.pspec
)])
30 self
.cordicstages
= []
32 initstage
= CordicInitialStage(pspec
)
34 for i
in range(pspec
.iterations
):
35 stages
.append(CordicStage(pspec
, i
))
36 chunks
= self
.chunkify(initstage
, stages
)
38 chain
= CordicPipeChain(pspec
, chunk
)
39 self
.cordicstages
.append(chain
)
41 self
._eqs
= self
.connect([self
.denorm
] + self
.cordicstages
)
43 def chunkify(self
, initstage
, stages
):
46 for i
in range(0, len(stages
), self
.pspec
.rounds_per_stage
):
47 chunks
.append(stages
[i
:i
+ self
.pspec
.rounds_per_stage
])
48 chunks
[0].insert(0, initstage
)
52 def elaborate(self
, platform
):
53 m
= ControlBase
.elaborate(self
, platform
)
54 m
.submodules
.denorm
= self
.denorm
55 for i
, stage
in enumerate(self
.cordicstages
):
56 setattr(m
.submodules
, "cordic%d" % i
,