-
Notifications
You must be signed in to change notification settings - Fork 908
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
$scopeinfo support #4084
$scopeinfo support #4084
Conversation
passes/techmap/flatten.cc
Outdated
log(" -noscopeinfo\n"); | ||
log(" Do not create '$scopeinfo' cells that preserve attributes of cells and\n"); | ||
log(" modules that were removed during flattening. With this option the\n"); | ||
log(" 'src' attributes is handled like it was before '$scopeinfo' was\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: typos here, either "attribute is handled" or "attributes are handled", "separated"
passes/techmap/flatten.cc
Outdated
log(" 'src' attributes is handled like it was before '$scopeinfo' was\n"); | ||
log(" introduced, i.e. multiple 'src' locations are combined separted by\n"); | ||
log(" whitespace. Without this option these 'src' locations can be found\n"); | ||
log(" via the 'cell_src' and 'module_src' attribute of '$scopeinfo' cells.\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest not referring to how this was handled in the past, just explain source locations would be collected from different points on the hierarchy and combined without distinction on the cell post flattening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Also FYI strpool uses |
not whitespace as separator).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I must have been thinking of hdlname
, I'll update the description.
passes/techmap/flatten.cc
Outdated
{ | ||
// The $scopeinfo's name will be changed below after removing the flattened cell | ||
scopeinfo = module->addCell(NEW_ID, ID($scopeinfo)); | ||
scopeinfo->setParam(ID::TYPE, RTLIL::Const("cell")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have probably thought this out already and I am curious to hear it. Should this be cell
or module
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Also sorry for bikeshedding but the only other occurences of enums on cell parameters within Yosys I have seen were on some vendor cells, where the values were fully uppercase. Also e.g. in select syntax we would have the parameter name and its value next to each other. For reasons of consistence we could say the values for an enum-style parameter should be uppercase.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have probably thought this out already and I am curious to hear it. Should this be cell or module?
It refers to a module instantiation (a module
was written by the designer at some point) so I would say "module" and not "cell".
(Also sorry for bikeshedding but the only other occurences of enums on cell parameters within Yosys I have seen were on some vendor cells, where the values were fully uppercase. Also e.g. in select syntax we would have the parameter name and its value next to each other. For reasons of consistence we could say the values for an enum-style parameter should be uppercase.)
I think it's consistent enough with lowercase. In Verilog and RTLIL both the module is spelled as module
, and when extending this I think we might have other scopes such as begin
or maybe struct
. We aren't writing ALGOL to have BEGIN
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's consistent enough with lowercase. In Verilog and RTLIL both the module is spelled as module, and when extending this I think we might have other scopes such as begin or maybe struct. We aren't writing ALGOL to have BEGIN :)
No contest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't decide between "cell" and "module" as which one is more appropriate depends on whether you want to indicate what caused the presence of the scope i.e. the entity that has the same hierarchical name as the $scopeinfo
cell, in which case it would be "cell" (or "instance" if we're using verilog not RTLIL terminology). If we're indicating what defines the contents of the scope then "module" is clearly the correct choice.
Since both approaches make sense to me and changing it is trivial at this point, I went with an arbitrary choice.
Given the feedback so far, I'd change this to "module".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not opposed to instance
, though I feel it might be a little too ambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Currently |
I do want |
Currently opt_merge considers all $scopeinfo cells identical and will remove all but one of them. Should we special-case $scopeinfo there too, or should we perhaps have a global ignorelist in yosys_celltypes that all optimization passes can check against so as to not touch those cells?
Huh, I thought there was some logic to consider cells equal only if the attributes match (except for src I suppose). Or was that only for wires?
… Message ID: ***@***.***>
|
I think that makes sense if we think that list will grow or can already start out containing other cells too. If it's only going to be |
I'm currently working on getting this PR ready (as wall as a followup PR with code to build a $scopeinfo aware hierarchical index for use in yosys passes) and I'm not sure how the various backend passes should treat I'm assuming that the current state of this PR is likely to break existing synthesis setups with other tools potentially failing on unexpected $scopeinfo cells. I can also imagine the $scopeinfo data could eventually be of use for some of the tools that would currently fail due to its presence. Since I use yosys almost exclusively for FV, I could use some input on how to handle this, though. |
Personally, I would be OK with every backend except for CXXRTL and JSON ignoring Maybe we could handle that when we encounter it? |
That also makes sense to me, but for JSON there is the issue that on one hand the JSON backend is intended to include all of the RTLIL netlist but also that nextpnr which reads that JSON output will fail with A way to work around this would be to have the corresponding synth passes explicitly delete Does that sound acceptable? Alternatives would be to get nextpnr to ignore these cells before merging this PR or to ignore |
I think we can do this. |
I am happy to add this if we really want to avoid removing these cells in Yosys - however, despite the lack of any firm compatibility guarantees between Yosys and nextpnr, I do try hard to avoid situations like this (not least because they make bisecting more annoying) and it's been some time since we last had to introduce one. |
I think we can just not emit the |
How about both deleting the |
Now that I think of it, we want |
Well, at least in the future, when the synthesis flow will stop losing source attribution because of a roundtrip through ABC... |
Yes, which is why I proposed to have it in JSON initially. |
We will have the exact same problem with Similarly with any |
As I see it, |
Right, even if I do want |
Either way, I'll update nextpnr to ignore |
I think My current plan for I don't have any opinion, though, on whether to add something temporary and/or optional to the JSON backend and/or to the relevant synth passes to ignore |
My suggestion is:
|
SGTM |
Only declares the cell interface, doesn't make anything use or understand $scopeinfo yet.
While SBY's aiger flow already removes non-assertion driving logic, there are some uses of write_aiger outside of SBY that could end up with $scopeinfo cells, so we explicitly ignore them. The write_btor backend works differently and due to the way it recursively visits cells, it would never reach isolated cells like $scopeinfo.
I've been looking into integrating this with CXXRTL. I've actually hit a small amount of trouble since I'm not entirely sure how to expose both module and cell attributes, but this is CXXRTL-side. I will probably be done with it by the end of next week, but I do not mind having this PR merged before then. |
This PR adds
$scopeinfo
cells to preserve information about the hierarchy during flattening, in particular attributes includingsrc
.This is still missing a kernel header containing utilities for easily querying
$scopeinfo
data.