rewrite pcdec. pseudocode to work better for JPEG
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 30 Sep 2022 03:17:50 +0000 (20:17 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Fri, 30 Sep 2022 03:17:50 +0000 (20:17 -0700)
the pcdec. unittests aren't updated yet

openpower/isa/prefix_codes.mdwn
openpower/isatables/RM-1P-3S1D.csv
openpower/isatables/fields.text
openpower/isatables/minor_4.csv
src/openpower/decoder/power_decoder2.py
src/openpower/sv/trans/svp64.py
src/openpower/test/prefix_codes/prefix_codes_cases.py

index 11f5e62e944085eaeab8de323af256452315b6aa..1d11b15959a3a5aa1ff9455feb7be91a55d32c65 100644 (file)
@@ -2,31 +2,28 @@
 
 # [DRAFT] Prefix-code decode
 
-VA2-Form
+VA-Form
 
-* pcdec. RT,RA,RB,RC,once
+* pcdec. RT,RA,RB,RC
 
 Pseudo-code:
 
     tree[0:63] <- (RB)
+    mode <- tree[62:63]
+    tree[62:63] <- 0
     ra_used <- 0b0
     in_bits[0:63] <- (RC|0)
     if in_bits = 0 then
         in_bits[0:63] <- 1
-    final_in_bits <- in_bits
-    final_ra_used <- ra_used
-    output <- [0] * 64
-    out_byte <- 0
-    decoded[0:7] <- 1
-    so_bit <- 0b0
-    early_stop <- 0b0
-    do while out_byte < 8
+    orig_in_bits <- in_bits
+    tree_index <- 1
+    found <- 0b0
+    hit_end <- 0b0
+    do bit_length = 1 to 6
         in_bit <- in_bits[63]
         if in_bits = 1 then
             if ra_used | (_RA = 0) then
-                early_stop <- 0b1
-                if decoded != 1 then  # error: stopped in the middle of a code
-                    so_bit <- 0b1
+                hit_end <- 0b1
                 leave
             ra_used <- 0b1
             in_bit <- (RA)[63]
@@ -34,23 +31,45 @@ Pseudo-code:
         else
             in_bits <- 0b0 || in_bits[0:62]
         # walk the binary tree in `tree` from parent to the selected child
-        decoded <- decoded[1:7] || in_bit
-        if decoded <u 64 then
-            if tree[63 - decoded] then
-                final_in_bits <- in_bits
-                final_ra_used <- ra_used
-                output[56 - 8 * out_byte:63 - 8 * out_byte] <- decoded
-                decoded[0:7] <- 1
-                out_byte <- out_byte + 1
-                if once then
-                    leave
-        else
-            so_bit <- 0b1
-            early_stop <- 0b1
+        tree_index <- tree_index * 2
+        if in_bit = 1 then
+            tree_index <- tree_index + 1
+        if tree_index < 64 then
+            if tree[63 - tree_index] then
+                found <- 0b1
+                leave
+    compressed_index <- 0
+    do i = 0 to 127
+        if i = tree_index then
             leave
-    RT <- output
-    RS <- final_in_bits
-    CR0 <- final_ra_used || (output = 0) || early_stop || so_bit
+        else if i >= 64 then
+            compressed_index <- compressed_index + 1
+        else if tree[63 - i] = 1 then
+            compressed_index <- compressed_index + 1
+    switch(mode)
+        case(0):
+            RT[0:63] <- tree_index
+            if ¬found then
+                in_bits <- orig_in_bits
+                ra_used <- 0b0
+        case(1):
+            RT[0:63] <- tree_index
+            if hit_end then
+                in_bits <- orig_in_bits
+                ra_used <- 0b0
+        case(2):
+            RT[0:63] <- compressed_index
+            if ¬found then
+                in_bits <- orig_in_bits
+                ra_used <- 0b0
+                RT[0:63] <- tree_index
+        default:
+            RT[0:63] <- compressed_index
+            if hit_end then
+                in_bits <- orig_in_bits
+                ra_used <- 0b0
+    RS <- in_bits
+    CR0 <- ra_used || (tree_index >= 64) || found || hit_end
 
 Special Registers Altered:
 
index 6a2990c12a8fe034d225f2aba464c0fd2c303574..31105cf77abd86e7efbbd7e2c9ffd130a2e4f32a 100644 (file)
@@ -39,7 +39,6 @@ divmod2du,NORMAL,,1P,EXTRA2,NO,d:RT,s:RA,s:RB,s:RC,RA,RB,RC,RT,0,0,0
 absdacs,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RT,RA,RB,RT,RT,0,CR0,0
 absdacu,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RT,RA,RB,RT,RT,0,CR0,0
 pcdec,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RC,RA,RB,RC,RT,0,CR0,0
-pcdec,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RC,RA,RB,RC,RT,0,CR0,0
 ternlogi,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RT,RA,RB,RT,RT,0,CR0,0
 ffmsubs,NORMAL,,1P,EXTRA2,NO,d:FRT;d:CR1,s:FRA,s:FRB,s:FRC,FRA,FRB,FRC,FRT,0,CR1,0
 ffmadds,NORMAL,,1P,EXTRA2,NO,d:FRT;d:CR1,s:FRA,s:FRB,s:FRC,FRA,FRB,FRC,FRT,0,CR1,0
index fd584701509efffc7091bc8f900a74d71583c242..a90c29fc832e46ab38f700c3e2a61dbf7d3d9e5f 100644 (file)
 # 1.6.21.1 VA2-FORM
     |0      |6     |11     |16     |21  |24|26  |31  |
     | PO    |  RT  |   RA  |   RB  | RC    | XO | Rc |
-    | PO    |  RT  |   RA  |   RB  | RC    | XO |once|
 
 # 1.6.22 VC-FORM
     |0      |6     |11     |16     |21|22   |31|
         Field used by XO-form instructions to enable set-
         ting OV and SO in the XER.
         Formats: XO
-    once (31)
-        Once bit. Used by Prefix-code encode/decode instructions.
-        0    Decode/Encode multiple times per instruction.
-        1    Only Decode once per instruction
-        Formats: VA2
     PO (0:5)
         Primary opcode field.
         Formats: all
index d0f3f962197ec8c762dcf295e0653167e6851ae7..554b6b552fecbaa06800594e0a66a476741423f6 100644 (file)
@@ -7,4 +7,3 @@ opcode,unit,internal op,in1,in2,in3,out,CR in,CR out,inv A,inv out,cry in,cry ou
 51,ALU,OP_MADDLD,RA,RB,RC,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,maddld,VA,,,
 52,ALU,OP_DIVMOD2DU,RA,RB,RC,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,divmod2du,VA,,1,unofficial until submitted and approved/renumbered by the opf isa wg
 56,ALU,OP_PCDEC,RA,RB,RC,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,1,0,ONE,0,0,pcdec,VA2,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-57,ALU,OP_PCDEC,RA,RB,RC,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,1,0,ONE,0,0,pcdec,VA2,,1,unofficial until submitted and approved/renumbered by the opf isa wg
index b13e5b93dc16295b544c365a8c1830beb5066d18..4bafa456c1b3b96a3730a3cc7ff609c1a28cdc65 100644 (file)
@@ -1046,7 +1046,7 @@ class PowerDecodeSubset(Elaboratable):
             xo6 = Signal(6)
             comb += xo6.eq(self.dec.opcode_in[0:6])
             with m.If((major == 4) & xo6.matches(
-                    '11100-',  # pcdec
+                    '111000',  # pcdec
                     '110010',  # maddedu
                     '110100',  # divmod2du
                 )):
index e08c9775e2c1b89af5d4c6e4e4534ebc35b0f26e..283f8ba738a280cb9cabe23170efd695e438d1f9 100644 (file)
@@ -569,20 +569,19 @@ def fishmv(fields):
 )
 def pcdec(fields):
     # XXX WARNING THESE ARE NOT APPROVED BY OPF ISA WG
-    # 1.6.21.1 VA2-FORM
-    #    |0      |6     |11     |16     |21  |24|26  |31  |
-    #    | PO    |  RT  |   RA  |   RB  | RC    | XO |once|
+    # 1.6.21.1 VA-FORM
+    #    |0      |6     |11     |16     |21  |24|26  |
+    #    | PO    |  RT  |   RA  |   RB  | RC    | XO |
     PO = 4
-    XO = 0b11100
-    (RT, RA, RB, RC, once) = fields
+    XO = 0b111000
+    (RT, RA, RB, RC, PCDc) = fields
     return instruction(
         (PO, 0, 5),
         (RT, 6, 10),
         (RA, 11, 15),
         (RB, 16, 20),
         (RC, 21, 25),
-        (XO, 26, 30),
-        (once, 31, 31),
+        (XO, 26, 31),
     )
 
 
@@ -1733,7 +1732,7 @@ if __name__ == '__main__':
         'sv.ld 5.v, 4(1.v)',
         'sv.stw 5.v, 4(1.v)',
         'sv.bc/all 3,12,192',
-        'pcdec. 0,0,0,0,0',
+        'pcdec. 0,0,0,0',
     ]
     isa = SVP64Asm(lst, macros=macros)
     log("list:\n", "\n\t".join(list(isa)))
index 1e2212b6a76530d93dffcf531e8c285f389a51cd..8bdc0382028296f93f76011d2971dbfa1df33a91 100644 (file)
@@ -1,6 +1,6 @@
 import functools
 import itertools
-from openpower.test.common import TestAccumulatorBase
+from openpower.test.common import TestAccumulatorBase, skip_case
 from openpower.sv.trans.svp64 import SVP64Asm
 from openpower.test.state import ExpectedState
 from openpower.simulator.program import Program
@@ -58,6 +58,7 @@ def _cached_program(*instrs):
 
 
 class PrefixCodesCases(TestAccumulatorBase):
+    @skip_case("FIXME(programmerjake): update for new pcdec. pseudocode")
     def check_pcdec(self, supported_codes, input_bits, once, src_loc_at=0):
         # type: (set[str], str, bool, int) -> None
         original_input_bits = input_bits