Add safer Chisel annotation API, deprecate old ones (backport #4643) #4697
+286
−203
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.
Note that I tested that the deprecated versions of
annotate
work by updating them first, making sure all tests pass, then removing all uses of ChiselAnnotation and ChiselMultiAnnotation except in ChiselEnum. The ones in ChiselEnum have duplication checking that I could replicate with the annotations, but is annoying. I figure we'd rather just remove those (and roll out firrtl enums? 🙏) so I just left them. They also do help test the deprecated APIs.This PR has two purposes:
(2) will be in a follow on PR.
One weirdness in the PR that I would appreciate review of is that the new API asks the caller to "report" all
InstanceIds
that will be annotated. We really only currently care aboutData
but I figure in the future we may want checks for other things. The awkwardness though, is thatInstanceId
includesData
,BaseModule
, andMemBase
, but notHierarchy
nor the new SRAM targets. So if we wanted more checks, we might need to change the API anyway in the future since users can't currently reportHierarchy
orSRAM
targets being annotated. I could take a step back and try to find a way to unify all of these, or just leave it, or switch the API toData
to make it more clear that that is all we're checking. WDYT?Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Creating annotations in Chisel now requires reporting what
InstanceIds
are going to be annotated so that Chisel can do some safety checks.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
.This is an automatic backport of pull request #4643 done by [Mergify](https://mergify.com).