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
,
9 from ieee754
.cordic
.renormalize
import CordicRenormalize
12 class CordicPipeChain(PipeModBaseChain
):
13 def __init__(self
, pspec
, stages
):
15 super().__init
__(pspec
)
21 class FPCordicBasePipe(ControlBase
):
22 def __init__(self
, pspec
):
23 ControlBase
.__init
__(self
)
26 self
.denorm
= CordicPipeChain(pspec
,
27 [FPCordicInitStage(self
.pspec
),
28 FPAddDeNormMod(self
.pspec
, False),
29 FPCordicConvertFixed(self
.pspec
)])
31 self
.cordicstages
= []
33 initstage
= CordicInitialStage(pspec
)
34 finalstage
= CordicRenormalize(pspec
)
36 for i
in range(pspec
.iterations
):
37 stages
.append(CordicStage(pspec
, i
))
38 chunks
= self
.chunkify(initstage
, stages
)
39 chunks
[-1].append(finalstage
)
41 chain
= CordicPipeChain(pspec
, chunk
)
42 self
.cordicstages
.append(chain
)
44 self
._eqs
= self
.connect([self
.denorm
] + self
.cordicstages
)
46 def chunkify(self
, initstage
, stages
):
49 for i
in range(0, len(stages
), self
.pspec
.rounds_per_stage
):
50 chunks
.append(stages
[i
:i
+ self
.pspec
.rounds_per_stage
])
51 chunks
[0].insert(0, initstage
)
55 def elaborate(self
, platform
):
56 m
= ControlBase
.elaborate(self
, platform
)
57 m
.submodules
.denorm
= self
.denorm
58 for i
, stage
in enumerate(self
.cordicstages
):
59 setattr(m
.submodules
, "cordic%d" % i
,