def on_Operator_mux(self, value):
sel, val1, val0 = value.operands
+ if len(sel) != 1:
+ sel = sel.bool()
val1_bits, val1_sign = val1.shape()
val0_bits, val0_sign = val0.shape()
res_bits, res_sign = value.shape()
def test_mux_wide(self):
s = Const(0b100)
v = Mux(s, Const(0, unsigned(4)), Const(0, unsigned(6)))
- self.assertEqual(repr(v), "(m (b (const 3'd4)) (const 4'd0) (const 6'd0))")
+ self.assertEqual(repr(v), "(m (const 3'd4) (const 4'd0) (const 6'd0))")
def test_mux_bool(self):
v = Mux(True, Const(0), Const(0))
self.assertStatement(stmt, [C(2, 4), C(3, 4), C(0)], C(2, 4))
self.assertStatement(stmt, [C(2, 4), C(3, 4), C(1)], C(3, 4))
+ def test_mux_wide(self):
+ stmt = lambda y, a, b, c: y.eq(Mux(c, a, b))
+ self.assertStatement(stmt, [C(2, 4), C(3, 4), C(0, 2)], C(3, 4))
+ self.assertStatement(stmt, [C(2, 4), C(3, 4), C(1, 2)], C(2, 4))
+ self.assertStatement(stmt, [C(2, 4), C(3, 4), C(2, 2)], C(2, 4))
+
def test_abs(self):
stmt = lambda y, a: y.eq(abs(a))
self.assertStatement(stmt, [C(3, unsigned(8))], C(3, unsigned(8)))