add fast spr1/2 sim ALUHelpers
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 11 Jun 2020 06:14:49 +0000 (07:14 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 11 Jun 2020 06:14:49 +0000 (07:14 +0100)
src/soc/fu/branch/test/test_pipe_caller.py
src/soc/fu/test/common.py

index b7d5ec8a01d26c1493e9a47cf9ff6e0cab0f132f..c2eb08885ad2e69582c32857a0f7684395a5c2bb 100644 (file)
@@ -56,25 +56,9 @@ def get_cu_inputs(dec2, sim):
     # CIA (PC)
     res['cia'] = sim.pc.CIA.value
 
-    fast1_en = yield dec2.e.read_fast1.ok
-    if fast1_en:
-        fast1_sel = yield dec2.e.read_fast1.data
-        spr1_sel = fast_reg_to_spr(fast1_sel)
-        spr1_data = sim.spr[spr1_sel].value
-        res['spr1'] = spr1_data
-
-    fast2_en = yield dec2.e.read_fast2.ok
-    if fast2_en:
-        fast2_sel = yield dec2.e.read_fast2.data
-        spr2_sel = fast_reg_to_spr(fast2_sel)
-        spr2_data = sim.spr[spr2_sel].value
-        res['spr2'] = spr2_data
-
-    cr_en = yield dec2.e.read_cr1.ok
-    if cr_en:
-        cr_sel = yield dec2.e.read_cr1.data
-        cr = sim.crl[cr_sel].get_range().value
-        res['cr_a'] = cr
+    yield from ALUHelpers.get_sim_fast_spr1(res, sim, dec2)
+    yield from ALUHelpers.get_sim_fast_spr2(res, sim, dec2)
+    yield from ALUHelpers.get_sim_cr_a(res, sim, dec2)
 
     print ("get inputs", res)
     return res
index 2ca7df638be0a2b204577cc249731202f8917150..66d248b15127e0c28aac0769876a301bb08c0091 100644 (file)
@@ -4,6 +4,7 @@ Bugreports:
 """
 
 from soc.decoder.power_enums import XER_bits
+from soc.regfile.util import fast_reg_to_spr # HACK!
 
 
 class TestCase:
@@ -27,6 +28,22 @@ class TestCase:
 
 class ALUHelpers:
 
+    def get_sim_fast_spr1(res, sim, dec2):
+        fast1_en = yield dec2.e.read_fast1.ok
+        if fast1_en:
+            fast1_sel = yield dec2.e.read_fast1.data
+            spr1_sel = fast_reg_to_spr(fast1_sel)
+            spr1_data = sim.spr[spr1_sel].value
+            res['spr1'] = spr1_data
+
+    def get_sim_fast_spr2(res, sim, dec2):
+        fast2_en = yield dec2.e.read_fast2.ok
+        if fast2_en:
+            fast2_sel = yield dec2.e.read_fast2.data
+            spr2_sel = fast_reg_to_spr(fast2_sel)
+            spr2_data = sim.spr[spr2_sel].value
+            res['spr2'] = spr2_data
+
     def get_sim_cr_a(res, sim, dec2):
         cridx_ok = yield dec2.e.read_cr1.ok
         if cridx_ok: