Difference between revisions of "Modules with " 1", " 2", ..., suffix in their names"

From Verific Design Automation FAQ
Jump to: navigation, search
Line 7: Line 7:
 
An example :
 
An example :
  
  module test ;
+
<nowiki>
 +
module test ;
 
     parameter p = 12 ;
 
     parameter p = 12 ;
 
     mod I() ;
 
     mod I() ;
     xx I2() ;
+
     foo I2() ;
  endmodule
+
endmodule
  module xx ;
+
 
 +
module foo ;
 
     test1 test() ;
 
     test1 test() ;
  endmodule
+
endmodule
  module test1 ;
+
 
 +
module test1 ;
 
     parameter p = 2 ;
 
     parameter p = 2 ;
 
     mod I3() ;
 
     mod I3() ;
  endmodule
+
endmodule
  module mod ;
+
 
 +
module mod ;
 
     initial $display(test.p) ; // This is hierarchical identifier
 
     initial $display(test.p) ; // This is hierarchical identifier
  endmodule
+
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>". 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
  
Here the hierarchy is:
+
module mod_2 ;
 +
    initial
 +
        $display (test.p) ;
 +
endmodule
  
test
+
module mod_3 ;
  |
+
    initial
  |    |
+
        $display (test.p) ;
  mod test1
+
endmodule
        |
+
</nowiki>
        mod
+
  
So here module 'mod' is instantiated twice in the hierarchy. Now if you look at the hierarchical identifier 'test.p' inside module 'mod', it is referring to parameter 'p' inside top level module 'test' for the instance I of module mod, but hierarchical identifier is referring parameter 'p' inside module 'test1' for the instance 'I3' of module mod (Here first element of hierarchical name 'test.p' is instance name not module 'test').
+
The design hierarchy is:
 +
<nowiki>
 +
test (top module)
 +
    I (mod_2)
 +
    I2 (foo)
 +
        test (test1)
 +
            I3 (mod_3)
 +
</nowiki>
  
So you can see that 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>". Hierarchical identifier in these two modules are resolved with proper identifiers.
+
The original module 'mod' is not instantiated.

Revision as of 14:42, 27 September 2022

        • Under construction ****

Static elaboration process adds the "_<number>" to the module name when: 1) Module contains hierarchical identifier(s), and 2) 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>". 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.