m.d.comb += [a1.v.eq(self.i.a),
b1.v.eq(self.i.b)]
+ ab_equal = Signal()
+ m.d.comb += ab_equal.eq(a1.v == b1.v)
- comb += z1.eq(0)
+ with m.Switch(opcode):
+ with m.Case(0b10):
+ comb += z1.eq(ab_equal)
# copy the context (muxid, operator)
comb += self.o.ctx.eq(self.i.ctx)
Fan-in and Fan-out are combinatorial.
"""
- def __init__(self, in_width, num_rows, op_wid=1):
+ def __init__(self, in_width, num_rows, op_wid=2):
self.op_wid = op_wid
self.id_wid = num_bits(num_rows)
def fpmax_f32_max(a, b):
+ # Apparently, sfpy doesn't include a min or max function. Python's
+ # min/max work, however python min/max are not IEEE754 Compliant
+ # (namely, they don't behave correctly with NaNs
+ # IEEE754 defines max(num, NaN) and max(NaN, num) as both
+ # returning num (and the same for min)
if math.isnan(a) or math.isnan(b):
if math.isnan(a) and math.isnan(b):
return Float32(float('nan'))
if __name__ == '__main__':
for i in range(50):
- test_fpmax_f32_min()
test_fpmax_f32_max()
+ test_fpmax_f32_min()