run tests in parallel
[ieee754fpu.git] / src / ieee754 / cordic / sin_cos_pipeline.py
1 from nmutil.singlepipe import ControlBase
2 from nmutil.pipemodbase import PipeModBaseChain
3
4 from ieee754.cordic.sin_cos_pipe_stage import (
5 CordicStage, CordicInitialStage)
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 CordicBasePipe(ControlBase):
18 def __init__(self, pspec):
19 ControlBase.__init__(self)
20 self.pspec = pspec
21 self.cordicstages = []
22 initstage = CordicInitialStage(pspec)
23 stages = []
24 for i in range(pspec.iterations):
25 stages.append(CordicStage(pspec, i))
26 chunks = self.chunkify(initstage, stages)
27 print(len(chunks))
28 for chunk in chunks:
29 chain = CordicPipeChain(pspec, chunk)
30 self.cordicstages.append(chain)
31
32 self._eqs = self.connect(self.cordicstages)
33
34 def chunkify(self, initstage, stages):
35 chunks = []
36
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)
40
41 return chunks
42
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,
47 stage)
48 m.d.comb += self._eqs
49 return m