forked from amaranth-lang/amaranth
-
Notifications
You must be signed in to change notification settings - Fork 0
Ivy #1
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
Draft
Ivy-yu7
wants to merge
7
commits into
main
Choose a base branch
from
ivy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Ivy #1
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8a771ff
wip
robtaylor 72611e6
started observer & toggle coverage implementation
Ivy-yu7 f6580d4
Add setting of fs_per_delta to base observer class
robtaylor 1da678b
moved test_base.py to ./tests and into a unittest
Ivy-yu7 493dbbc
implemented toggle coverage with regular & irregular toggleDUT, track…
Ivy-yu7 58ebf99
fixed reviewer's comments, multi-bit toggle DUT works, 0-
Ivy-yu7 f8306d5
started statement coverage, works for basic DUT
Ivy-yu7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,59 @@ | ||
| from ._base import Observer | ||
| from amaranth.sim._vcdwriter import eval_value, eval_format | ||
|
|
||
| class ToggleCoverageObserver(Observer): | ||
| def __init__(self, state, **kwargs): | ||
| self.state = state | ||
| self._prev_values = {} | ||
| self._toggles = {} | ||
| self._signal_names = {} | ||
| super().__init__(**kwargs) | ||
|
|
||
| def update_signal(self, timestamp, signal): | ||
| if getattr(signal, "name", "") != "out": | ||
| return | ||
|
|
||
| sig_id = id(signal) | ||
| try: | ||
| val = eval_value(self.state, signal) | ||
| except Exception: | ||
| val = int(self.state.get_signal(signal)) | ||
| try: | ||
| curr_val = int(val) | ||
| except TypeError: | ||
| curr_val = val | ||
| print(f"[DEBUG] Signal {getattr(signal, 'name', signal)} = {curr_val}") | ||
|
|
||
| if sig_id not in self._prev_values: | ||
| self._prev_values[sig_id] = curr_val | ||
| self._toggles[sig_id] = {"0->1": 0, "1->0": 0} | ||
| self._signal_names[sig_id] = signal.name | ||
| return | ||
|
|
||
| prev_val = self._prev_values[sig_id] | ||
|
|
||
| if prev_val == 0 and curr_val == 1: | ||
gatecat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| self._toggles[sig_id]["0->1"] += 1 | ||
gatecat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| elif prev_val == 1 and curr_val == 0: | ||
| self._toggles[sig_id]["1->0"] += 1 | ||
|
|
||
| self._prev_values[sig_id] = curr_val | ||
|
|
||
| def update_memory(self, timestamp, memory, addr): | ||
| pass | ||
|
|
||
| def get_results(self): | ||
| return { | ||
| self._signal_names[sig_id]: toggles | ||
| for sig_id, toggles in self._toggles.items() | ||
| } | ||
|
|
||
| def close(self, timestamp): | ||
| results = self.get_results() | ||
| print("=== Toggle Coverage Report ===") | ||
| for signal, toggles in results.items(): | ||
| print(f"{signal}: 0→1={toggles['0->1']}, 1→0={toggles['1->0']}") | ||
|
|
||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.