@@ -108,6 +108,10 @@ typedef enum {
108
108
K_NETTYPE ,
109
109
} verilogKind ;
110
110
111
+ typedef enum {
112
+ R_MODULE_DEFINSTANCE ,
113
+ } verilogModuleRole ;
114
+
111
115
typedef struct {
112
116
const char * keyword ;
113
117
verilogKind kind ;
@@ -141,11 +145,16 @@ static int Ungetc;
141
145
static int Lang_verilog ;
142
146
static int Lang_systemverilog ;
143
147
148
+ static roleDefinition VerilogModuleRoles [] = {
149
+ { true, "defInstance" , "defining instances" },
150
+ };
151
+
144
152
static kindDefinition VerilogKinds [] = {
145
153
{ true, 'c' , "constant" , "constants (define, parameter, specparam)" },
146
154
{ true, 'e' , "event" , "events" },
147
155
{ true, 'f' , "function" , "functions" },
148
- { true, 'm' , "module" , "modules" },
156
+ { true, 'm' , "module" , "modules" ,
157
+ .referenceOnly = false, ATTACH_ROLES (VerilogModuleRoles )},
149
158
{ true, 'n' , "net" , "net data types" },
150
159
{ true, 'p' , "port" , "ports" },
151
160
{ true, 'r' , "register" , "variable data types" },
@@ -406,6 +415,7 @@ static fieldDefinition SystemVerilogFields[] = {
406
415
* PROTOTYPE DEFINITIONS
407
416
*/
408
417
418
+ static void createTagFull (tokenInfo * const token , verilogKind kind , int role , tokenInfo * const typeref );
409
419
static bool isIdentifier (tokenInfo * token );
410
420
static int processDefine (tokenInfo * const token , int c );
411
421
static int processType (tokenInfo * token , int c , verilogKind * kind , bool * with );
@@ -950,6 +960,11 @@ static int dropEndContext (tokenInfo *const token, int c)
950
960
951
961
952
962
static void createTag (tokenInfo * const token , verilogKind kind )
963
+ {
964
+ createTagFull (token , kind , ROLE_DEFINITION_INDEX , NULL );
965
+ }
966
+
967
+ static void createTagFull (tokenInfo * const token , verilogKind kind , int role , tokenInfo * const typeref )
953
968
{
954
969
tagEntryInfo tag ;
955
970
@@ -981,7 +996,10 @@ static void createTag (tokenInfo *const token, verilogKind kind)
981
996
}
982
997
983
998
/* Create tag */
984
- initTagEntry (& tag , vStringValue (token -> name ), kind );
999
+ if (role == ROLE_DEFINITION_INDEX )
1000
+ initTagEntry (& tag , vStringValue (token -> name ), kind );
1001
+ else
1002
+ initRefTagEntry (& tag , vStringValue (token -> name ), kind , role );
985
1003
tag .lineNumber = token -> lineNumber ;
986
1004
tag .filePosition = token -> filePosition ;
987
1005
@@ -1000,12 +1018,19 @@ static void createTag (tokenInfo *const token, verilogKind kind)
1000
1018
verbose ("Class %s extends %s\n" , vStringValue (token -> name ), tag .extensionFields .inheritance );
1001
1019
}
1002
1020
1021
+ if (typeref )
1022
+ {
1023
+ tag .extensionFields .typeRef [0 ] = getNameForKind (typeref -> kind );
1024
+ tag .extensionFields .typeRef [1 ] = vStringValue (typeref -> name );
1025
+ }
1026
+
1003
1027
if (token -> parameter )
1004
1028
attachParserField (& tag , false, fieldTable [F_PARAMETER ].ftype , "" );
1005
1029
1006
1030
makeTagEntry (& tag );
1007
1031
1008
- if (isXtagEnabled (XTAG_QUALIFIED_TAGS ) && currentContext -> kind != K_UNDEFINED )
1032
+ if (isXtagEnabled (XTAG_QUALIFIED_TAGS ) && currentContext -> kind != K_UNDEFINED
1033
+ && role == ROLE_DEFINITION_INDEX )
1009
1034
{
1010
1035
vString * const scopedName = vStringNew ();
1011
1036
@@ -1021,7 +1046,7 @@ static void createTag (tokenInfo *const token, verilogKind kind)
1021
1046
}
1022
1047
1023
1048
/* Push token as context if it is a container */
1024
- if (container )
1049
+ if (container && role == ROLE_DEFINITION_INDEX )
1025
1050
{
1026
1051
createContext (kind , token -> name );
1027
1052
@@ -1409,7 +1434,7 @@ static int processAssertion (tokenInfo *const token, int c)
1409
1434
1410
1435
// data_declaration ::=
1411
1436
// ...
1412
- // import < package_identifier :: identifier | package_identifier :: * > ;
1437
+ // import < package_identifier :: identifier | package_identifier :: * > ;
1413
1438
// dpi_import_export ::=
1414
1439
// import ( "DPI-C" | "DPI" ) [ context | pure ] [ c_identifier = ] function data_type_or_void function_identifier [ ( [ tf_port_list ] ) ] ;
1415
1440
// | import ( "DPI-C" | "DPI" ) [ context ] [ c_identifier = ] task task_identifier [ ( [ tf_port_list ] ) ] ;
@@ -1824,16 +1849,19 @@ static int tagIdsInPort (tokenInfo *const token, int c, verilogKind kind, bool m
1824
1849
// Tag a list of identifiers in a data declaration
1825
1850
static int tagIdsInDataDecl (tokenInfo * token , int c , verilogKind kind )
1826
1851
{
1852
+ tokenInfo * module = dupToken (token );
1853
+ module -> kind = K_MODULE ;
1854
+
1827
1855
c = skipClassType (token , c );
1828
1856
if (c == ';' )
1829
- return c ;
1857
+ goto out ;
1830
1858
1831
1859
// skip drive|charge strength or type_reference, dimensions, and delay for net
1832
1860
if (c == '(' )
1833
1861
c = skipPastMatch ("()" );
1834
1862
c = skipDimension (c );
1835
1863
if (c == '.' )
1836
- return c ; // foo[...].bar = ..;
1864
+ goto out ; // foo[...].bar = ..;
1837
1865
c = skipDelay (token , c ); // ## (cycle delay)
1838
1866
1839
1867
while (c != EOF )
@@ -1859,7 +1887,8 @@ static int tagIdsInDataDecl (tokenInfo* token, int c, verilogKind kind)
1859
1887
if (c == ';' || c == ',' )
1860
1888
{
1861
1889
verbose ("find instance: %s with kind %s\n" , vStringValue (token -> name ), getNameForKind (K_INSTANCE ));
1862
- createTag (token , K_INSTANCE );
1890
+ createTagFull (module , module -> kind , R_MODULE_DEFINSTANCE , NULL );
1891
+ createTagFull (token , K_INSTANCE , ROLE_DEFINITION_INDEX , module );
1863
1892
}
1864
1893
}
1865
1894
c = skipMacro (c , token ); // `ifdef, `else, `endif, etc. (before comma)
@@ -1868,6 +1897,8 @@ static int tagIdsInDataDecl (tokenInfo* token, int c, verilogKind kind)
1868
1897
c = skipWhite (vGetc ()); // skip ','
1869
1898
c = skipMacro (c , token ); // `ifdef, `else, `endif, etc. (after comma)
1870
1899
}
1900
+ out :
1901
+ deleteToken (module );
1871
1902
return c ;
1872
1903
}
1873
1904
0 commit comments