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

Add ifElseFatal intrinsics; use it for chisel3.assert emission #3825

Merged
merged 6 commits into from
Mar 6, 2024

Conversation

uenoku
Copy link
Contributor

@uenoku uenoku commented Feb 16, 2024

  • Replaced printf-encoded assertion with ifElseFatal intrinsics[0]. Currently the intrinsic is a private object of core since we don't want to expose it other than chisel3.assert.
  • Removed outdated comments regarding verification statements.
  • Added a new case class PrintableParam for lazily constructing a string parameter for format string.

[0] https://github.com/llvm/circt/blob/main/docs/Dialects/FIRRTL/FIRRTLIntrinsics.md#circtchisel_ifelsefatal

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • Backend code generation

Desired Merge Strategy

  • Squash: The PR will be squashed and merged (choose this if you have no preference).

Release Notes

Support circt_chisel_ifelsefatal intrinsics and use it for chisel3.assert emission.

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
  • Did you mark the proper milestone (Bug fix: 3.6.x, 5.x, or 6.x depending on impact, API modification or big change: 7.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you do one of the following when ready to merge:
    • Squash: You/ the contributor Enable auto-merge (squash), clean up the commit message, and label with Please Merge.
    • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

@jackkoenig jackkoenig added the Feature New feature, will be included in release notes label Feb 16, 2024
@uenoku uenoku marked this pull request as draft February 16, 2024 19:04
@uenoku uenoku changed the title Support circt_chisel_ifelsefatal intrinsics Add ifElseFatal intrinsics; use it for chisel3.assert emission Feb 28, 2024
@uenoku uenoku force-pushed the dev/hidetou/verif-int branch 3 times, most recently from 1c7698f to afb4e3f Compare February 29, 2024 14:36
@@ -75,14 +75,12 @@ class NamePluginSpec extends ChiselFlatSpec with Utils {
val foo, bar = IO(Input(UInt(8.W)))

{
val x1 = chisel3.assert(1.U === 1.U)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted because a label doesn't make sense for chisel3.assert

Copy link
Contributor

Choose a reason for hiding this comment

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

Does that change match the firrtl spec (not sure whether asserts having labels ever was in the spec)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that chisel3.assert never use plain FIRRTL assert. IfElseFatal style assertion doesn't have a label and we have ignored labels. I think it's fair to add a new API for emitting a plain FIRRTL assert and use that API here though.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're saying it never had a label, but if it didn't, how did this test pass previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

chisel3.assert emitted an assert op along with print op. The assert op is actually a dummy op deleted by a parser and this test passed because the dummy assert had a label.

@uenoku uenoku marked this pull request as ready for review February 29, 2024 14:37
src/main/scala/chisel3/stage/ChiselAnnotations.scala Outdated Show resolved Hide resolved
@@ -75,14 +75,12 @@ class NamePluginSpec extends ChiselFlatSpec with Utils {
val foo, bar = IO(Input(UInt(8.W)))

{
val x1 = chisel3.assert(1.U === 1.U)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does that change match the firrtl spec (not sure whether asserts having labels ever was in the spec)

@uenoku uenoku force-pushed the dev/hidetou/verif-int branch 2 times, most recently from e45c7af to ddc39b0 Compare March 1, 2024 02:45
This replaces printf-encoded assertion with ifElseFatal intrinsics.
The intrinsic is a private object of core since we don't want to expose it other than chisel3.assert.
@jackkoenig jackkoenig added this to the 7.0 milestone Mar 1, 2024
@jackkoenig jackkoenig added Backend Code Generation Affects backend code generation, will be included in release notes and removed Feature New feature, will be included in release notes labels Mar 1, 2024
@uenoku uenoku requested a review from jackkoenig March 4, 2024 15:03
Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

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

A few last nits but looks good

core/src/main/scala/chisel3/Printable.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Printable.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Printable.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/BlackBox.scala Outdated Show resolved Hide resolved
uenoku and others added 2 commits March 6, 2024 23:13
Co-authored-by: Jack Koenig <jack.koenig3@gmail.com>
@uenoku
Copy link
Contributor Author

uenoku commented Mar 6, 2024

@jackkoenig Thank you for reviews! Could you merge this?

Copy link
Member

@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!

@dtzSiFive dtzSiFive merged commit 386a7f3 into chipsalliance:main Mar 6, 2024
14 checks passed
uenoku added a commit to uenoku/chisel that referenced this pull request Mar 7, 2024
This is a follow-up to chipsalliance#3825.

MFC has attached a laebl "chisel3_builtin" to every ifElseFatal assertion.
Usually a label on ifElseFatal is just ignored but the label is emitted
when compiled with `-emit-chisel-asserts-as-sva`. So labels on assertions
converted from ifElseFatal disappear due to chipsalliance#3825. This PR restores labels
to preserve the old behavior.
dtzSiFive pushed a commit that referenced this pull request Mar 7, 2024
This is a follow-up to #3825.

MFC has attached a laebl "chisel3_builtin" to every ifElseFatal assertion.
Usually a label on ifElseFatal is just ignored but the label is emitted
when compiled with `-emit-chisel-asserts-as-sva`. So labels on assertions
converted from ifElseFatal disappear due to #3825. This PR restores labels
to preserve the old behavior.
dtzSiFive added a commit that referenced this pull request Mar 7, 2024
dtzSiFive added a commit that referenced this pull request Mar 7, 2024
dtzSiFive added a commit to dtzSiFive/chisel3 that referenced this pull request Apr 17, 2024
Restore chipsalliance#3912 and chipsalliance#3825.
Use intrinsic expression instead of intrinsic module.

This reverts commit 347d82b.
dtzSiFive added a commit to dtzSiFive/chisel3 that referenced this pull request Apr 17, 2024
Restore chipsalliance#3912 and chipsalliance#3825.
Use intrinsic expression instead of intrinsic module.

This reverts commit 347d82b.
dtzSiFive added a commit that referenced this pull request Apr 24, 2024
Restore #3912 and #3825.
Use intrinsic expression instead of intrinsic module.

This reverts commit 347d82b.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Code Generation Affects backend code generation, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants