From: Luke Kenneth Casson Leighton Date: Sat, 9 Oct 2021 16:26:32 +0000 (+0100) Subject: covert PartitionedCat (and PCat) over to PartType format X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4bbf1d04380bd2f15f8fc4cfb7537b9144a23f81;p=ieee754fpu.git covert PartitionedCat (and PCat) over to PartType format https://bugs.libre-soc.org/show_bug.cgi?id=713#c56 --- diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index d02dac4a..78658826 100644 --- a/src/ieee754/part/partsig.py +++ b/src/ieee754/part/partsig.py @@ -119,7 +119,7 @@ class PartitionedSignal(UserValue): 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) diff --git a/src/ieee754/part_cat/cat.py b/src/ieee754/part_cat/cat.py index 27abb19a..8fcf8bcf 100644 --- a/src/ieee754/part_cat/cat.py +++ b/src/ieee754/part_cat/cat.py @@ -59,18 +59,17 @@ def get_runlengths(pbit, size): 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 @@ -94,10 +93,10 @@ class PartitionedCat(Elaboratable): 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<