-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
236 additions
and
71 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
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
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
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
Empty file.
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,32 @@ | ||
from amaranth import * | ||
|
||
from transactron.utils import assertion | ||
from transactron.testing import TestCaseWithSimulator | ||
|
||
|
||
class AssertionTest(Elaboratable): | ||
def __init__(self): | ||
self.input = Signal() | ||
self.output = Signal() | ||
|
||
def elaborate(self, platform): | ||
m = Module() | ||
|
||
m.d.comb += self.output.eq(self.input & ~self.input) | ||
|
||
assertion(self.input == self.output) | ||
|
||
return m | ||
|
||
|
||
class TestAssertion(TestCaseWithSimulator): | ||
def test_assertion(self): | ||
m = AssertionTest() | ||
|
||
def proc(): | ||
yield | ||
yield m.input.eq(1) | ||
|
||
with self.assertRaises(AssertionError): | ||
with self.run_simulation(m) as sim: | ||
sim.add_sync_process(proc) |
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
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
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,23 @@ | ||
from collections.abc import Callable | ||
from typing import Any | ||
from amaranth.sim import Passive, Tick | ||
from transactron.utils import assert_bit, assert_bits | ||
from transactron.utils.dependencies import DependencyContext | ||
|
||
|
||
__all__ = ["make_assert_handler"] | ||
|
||
|
||
def make_assert_handler(my_assert: Callable[[int, str], Any]): | ||
dependency_manager = DependencyContext.get() | ||
|
||
def assert_handler(): | ||
yield Passive() | ||
while True: | ||
yield Tick("sync_neg") | ||
if not (yield assert_bit(dependency_manager)): | ||
for v, (n, i) in assert_bits(dependency_manager): | ||
my_assert((yield v), f"Assertion at {n}:{i}") | ||
yield | ||
|
||
return assert_handler |
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
Oops, something went wrong.