fix wb_get error where data was being corrupted
[soc.git] / src / soc / experiment / test / test_compalu_multi.py
index ae4f819983e37ee1bfe048c4a5de734e202730ec..2f858b6cfa2f628821177bf8bceeb4b57bcb8e38 100644 (file)
@@ -15,7 +15,7 @@ from soc.fu.alu.alu_input_record import CompALUOpSubset
 from soc.fu.cr.cr_input_record import CompCROpSubset
 from soc.experiment.alu_hier import ALU, DummyALU
 from soc.experiment.compalu_multi import MultiCompUnit
-from soc.decoder.power_enums import MicrOp
+from openpower.decoder.power_enums import MicrOp
 from nmutil.gtkw import write_gtkw
 from nmigen import Module, Signal
 from nmigen.cli import rtlil
@@ -430,6 +430,7 @@ class OpSim:
 
 
 def scoreboard_sim(op):
+    # the following tests cases have rc=0, so no CR output is expected
     # zero (no) input operands test
     # 0 + 8 = 8
     yield from op.issue([5, 2], MicrOp.OP_ADD, [8, 0],
@@ -476,6 +477,22 @@ def scoreboard_sim(op):
     yield from op.issue([2, 0x80], MicrOp.OP_EXTSWSLI, [0xFF80, 0],
                         rdmaskn=[1, 0], wrmask=[0, 1],
                         src_delays=[1, 2], dest_delays=[1, 0])
+    # test with rc=1, so expect results on the CR output port
+    # 5 + 2 = 7
+    # 7 > 0 => CR = 0b100
+    yield from op.issue([5, 2], MicrOp.OP_ADD, [7, 0b100],
+                        rc=1,
+                        src_delays=[1, 1], dest_delays=[1, 0])
+    # sign_extend(0x80) = 0xFF80
+    # -128 < 0 => CR = 0b010
+    yield from op.issue([0x80, 2], MicrOp.OP_EXTS, [0xFF80, 0b010],
+                        rc=1, rdmaskn=[0, 1],
+                        src_delays=[2, 1], dest_delays=[0, 2])
+    # 5 - 5 = 0
+    # 0 == 0 => CR = 0b001
+    yield from op.issue([5, 2], MicrOp.OP_CMP, [0, 0b001],
+                        imm=5, imm_ok=1, rc=1,
+                        src_delays=[0, 1], dest_delays=[2, 1])
 
 
 def test_compunit_fsm():
@@ -704,7 +721,7 @@ def test_compunit_regspec1():
             ('cu_wrmask_o[1:0]', {'bit': 0}),
             ('cu_wr__rel_o[1:0]', {'bit': 0}),
             ('cu_wr__go_i[1:0]', {'bit': 0}),
-            'dest2_o[2:0]']),
+            'dest2_o[15:0]']),
         ('alu', {'submodule': 'alu'}, [
             ('prev port', 'in', [
                 'op__insn_type', 'op__invert_in', 'a[15:0]', 'b[15:0]',