```
if extra3_mode:
- if EXTRA3[0]: # vector
- return (RA << 2) | EXTRA3[1:2]
- else: # scalar
- return (EXTRA3[1:2] << 5) | RA
- else: # EXTRA2 mode
- if EXTRA2[0]: # vector
- return (RA << 2) | (EXTRA2[1] << 1)
- else:
- return (EXTRA2[1] << 5) | RA
+ spec = EXTRA3
+ else:
+ spec = EXTRA2 << 1 # same as EXTRA3, shifted
+ if spec[0]: # vector
+ return (RA << 2) | spec[1:2]
+ else: # scalar
+ return (spec[1:2] << 5) | RA
```
Future versions may extend to 256 by shifting Vector numbering up.
```
if extra3_mode:
- is_vec = EXTRA3[0]
- extra = EXTRA3[1:2]
+ spec = EXTRA3
else:
- is_vec = EXTRA2[0]
- if is_vec:
- extra = EXTRA2[1] << 1
- else:
- extra = EXTRA2[1]
- if is_vec:
- # vector constructs "BA[0:2] extra 00 BA[3:4]"
- return ((BA >> 2) << 6) | # hi 3 bits shifted up
- (extra << 4) | # to make room for these
- (BA & 0b11) # CR_bit on the end
+ spec = EXTRA2<<1 | 0b0
+ if spec[0]:
+ # vector constructs "BA[0:2] spec[1:2] 00 BA[3:4]"
+ return ((BA >> 2)<<6) | # hi 3 bits shifted up
+ (spec[1:2]<<4) | # to make room for these
+ (BA & 0b11) # CR_bit on the end
else:
- # scalar constructs "00 extra BA[0:4]"
- return (extra << 5) | BA
+ # scalar constructs "00 spec[1:2] BA[0:4]"
+ return (spec[1:2] << 5) | BA
```
Thus, for example, to access a given bit for a CR in SV mode, the v3.0B
```
CR_index = (BA>>2) # top 3 bits
- if is_vec:
+ if spec[0]:
# vector mode, 0-124 increments of 4
- CR_index = (CR_index << 4) | (extra << 2)
+ CR_index = (CR_index<<4) | (spec[1:2] << 2)
else:
# scalar mode, 0-32 increments of 1
- CR_index = (extra << 3) | CR_index
+ CR_index = (spec[1:2]<<3) | CR_index
# same as for v3.0/v3.1 from this point onwards
bit_index = (BA & 0b11) # low 2 bits
CR_reg = CR{CR_index} # get the CR