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

Implementing $root #2150

Open
Kuree opened this issue Feb 3, 2020 · 1 comment
Open

Implementing $root #2150

Kuree opened this issue Feb 3, 2020 · 1 comment

Comments

@Kuree
Copy link

@Kuree Kuree commented Feb 3, 2020

I notice that $root was mentioned in some of the earlier release logs such as 3.864. However the master branch no longer works with $root.

Here is a minimal example of code that runs on commercial simulators:

module mod();
integer value = 1;
initial begin
    $display("value is %d", $root.mod.value);
end
endmodule

Here is the error I got when running the verilator with lint only option:

$ verilator --lint-only mod.sv 
%Error: mod.sv:4: Unsupported: SystemVerilog 2005 reserved word not implemented: '$root'
    $display("value is %d", $root.mod.value);
                            ^~~~~
%Error: mod.sv:4: syntax error, unexpected '.', expecting TYPE-IDENTIFIER
    $display("value is %d", $root.mod.value);
                                 ^
%Error: Exiting due to 2 error(s)
        ... See the manual and https://verilator.org for more assistance.

For a quick reference, $root is defined in 1800-2017 23.3.1, so this should be a IEEE feature.

Although I never touched Verilator internal before, I'm very interested in helping implementing this feature. Please let me know if there is a place I should start looking at.

@Kuree Kuree added the new label Feb 3, 2020
@wsnyder

This comment has been minimized.

Copy link
Member

@wsnyder wsnyder commented Feb 3, 2020

Great, would love to have the assistance to add this. I think the $root reference in the change log was just a way of saying there was two top conflicts not that $root itself worked.

The first step is to make a test_regress format test (see the internals doc), it would be good to make sure there is a e.g, "logic mod;" inside a function so that $root.mod is required to disambiguate which mod is needed.

To support this, add $root to verilog.l replacing the error you see. Add the token to verilog.l, there's comments where it properly goes. Add a new AstRoot in AstNodes.h, and in verilog.y make a AstRoot. Search for where AstDot is used; ultimately the code uses AstDot (the "." in a dotted id) to find the symbols in an AstSym; in the case of $root rather than starting the symbol search in the normal place, it needs to use the root symbol tree, then search down for each dotted component from there as normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.