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

add ElaborationArtefactAnnotation #2727

Merged
merged 3 commits into from
Nov 12, 2020

Conversation

albertchen-sifive
Copy link
Contributor

Stopgap solution to issue of ElaborationArtefacts outputting stale instance paths. This adds ElaborationArtefactAnnotation which contains the filename and list of Tokens that contain the contents of the file. Token subclasses are StringToken, ModulePathToken, and ReferencePathToken. ModulePathToken and ReferencePathToken contain Targets that are updated by firrtl. ElaborationArtefactsTransform serializes the ElaborationArtefactAnnotations

ElaborationArtefactAnnotations can be annotated with the ElaborationArtefactAnnotation.annotate and Token.apply methods e.g.

ElaborationArtefactAnnotation.annotate("foo.json",
  Seq(Token(s"""{ foo: $foo, bar: $bar, mod: """"), Token(module), Token("""", ref: """"), Token(module.reset), Token("""" }"""))

there is a TokensInterpolator implicit to make constructing Tokens easier.

ElaborationArtefactAnnotation.annotate("foo.json",
  tokens"""{ foo: $foo, bar: $bar, mod: $module, ref: ${module.reset} }""")

Token.apply requires a Tokenizer typeclass instance. instances are defined for String, Data, BaseModule, SyncReadMem

Type of change: feature request

Impact: API addition (no impact on existing code)

Development Phase: implementation

Release Notes

@albertchen-sifive albertchen-sifive merged commit 923ec05 into master Nov 12, 2020
@albertchen-sifive albertchen-sifive deleted the elaboration-artefacts-annotation branch November 12, 2020 02:28
@DecodeTheEncoded
Copy link

so, what is the purpose of ElaborationArtefacts in general? I have no idea what it is for? Thanks!

@albertchen-sifive
Copy link
Contributor Author

ElaborationArtefacts is a way to emit metadata to the generator build directory during elaboration. it's used to emit graphml and dts along with a bunch of other metadata files

ElaborationArtefacts.add("graphml", outer.graphML)
ElaborationArtefacts.add("dts", outer.dts)
ElaborationArtefacts.add("json", outer.json)
ElaborationArtefacts.add("plusArgs", PlusArgArtefacts.serialize_cHeader)

the ElaborationArtefacts.add method takes two arguments, first one is the file extension and the second is the contents of that file as a String. so ElaborationArtefacts.add("foo", "bar") would write a file called $configName.foo with contents bar, where $configName would be either the config name or the name specified by the --name cmdline argument if it is present.

this PR adds ElaborationArtefactsAnnotation which works similarly to ElaborationArtefacts except that it is passed as an annotation through the firrtl compiler and takes a list of Tokens which may embed firrtl Targets. this allows for emitting metadata that relies on having correct instance paths and signal names.

@DecodeTheEncoded
Copy link

ElaborationArtefacts is a way to emit metadata to the generator build directory during elaboration. it's used to emit graphml and dts along with a bunch of other metadata files

ElaborationArtefacts.add("graphml", outer.graphML)
ElaborationArtefacts.add("dts", outer.dts)
ElaborationArtefacts.add("json", outer.json)
ElaborationArtefacts.add("plusArgs", PlusArgArtefacts.serialize_cHeader)

the ElaborationArtefacts.add method takes two arguments, first one is the file extension and the second is the contents of that file as a String. so ElaborationArtefacts.add("foo", "bar") would write a file called $configName.foo with contents bar, where $configName would be either the config name or the name specified by the --name cmdline argument if it is present.

this PR adds ElaborationArtefactsAnnotation which works similarly to ElaborationArtefacts except that it is passed as an annotation through the firrtl compiler and takes a list of Tokens which may embed firrtl Targets. this allows for emitting metadata that relies on having correct instance paths and signal names.

Sorry for the delayed reply, Thank you for your detailed reply, I got it!

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