-
Notifications
You must be signed in to change notification settings - Fork 57
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
Assume/Assert Cell Support #18
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
32c972d
hdl.ast: Add Assert and Assign statements.
cr1901 99b0a99
hdl.dsl: Support Assert and Assume where an Assign can occur.
cr1901 0596910
hdl.xfrm: Add Assert and Assume abstract methods for StatementVisitor…
cr1901 220c313
back.rtlil: Generate RTLIL for Assert/Assume statements.
cr1901 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 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
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 |
---|---|---|
|
@@ -141,6 +141,14 @@ class StatementVisitor(metaclass=ABCMeta): | |
def on_Assign(self, stmt): | ||
pass # :nocov: | ||
|
||
@abstractmethod | ||
def on_Assert(self, stmt): | ||
pass # :nocov: | ||
|
||
@abstractmethod | ||
def on_Assume(self, stmt): | ||
pass # :nocov: | ||
|
||
@abstractmethod | ||
def on_Switch(self, stmt): | ||
pass # :nocov: | ||
|
@@ -155,6 +163,10 @@ def on_unknown_statement(self, stmt): | |
def on_statement(self, stmt): | ||
if type(stmt) is Assign: | ||
return self.on_Assign(stmt) | ||
elif type(stmt) is Assert: | ||
return self.on_Assert(stmt) | ||
elif type(stmt) is Assume: | ||
return self.on_Assume(stmt) | ||
elif isinstance(stmt, Switch): | ||
# Uses `isinstance()` and not `type() is` because nmigen.compat requires it. | ||
return self.on_Switch(stmt) | ||
|
@@ -174,6 +186,12 @@ def on_value(self, value): | |
def on_Assign(self, stmt): | ||
return Assign(self.on_value(stmt.lhs), self.on_value(stmt.rhs)) | ||
|
||
def on_Assert(self, stmt): | ||
return Assert(self.on_value(stmt.test), _en=stmt._en, _check=stmt._check) | ||
|
||
def on_Assume(self, stmt): | ||
return Assume(self.on_value(stmt.test), _en=stmt._en, _check=stmt._check) | ||
|
||
def on_Switch(self, stmt): | ||
cases = OrderedDict((k, self.on_statement(s)) for k, s in stmt.cases.items()) | ||
return Switch(self.on_value(stmt.test), cases) | ||
|
@@ -294,6 +312,10 @@ class SwitchCleaner(StatementVisitor): | |
def on_Assign(self, stmt): | ||
return stmt | ||
|
||
on_Assert = on_Assign | ||
|
||
on_Assume = on_Assign | ||
|
||
def on_Switch(self, stmt): | ||
cases = OrderedDict((k, self.on_statement(s)) for k, s in stmt.cases.items()) | ||
if any(len(s) for s in cases.values()): | ||
|
@@ -338,6 +360,10 @@ def groups(self): | |
def on_Assign(self, stmt): | ||
self.unify(*stmt._lhs_signals()) | ||
|
||
on_Assert = on_Assign | ||
|
||
on_Assume = on_Assign | ||
|
||
def on_Switch(self, stmt): | ||
for case_stmts in stmt.cases.values(): | ||
self.on_statements(case_stmts) | ||
|
@@ -362,6 +388,13 @@ def on_Assign(self, stmt): | |
if any_lhs_signal in self.signals: | ||
return stmt | ||
|
||
def on_Assert(self, stmt): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
any_lhs_signal = next(iter(stmt._lhs_signals())) | ||
if any_lhs_signal in self.signals: | ||
return stmt | ||
|
||
on_Assume = on_Assert | ||
|
||
|
||
class _ControlInserter(FragmentTransformer): | ||
def __init__(self, controls): | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This produces utterly gigantic IL statements like
connect \A \assert$/home/whitequark/Projects/Boneless-CPU/boneless/gateware/formal.py:25$check. I think it's sufficient to call them something like
$assume$en`