1 from openpower
.test
.common
import TestAccumulatorBase
2 from openpower
.endian
import bigendian
3 from openpower
.simulator
.program
import Program
4 from hashlib
import sha256
9 sha256(bytes(v
, encoding
='utf-8')).digest(),
14 class BitManipTestCase(TestAccumulatorBase
):
15 def case_ternlogi(self
):
23 imm
= hash_256(f
"ternlogi imm {i}") & 0xFF
25 instr
= (instr
<< 5) | rt
26 instr
= (instr
<< 5) | ra
27 instr
= (instr
<< 5) | rb
28 instr
= (instr
<< 8) | imm
29 instr
= (instr
<< 2) | xo
30 instr
= (instr
<< 1) | rc
31 lst
= [f
".4byte {hex(instr)}"]
32 initial_regs
= [0] * 32
33 initial_regs
[3] = hash_256(f
"ternlogi rt {i}") % 2 ** 64
34 initial_regs
[4] = hash_256(f
"ternlogi ra {i}") % 2 ** 64
35 initial_regs
[5] = hash_256(f
"ternlogi rb {i}") % 2 ** 64
36 self
.add_case(Program(lst
, bigendian
), initial_regs
)