Begin adding floating point cordic pipeline
[ieee754fpu.git] / src / ieee754 / cordic / fp_pipeline.py
1 from nmutil.singlepipe import ControlBase
2 from nmutil.pipemodbase import PipeModBaseChain
3
4 from ieee754.fpcommon.denorm import FPAddDeNormMod
5 from ieee754.cordic.fp_pipe_init_stages import (FPCordicInitStage)
6
7
8 class CordicPipeChain(PipeModBaseChain):
9 def __init__(self, pspec, stages):
10 self.stages = stages
11 super().__init__(pspec)
12
13 def get_chain(self):
14 return self.stages
15
16
17 class FPCordicBasePipe(ControlBase):
18 def __init__(self, pspec):
19 ControlBase.__init__(self)
20 self.pspec = pspec
21
22 self.denorm = CordicPipeChain(pspec,
23 [FPCordicInitStage(self.pspec),
24 FPAddDeNormMod(self.pspec, False)])
25
26 self._eqs = self.connect([self.denorm])
27
28 def chunkify(self, initstage, stages):
29 chunks = []
30
31 for i in range(0, len(stages), self.pspec.rounds_per_stage):
32 chunks.append(stages[i:i + self.pspec.rounds_per_stage])
33 chunks[0].insert(0, initstage)
34
35 return chunks
36
37 def elaborate(self, platform):
38 m = ControlBase.elaborate(self, platform)
39 m.submodules.denorm = self.denorm
40 m.d.comb += self._eqs
41 return m