-
Notifications
You must be signed in to change notification settings - Fork 292
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] Type Canonicalization May Require Connect Canonicalization #380
Comments
I think this came up when flattening bundle types, specifically when generating connects for each field. I added this logic to check if the field was flipped, and swap the LHS and RHS accordingly: circt/lib/Dialect/FIRRTL/Transforms/LowerTypes.cpp Lines 327 to 330 in 92571ec
That seemed to work, but I wasn't sure if something more robust would be needed... |
This will accept more circuits than we want, but I've already advocated for falsely accepting circuits as being preferable to falsely rejecting circuits. Your solution seems fine right now, @mikeurbach. 👍 As a note: seeing any usages of aggregates using |
The other underlying problem here is that if What I seem to be running into is that the FIRRTL spec is wrapping up types, kinds, and flows into the type system while we only capture the former. I've thought about using the RTL dialect's |
Yes, I agree that port canonicalization into types is going to be problematic for the whole notion of 'flow' in section 8 of the firrtl spec. Your examples are great:
I don't think that flip canonicalization is the actual problem, it is that we model output as flip that is the issue. I think we have two options:
I'm in favor of #2 unless there is a downside. |
should this stay open? |
I think we can close this. We've been pushing in the If I have a clear situations that requires us to flip a connect, I'll re-open this. |
Consider the following two circuits that the Scala FIRRTL Compiler (SFC) treats as equivalent:
Here, the inputs are flipped and the connection order is flipped:
Either a connect (
<=
) or partial connect (<-
) can be used.This is problematic, because MLIR FIRRTL Dialect type canonicalization changes the types of the ports from
Foo2
into those ofFoo1
. However, the connect is untouched.I'm not 100% sure how to handle this, but this may require tracking when type canonicalization results in an outer flip and then optionally updating the LHS and RHS.
Simply swapping the connection order so it works is differently problematic because this will cause erroneous circuits to be accepted, e.g.,
a <= b
would then work inFoo1
andb <= a
would work inFoo2
when these are rejected by the SFC.The text was updated successfully, but these errors were encountered: