move sanity-checks, add mode into svp64_rm
[soc.git] / src / soc / sv / trans / svp64.py
index e598c9bb38744442e2d7dd06cd75c655526a1aeb..79090c9651be46a5a1ecbf7e1ecb6ee5537ba718 100644 (file)
@@ -471,6 +471,17 @@ class SVP64:
                 elif encmode == 'svm': # sub-vector mode
                     mapreduce_svm = True
 
+            # sanity-check that 2Pred mask is same mode
+            if has_pmask and has_smask:
+                assert smmode == pmmode, \
+                    "predicate masks %s and %s must be same reg type" % \
+                        (pme, sme)
+
+            # sanity-check that twin-predication mask only specified in 2P mode
+            if ptype == '1P':
+                assert has_smask == False, \
+                    "source-mask can only be specified on Twin-predicate ops"
+
             # construct the mode field, doing sanity-checking along the way
 
             if mapreduce_svm:
@@ -485,6 +496,7 @@ class SVP64:
             # "normal" mode
             if sv_mode is None:
                 mode |= (src_zero << 3) | (dst_zero << 4) # predicate zeroing
+                sv_mode = 0b00
 
             # "mapreduce" modes
             elif sv_mode == 0b00:
@@ -503,7 +515,6 @@ class SVP64:
             # "failfirst" modes
             elif sv_mode == 0b01:
                 assert dst_zero == 0, "dest-zero not allowed in failfirst mode"
-                mode |= 0b01 # sets failfirst
                 if failfirst == 'RC1':
                     mode |= (0b1<<4) # sets RC1 mode
                     mode |= (src_zero << 3) # predicate src-zeroing
@@ -520,14 +531,12 @@ class SVP64:
 
             # "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
 
             # "predicate-result" modes.  err... code-duplication from ffirst
             elif sv_mode == 0b11:
                 assert dst_zero == 0, "dest-zero not allowed in predresult mode"
-                mode |= 0b11 # sets predicate-result
                 if predresult == 'RC1':
                     mode |= (0b1<<4) # sets RC1 mode
                     mode |= (src_zero << 3) # predicate src-zeroing
@@ -542,18 +551,10 @@ class SVP64:
                     assert rc_mode, "pr-mode BO only possible when Rc=1"
                     mode |= (predresult << 2) # set BO
 
-            # whewww.... modes all done... :)
-
-            # sanity-check that 2Pred mask is same mode
-            if has_pmask and has_smask:
-                assert smmode == pmmode, \
-                    "predicate masks %s and %s must be same reg type" % \
-                        (pme, sme)
-
-            # sanity-check that twin-predication mask only specified in 2P mode
-            if ptype == '1P':
-                assert has_smask == False, \
-                    "source-mask can only be specified on Twin-predicate ops"
+            # whewww.... modes all done :)
+            # now put into svp64_rm
+            mode |= sv_mode
+            svp64_rm |= (mode << 19) # mode: bits 19-23
 
             # put in predicate masks into svp64_rm
             if ptype == '2P':