decode SPRs for branch
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 1 Jun 2020 04:50:28 +0000 (05:50 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 1 Jun 2020 04:50:28 +0000 (05:50 +0100)
src/soc/decoder/power_enums.py
src/soc/fu/compunits/test/test_branch_compunit.py

index b294324e26ecc1ba228e8c6a120eb56d3aec3238..a9e4c745b5fc025aee1fd499afb3bbd7ff3e810a 100644 (file)
@@ -273,5 +273,6 @@ if __name__ == '__main__':
     print ("sprs", len(SPR))
     print (dir(SPR))
     print (dir(Enum))
+    print (SPR.__members__['TAR'])
     for x in SPR:
-        print (x, x.value)
+        print (x, x.value, str(x), x.name)
index 256d9cc07566e1285a981564aab79910587dba4b..c7cd772a0f79f5c3725a3162a1a75e783b35e191 100644 (file)
@@ -1,5 +1,5 @@
 import unittest
-from soc.decoder.power_enums import (XER_bits, Function)
+from soc.decoder.power_enums import (XER_bits, Function, spr_dict)
 
 # XXX bad practice: use of global variables
 from soc.fu.branch.test.test_pipe_caller import BranchTestCase
@@ -47,14 +47,16 @@ class BranchTestRunner(TestRunner):
             res['cr_a'] = sim.crl[cr1_sel].get_range().value
 
         # SPR1
-        cr1_en = yield dec2.e.read_spr1.ok
-        res['spr1'] = sim.spr['CTR'].value
-
-        # RB (or immediate)
-        reg2_ok = yield dec2.e.read_reg2.ok
-        if reg2_ok:
-            data2 = yield dec2.e.read_reg2.data
-            res['b'] = sim.gpr(data2).value
+        spr_ok = yield dec2.e.read_spr1.ok
+        spr_num = yield dec2.e.read_spr1.data
+        if spr_ok:
+            res['spr1'] = sim.spr[spr_dict[spr_num].SPR].value
+
+        # SPR2
+        spr_ok = yield dec2.e.read_spr2.ok
+        spr_num = yield dec2.e.read_spr2.data
+        if spr_ok:
+            res['spr2'] = sim.spr[spr_dict[spr_num].SPR].value
 
         print ("get inputs", res)
         return res