add svp64 saturation decoding
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 23 Jan 2021 20:50:30 +0000 (20:50 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 23 Jan 2021 20:50:30 +0000 (20:50 +0000)
src/soc/sv/trans/svp64.py

index 3ad6a5f2b7fd7cd9a7a0cd6ad95badce8bff920a..c668114bf1b985491d30915c806c075249df54b3 100644 (file)
@@ -476,7 +476,7 @@ class SVP64:
 
             # "normal" mode
             if sv_mode is None:
 
             # "normal" mode
             if sv_mode is None:
-                mode |= (src_zero << 3) | (dst_zero << 4)
+                mode |= (src_zero << 3) | (dst_zero << 4) # predicate zeroing
 
             # "mapreduce" modes
             elif sv_mode == 0b00:
 
             # "mapreduce" modes
             elif sv_mode == 0b00:
@@ -507,8 +507,15 @@ class SVP64:
                     assert rc_mode==False, "ffirst RC1 only possible when Rc=0"
                 else:
                     assert src_zero == 0, "src-zero not allowed in ffirst BO"
                     assert rc_mode==False, "ffirst RC1 only possible when Rc=0"
                 else:
                     assert src_zero == 0, "src-zero not allowed in ffirst BO"
+                    assert rc_mode, "ffirst BO only possible when Rc=1"
                     mode |= (failfirst << 2) # set BO
 
                     mode |= (failfirst << 2) # set BO
 
+            # "saturation" modes
+            elif sv_mode == 0b10:
+                mode |= 0b10 # sets saturation mode
+                mode |= (src_zero << 3) | (dst_zero << 4) # predicate zeroing
+                mode |= (saturation<<2) # sets signed/unsigned saturation
+
             # sanity-check that 2Pred mask is same mode
             if has_pmask and has_smask:
                 assert smmode == pmmode, \
             # sanity-check that 2Pred mask is same mode
             if has_pmask and has_smask:
                 assert smmode == pmmode, \
@@ -566,5 +573,6 @@ if __name__ == '__main__':
                  'sv.setb/vec2 5, 31',
                  'sv.setb/sw=8.ew=16 5, 31',
                  'sv.extsw./ff=eq 5, 31',
                  'sv.setb/vec2 5, 31',
                  'sv.setb/sw=8.ew=16 5, 31',
                  'sv.extsw./ff=eq 5, 31',
+                 'sv.extsw./satu.sz.dz 5, 31',
                 ])
     csvs = SVP64RM()
                 ])
     csvs = SVP64RM()