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

[FIRRTL] Add YAML output to Grand Central #2045

Merged
merged 2 commits into from
Oct 28, 2021

Conversation

seldridge
Copy link
Member

@seldridge seldridge commented Oct 27, 2021

Add support to the Grand Central Views/Interface pass to generate a YAML
description of all interfaces created based on the presence of a
GrandCentralHierarchyFileAnnotation.

This is doing the following things:

  1. This adds some attributes to operations that Grand Central constructs that provide information about what they are (e.g., the symbol associated with a verbatim-encoded interface instance).
  2. A bunch of code using the LLVM YAML library that converts an sv::InterfaceOp to a YAML representation.
  3. Unit tests of the pass.
  4. An extension of the integration test to check YAML output.

@seldridge seldridge force-pushed the dev/seldridge/gct-interfaces-yaml branch from 6f66983 to 8cb62d8 Compare October 28, 2021 05:21
@seldridge seldridge marked this pull request as ready for review October 28, 2021 05:22
@seldridge seldridge force-pushed the dev/seldridge/gct-interfaces-yaml branch from 8cb62d8 to f88768d Compare October 28, 2021 05:30
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

This looks good to me! I also love the ratio of implementation versus tests here 💯 😁

lib/Dialect/FIRRTL/Transforms/GrandCentral.cpp Outdated Show resolved Hide resolved
Comment on lines +118 to +122
/// Conversion from a `DescribedSignal` to YAML. This is
/// implemented using YAML normalization to first convert this to an internal
/// `Field` structure which has a one-to-one mapping to the YAML represntation.
template <>
struct MappingContextTraits<DescribedSignal, Context> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow this really is the most unintuitive YAML library I've seen so far 😢

Copy link
Member Author

Choose a reason for hiding this comment

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

It took me a while to figure out. As I've mentioned, it appears to be ad-hoc polymorphic with some type classes that you have to implement or you get a compiler error. I didn't think this pattern was reasonable to do in C++. 🤯

lib/Dialect/FIRRTL/Transforms/GrandCentral.cpp Outdated Show resolved Hide resolved
Comment on lines +916 to +930
if (anno.isClass("sifive.enterprise.grandcentral."
"GrandCentralHierarchyFileAnnotation")) {
if (maybeHierarchyFileYAML.hasValue()) {
emitCircuitError("more than one 'GrandCentralHierarchyFileAnnotation' "
"was found, but zero or one may be provided");
removalError = true;
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like something @darthscsi will eventually want to have as a firtool CLI argument rather than an annotation 😁. But good to have it here so we are compatible with the Scala implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree.

Comment on lines +196 to +252
; YAML: FILE "Wire/firrtl/gct/gct.yaml"
; YAML: - name: MyInterface
; YAML-NEXT: fields:
; YAML-NEXT: - name: uint
; YAML-NEXT: description: 'a wire called ''uint'''
; YAML-NEXT: dimensions: [ ]
; YAML-NEXT: width: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

This all looks very nice!

@seldridge seldridge force-pushed the dev/seldridge/gct-interfaces-yaml branch from f88768d to d304914 Compare October 28, 2021 19:19
Add support to the Grand Central Views/Interface pass to generate a YAML
description of all interfaces created based on the presence of a
GrandCentralHierarchyFileAnnotation.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge force-pushed the dev/seldridge/gct-interfaces-yaml branch from d304914 to 46b8d7a Compare October 28, 2021 19:56
@seldridge seldridge merged commit 6a45ada into main Oct 28, 2021
@seldridge seldridge deleted the dev/seldridge/gct-interfaces-yaml branch October 28, 2021 23:32
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.

2 participants