-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
ec1d4ed
commit 0a55ef5
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import unittest | ||
|
||
from migen import * | ||
from migen.genlib.divider import Divider | ||
from migen.test.support import SimCase | ||
|
||
|
||
class DivisionCase(SimCase, unittest.TestCase): | ||
class TestBench(Module): | ||
def __init__(self): | ||
self.submodules.dut = Divider(4) | ||
|
||
def test_division(self): | ||
def gen(): | ||
for dividend in range(16): | ||
for divisor in range(1, 16): | ||
yield self.tb.dut.dividend_i, dividend | ||
yield self.tb.dut.divisor_i, divisor | ||
yield self.tb.dut.start_i, 1 | ||
yield | ||
yield self.tb.dut.start_i, 0 | ||
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()) |