assert isinstance(sig, PartitionedSignal), \
"All PartitionedSignal.__Cat__ arguments must be " \
"a PartitionedSignal. %s is not." % repr(sig)
- return PCat(self.m, args, self.partpoints)
+ return PCat(self.m, args, self.ptype)
def __Mux__(self, val1, val2):
# print ("partsig mux", self, val1, val2)
class PartitionedCat(Elaboratable):
- def __init__(self, catlist, mask):
+ def __init__(self, catlist, ctx):
"""Create a ``PartitionedCat`` operator
"""
# work out the length (total of all PartitionedSignals)
self.catlist = catlist
- if isinstance(mask, dict):
- mask = list(mask.values())
- self.mask = mask
+ self.ptype = ctx
width = 0
for p in catlist:
width += len(p.sig)
self.width = width
+ mask = ctx.get_mask()
self.output = PartitionedSignal(mask, self.width, reset_less=True)
self.partition_points = self.output.partpoints
self.mwidth = len(self.partition_points)+1
keys = list(self.partition_points.keys())
print ("keys", keys, "values", self.partition_points.values())
- print ("mask", self.mask)
- with m.Switch(Cat(self.mask)):
+ print ("ptype", self.ptype)
+ with m.Switch(self.ptype.get_switch()):
# for each partition possibility, create a Cat sequence
- for pbit in range(1<<len(keys)):
+ for pbit in self.ptype.get_cases():
# set up some indices pointing to where things have got
# then when called below in the inner nested loop they give
# the relevant sequential chunk
a = PartitionedSignal(mask, 32)
b = PartitionedSignal(mask, 16)
catlist = [a, b]
- m.submodules.cat = cat = PartitionedCat(catlist, mask)
+ m.submodules.cat = cat = PartitionedCat(catlist, a.ptype)
traces = cat.ports()
sim = create_simulator(m, traces, "partcat")
modcount = 0 # global for now
-def PCat(m, arglist, mask):
+def PCat(m, arglist, ctx):
from ieee754.part_cat.cat import PartitionedCat # avoid recursive import
global modcount
modcount += 1
- pc = PartitionedCat(arglist, mask)
+ pc = PartitionedCat(arglist, ctx)
setattr(m.submodules, "pcat%d" % modcount, pc)
return pc.output