from ieee754.part_mul_add.adder import PartitionedAdder
from ieee754.part_cmp.eq_gt_ge import PartitionedEqGtGe
from ieee754.part_bits.xor import PartitionedXOR
+from ieee754.part_bits.bool import PartitionedBool
from ieee754.part_shift.part_shift_dynamic import PartitionedDynamicShift
from ieee754.part_shift.part_shift_scalar import PartitionedScalarShift
from ieee754.part_mul_add.partpoints import make_partition2, PartitionPoints
modnames = {}
# for sub-modules to be created on-demand. Mux is done slightly
# differently (has its own global)
-for name in ['add', 'eq', 'gt', 'ge', 'ls', 'xor']:
+for name in ['add', 'eq', 'gt', 'ge', 'ls', 'xor', 'bool']:
modnames[name] = 0
Value, out
``1`` if any bits are set, ``0`` otherwise.
"""
- return self.any() # have to see how this goes
- #return Operator("b", [self])
+ width = len(self.sig)
+ pa = PartitionedBool(width, self.partpoints)
+ setattr(self.m.submodules, self.get_modname("bool"), pa)
+ self.m.d.comb += pa.a.eq(self.sig)
+ return pa.output
def any(self):
"""Check if any bits are ``1``.
self.sub_carry_out = Signal(len(partpoints)+1)
self.neg_output = Signal(width)
self.xor_output = Signal(len(partpoints)+1)
+ self.bool_output = Signal(len(partpoints)+1)
def elaborate(self, platform):
m = Module()
comb += self.neg_output.eq((-self.a).sig)
# horizontal operators
comb += self.xor_output.eq(self.a.xor())
+ comb += self.bool_output.eq(self.a.bool())
# left shift
comb += self.ls_output.eq(self.a << self.b)
# right shift
test >>= 1
return result
+ def test_bool_fn(a, mask):
+ test = (a & mask)
+ result = 0
+ while test != 0:
+ bit = (test & 1)
+ result |= bit
+ test >>= 1
+ return result
+
def test_horizop(msg_prefix, test_fn, mod_attr, *maskbit_list):
randomvals = []
for i in range(10):
self.assertEqual(y, outval, msg % str(maskbit_list))
for (test_fn, mod_attr) in ((test_xor_fn, "xor"),
+ (test_bool_fn, "bool"),
#(test_ne_fn, "ne"),
):
yield part_mask.eq(0)