class SVSHAPE(SelectableInt):
- def __init__(self, value):
+ def __init__(self, value, gpr=None):
SelectableInt.__init__(self, value, 32)
+ self.gpr = gpr # for Indexed mode
offs = 0
# set up sub-fields from Record layout
self.fsi = {}
log("SVSHAPE setup field", field, offs, end)
offs = end
+ def copy(self):
+ return SVSHAPE(self.value, self.gpr)
+
def is_indexed(self):
"REMAP Indexed Mode"
return self.mode == 0b00 and self.submode2 in [0b110, 0b111]
def offset(self, value):
self.fsi['offset'].eq(value)
+ def postprocess(self, idx, step):
+ if self.mode != 0b00 or not self.is_indexed():
+ return idx
+ if self.gpr is None:
+ return idx
+ if self.xdimsz == 1 and self.ydimsz == 1:
+ idx = step # no Index remapping
+ remap = self.gpr(self.svgpr+idx).value # TODO: elwidths
+ log ("indexed_iterator", self.svgpr, idx, remap)
+ return remap
+
def get_iterator(self):
- log ("SVSHAPE get_iterator", self.mode, self.ydimsz)
+ log ("SVSHAPE get_iterator", self.mode, self.ydimsz, self.is_indexed())
if self.mode == 0b00:
iterate_fn = iterate_indices
elif self.mode in [0b01, 0b11]:
elif self.ydimsz in [6, 14, 15]:
iterate_fn = iterate_dct_inner_halfswap_loadstore
# create a **NEW** iterator each time this is called
- return iterate_fn(deepcopy(self))
+ return iterate_fn(self.copy())
if __name__ == '__main__':
os.environ['SILENCELOG'] = "1"
- xdim = 2
- ydim = 3
+ xdim = 3
+ ydim = 2000
zdim = 1
SVSHAPE0 = SVSHAPE(0)
SVSHAPE0.lims = [xdim, ydim, zdim]
SVSHAPE0.mode = 0b00
SVSHAPE0.skip = 0b00
SVSHAPE0.offset = 0 # experiment with different offset, here
- SVSHAPE0.invxyz = [0,0,1] # inversion if desired
+ SVSHAPE0.invxyz = [0,0,1] # xy inversion (indices 0,1) , skip if desired (2)
- VL = xdim * ydim * zdim
+ VL = 6 # xdim * ydim * zdim
print ("Matrix Indexed Mode", SVSHAPE0.order, SVSHAPE0.invxyz)
for idx, new_idx in enumerate(SVSHAPE0.get_iterator()):
print ("")
-
xdim = 3
ydim = 2
zdim = 1