Difference between revisions of "Modules with " 1", " 2", ..., suffix in their names"
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | Static elaboration process adds the suffix "_<number>" to the module name when: | |
− | + | #Module contains hierarchical identifier(s), and | |
− | Static elaboration process adds the "_<number>" to the module name when: | + | #Hierarchical identifier(s) in that module point(s) to different objects depending on the hierarchical position of that module instance. |
− | + | ||
− | + | ||
An example : | An example : | ||
− | + | <nowiki> | |
+ | module test ; | ||
parameter p = 12 ; | parameter p = 12 ; | ||
mod I() ; | mod I() ; | ||
− | + | foo I2() ; | |
− | + | endmodule | |
− | + | module foo ; | |
test1 test() ; | test1 test() ; | ||
− | + | endmodule | |
− | + | module test1 ; | |
parameter p = 2 ; | parameter p = 2 ; | ||
mod I3() ; | mod I3() ; | ||
− | + | endmodule | |
− | + | module mod ; | |
initial $display(test.p) ; // This is hierarchical identifier | initial $display(test.p) ; // This is hierarchical identifier | ||
− | + | endmodule | |
+ | </nowiki> | ||
+ | |||
+ | The hierarchy is: | ||
+ | |||
+ | <nowiki> | ||
+ | test (top module) | ||
+ | I (mod) | ||
+ | I2 (foo) | ||
+ | test (test1) | ||
+ | I3 (mod) | ||
+ | </nowiki> | ||
+ | |||
+ | So here module 'mod' is instantiated twice in the hierarchy. The hierarchical identifier 'test.p' inside module 'mod', can refer to parameter 'p' inside top level module 'test' for the instance I of module mod; but it can also refer to parameter 'p' inside module 'test1' for the instance 'I3' of module mod. In other words, the prefix 'test' can refer to module 'test' (top module) or instance 'top' inside module foo. | ||
+ | |||
+ | In the example above, one hierarchical name can refer to different objects in the hierarchy. In this situation static elaboration creates 2 different copies of module 'mod' and their names are differentiated by adding "_<number>" ('mod_2' and 'mod_3'). Hierarchical identifiers in these two modules are resolved with proper identifiers. | ||
+ | |||
+ | The parsetree after static elaboration: | ||
+ | |||
+ | <nowiki> | ||
+ | module test ; | ||
+ | parameter p = 12 ; | ||
+ | mod_2 I () ; | ||
+ | foo I2 () ; | ||
+ | endmodule | ||
+ | |||
+ | module foo ; | ||
+ | test1 test () ; | ||
+ | endmodule | ||
+ | |||
+ | module test1 ; | ||
+ | parameter p = 2 ; | ||
+ | mod_3 I3 () ; | ||
+ | endmodule | ||
+ | |||
+ | module mod ; | ||
+ | initial | ||
+ | $display (test.p) ; | ||
+ | endmodule | ||
− | + | module mod_2 ; | |
+ | initial | ||
+ | $display (test.p) ; | ||
+ | endmodule | ||
− | + | module mod_3 ; | |
− | + | initial | |
− | + | $display (test.p) ; | |
− | + | endmodule | |
− | + | </nowiki> | |
− | + | ||
− | + | The design hierarchy is: | |
+ | <nowiki> | ||
+ | test (top module) | ||
+ | I (mod_2) | ||
+ | I2 (foo) | ||
+ | test (test1) | ||
+ | I3 (mod_3) | ||
+ | </nowiki> | ||
− | + | The original module 'mod' is not instantiated. |
Latest revision as of 14:46, 27 September 2022
Static elaboration process adds the suffix "_<number>" to the module name when:
- Module contains hierarchical identifier(s), and
- Hierarchical identifier(s) in that module point(s) to different objects depending on the hierarchical position of that module instance.
An example :
module test ; parameter p = 12 ; mod I() ; foo I2() ; endmodule module foo ; test1 test() ; endmodule module test1 ; parameter p = 2 ; mod I3() ; endmodule module mod ; initial $display(test.p) ; // This is hierarchical identifier endmodule
The hierarchy is:
test (top module) I (mod) I2 (foo) test (test1) I3 (mod)
So here module 'mod' is instantiated twice in the hierarchy. The hierarchical identifier 'test.p' inside module 'mod', can refer to parameter 'p' inside top level module 'test' for the instance I of module mod; but it can also refer to parameter 'p' inside module 'test1' for the instance 'I3' of module mod. In other words, the prefix 'test' can refer to module 'test' (top module) or instance 'top' inside module foo.
In the example above, one hierarchical name can refer to different objects in the hierarchy. In this situation static elaboration creates 2 different copies of module 'mod' and their names are differentiated by adding "_<number>" ('mod_2' and 'mod_3'). Hierarchical identifiers in these two modules are resolved with proper identifiers.
The parsetree after static elaboration:
module test ; parameter p = 12 ; mod_2 I () ; foo I2 () ; endmodule module foo ; test1 test () ; endmodule module test1 ; parameter p = 2 ; mod_3 I3 () ; endmodule module mod ; initial $display (test.p) ; endmodule module mod_2 ; initial $display (test.p) ; endmodule module mod_3 ; initial $display (test.p) ; endmodule
The design hierarchy is:
test (top module) I (mod_2) I2 (foo) test (test1) I3 (mod_3)
The original module 'mod' is not instantiated.