Skip to content

Call expect_sequences_finished by default #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion fault/ready_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,20 @@ def __init__(self, ckt: m.DefineCircuitKind, sequences: Mapping,
*args, **kwargs):
self.wrapped = wrap_with_sequence(ckt, sequences)
super().__init__(self.wrapped, *args, **kwargs)
self._sequence_finish_expected = False

def finish_sequences(self, timeout=1000):
self.wait_until_high(self.wrapped._fault_rv_tester_done_,
timeout=timeout)

def expect_sequences_finished(self):
self.expect(self.wrapped._fault_rv_tester_done_, 1)
self.expect(self.wrapped._fault_rv_tester_done_, 1,
msg="ERROR: ReadyValidTester sequences not finished")
self._sequence_finish_expected = True

def compile_and_run(self, target, *args, **kwargs):
if target == "verilator":
kwargs = _add_verilator_assert_flag(kwargs)
if not self._sequence_finish_expected:
self.expect_sequences_finished()
super().compile_and_run(*args, **kwargs)
11 changes: 11 additions & 0 deletions tests/test_ready_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,14 @@ def test_lifted_ready_valid_sequence_changing_inc():
tester.advance_cycle()
tester.expect_sequences_finished()
tester.compile_and_run("verilator", disp_type="realtime")


def test_default_expect_finished():
if verilator_version() < 4.0:
pytest.skip("Untested with earlier verilator versions")
I = [BitVector.random(8) for _ in range(8)] + [0]
O = [0] + [i + 2 for i in I[:-1]]
tester = f.ReadyValidTester(Main2, {"I": I, "O": O})
tester.circuit.inc = 2
with pytest.raises(AssertionError):
tester.compile_and_run("verilator", disp_type="realtime")