1 from nmutil
.singlepipe
import ControlBase
2 from nmutil
.pipemodbase
import PipeModBaseChain
4 from ieee754
.cordic
.sin_cos_pipe_stage
import (
5 CordicStage
, CordicInitialStage
)
8 class CordicPipeChain(PipeModBaseChain
):
9 def __init__(self
, pspec
, stages
):
11 super().__init
__(pspec
)
17 class CordicBasePipe(ControlBase
):
18 def __init__(self
, pspec
):
19 ControlBase
.__init
__(self
)
21 self
.cordicstages
= []
22 initstage
= CordicInitialStage(pspec
)
24 for i
in range(pspec
.iterations
):
25 stages
.append(CordicStage(pspec
, i
))
26 chunks
= self
.chunkify(initstage
, stages
)
29 chain
= CordicPipeChain(pspec
, chunk
)
30 self
.cordicstages
.append(chain
)
32 self
._eqs
= self
.connect(self
.cordicstages
)
34 def chunkify(self
, initstage
, stages
):
37 for i
in range(0, len(stages
), self
.pspec
.rounds_per_stage
):
38 chunks
.append(stages
[i
:i
+ self
.pspec
.rounds_per_stage
])
39 chunks
[0].insert(0, initstage
)
43 def elaborate(self
, platform
):
44 m
= ControlBase
.elaborate(self
, platform
)
45 for i
, stage
in enumerate(self
.cordicstages
):
46 setattr(m
.submodules
, "cordic%d" % i
,