assert len(val1) == len(val2), \
"PartitionedSignal width sources must be the same " \
"val1 == %d, val2 == %d" % (len(val1), len(val2))
- return PMux(self.m, self.partpoints, self, val1, val2)
+ return PMux(self.m, self.partpoints, self, val1, val2, self.ptype)
def __Assign__(self, val, *, src_loc_at=0):
# print ("partsig ass", self, val)
self.le_output = Signal(len(partpoints)+1)
self.mux_sel2 = Signal(len(partpoints)+1)
self.mux_sel2 = PartitionedSignal(partpoints, len(partpoints))
- self.mux_out = Signal(width)
self.mux2_out = Signal(width)
self.carry_in = Signal(len(partpoints)+1)
self.add_carry_out = Signal(len(partpoints)+1)
sync += self.ls_output.eq(self.a << self.b)
sync += self.rs_output.eq(self.a >> self.b)
ppts = self.partpoints
- sync += self.mux_out.eq(PMux(m, ppts, self.mux_sel, self.a, self.b))
sync += self.mux_out2.eq(Mux(self.mux_sel2, self.a, self.b))
# scalar left shift
comb += self.bsig.eq(self.b.lower())
self.b = PartitionedSignal(partpoints, width)
self.mux_sel = Signal(len(partpoints)+1)
self.mux_sel2 = PartitionedSignal(partpoints, len(partpoints)+1)
- self.mux_out = Signal(width)
self.mux_out2 = Signal(width)
def elaborate(self, platform):
self.mux_sel2.set_module(m)
ppts = self.partpoints
- comb += self.mux_out.eq(PMux(m, ppts, self.mux_sel, self.a, self.b))
comb += self.mux_out2.eq(Mux(self.mux_sel2, self.a, self.b))
return m
traces = [part_mask,
module.a.sig,
module.b.sig,
- module.mux_out,
module.mux_out2]
sim = create_simulator(module, traces, test_name)
else:
y |= (b & mask)
# check the result
- outval = (yield module.mux_out)
outval2 = (yield module.mux_out2)
msg = f"{msg_prefix}: mux " + \
f"0x{sel:X} ? 0x{a:X} : 0x{b:X}" + \
modcount = 0 # global for now
-def PMux(m, mask, sel, a, b):
+def PMux(m, mask, sel, a, b, ctx):
global modcount
modcount += 1
width = len(a.sig) # get width
part_pts = make_partition2(mask, width) # create partition points
- pm = PartitionedMux(width, part_pts)
+ pm = PartitionedMux(width, part_pts, ctx)
m.d.comb += pm.a.eq(a.sig)
m.d.comb += pm.b.eq(b.sig)
m.d.comb += pm.sel.eq(sel)
consequently the incoming selector (sel) can completely
ignore what the *actual* partition bits are.
"""
- def __init__(self, width, partition_points):
+ def __init__(self, width, partition_points, ctx):
self.width = width
+ self.ctx = ctx
self.partition_points = PartitionPoints(partition_points)
self.mwidth = len(self.partition_points)+1
self.a = Signal(width, reset_less=True)