# "undefined", just set to variable-bit-width int (use exts "max")
self.undefined = SelectableInt(0, 256) # TODO, not hard-code 256!
+ self._overflow = None
self.namespace = {'GPR': self.gpr,
'MEM': self.mem,
'CR': self.cr,
'MSR': self.msr,
'undefined': self.undefined,
+ 'overflow': self._overflow,
'mode_is_64bit': True,
'SO': XER_bits['SO']
}
self.namespace['XER'] = self.spr['XER']
self.namespace['CA'] = self.spr['XER'][XER_bits['CA']].value
self.namespace['CA32'] = self.spr['XER'][XER_bits['CA32']].value
+ self.namespace['overflow'] = None
def handle_carry_(self, inputs, outputs, already_done):
inv_a = yield self.dec2.e.invert_a
carry_en = yield self.dec2.e.output_carry
if carry_en:
yield from self.handle_carry_(inputs, results, already_done)
+
+ # detect if overflow was in return result
+ overflow = None
+ if info.write_regs:
+ for name, output in zip(output_names, results):
+ if name == 'overflow':
+ self._overflow = output
+
ov_en = yield self.dec2.e.oe.oe
ov_ok = yield self.dec2.e.oe.ok
+ print ("internal overflow", self._overflow)
if ov_en & ov_ok:
yield from self.handle_overflow(inputs, results)
+
rc_en = yield self.dec2.e.rc.data
if rc_en:
self.handle_comparison(results)
# any modified return results?
if info.write_regs:
for name, output in zip(output_names, results):
+ if name == 'overflow': # ignore, done already (above)
+ continue
if isinstance(output, int):
output = SelectableInt(output, 256)
if name in ['CA', 'CA32']:
class DivTestCases(FHDLTestCase):
test_data = []
- def __init__(self, name="general"):
+ def __init__(self, name="div"):
super().__init__(name)
self.test_name = name
with Program(lst) as program:
self.run_tst_program(program, [1, 2, 3])
- def test_1_divw_byzero(self):
+ def test_1_divwe(self):
+ lst = ["addi 1, 0, 0x5678",
+ "addi 2, 0, 0x1234",
+ "divwe 3, 1, 2",
+ ]
+ with Program(lst) as program:
+ self.run_tst_program(program, [1, 2, 3])
+
+ def test_2_divweu(self):
+ lst = ["addi 1, 0, 0x5678",
+ "addi 2, 0, 0x1234",
+ "divweu 3, 1, 2",
+ ]
+ with Program(lst) as program:
+ self.run_tst_program(program, [1, 2, 3])
+
+ @unittest.skip("qemu_wrong_result")
+ def test_3_divwo_byzero(self):
lst = ["addi 1, 0, 0x5678",
"addi 2, 0, 0x0",
"divw 3, 1, 2",
with Program(lst) as program:
self.run_tst_program(program, [1, 2, 3])
- def test_2_moduw(self):
+ def test_4_moduw(self):
lst = ["addi 1, 0, 0x5678",
"addi 2, 0, 0x1234",
"moduw 3, 1, 2",