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] Isolate reset inference to a cast rather than connect #4804

Merged
merged 14 commits into from
Apr 8, 2023

Conversation

darthscsi
Copy link
Contributor

@darthscsi darthscsi commented Mar 10, 2023

Add a resetCast operation. This lets more connects be strictconnects as more typeconversion can be expressed explicitly.

Copy link
Contributor

@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

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

Generally LGTM!

Added some comments. Should this support aggregates / references (which are kinda like aggregates in a type sense)?

Can't speak for this direction as brain is a bit full of references, but this makes sense to me re:approach, and breaking out RTP probably needs to happen, thanks!

Should this be added to FIRRTLVisitor ?

Cast between reset types. This is used to enable strictconnects early in
the pipeline by isolating all uninferred reset connections to a single op.
}];
let arguments = (ins AnyResetType:$input);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this instead cast between aggregate types that contain resets? That would help to use this in front of connects before LowerTypes, and similarly with references / ref-define.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm leaning towards splitting connect up instead.

@@ -88,6 +89,12 @@ void circt::firrtl::emitConnect(ImplicitLocOpBuilder &builder, Value dst,
return;
}

if ((dstType.hasUninferredReset() || srcType.hasUninferredReset()) &&
dstType != srcType) {
src = builder.create<UninferredResetCastOp>(dstType, src);
Copy link
Contributor

@dtzSiFive dtzSiFive Mar 13, 2023

Choose a reason for hiding this comment

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

(if UninferredResetCastOp supports aggregates, this could be hoisted above the checks for connecting bundles/vectors)

; CHECK: %3 = firrtl.subfield %b[b] : !firrtl.bundle<a: reset, b: reset>
; CHECK: %4 = firrtl.subfield %a[b] : !firrtl.bundle<a: uint<1>, b: asyncreset>
; CHECK: %[[r4:.*]] = firrtl.resetCast %4
; CHECK: firrtl.strictconnect %3, %[[r4]] : !firrtl.reset
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any dedicated tests / errors to check for this new operation?

@dtzSiFive
Copy link
Contributor

(micro-nit: commit/PR title: s/Issolate/Isolate/)

@darthscsi darthscsi changed the title [FIRRTL] Issolate reset inference to a cast rather than connect [FIRRTL] Isolate reset inference to a cast rather than connect Mar 13, 2023
@darthscsi darthscsi merged commit 7563aaa into main Apr 8, 2023
@darthscsi darthscsi deleted the dev/darthscsi/InferResetCast branch April 11, 2024 17:14
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