hdl.ast: actually implement the // operator.
This commit is contained in:
parent
450d7efdf2
commit
1621ceb65a
5 changed files with 29 additions and 5 deletions
|
|
@ -181,6 +181,17 @@ class OperatorTestCase(FHDLTestCase):
|
|||
v5 = 10 * Const(0, 4)
|
||||
self.assertEqual(v5.shape(), (8, False))
|
||||
|
||||
def test_floordiv(self):
|
||||
v1 = Const(0, (4, False)) // Const(0, (6, False))
|
||||
self.assertEqual(repr(v1), "(// (const 4'd0) (const 6'd0))")
|
||||
self.assertEqual(v1.shape(), (4, False))
|
||||
v2 = Const(0, (4, True)) // Const(0, (6, True))
|
||||
self.assertEqual(v2.shape(), (5, True))
|
||||
v3 = Const(0, (4, True)) // Const(0, (4, False))
|
||||
self.assertEqual(v3.shape(), (4, True))
|
||||
v5 = 10 // Const(0, 4)
|
||||
self.assertEqual(v5.shape(), (4, False))
|
||||
|
||||
def test_and(self):
|
||||
v1 = Const(0, (4, False)) & Const(0, (6, False))
|
||||
self.assertEqual(repr(v1), "(& (const 4'd0) (const 6'd0))")
|
||||
|
|
|
|||
|
|
@ -95,6 +95,12 @@ class SimulatorUnitTestCase(FHDLTestCase):
|
|||
self.assertStatement(stmt, [C(2, 4), C(2, 4)], C(4, 8))
|
||||
self.assertStatement(stmt, [C(7, 4), C(7, 4)], C(49, 8))
|
||||
|
||||
def test_floordiv(self):
|
||||
stmt = lambda y, a, b: y.eq(a // b)
|
||||
self.assertStatement(stmt, [C(2, 4), C(1, 4)], C(2, 8))
|
||||
self.assertStatement(stmt, [C(2, 4), C(2, 4)], C(1, 8))
|
||||
self.assertStatement(stmt, [C(7, 4), C(2, 4)], C(3, 8))
|
||||
|
||||
def test_and(self):
|
||||
stmt = lambda y, a, b: y.eq(a & b)
|
||||
self.assertStatement(stmt, [C(0b1100, 4), C(0b1010, 4)], C(0b1000, 4))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue