Skip to content
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

[LowerToHW] Lower i0 operand in printf-encoded assertions to i1 #4311

Merged
merged 3 commits into from
Nov 16, 2022

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Nov 15, 2022

This supports i0 value operand of verification statements. Following the implementation of printf, we use i1 value as a result.

Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! This nicely unifies the behavior of firrtl.printf and the verification statements. 👍

Copy link
Contributor

@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

This seems reasonable for %d format specifier in particular, and for many others not sure we should worry about what "right semantics" are here. Aligning with printf is nice!

// CHECK-NEXT: [[TRUE:%.+]] = hw.constant true
// CHECK-NEXT: [[TMP1:%.+]] = comb.xor %enable, [[TRUE]]
// CHECK-NEXT: [[TMP2:%.+]] = comb.or bin [[TMP1]], %cond
// CHECK-NEXT: sv.assert.concurrent posedge %clock, [[TMP2]] message "assert0"
// CHECK-NEXT: sv.ifdef "USE_PROPERTY_AS_CONSTRAINT" {
// CHECK-NEXT: sv.assume.concurrent posedge %clock, [[TMP2]]
// CHECK-NEXT: }
firrtl.assert %clock, %cond, %enable, "assert1"(%value) : !firrtl.uint<42> {isConcurrent = true, format = "ifElseFatal"}
firrtl.assert %clock, %cond, %enable, "assert1"(%value, %i0) : !firrtl.uint<42>, !firrtl.uint<0> {isConcurrent = true, format = "ifElseFatal"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can this string be changed so "substitutions" are used? I know we don't inspect it presently, but as-is it doesn't seem entirely unreasonable to elide the substitutions as trivially unused.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

Copy link
Contributor

@darthscsi darthscsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable.

@uenoku uenoku merged commit 77f14bf into main Nov 16, 2022
@uenoku uenoku deleted the dev/uenoku/fix-i0-in-assert branch November 16, 2022 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants