convert test_caller_svp64.py to new vector numbering convention
[openpower-isa.git] / openpower / isa / simplev.mdwn
index a48c405ecce47435c9f0143de18043db87fe901e..f407851ee817ac8807cd55ad4130f19f81e0de17 100644 (file)
@@ -28,30 +28,30 @@ Pseudo-code:
 
     if (vf & (¬vs) & ¬(ms)) = 1 then
         step <- SVSTATE_NEXT(SVi, 0b0)
-        if _RT != 0b00000 then
+        if _RT != 0 then
            GPR(_RT) <- [0]*57 || step
     else
         VLimm <- SVi + 1
-        if vs = 1 then
-            if _RA != 0 then
-                VL <- (RA|0)[57:63]
-            else
-                VL <- VLimm[0:6]
-        else
-            VL <- SVSTATE[7:13]
-        if ms = 1 then
-            MVL <- VLimm[0:6]
-        else
-            MVL <- SVSTATE[0:6]
-        if VL > MVL then
-            VL = MVL
+        # set or get MVL
+        if ms = 1 then MVL <- VLimm[0:6]
+        else           MVL <- SVSTATE[0:6]
+        # set or get VL
+        if vs = 0                then VL <- SVSTATE[7:13]
+        else if _RA != 0         then VL <- (RA)[57:63]
+        else if _RT = 0          then VL <- VLimm[0:6]
+        else if CTR >u 0b1111111 then VL <- 0b1111111
+        else                          VL <- CTR[57:63]
+        # limit VL to within MVL
+        if VL >u MVL then
+            VL <- MVL
         SVSTATE[0:6] <- MVL
         SVSTATE[7:13] <- VL
-        if _RT != 0b00000 then
+        if _RT != 0 then
            GPR(_RT) <- [0]*57 || VL
-        # set requested Vertical-First mode, clear persist
-        SVSTATE[63] <- vf
-        SVSTATE[62] <- 0b0
+        if ((¬vs) & ¬(ms)) = 0 then
+            # set requested Vertical-First mode, clear persist
+            SVSTATE[63] <- vf
+            SVSTATE[62] <- 0b0
 
 Special Registers Altered:
 
@@ -84,7 +84,7 @@ Special Registers Altered:
 
 SVM-Form
 
-* svshape SVxd,SVyd,SVzd,SVRM,vf
+* svshape SVxd,SVyd,SVzd,SVrm,vf
 
 Pseudo-code:
 
@@ -108,7 +108,7 @@ Pseudo-code:
     SVSHAPE2[0:31] <- [0] * 32
     SVSHAPE3[0:31] <- [0] * 32
     # set schedule up for multiply
-    if (SVRM = 0b0000) then
+    if (SVrm = 0b0000) then
         # VL in Matrix Multiply is xd*yd*zd
         n <- (0b00 || SVxd) * (0b00 || SVyd) * (0b00 || SVzd)
         vlen[0:6] <- n[14:20]
@@ -128,7 +128,7 @@ Pseudo-code:
         SVSHAPE2[18:20] <- 0b001          # permute x,z,y
         SVSHAPE2[28:29] <- 0b11           # skip y
     # set schedule up for FFT butterfly
-    if (SVRM = 0b0001) then
+    if (SVrm = 0b0001) then
         # calculate O(N log2 N)
         n <- [0] * 3
         do while n < 5
@@ -148,10 +148,11 @@ Pseudo-code:
         SVSHAPE1[28:29] <- 0b01           # j+halfstep schedule
         # FRC (coefficients)
         SVSHAPE2[28:29] <- 0b10           # k schedule
-    # set schedule up for DCT Inner butterfly
-    # SVRM Mode 2 is for pre-calculated coefficients,
-    # SVRM Mode 4 is for on-the-fly (Vertical-First Mode)
-    if (SVRM = 0b0010) | (SVRM = 0b0100) then
+    # set schedule up for (i)DCT Inner butterfly
+    # SVrm Mode 2 (Mode 6 for iDCT) is for pre-calculated coefficients,
+    # SVrm Mode 4 (Mode 12 for iDCT) is for on-the-fly (Vertical-First Mode)
+    if ((SVrm = 0b0010) | (SVrm = 0b0100) |
+        (SVrm = 0b1010) | (SVrm = 0b1100)) then
         # calculate O(N log2 N)
         n <- [0] * 3
         do while n < 5
@@ -163,26 +164,30 @@ Pseudo-code:
         # set up template in SVSHAPE0, then copy to 1-3
         # set up FRB and FRS
         SVSHAPE0[0:5] <- (0b0 || SVxd)   # xdim
-        SVSHAPE0[30:31] <- 0b01          # DCT/FFT mode
-        if (SVRM = 0b0100) then
-            SVSHAPE0[6:11] <- 0b000011       # DCT Inner Butterfly mode 4
+        if (SVrm = 0b1010) | (SVrm = 0b1100) then
+            SVSHAPE0[30:31] <- 0b11          # iDCT mode
+            SVSHAPE0[18:20] <- 0b011         # iDCT Inner Butterfly sub-mode
+        else
+            SVSHAPE0[30:31] <- 0b01          # DCT mode
+            SVSHAPE0[18:20] <- 0b001         # DCT Inner Butterfly sub-mode
+            SVSHAPE0[21:23] <- 0b001         # "inverse" on outer loop
+        if (SVrm = 0b1100) | (SVrm = 0b0100) then
+            SVSHAPE0[6:11] <- 0b000011       # (i)DCT Inner Butterfly mode 4
         else
-            SVSHAPE0[6:11] <- 0b000001       # DCT Inner Butterfly mode 2
-        SVSHAPE0[18:20] <- 0b001         # DCT Inner Butterfly sub-mode
-        SVSHAPE0[21:23] <- 0b001         # "inverse" on outer loop
+            SVSHAPE0[6:11] <- 0b000001       # (i)DCT Inner Butterfly mode 2
         # copy
         SVSHAPE1[0:31] <- SVSHAPE0[0:31]
         SVSHAPE2[0:31] <- SVSHAPE0[0:31]
-        if (SVRM != 0b0100) then
+        if (SVrm != 0b0100) & (SVrm != 0b1100) then
             SVSHAPE3[0:31] <- SVSHAPE0[0:31]
         # for FRA and FRT
         SVSHAPE0[28:29] <- 0b01           # j+halfstep schedule
         # for cos coefficient
         SVSHAPE2[28:29] <- 0b10           # ci (k for mode 4) schedule
-        if (SVRM != 0b0100) then
+        if (SVrm != 0b0100) & (SVrm != 0b1100) then
             SVSHAPE3[28:29] <- 0b11           # size schedule
-    # set schedule up for DCT Outer butterfly
-    if (SVRM = 0b0011) then
+    # set schedule up for (i)DCT Outer butterfly
+    if (SVrm = 0b0011) | (SVrm = 0b1011) then
         # calculate O(N log2 N) number of outer butterfly overlapping adds
         vlen[0:6] <- [0] * 7
         n <- 0b000
@@ -200,16 +205,21 @@ Pseudo-code:
         # set up template in SVSHAPE0, then copy to 1-3
         # set up FRB and FRS
         SVSHAPE0[0:5] <- (0b0 || SVxd)   # xdim
-        SVSHAPE0[30:31] <- 0b01          # DCT/FFT mode
+        if (SVrm = 0b1011) then
+            SVSHAPE0[30:31] <- 0b11      # iDCT mode
+            SVSHAPE0[18:20] <- 0b011     # iDCT Outer Butterfly sub-mode
+            SVSHAPE0[21:23] <- 0b101     # "inverse" on outer and inner loop
+        else
+            SVSHAPE0[30:31] <- 0b01      # DCT mode
+            SVSHAPE0[18:20] <- 0b100     # DCT Outer Butterfly sub-mode
         SVSHAPE0[6:11] <- 0b000010       # DCT Butterfly mode
-        SVSHAPE0[18:20] <- 0b100         # DCT Outer Butterfly sub-mode
         # copy
         SVSHAPE1[0:31] <- SVSHAPE0[0:31]
         SVSHAPE2[0:31] <- SVSHAPE0[0:31]
         # for FRA and FRT
         SVSHAPE1[28:29] <- 0b01           # j+halfstep schedule
     # set schedule up for DCT COS table generation
-    if (SVRM = 0b0101) then
+    if (SVrm = 0b0101) | (SVrm = 0b1101) then
         # calculate O(N log2 N)
         vlen[0:6] <- [0] * 7
         itercount[0:6] <- (0b00 || SVxd) + 0b0000001
@@ -226,19 +236,25 @@ Pseudo-code:
         SVSHAPE0[0:5] <- (0b0 || SVxd)   # xdim
         SVSHAPE0[30:31] <- 0b01          # DCT/FFT mode
         SVSHAPE0[6:11] <- 0b000100       # DCT Inner Butterfly COS-gen mode
-        SVSHAPE0[21:23] <- 0b001         # "inverse" on outer loop
+        if (SVrm = 0b0101) then
+            SVSHAPE0[21:23] <- 0b001     # "inverse" on outer loop for DCT
         # copy
         SVSHAPE1[0:31] <- SVSHAPE0[0:31]
         SVSHAPE2[0:31] <- SVSHAPE0[0:31]
         # for cos coefficient
         SVSHAPE1[28:29] <- 0b10           # ci schedule
         SVSHAPE2[28:29] <- 0b11           # size schedule
-    # set schedule up for DCT inverse of half-swapped ordering
-    if (SVRM = 0b0110) then
+    # set schedule up for iDCT / DCT inverse of half-swapped ordering
+    if (SVrm = 0b0110) | (SVrm = 0b1110) | (SVrm = 0b1111) then
         vlen[0:6] <- (0b00 || SVxd) + 0b0000001
         # set up template in SVSHAPE0
         SVSHAPE0[0:5] <- (0b0 || SVxd)   # xdim
-        SVSHAPE0[30:31] <- 0b01          # DCT/FFT mode
+        if (SVrm = 0b1110) then
+            SVSHAPE0[18:20] <- 0b001     # DCT opposite half-swap
+        if (SVrm = 0b1111) then
+            SVSHAPE0[30:31] <- 0b01          # FFT mode
+        else
+            SVSHAPE0[30:31] <- 0b11          # DCT mode
         SVSHAPE0[6:11] <- 0b000101       # DCT "half-swap" mode
     # set VL, MVL and Vertical-First
     SVSTATE[0:6] <- vlen