Hi all,
After reading LRM sections 23.7–23.9, I have a few questions about the concept of hierarchical references.
Q1.
int i = 8;
module tb;
initial begin: init_blk
$display("i: %0d", i);
end
endmodule
According to LRM Chapter 23.9: “If an identifier is referenced directly (without a hierarchical path)… If the item is a variable, it shall stop at a module boundary.”
So the search should stop once it reaches module tb. But in practice, the variable i can still be referenced. What is meant by “module boundary” in this context?
Q2.
interface intf;
int i = 8;
endinterface
module tb;
initial begin: init_blk
$display("i: %0d", intf.i);
end
endmodule
According to LRM Chapter 23.9: “If an identifier is referenced with a hierarchical name, the path can start with a module name, interface name…”.
In my case, I used the interface name intf, but the compiler still reports an error.
Q3.
Based on the rules and examples in LRM Chapter 23.8 Upwards Name Referencing, it appears that scope_name in a hierarchical reference can be a module name only when it refers to the module containing the statement. In all other cases, only instance names are allowed, and item_name always refers to an instance name. Is my understanding of this correct?
Also, based on my understanding, the search first proceeds in the declaration scope until it reaches the design element scope, and then it continues in the scope where the module is instantiated. Does this mean the lookup alternates between the declaration scope and the instantiation scope?
BR,
Boris