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

Wrap printfs in the Verification layerblock #4506

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

seldridge
Copy link
Member

Change the emission of printfs to emit these under the Verification layerblock. This is done as part of replacing the firtool extract-test-code feature with layers and the "advanced layer sink" firtool feature.

The extract-test-code feature will extract asserts and printfs together. This is technically a deviation from this behavior. However, it seems better to not lump these in with asserts. Nonetheless, this is a backwards compatible change from the perspective of extract-test-code because the Verification layer is always loaded if the Assert layer is present. (Prints will always show up if you turn on assertions.)

In the future, we probably want to add a Debug layer under the Verification layer where these will live. I would like to hold off on making this change until extract-test-code is gone.

Release Notes

Move printfs under the Verification layer by default.

Change the emission of printfs to emit these under the `Verification`
layerblock.  This is done as part of replacing the `firtool`
extract-test-code feature with layers and the "advanced layer sink"
`firtool` feature.

The extract-test-code feature will extract asserts _and_ printfs
together. This is technically a deviation from this behavior.  However, it
seems better to not lump these in with asserts.  Nonetheless, this is a
backwards compatible change from the perspective of extract-test-code
because the `Verification` layer is always loaded if the `Assert` layer is
present.  (Prints will always show up if you turn on assertions.)

In the future, we probably want to add a `Debug` layer under the
`Verification` layer where these will live.  I would like to hold off on
making this change until extract-test-code is gone.

Signed-off-by: Schuyler Eldridge <[email protected]>
@seldridge seldridge added the Backend Code Generation Affects backend code generation, will be included in release notes label Nov 13, 2024
@seldridge seldridge requested review from rwy7 and jackkoenig November 13, 2024 23:35
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.

LGTM

@@ -8,24 +8,20 @@ import circt.stage.ChiselStage
class SinglePrintfTester() extends Module {
val x = 254.U
printf("x=%x", x)
stop()
Copy link
Member Author

Choose a reason for hiding this comment

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

This stop is removed so that the test can simply check if a layerblock shows up. Stops are placed under layerblocks which means that the test would pass even without the change in this PR to move printfs under layers.

FileCheck would really help here. 🙃

@seldridge seldridge enabled auto-merge (squash) November 13, 2024 23:44
@sequencer
Copy link
Member

What if user specially want to put the printf into another layer?

@seldridge seldridge merged commit abaf2b2 into main Nov 13, 2024
18 checks passed
@seldridge seldridge deleted the dev/seldridge/printfs-in-verification-layer branch November 13, 2024 23:54
@seldridge
Copy link
Member Author

What if user specially want to put the printf into another layer?

If the user wraps them in any other layer, then the printf will go in that layer. If the user puts them in a module with layers enabled, then they will not be put in a layer.

This is using the same additional arguments that layer.block has for skipIfAlreadyInBlock and skipIfLayersEnabled: https://github.com/chipsalliance/chisel/pull/4506/files#diff-989569982cecd89c52b0475d7be8bba9b776eb074224f89791a1c02f6fb6c1feR79

So, a user can override this on a case-by-case basis.

If the user wants to globally change a layer to another layer or if they cannot change the printfs, then they need to use the --remap-layers argument to Chisel (#4322). The case for this is if we have printfs in upstream Chisel and the user wants to put these into a different layer, but can't modify the source.

@sequencer
Copy link
Member

neat!

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.

3 participants