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

feat: implement SerializableModuleElaborator #4409

Merged
merged 2 commits into from
Sep 22, 2024

Conversation

unlsycn
Copy link
Contributor

@unlsycn unlsycn commented Sep 21, 2024

This PR implements the SerializableModuleElaborator trait, which is used to create elaborators for SerializableModule. In t1, we compile all the Scala code into a jar file and specify different main classes to elaborate different modules.
The config API is used to guarantee the type safety of the parameters, and the design API actually produces the circuit, which is used this way:

  @main
  def config(
    @arg(name = "parameter") parameter:  GCDParameterMain,
    @arg(name = "target-dir") targetDir: os.Path = os.pwd
  ) =
    os.write.over(targetDir / s"${topName}.json", configImpl(parameter.convert))

  @main
  def design(
    @arg(name = "parameter") parameter:  os.Path,
    @arg(name = "target-dir") targetDir: os.Path = os.pwd
  ) = {
    val (firrtl, annos) = designImpl[GCD, GCDParameter](os.read.stream(parameter))
    os.write.over(targetDir / s"${topName}.fir", firrtl)
    os.write.over(targetDir / s"${topName}.anno.json", annos)
  }

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 SerializableModuleElaborator

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

linux-foundation-easycla bot commented Sep 21, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@unlsycn unlsycn force-pushed the serializable-elaborator branch 3 times, most recently from 2966d51 to 0495756 Compare September 21, 2024 15:16
@unlsycn unlsycn force-pushed the serializable-elaborator branch 6 times, most recently from 1b07a17 to 4a50ec0 Compare September 22, 2024 12:35
@sequencer sequencer added Feature New feature, will be included in release notes Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI. labels Sep 22, 2024
Copy link
Member

@sequencer sequencer left a comment

Choose a reason for hiding this comment

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

Maybe you or someone can add more documents in the documentation on how to use the SerializableModule in the future, I think for now the chisel-nix project already give a comprehensive example to it. Please update that to use this Elaborator, and point new users to there.

case _: firrtl.options.Unserializable => None
case a => Some(a)
}
val firrtlStream: Readable = fir.serialize
Copy link
Member

Choose a reason for hiding this comment

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

I still doubt there is an extra copy to Sting here, but the return type is good now and we can improve the internal performance with StringBuild in the future.

@chiselbot chiselbot merged commit 2e4f69f into chipsalliance:main Sep 22, 2024
18 of 19 checks passed
debs-sifive pushed a commit that referenced this pull request Oct 15, 2024
* feat: implement SerializableModuleElaborator

Signed-off-by: unlsycn <[email protected]>

* fix: return tuple of Readable from designImpl

Signed-off-by: unlsycn <[email protected]>

---------

Signed-off-by: unlsycn <[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