-
Notifications
You must be signed in to change notification settings - Fork 893
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
Verilog globals appended to modules instead of prepended #4653
Comments
!source_offset && !id2ast->range_swapped
)!source_offset && !id2ast->range_swapped
)
Found an even simpler example, which indicates the issue manifests when using struct fields anywhere: typedef struct packed {
logic y;
logic x;
} Vec_2_B;
(* top *)
module Top;
Vec_2_B two_dee;
wire foo = two_dee.x;
endmodule |
Another hint: this other example seems to work fine. (* top *)
module Top;
typedef struct packed {
logic y;
logic x;
} Vec_2_B;
Vec_2_B two_dee;
wire foo = two_dee.x;
endmodule |
More hints: dumping the AST for both cases reveals only a single meaningful difference: the placement of the
|
!source_offset && !id2ast->range_swapped
)
Tried the obvious thing after seeing both ASTs (getting the global Verilog definitions to be at the beginning of the module definition instead of the end) and it seems to solve not only this particular problem, but apparently any usage of them in general (even if I didn't trigger this particular issue, global So, in // [...]
if (child->type == AST_MODULE || child->type == AST_INTERFACE)
{
for (auto n : design->verilog_globals)
child->children.push_back(n->clone());
// [...]
to: // [...]
if (child->type == AST_MODULE || child->type == AST_INTERFACE)
{
for (auto n : design->verilog_globals)
child->children.insert(child->children.begin(), n->clone());
// [...] seems to work fine. I'll make a PR for it ASAP, although I don't know whether this fix is just hiding a deeper problem. In any case, that's not a decision for me to take I guess. |
Fixes YosysHQ#4653. Further AST and RTLIL stages seem to be order-sensitive, and appending globals to the module children list did not work.
Fixes YosysHQ#4653. Further AST and RTLIL stages seem to be order-sensitive, and appending globals to the module children list did not work.
Version
Yosys 0.46+11 (git sha1 0200a76, clang++ 14.0.0-1ubuntu1.1 -fPIC -O3)
On which OS did this happen?
Linux
Reproduction Steps
Minimal reproducible example
SoC.sv
:Build command:
Expected Behavior
The SV file is accepted without any error messages.
Actual Behavior
An assertion fails:
The text was updated successfully, but these errors were encountered: