from nmigen import Signal, Const
-from nmutil.dynamicpipe import DynamicPipe, SimpleHandshakeRedir
+from nmutil.dynamicpipe import SimpleHandshakeRedir
import math
+
class CordicInitialData:
def __init__(self, pspec):
def eq(self, i):
return [self.z0.eq(i.z0)]
+
class CordicData:
def __init__(self, pspec):
# later be used to verify the operation of a pipelined version
# see http://bugs.libre-riscv.org/show_bug.cgi?id=208
-from nmigen import Module, Elaboratable, Signal, Memory, signed
+from nmigen import Module, Elaboratable, Signal, Memory
from nmigen.cli import rtlil
import math
from enum import Enum, unique
comb = m.d.comb
sync = m.d.sync
-
# Calculate initial amplitude?
An = 1.0
for i in range(self.iterations):
return [self.cos, self.sin, self.z0,
self.ready, self.start]
+
if __name__ == '__main__':
dut = CORDIC(8)
vl = rtlil.convert(dut, ports=dut.ports())
with open("cordic.il", "w") as f:
f.write(vl)
-
-from nmigen import Module, Signal, Cat, Mux
+from nmigen import Module, Signal
from nmutil.pipemodbase import PipeModBase
from ieee754.cordic.pipe_data import CordicData, CordicInitialData
import math
+
class CordicInitialStage(PipeModBase):
def __init__(self, pspec):
super().__init__(pspec, "cordicinit")
return m
-
class CordicStage(PipeModBase):
def __init__(self, pspec, stagenum):
super().__init__(pspec, "cordicstage%d" % stagenum)
from nmutil.singlepipe import ControlBase
-from nmutil.concurrentunit import ReservationStations, num_bits
from nmutil.pipemodbase import PipeModBaseChain
from ieee754.cordic.sin_cos_pipe_stage import (
CordicStage, CordicInitialStage)
-from ieee754.cordic.pipe_data import (CordicPipeSpec, CordicData,
- CordicInitialData)
+
class CordicPipeChain(PipeModBaseChain):
def __init__(self, pspec, stages):
def get_chain(self):
return self.stages
-
+
class CordicBasePipe(ControlBase):
def __init__(self, pspec):
self.cordicstages.append(stage)
self._eqs = self.connect(self.cordicstages)
-
+
def elaborate(self, platform):
m = ControlBase.elaborate(self, platform)
for i, stage in enumerate(self.cordicstages):
from nmigen import Module, Signal
-from nmigen.back.pysim import Simulator, Delay, Passive
+from nmigen.back.pysim import Simulator, Passive
from nmigen.test.utils import FHDLTestCase
from ieee754.cordic.sin_cos_pipeline import CordicBasePipe
except StopIteration:
break
-
sim.add_sync_process(writer_process)
sim.add_sync_process(reader_process)
with sim.write_vcd("pipeline.vcd", "pipeline.gtkw", traces=[
z, x, y]):
sim.run()
-
def test_rand(self):
fracbits = 16
M = (1 << fracbits)
self.run_test(iter(inputs), iter(outputs), fracbits=fracbits)
-
if __name__ == "__main__":
unittest.main()