from nmigen.cli import rtlil
-from test_partsig import TestAddMod2
+from test_partsig import TestAddMod2, TestLS
import subprocess
import os
from nmigen import Signal
def test():
width = 16
pmask = Signal(3) # divide into 4-bits
- module = TestAddMod2(width, pmask)
- sim = create_ilang(module,
- [pmask,
- module.a.sig,
- module.b.sig,
- module.add_output,
- module.ls_output,
- module.sub_output,
- module.carry_in,
- module.add_carry_out,
- module.sub_carry_out,
- module.neg_output,
- ],
+ #module = TestAddMod2(width, pmask)
+ module = TestLS(width, pmask)
+ sim = create_ilang(module, [pmask] + module.ports(),
"part_sig_add")
def create_ilang(dut, ports, test_name):
from ieee754.part_mux.part_mux import PMux
+# XXX this is for coriolis2 experimentation
+class TestLS(Elaboratable):
+ def __init__(self, width, partpoints):
+ self.partpoints = partpoints
+ self.a = PartitionedSignal(partpoints, width, name="a")
+ self.b = PartitionedSignal(partpoints, width, name="b")
+ self.ls_output = Signal(width) # left shift
+ self.dummy_output = Signal(width) # left shift
+
+ def elaborate(self, platform):
+ m = Module()
+ comb = m.d.comb
+ sync = m.d.sync
+ self.a.set_module(m)
+ self.b.set_module(m)
+ # left shift
+ sync += self.dummy_output.eq(self.b.sig) # stops sigs being ignored
+ sync += self.ls_output.eq(self.a << self.b)
+ ppts = self.partpoints
+
+ return m
+
+ def ports(self):
+ return [self.a.sig, self.b.sig,
+ self.ls_output,
+ self.dummy_output]
+
+
# XXX this is for coriolis2 experimentation
class TestAddMod2(Elaboratable):
def __init__(self, width, partpoints):
self.partpoints = partpoints
- self.a = PartitionedSignal(partpoints, width)
- self.b = PartitionedSignal(partpoints, width)
+ self.a = PartitionedSignal(partpoints, width, name="a")
+ self.b = PartitionedSignal(partpoints, width, name="b")
self.add_output = Signal(width)
self.ls_output = Signal(width) # left shift
self.sub_output = Signal(width)
return m
+ def ports(self):
+ return [self.a.sig, self.b.sig,
+ self.add_output,
+ self.ls_output,
+ self.sub_output,
+ self.carry_in,
+ self.add_carry_out,
+ self.sub_carry_out,
+ self.neg_output]
+