selectconcat)
from soc.decoder.power_enums import (spr_dict, spr_byname, XER_bits,
insns, MicrOp)
-from soc.decoder.helpers import exts
+from soc.decoder.helpers import exts, gtu, ltu
from soc.consts import PIb, MSRb # big-endian (PowerISA versions)
from collections import namedtuple
gts = []
for x in inputs:
print("gt input", x, output)
- gt = (x > output)
+ gt = (gtu(x, output))
gts.append(gt)
print(gts)
cy = 1 if any(gts) else 0
gts = []
for x in inputs:
print("input", x, output)
- gt = (x[32:64] > output[32:64]) == SelectableInt(1, 1)
+ gt = (gtu(x[32:64], output[32:64])) == SelectableInt(1, 1)
gts.append(gt)
cy32 = 1 if any(gts) else 0
if not (2 & already_done):
fs[0:2] = 0b10
self.assertEqual(fs.get_range(), 0b1011)
-
class SelectableInt:
"""SelectableInt - a class that behaves exactly like python int
self.value = b.value
self.bits = b.bits
+ def to_signed_int(self):
+ print ("to signed?", self.value & (1<<(self.bits-1)), self.value)
+ if self.value & (1<<(self.bits-1)) != 0: # negative
+ res = self.value - (1<<self.bits)
+ print (" val -ve:", self.bits, res)
+ else:
+ res = self.value
+ print (" val +ve:", res)
+ return res
+
def _op(self, op, b):
if isinstance(b, int):
b = SelectableInt(b, self.bits)
if isinstance(other, SelectableInt):
other = check_extsign(self, other)
assert other.bits == self.bits
- other = other.value
+ other = other.to_signed_int()
if isinstance(other, int):
- return onebit(self.value >= other.value)
+ return onebit(self.to_signed_int() >= other)
assert False
def __le__(self, other):
if isinstance(other, SelectableInt):
other = check_extsign(self, other)
assert other.bits == self.bits
- other = other.value
+ other = other.to_signed_int()
if isinstance(other, int):
- return onebit(self.value <= other)
+ return onebit(self.to_signed_int() <= other)
assert False
def __gt__(self, other):
if isinstance(other, SelectableInt):
other = check_extsign(self, other)
assert other.bits == self.bits
- other = other.value
+ other = other.to_signed_int()
if isinstance(other, int):
- return onebit(self.value > other)
+ return onebit(self.to_signed_int() > other)
assert False
def __lt__(self, other):
+ print ("SelectableInt lt", self, other)
if isinstance(other, FieldSelectableInt):
other = other.get_range()
if isinstance(other, SelectableInt):
other = check_extsign(self, other)
assert other.bits == self.bits
- other = other.value
+ other = other.to_signed_int()
if isinstance(other, int):
- return onebit(self.value < other)
+ a = self.to_signed_int()
+ res = onebit(a < other)
+ print (" a < b", a, other, res)
+ return res
assert False
def __eq__(self, other):
other = check_extsign(self, other)
assert other.bits == self.bits
other = other.value
+ print (" eq", other, self.value, other == self.value)
if isinstance(other, int):
return onebit(other == self.value)
assert False