How to get linefile information of macro definitions

From Verific Design Automation FAQ
Revision as of 15:45, 22 March 2017 by Hoa (Talk | contribs) (Created page with "'''Q: How do I get linefile information of macro definitions?''' Take the following example: 1 `define A 2 `define B 10 3 `define C(a) a 4 `define D(a, b) a + b 5...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Q: How do I get linefile information of macro definitions?

Take the following example:

 1 `define A
 2 `define B 10
 3 `define C(a) a
 4 `define D(a, b) a + b
 5 `define E(a, b, c) a \
 6                      + b \
 7                      + c
 8 
 9 module test ;
10     initial
11 `ifdef A
12         $display("macro A is defined") ;
13 `else
14         $display("macro A is defined") ;
15 `endif
16 
17     parameter PB = `B ;
18     parameter PC = `C(10) ;
19     parameter PD = `D(4, 6) ;
20     parameter PE = `E(1, 3, 6) ;
21 endmodule

Macro definition (MacroDef) linefile info is stored that span the whole macro definition including the `define. These linefile info can be accessed using API veri_file::GetMacroDefLinefiles(). It returns you a Map hashed with char *strings and the value is linefile_type.

Here is the table for the above macro definitions:

   MacroDef  [start line:start col] [end line:end column]
   A         [1:1]                  [2:1]
   B         [2:1]                  [3:1]
   C         [3:1]                  [4:1]
   D         [4:1]                  [5:1]
   E         [5:1]                  [8:1]

Macro reference (MacroRef) linefile info is also stored. The linefile spans the whole macro ref including the starting ` and the ending parenthesis in case it passed arguments. These linefile info are accessed using API veri_file::GetMacroRefLinefiles(). It returns you a Map hashed with linefile_type of the macro reference and the value is also linefile_type but of the macro definition.

Here is the table for the above macro references:

   MacroRef  [start line:start col] [end line:end column]
   A         [11:8]                 [11:9]
   B         [17:20]                [17:22]
   C         [18:20]                [18:26]
   D         [19:20]                [19:28]
   E         [20:20]                [20:31]