fix scalar EXTRA2 in EXTRA2/3 decoding algorithms
[libreriscv.git] / openpower / sv / svp64 / appendix.mdwn
index 73426d430b51facb4d43d1c59bd51b9ad211d7d2..60c8962c7d7df9a0e5d2a37db4e2d6622e10ffec 100644 (file)
@@ -615,17 +615,22 @@ applies, **not** the `CR_bit` portion (bits 3-4):
 
 ```
     if extra3_mode:
-        spec = EXTRA3
+        is_vec = EXTRA3[0]
+        extra = EXTRA3[1:2]
     else:
-        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
+        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
     else:
-       # scalar constructs "00 spec[1:2] BA[0:4]"
-       return (spec[1:2] << 5) | BA
+        # scalar constructs "00 extra BA[0:4]"
+        return (extra << 5) | BA
 ```
 
 Thus, for example, to access a given bit for a CR in SV mode, the v3.0B
@@ -633,12 +638,12 @@ algorithm to determine CR\_reg is modified to as follows:
 
 ```
     CR_index = (BA>>2)      # top 3 bits 
-    if spec[0]:
+    if is_vec:
         # vector mode, 0-124 increments of 4
-        CR_index = (CR_index<<4) | (spec[1:2] << 2)
+        CR_index = (CR_index << 4) | (extra << 2)
     else:
         # scalar mode, 0-32 increments of 1
-        CR_index = (spec[1:2]<<3) | CR_index
+        CR_index = (extra << 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