-
Notifications
You must be signed in to change notification settings - Fork 28
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
When to use <-
or <=
#52
Comments
I think you could be right that the eventual (near future?) move is to remove it from the spec. Current chisel3 project emits But neither of those changes are yet in an official supported version of chisel3 which is a major producer of .fir IR, so removing the operator is not something we could commit immediately to the spec (as it would be a major change and we may want to coordinate ordering of other major breaking changes). But feel free to open a PR! |
The main difference between the two is that there can be missing fields or mismatched UInt width fields in a
The I'm not sure why you say there is no formal definition of it, it is described at the same level as the Connect is in the "Partial Connect" section: https://github.com/chipsalliance/firrtl-spec/blob/main/spec.md#partial-connects just after the Connect sectinon. Which i guess you found since the example you pasted is from there, which shows that the |
My confusing might stem from the fact that the second example also uses So a quick idea that does not break anything would be
myinput.a <= myoutput.a
myoutput.b[0] <= myinput.b[0]
myoutput.b[1] <= myinput.b[1] stressing the difference in the connection and
above. I can prepare a PR for that if the idea sounds good. |
I'm actually now wondering if
(or the way it was written before) is even legal firrtl, i thought we didn't support that on the LHS until #26 lands a better way would be showing the sub-extraction on the RHS https://github.com/chipsalliance/firrtl-spec/blob/main/spec.md#bit-extraction-operation
with maybe a comment on what it's actually doing since we haven't really explained |
Yeah, the example should really just be:
IMO, it would be better to show this as a vector and a bundle as this is where the behavior of connect and partial connect differ. I.e., the original point of partial connect I'd suggest the following two examples. This shows the behavior of partial connect for vectors:
This becomes (
The bundle equivalent is:
This becomes:
Both of these examples are illegal if the partial connects are replaced with connects. Going forward, I think we will likely drop partial connect
This connect/strict connect split is what we use in the MLIR-based FIRRTL Compiler (MFC, i.e., CIRCT). All partial connects are removed during parsing and everything is converted to strict connect (with appropriate pads/tails) when possible (and connect will canonicalize to strict connect for convenience). Unknown widths prevents everything from being converted to strict connect immediately, though. This results in a relatively verbose IR, however, this can be remedied with additional operators |
Now I am confused, I read what you have written above @seldridge as it is legal to do
but the Connect section of the spec has this condition 2:
Condition 1 is OK because the bit widths don't matter for Uint type equivalence, as clearly stated. But then what is the (additional, only for Connect not Partial Connect) condition 2 trying to stay, if not that the above is illegal? |
Great point @mwachs5. The spec is actually wrong here! The SFC never obeyed this and did implicit truncation for connect as well. The MFC then inherited this behavior. For practical reasons, we should change the spec to align with the implementations. Example:
SFC ( module Foo(
input [1:0] a,
output [2:0] b,
output c
);
assign b = {{1'd0}, a};
assign c = a[0];
endmodule MFC ( // Generated by CIRCT unknown git version
module Foo(
input [1:0] a,
output [2:0] b,
output c);
assign b = {1'h0, a};
assign c = a[0];
endmodule For completeness of the example, if this is changed to partial connect it behaves the same:
SFC: module Foo(
input [1:0] a,
output [2:0] b,
output c
);
assign b = {{1'd0}, a};
assign c = a[0];
endmodule MFC: // Generated by CIRCT unknown git version
module Foo(
input [1:0] a,
output [2:0] b,
output c);
assign b = {1'h0, a};
assign c = a[0];
endmodule |
Thank you very much for the discussion. This clarified a lot for me. Is there a decision on changing the spec and if so, how? I am more than happy with creating a PR if that is helpful. |
@keszocze yes, i think we should:
I think we can have this as a |
Mea culpa! Yup. Thank you @keszocze for pointing this out. Indeed. SFC (and now MFC) always implicitly truncate the connections. I believe originally that this width restriction on connections was only for FIRRTL in Low Form, but something was lost in translation and the spec wasn't updated. |
Connect is now marked as truncating after 9d040da. |
Partial connect is now gone after d569a5a. This should fully close this issue. Feel free to re-open if there's more to discuss! |
I am wondering when exactly the single line arrow
<-
is used to connect things. In the Partial Connects Section they are usedI searched the document for further occurrences of
<-
and found none. What exactly are the semantics of<-
? It does not seem to be a typo as<-
is also used to define the grammar in the Language Definition SectionI propose to either
<-
from the spec or<-
.I am very much in favor of 1 as it simplifies the grammar and I do not see the need for a distinction between partial and non-partial assignments in the first place.
If there is a consensus here, I will happily prepare a corresponding pull request.
The text was updated successfully, but these errors were encountered: