-
Notifications
You must be signed in to change notification settings - Fork 549
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
SV interface name collision in different parts of design hierarchy -- Verilator muddles names between levels of hierarchy #5120
Comments
We will need a complete, small example, thanks. One thing to try is change the default parameter value for N in the interface definition. |
I will try to reproduce with something less than my full design. The interface definition is not arrayed and is basically just what you would expect:
Declarations/instances of interfaces of this type are declared as [N-1:0], since everything works fine when N=4. |
Below is a complete example that demonstrates the bug in Verilator 5.024. By continuously deleting things and linting the module using Verilator, I found that the problem is that Verilator doesn't handle names correctly when two different instances of an interface have the same local variable name in different layers of hierarchy in the design! Basically a::myif and b::myif are two separate instances of the MYIF interface. Verilator thinks they're the same thing, and due to a::myif being a slave port, the assignment to b::myif is invalid according to Verilator, even though it appears to be valid Verilog and those are two distinct instances of the interface. Ignore the fact that this doesn't appear to be a useful design. In my real design where I discovered this issue, there is no name collision when a::myif[3:0] is passed down the hierarchy to b::myif (basically in a generate loop where 4 copies of b are instantiated). But, when I changed from 4 to 1 instance of b, then a::myif[0:0] is passed down to just one instance of b::myif, and then the names collide and it reveals this bug in the way Verilator handles names across hierarchy.
|
This seems like a pretty major flaw -- it means Verilator could be mixing up SV interfaces across levels of design hierarchy, just by chance if they happen to have the same name in their local block of code. |
This is because the module's parent has a interface of the same name, and the child and parent are both inlined. As a workaround add to the child module
Need more time to fix this, as simple fixes all broke other things. Interfaces are complicated. |
No worries. I just avoid name reuse in the hierarchy for now when they don't actually refer to the same thing. |
When I have an array of SV interfaces like this, Verilator works as expected for N=4.
However, when I change to N=1, I get errors where Verilator has apparently mixed up master/slave modports and thinks I am assigning to an sv signal with the wrong direction. Basically Verilator seems to have confused master/slave modport determination, which usually automatic based on what the modport is connected to (ex: an AXIS_IF.master or AXIS_IF.slave modport of some module should and does cause it to pick the correct modport of the interface when N > 1).
This produces errors like:
In this example,
tdata
is an input andaxis_if
is not even exposed as a port of the module.The text was updated successfully, but these errors were encountered: