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

Implement typeName API for stable Module names #3130

Merged
merged 27 commits into from
Apr 5, 2023
Merged

Implement typeName API for stable Module names #3130

merged 27 commits into from
Apr 5, 2023

Conversation

jared-barocsi
Copy link
Contributor

@jared-barocsi jared-barocsi commented Mar 22, 2023

typeName is a new member of Data types which specifies a default, non-ambiguous name of its type. This is useful for problems like generating a descriptive name for a Chisel type, as it allows modules (e.g. Queue) to use this naming information for their own desiredName.

As a motivating use case, Queue modules now have a default name based on the depth parameter of the Queue as well as the generated typeName of the Chisel type passed to it. For example, Queue4_UInt4 describes a Queue of size 4 which takes a UInt(4.W), and would be the default desiredName of such a queue.

User-defined types like Bundles should override this feature if needed to diversify the names of Modules that use them, preventing situations like multiple Queues all sharing the same name and having unstable names as a result.

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

  • new feature/API

API Impact

Adds a new public-facing feature to Data

Backend Code Generation Impact

Module names in FIRRTL will now include the parameter information of their respective Chisel modules in their names (via overriding desiredName), and consequently Verilog names will differ as well.

Desired Merge Strategy

Squash and merge

Release Notes

This gives a flexible way to generate a stable name for a Chisel type, which is useful for problems like generating stable names for Modules and Queues

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (Bug fix: 3.5.x or 3.6.x depending on impact, API modification or big change: 5.0.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

@mwachs5 mwachs5 left a comment

Choose a reason for hiding this comment

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

@jared-barocsi
Copy link
Contributor Author

Should you update the naming cookbook, especially https://github.com/chipsalliance/chisel/blob/main/docs/src/cookbooks/naming.md#my-module-names-are-super-unstable---i-change-one-thing-and-queue_1-becomes-queue_42-help after this change?

I think I will, but also clarify that queue names will still have some measure of instability based on the specificity of the typeName that's being used, and that users should add enough relevant parameter information to a typeName as necessary.

Copy link
Contributor

@mwachs5 mwachs5 left a comment

Choose a reason for hiding this comment

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

LGTM!

@mwachs5 mwachs5 added the Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI. label Apr 5, 2023
@mergify mergify bot merged commit 0ce115e into main Apr 5, 2023
@mergify mergify bot deleted the typename-api branch April 5, 2023 20:55
@jackkoenig jackkoenig added the Feature New feature, will be included in release notes label Apr 6, 2023
jared-barocsi added a commit that referenced this pull request Apr 11, 2023
* Implement `typeName` API for a few `Data` types

* Fix silly compilation error

* Implement typeName API further for most data types and modules which need it

* Compilation error fixes

* Remove width parameter from Bool

* Test for Queue naming using typeNames

* Remove width-sensitive override for AsyncReset as it is irrelevant

* Add typeName for Analogs

* Add additional types to be tested

* Scalafmt

* Use circt ChiselStage

* Update queue naming of existing tests

* Scalafmt

* Change pipe desiredName to be consistent with other modules

* Update naming cookbook

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Add SInt to TypenameSpec

* Fix cookbook mdoc errors

* compileOnly tag on scala code

* More improvements of mdoc

* compileOnly -> compile-only

* Final mdoc review and fixes

* Add inferred UInt to test

---------

Co-authored-by: Megan Wachs <[email protected]>
azidar pushed a commit that referenced this pull request Apr 11, 2023
* Implement `typeName` API for a few `Data` types

* Fix silly compilation error

* Implement typeName API further for most data types and modules which need it

* Compilation error fixes

* Remove width parameter from Bool

* Test for Queue naming using typeNames

* Remove width-sensitive override for AsyncReset as it is irrelevant

* Add typeName for Analogs

* Add additional types to be tested

* Scalafmt

* Use circt ChiselStage

* Update queue naming of existing tests

* Scalafmt

* Change pipe desiredName to be consistent with other modules

* Update naming cookbook

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Add SInt to TypenameSpec

* Fix cookbook mdoc errors

* compileOnly tag on scala code

* More improvements of mdoc

* compileOnly -> compile-only

* Final mdoc review and fixes

* Add inferred UInt to test

---------

Co-authored-by: Megan Wachs <[email protected]>
@jackkoenig
Copy link
Contributor

@Mergifyio backport 3.6.x

Copy link
Contributor

mergify bot commented Jun 5, 2024

backport 3.6.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jun 5, 2024
* Implement `typeName` API for a few `Data` types

* Fix silly compilation error

* Implement typeName API further for most data types and modules which need it

* Compilation error fixes

* Remove width parameter from Bool

* Test for Queue naming using typeNames

* Remove width-sensitive override for AsyncReset as it is irrelevant

* Add typeName for Analogs

* Add additional types to be tested

* Scalafmt

* Use circt ChiselStage

* Update queue naming of existing tests

* Scalafmt

* Change pipe desiredName to be consistent with other modules

* Update naming cookbook

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Add SInt to TypenameSpec

* Fix cookbook mdoc errors

* compileOnly tag on scala code

* More improvements of mdoc

* compileOnly -> compile-only

* Final mdoc review and fixes

* Add inferred UInt to test

---------

Co-authored-by: Megan Wachs <[email protected]>
(cherry picked from commit 0ce115e)

# Conflicts:
#	docs/src/cookbooks/naming.md
#	src/main/scala/chisel3/util/Decoupled.scala
#	src/main/scala/chisel3/util/Valid.scala
@jackkoenig
Copy link
Contributor

Backport requested by @jerryz123

jackkoenig added a commit that referenced this pull request Jun 24, 2024
* Implement `typeName` API for a few `Data` types

* Fix silly compilation error

* Implement typeName API further for most data types and modules which need it

* Compilation error fixes

* Remove width parameter from Bool

* Test for Queue naming using typeNames

* Remove width-sensitive override for AsyncReset as it is irrelevant

* Add typeName for Analogs

* Add additional types to be tested

* Scalafmt

* Use circt ChiselStage

* Update queue naming of existing tests

* Scalafmt

* Change pipe desiredName to be consistent with other modules

* Update naming cookbook

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Add SInt to TypenameSpec

* Fix cookbook mdoc errors

* compileOnly tag on scala code

* More improvements of mdoc

* compileOnly -> compile-only

* Final mdoc review and fixes

* Add inferred UInt to test

---------

Co-authored-by: Megan Wachs <[email protected]>
(cherry picked from commit 0ce115e)

# Conflicts:
#	docs/src/cookbooks/naming.md
#	src/main/scala/chisel3/util/Decoupled.scala
#	src/main/scala/chisel3/util/Valid.scala
chiselbot pushed a commit that referenced this pull request Jun 24, 2024
* Implement typeName API for stable Module names (#3130)

* Implement `typeName` API for a few `Data` types

* Fix silly compilation error

* Implement typeName API further for most data types and modules which need it

* Compilation error fixes

* Remove width parameter from Bool

* Test for Queue naming using typeNames

* Remove width-sensitive override for AsyncReset as it is irrelevant

* Add typeName for Analogs

* Add additional types to be tested

* Scalafmt

* Use circt ChiselStage

* Update queue naming of existing tests

* Scalafmt

* Change pipe desiredName to be consistent with other modules

* Update naming cookbook

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Update docs/src/cookbooks/naming.md

Co-authored-by: Megan Wachs <[email protected]>

* Add SInt to TypenameSpec

* Fix cookbook mdoc errors

* compileOnly tag on scala code

* More improvements of mdoc

* compileOnly -> compile-only

* Final mdoc review and fixes

* Add inferred UInt to test

---------

Co-authored-by: Megan Wachs <[email protected]>
(cherry picked from commit 0ce115e)

# Conflicts:
#	docs/src/cookbooks/naming.md
#	src/main/scala/chisel3/util/Decoupled.scala
#	src/main/scala/chisel3/util/Valid.scala

* Resolve conflicts, remove desiredName overrides, remove docs

All things that are removed can be enjoyed by users by bumping to a
newer version of Chisel.

---------

Co-authored-by: Jack Koenig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature, will be included in release notes Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants