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

Require AutoCloneType #2945

Merged
merged 9 commits into from
Jan 27, 2023

Conversation

adkian-sifive
Copy link
Contributor

@adkian-sifive adkian-sifive commented Jan 18, 2023

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 state the API impact?
  • Did you specify the code generation impact?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • code cleanup

API Impact

Deprecate cloneType for bundles and let the compiler plugin automatically clone bundle fields. Better error message for cases where the plugin is not able to clone types.

Backend Code Generation Impact

Desired Merge Strategy

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

Release Notes

Records now have auto cloneType always enabled. chisel3.experimental.AutoCloneType is now deprecated.

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (Bug fix: 3.4.x, [small] API extension: 3.5.x, API modification or big change: 3.6.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.

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.

This is close but I think there was a slight miscommunication on the idea--it's not that users should be required to mixin AutoCloneType, it's that AutoCloneType applies to all Records automatically and manually implementing cloneType is now banned.

core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
src/test/scala/chiselTests/AutoClonetypeSpec.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
class CustomBundleBroken(elts: (String, Data)*) extends Record {
val elements = ListMap(elts.map {
case (field, elt) =>
field -> DataMirror.internal.chiselTypeClone(elt)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this what we want vs chiselTypeOf(...) ? I wish we could just settle on one API here.

In other words, I don't want to actively encourage some weird pattern that people should never be doing in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is the right one, I'm not sure if chiselTypeOf clones the type

Copy link
Contributor

Choose a reason for hiding this comment

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

chiselTypeOf clones the type, it's the same as chiselTypeClone except it also checks that the type is bound as hardware. In this case, the elts will not be bound hardware so we need chiselTypeClone.

I agree we should settle on one API but they have different uses and figuring out how to not need both uses is subtle and beyond this PR.

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! I have a few very nitty suggestions but I will just merge them. Thanks!

core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
docs/src/cookbooks/cookbook.md Outdated Show resolved Hide resolved
docs/src/cookbooks/cookbook.md Outdated Show resolved Hide resolved
docs/src/cookbooks/cookbook.md Outdated Show resolved Hide resolved
@jackkoenig jackkoenig enabled auto-merge (squash) January 27, 2023 00:39
@jackkoenig jackkoenig added this to the 3.6.0 milestone Jan 27, 2023
@jackkoenig jackkoenig merged commit a64dd82 into chipsalliance:master Jan 27, 2023
ZenithalHourlyRate added a commit to chipsalliance/rocket-chip that referenced this pull request Feb 11, 2023
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.

3 participants