class CordicPipeSpec:
- def __init__(self, fracbits):
+ def __init__(self, fracbits, rounds_per_stage):
self.fracbits = fracbits
+ # Number of cordic operations per pipeline stage
+ self.rounds_per_stage = rounds_per_stage
self.M = (1 << fracbits)
self.ZMAX = int(round(self.M * math.pi/2))
zm = Const(-self.ZMAX)
class CordicBasePipe(ControlBase):
def __init__(self, pspec):
ControlBase.__init__(self)
+ self.pspec = pspec
self.cordicstages = []
+ initstage = CordicInitialStage(pspec)
+ stages = []
for i in range(pspec.iterations):
- if i == 0:
- stages = [CordicInitialStage(pspec), CordicStage(pspec, i)]
- else:
- stages = [CordicStage(pspec, i)]
- stage = CordicPipeChain(pspec, stages)
- self.cordicstages.append(stage)
+ stages.append(CordicStage(pspec, i))
+ chunks = self.chunkify(initstage, stages)
+ print(len(chunks))
+ for chunk in chunks:
+ chain = CordicPipeChain(pspec, chunk)
+ self.cordicstages.append(chain)
self._eqs = self.connect(self.cordicstages)
+ def chunkify(self, initstage, stages):
+ chunks = []
+
+ for i in range(0, len(stages), self.pspec.rounds_per_stage):
+ chunks.append(stages[i:i + self.pspec.rounds_per_stage])
+ chunks[0].insert(0, initstage)
+
+ return chunks
+
def elaborate(self, platform):
m = ControlBase.elaborate(self, platform)
for i, stage in enumerate(self.cordicstages):
class SinCosTestCase(FHDLTestCase):
def run_test(self, inputs, outputs, fracbits=8):
m = Module()
- pspec = CordicPipeSpec(fracbits=fracbits)
+ pspec = CordicPipeSpec(fracbits=fracbits, rounds_per_stage=4)
m.submodules.dut = dut = CordicBasePipe(pspec)
z = Signal(dut.p.data_i.z0.shape())