1312fb174dd7335be4c89b9ad6605f621fbef51b
2 from soc
.decoder
.power_enums
import (XER_bits
, Function
)
4 # XXX bad practice: use of global variables
5 from soc
.fu
.cr
.test
.test_pipe_caller
import get_cu_inputs
6 from soc
.fu
.cr
.test
.test_pipe_caller
import CRTestCase
8 from soc
.fu
.compunits
.compunits
import CRFunctionUnit
9 from soc
.fu
.compunits
.test
.test_compunit
import TestRunner
12 class CRTestRunner(TestRunner
):
13 def __init__(self
, test_data
):
14 super().__init
__(test_data
, CRFunctionUnit
, self
,
17 def get_cu_inputs(self
, dec2
, sim
):
18 """naming (res) must conform to CRFunctionUnit input regspec
20 res
= yield from get_cu_inputs(dec2
, sim
)
23 def check_cu_outputs(self
, res
, dec2
, sim
, code
):
24 """naming (res) must conform to CRFunctionUnit output regspec
27 print ("check extra output", repr(code
), res
)
30 whole_reg
= yield dec2
.e
.write_cr_whole
31 cr_en
= yield dec2
.e
.write_cr
.ok
33 full_cr
= res
['full_cr']
34 expected_cr
= sim
.cr
.get_range().value
35 print(f
"expected cr {expected_cr:x}, actual: {full_cr:x}")
36 self
.assertEqual(expected_cr
, full_cr
, code
)
40 cr_sel
= yield dec2
.e
.write_cr
.data
41 expected_cr
= sim
.crl
[cr_sel
].get_range().value
43 self
.assertEqual(expected_cr
, real_cr
, code
)
46 out_reg_valid
= yield dec2
.e
.write_reg
.ok
49 write_reg_idx
= yield dec2
.e
.write_reg
.data
50 expected
= sim
.gpr(write_reg_idx
).value
51 print(f
"expected {expected:x}, actual: {alu_out:x}")
52 self
.assertEqual(expected
, alu_out
, code
)
55 if __name__
== "__main__":
56 unittest
.main(exit
=False)
57 suite
= unittest
.TestSuite()
58 suite
.addTest(CRTestRunner(CRTestCase
.test_data
))
60 runner
= unittest
.TextTestRunner()