def __Assign__(self, val, *, src_loc_at=0):
# print ("partsig ass", self, val)
- return PAssign(self.m, self, val, self.partpoints)
+ return PAssign(self.m, self, val, self.ptype)
# TODO, http://bugs.libre-riscv.org/show_bug.cgi?id=458
#def __Switch__(self, cases, *, src_loc=None, src_loc_at=0,
class PartitionedAssign(Elaboratable):
- def __init__(self, shape, assign, mask):
+ def __init__(self, shape, assign, ctx):
"""Create a ``PartitionedAssign`` operator
"""
# work out the length (total of all PartitionedSignals)
self.assign = assign
- if isinstance(mask, dict):
- mask = list(mask.values())
- self.mask = mask
+ self.ptype = ctx
self.shape = shape
+ mask = ctx.get_mask()
self.output = PartitionedSignal(mask, self.shape, 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)
+ print ("ptype", self.ptype)
outpartsize = len(self.output) // self.mwidth
width, signed = self.output.shape()
print ("width, signed", width, signed)
- with m.Switch(Cat(self.mask)):
+ with m.Switch(self.ptype.get_switch()):
# for each partition possibility, create a Assign 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
m = Module()
mask = Signal(3)
a = PartitionedSignal(mask, 32)
- m.submodules.ass = ass = PartitionedAssign(signed(48), a, mask)
+ m.submodules.ass = ass = PartitionedAssign(signed(48), a, a.ptype)
omask = (1<<len(ass.output))-1
traces = ass.ports()
m = Module()
mask = Signal(3)
a = Signal(32)
- m.submodules.ass = ass = PartitionedAssign(signed(48), a, mask)
+ class PartType:
+ def __init__(self, mask):
+ self.mask = mask
+ def get_mask(self):
+ return mask
+ def get_switch(self):
+ return Cat(self.get_mask())
+ def get_cases(self):
+ return range(1<<len(self.get_mask()))
+ @property
+ def blanklanes(self):
+ return 0
+ ptype = PartType(mask)
+ m.submodules.ass = ass = PartitionedAssign(signed(48), a, ptype)
omask = (1<<len(ass.output))-1
traces = ass.ports()
modcount = 0 # global for now
-def PAssign(m, val, assign, mask):
+def PAssign(m, val, assign, ctx):
from ieee754.part_ass.assign import PartitionedAssign # recursion issue
global modcount
modcount += 1
- pc = PartitionedAssign(val.shape(), assign, mask)
+ pc = PartitionedAssign(val.shape(), assign, ctx)
setattr(m.submodules, "pass%d" % modcount, pc)
return val.lower().eq(pc.output.lower())