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][OMIR] Update OMIR SRAM Paths #2024

Merged
merged 10 commits into from
Oct 22, 2021
Merged

Conversation

prithayan
Copy link
Contributor

@prithayan prithayan commented Oct 21, 2021

This PR converts the SRAM paths in the OMIR from local to absolute paths.

  1. If the OMIR annotation has the field OMString:OMSRAM, then it is a candidate for path replacement.
  2. Record its tracker id, and search for the corresponding FIRRTL node, with the same tracker id.
  3. Next, get the instance path for the module, and construct the corresponding NonLocalAnchor.
  4. Add this NonLocalAnchor to the SRAM node.
  5. The following emission will generate the absolute appropriate path.
  6. Remove the firrtl.nla after processing.

Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

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

This is coming together nicely! Some notes throughout.

One thing: this currently requires that the blackbox memory pass is being run. If this runs without blackbox memory, then it'll error out due to emitTrackedTarget not handling firrtl.mem: SRAM.scala:38:34: error: invalid target for "OMMemberReferenceTarget" OMIR. I think this is just a missing case there.

Additionally, if you run with blackbox memory, that appears to be dropping the tracker annotations and you wind up with OMDeleted in the output. 😬

lib/Dialect/FIRRTL/Transforms/EmitOMIR.cpp Outdated Show resolved Hide resolved
lib/Dialect/FIRRTL/Transforms/EmitOMIR.cpp Outdated Show resolved Hide resolved
lib/Dialect/FIRRTL/Transforms/EmitOMIR.cpp Outdated Show resolved Hide resolved
lib/Dialect/FIRRTL/Transforms/EmitOMIR.cpp Outdated Show resolved Hide resolved
lib/Dialect/FIRRTL/Transforms/EmitOMIR.cpp Outdated Show resolved Hide resolved
lib/Dialect/FIRRTL/Transforms/EmitOMIR.cpp Outdated Show resolved Hide resolved
lib/Dialect/FIRRTL/Transforms/EmitOMIR.cpp Outdated Show resolved Hide resolved
lib/Dialect/FIRRTL/Transforms/EmitOMIR.cpp Outdated Show resolved Hide resolved
test/Dialect/FIRRTL/SFCTests/emit-omir.fir Outdated Show resolved Hide resolved
test/Dialect/FIRRTL/emit-omir.mlir Outdated Show resolved Hide resolved
@seldridge
Copy link
Member

seldridge commented Oct 22, 2021

I fixed the issue with BlackBoxMemory not copying over annotations in f239be4. This didn't touch annotations on ports. I'll file an issue about that (#2026).

@prithayan
Copy link
Contributor Author

I think I addressed most of the review comments.
Regarding BlackBox memory, I don't think we can run black box memory pass with the current memory lowering flow.
Lets try to see, if its enough to just handle the firrtl.mem here instead of the firrtl.instance.

fabianschuiki and others added 5 commits October 22, 2021 10:45
Extend the `EmitOMIR` pass to handle the conversion of relative targets
in the `instancePath` field of `OMSRAM` nodes to absolute targets.
@fabianschuiki
Copy link
Contributor

I've updated a few things and added additional test cases to ensure the SRAM path expansion also works on firrtl.mem operations.

@fabianschuiki fabianschuiki added the FIRRTL Involving the `firrtl` dialect label Oct 22, 2021
lib/Dialect/FIRRTL/Transforms/EmitOMIR.cpp Outdated Show resolved Hide resolved
Comment on lines +31 to +34
// expected-error @+4 {{OMIR node targets ambiguous component `mem`}}
// expected-note @+3 {{may refer to the following paths:}}
// expected-note @+2 {{- $root/sub1:Submodule}}
// expected-note @+1 {{- $root/sub2:Submodule}}
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

NamedAttrList fields;
fields.append("id",
IntegerAttr::get(IntegerType::get(ctx, 64), annotationID++));
fields.append("omir.tracker", UnitAttr::get(ctx));
fields.append("path", StringAttr::get(ctx, path));
Copy link
Member

Choose a reason for hiding this comment

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

Good thought to include this for error reporting later.

@fabianschuiki
Copy link
Contributor

Thanks for the reviews @seldridge. Going to merge this now. @prithayan has a follow-up PR adding a command line option to firtool to specify the OMIR output file explicitly.

@fabianschuiki fabianschuiki merged commit b77f14b into main Oct 22, 2021
@fabianschuiki fabianschuiki deleted the dev/fschuiki/omir-srams branch October 22, 2021 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FIRRTL Involving the `firrtl` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants