1 # Finite State Machine version of the REMAP system. much more likely
2 # to end up being actually used in actual hardware
4 # up to three dimensions permitted
9 VL
= xdim
* ydim
* zdim
# set total (can repeat, e.g. VL=x*y*z*4)
11 lims
= [xdim
, ydim
, zdim
]
12 idxs
= [0,0,0] # starting indices
13 applydim
= [1, 1] # apply lower dims
14 order
= [1,0,2] # experiment with different permutations, here
15 offset
= 0 # experiment with different offsetet, here
16 invxyz
= [0,1,0] # inversion allowed
18 # pre-prepare the index state: run for "offset" times before
19 # actually starting. this algorithm can also be used for re-entrancy
20 # if exceptions occur and a REMAP has to be started from where the
22 for idx
in range(offset
):
24 idxs
[order
[i
]] = idxs
[order
[i
]] + 1
25 if (idxs
[order
[i
]] != lims
[order
[i
]]):
29 break_count
= 0 # for pretty-printing
36 ix
[i
] = lims
[i
] - 1 - ix
[i
]
39 new_idx
= new_idx
* ydim
+ ix
[1]
41 new_idx
= new_idx
* xdim
+ ix
[0]
42 print ("%d->%d" % (idx
, new_idx
)),
44 if break_count
== lims
[order
[0]]:
47 # this is the exact same thing as the pre-preparation stage
48 # above. step 1: count up to the limit of the current dimension
49 # step 2: if limit reached, zero it, and allow the *next* dimension
50 # to increment. repeat for 3 dimensions.
52 idxs
[order
[i
]] = idxs
[order
[i
]] + 1
53 if (idxs
[order
[i
]] != lims
[order
[i
]]):