-
Notifications
You must be signed in to change notification settings - Fork 615
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
Add format strings to assert and assume #3802
Conversation
9e98628
to
d5ea924
Compare
This supports format strings for assert and assume statements. Internal representaion of `Verification` object is modified in a similar way to `Print`. Cover cannot be used with a format string so conversion raires an exception when we try constructing a cover statement with a format string.
d5ea924
to
78c751f
Compare
d2cf102
to
828aec3
Compare
The Panama part lgtm. Although we don’t have enough test for now. |
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.
LGTM, but may be good to get another approval 👍 .
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 looks good. I'm requesting @jackkoenig to take a look for some of the data class pieces.
if (op == Formal.Cover && args.nonEmpty) { | ||
throwException("cover message cannot be used as a format string") | ||
} |
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 can be done as a require
inside the constructor of the Verification
op. (Arguably that motivates splitting this into separate IR structures for assert, assume, and cover, but that's not necessary.)
@@ -436,6 +436,7 @@ object Formal extends Enumeration { | |||
pred: Expression, | |||
en: Expression, | |||
msg: StringLit, | |||
args: Seq[Expression], |
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.
If we're doing this the data class way, then this needs an @since(...)
. @jackkoenig: how do you want to handle this?
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.
We've deprecated everything in package firrtl._ and we should probably make it all private as part of Chisel 7 so I'm fine with just making the breaking change. WIth that, I'm fine with this as is, or we can change it back to a case class which would let us delete the unapply (and companion object) rather than updating it.
WDYT?
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.
I greatly prefer making all this private!
def unapply( | ||
s: Verification | ||
): Some[(Formal.Value, Info, Expression, Expression, Expression, StringLit, Seq[Expression])] = { | ||
Some((s.op, s.info, s.clk, s.pred, s.en, s.msg, s.args)) |
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.
@jackkoenig: is this necessary to update for data class?
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.
If we keep the data class (implying we're trying to maintain source and binary compatibility), we should not update this (but should instead deprecate it). As is, this is making a breaking change, but I support just breaking it, see my other comment.
98b677d
to
2f053bc
Compare
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.
I approve but please just change @data class Verification
to a case class
. To do this, replace @data
with case
, delete @since
, delete copy
, and delete the companion object and unapply
method.
def unapply( | ||
s: Verification | ||
): Some[(Formal.Value, Info, Expression, Expression, Expression, StringLit, Seq[Expression])] = { | ||
Some((s.op, s.info, s.clk, s.pred, s.en, s.msg, s.args)) |
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.
If we keep the data class (implying we're trying to maintain source and binary compatibility), we should not update this (but should instead deprecate it). As is, this is making a breaking change, but I support just breaking it, see my other comment.
@@ -436,6 +436,7 @@ object Formal extends Enumeration { | |||
pred: Expression, | |||
en: Expression, | |||
msg: StringLit, | |||
args: Seq[Expression], |
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.
We've deprecated everything in package firrtl._ and we should probably make it all private as part of Chisel 7 so I'm fine with just making the breaking change. WIth that, I'm fine with this as is, or we can change it back to a case class which would let us delete the unapply (and companion object) rather than updating it.
WDYT?
@jackkoenig @seldridge Could you merge this? Thanks! |
This supports format strings for assert and assume statements. Internal representaion of `Verification` object is modified in a similar way to `Print`. Cover cannot be used with a format string so conversion raires an exception when we try constructing a cover statement with a format string.
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
This supports format strings for assert and assume statements as proposed in chipsalliance/firrtl-spec#166. This change might break existing code if message contains
%
.Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.