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 FIRRTL type alias mechanism for Bundles #3445

Merged
merged 45 commits into from Sep 8, 2023

Conversation

jared-barocsi
Copy link
Contributor

Adds a simple mechanism to the Bundle type that emits a FIRRTL type alias statement as detailed in the FIRRTL spec.

This is achieved by overriding an aliasName: Option[String] with a non-empty string, resulting in a type ... = { ... } statement emitted in the FIRRTL. Additionally, any further definitions that normally use the bundle type now use the alias as the type.

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

  • Feature (or new API)

Desired Merge Strategy

Squash

Release Notes

Add aliasName to Bundles: a way for users to define a type alias for a bundle type, resulting in the emission and usage of alias type statements in FIRRTL.

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.5.x, 3.6.x, or 5.x depending on impact, API modification or big change: 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.

@jared-barocsi jared-barocsi added the Feature New feature, will be included in release notes label Jul 28, 2023
core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
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/TypeAliasSpec.scala Outdated Show resolved Hide resolved
@@ -280,7 +280,8 @@ object Serializer {
writers.foreach { w => b ++= "writer => "; b ++= legalize(w); newLineAndIndent(1) }
readwriters.foreach { r => b ++= "readwriter => "; b ++= legalize(r); newLineAndIndent(1) }
b ++= "read-under-write => "; b ++= readUnderWrite.toString
case Attach(info, exprs) =>
case DefTypeAlias(info, name, tpe) => b ++= "type "; b ++= name; b ++= " = "; s(tpe); s(info)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
case DefTypeAlias(info, name, tpe) => b ++= "type "; b ++= name; b ++= " = "; s(tpe); s(info)
case DefTypeAlias(info, name, tpe) => b ++= "type "; b ++= name; b ++= " = "; s(tpe);

Info locators are not supported on type alias statements. They're not in the spec grammar and firtool rejects them, so probably best to omit.

(not sure whether this removal should propagate up to remove it from DefTypeAlias and etc., but maybe?)

@jared-barocsi jared-barocsi enabled auto-merge (squash) August 29, 2023 22:06
core/src/main/scala/chisel3/Data.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/internal/package.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
@dtzSiFive
Copy link
Member

dtzSiFive commented Sep 2, 2023 via email

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! Thanks for the docs. though they are more starting to get more to explanation than cookbook, it is better than not having any docs to point to at all.

@jared-barocsi jared-barocsi merged commit 8d8b5f5 into main Sep 8, 2023
15 checks passed
@jared-barocsi jared-barocsi deleted the chisel-emit-type-aliases branch September 8, 2023 22:38
@jared-barocsi jared-barocsi mentioned this pull request Sep 8, 2023
14 tasks
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants