test/divider: subtests

This commit is contained in:
Sebastien Bourdeauducq 2015-10-13 18:39:41 +08:00
parent e0899c1424
commit 8817716d5f
1 changed files with 9 additions and 8 deletions

View File

@ -14,13 +14,14 @@ class DivisionCase(SimCase, unittest.TestCase):
def gen(): def gen():
for dividend in range(16): for dividend in range(16):
for divisor in range(1, 16): for divisor in range(1, 16):
yield self.tb.dut.dividend_i.eq(dividend) with self.subTest(dividend=dividend, divisor=divisor):
yield self.tb.dut.divisor_i.eq(divisor) yield self.tb.dut.dividend_i.eq(dividend)
yield self.tb.dut.start_i.eq(1) yield self.tb.dut.divisor_i.eq(divisor)
yield yield self.tb.dut.start_i.eq(1)
yield self.tb.dut.start_i.eq(0)
while not (yield self.tb.dut.ready_o):
yield yield
self.assertEqual((yield self.tb.dut.quotient_o), dividend//divisor) yield self.tb.dut.start_i.eq(0)
self.assertEqual((yield self.tb.dut.remainder_o), dividend%divisor) while not (yield self.tb.dut.ready_o):
yield
self.assertEqual((yield self.tb.dut.quotient_o), dividend//divisor)
self.assertEqual((yield self.tb.dut.remainder_o), dividend%divisor)
self.run_with(gen()) self.run_with(gen())