@@ -108,6 +108,10 @@ typedef enum {
108
108
K_NETTYPE ,
109
109
} verilogKind ;
110
110
111
+ typedef enum {
112
+ R_MODULE_DECL ,
113
+ } verilogModuleRole ;
114
+
111
115
typedef struct {
112
116
const char * keyword ;
113
117
verilogKind kind ;
@@ -141,11 +145,20 @@ static int Ungetc;
141
145
static int Lang_verilog ;
142
146
static int Lang_systemverilog ;
143
147
148
+ static roleDefinition VerilogModuleRoles [] = {
149
+ { true, "decl" , "declaring instances" },
150
+ };
151
+
152
+ static roleDefinition SystemVerilogModuleRoles [] = {
153
+ { true, "decl" , "declaring instances" },
154
+ };
155
+
144
156
static kindDefinition VerilogKinds [] = {
145
157
{ true, 'c' , "constant" , "constants (define, parameter, specparam)" },
146
158
{ true, 'e' , "event" , "events" },
147
159
{ true, 'f' , "function" , "functions" },
148
- { true, 'm' , "module" , "modules" },
160
+ { true, 'm' , "module" , "modules" ,
161
+ .referenceOnly = false, ATTACH_ROLES (VerilogModuleRoles ) },
149
162
{ true, 'n' , "net" , "net data types" },
150
163
{ true, 'p' , "port" , "ports" },
151
164
{ true, 'r' , "register" , "variable data types" },
@@ -158,7 +171,8 @@ static kindDefinition SystemVerilogKinds [] = {
158
171
{ true, 'c' , "constant" , "constants (define, parameter, specparam, enum values)" },
159
172
{ true, 'e' , "event" , "events" },
160
173
{ true, 'f' , "function" , "functions" },
161
- { true, 'm' , "module" , "modules" },
174
+ { true, 'm' , "module" , "modules" ,
175
+ .referenceOnly = false, ATTACH_ROLES (SystemVerilogModuleRoles ) },
162
176
{ true, 'n' , "net" , "net data types" },
163
177
{ true, 'p' , "port" , "ports" },
164
178
{ true, 'r' , "register" , "variable data types" },
@@ -949,7 +963,7 @@ static int dropEndContext (tokenInfo *const token, int c)
949
963
}
950
964
951
965
952
- static void createTagWithTypeRef (tokenInfo * const token , verilogKind kind , tokenInfo * const typeref )
966
+ static void createTagFull (tokenInfo * const token , verilogKind kind , int role , tokenInfo * const typeref )
953
967
{
954
968
tagEntryInfo tag ;
955
969
@@ -981,7 +995,10 @@ static void createTagWithTypeRef (tokenInfo *const token, verilogKind kind, toke
981
995
}
982
996
983
997
/* Create tag */
984
- initTagEntry (& tag , vStringValue (token -> name ), kind );
998
+ if (role == ROLE_DEFINITION_INDEX )
999
+ initTagEntry (& tag , vStringValue (token -> name ), kind );
1000
+ else
1001
+ initRefTagEntry (& tag , vStringValue (token -> name ), kind , role );
985
1002
tag .lineNumber = token -> lineNumber ;
986
1003
tag .filePosition = token -> filePosition ;
987
1004
@@ -1011,7 +1028,8 @@ static void createTagWithTypeRef (tokenInfo *const token, verilogKind kind, toke
1011
1028
1012
1029
makeTagEntry (& tag );
1013
1030
1014
- if (isXtagEnabled (XTAG_QUALIFIED_TAGS ) && currentContext -> kind != K_UNDEFINED )
1031
+ if (isXtagEnabled (XTAG_QUALIFIED_TAGS ) && currentContext -> kind != K_UNDEFINED
1032
+ && role == ROLE_DEFINITION_INDEX )
1015
1033
{
1016
1034
vString * const scopedName = vStringNew ();
1017
1035
@@ -1027,7 +1045,7 @@ static void createTagWithTypeRef (tokenInfo *const token, verilogKind kind, toke
1027
1045
}
1028
1046
1029
1047
/* Push token as context if it is a container */
1030
- if (container )
1048
+ if (container && role == ROLE_DEFINITION_INDEX )
1031
1049
{
1032
1050
createContext (kind , token -> name );
1033
1051
@@ -1037,7 +1055,7 @@ static void createTagWithTypeRef (tokenInfo *const token, verilogKind kind, toke
1037
1055
for (unsigned int i = 0 ; i < ptrArrayCount (tagContents ); i ++ )
1038
1056
{
1039
1057
tokenInfo * content = ptrArrayItem (tagContents , i );
1040
- createTagWithTypeRef (content , content -> kind , NULL );
1058
+ createTagFull (content , content -> kind , ROLE_DEFINITION_INDEX , NULL );
1041
1059
}
1042
1060
1043
1061
/* Drop temporary contexts */
@@ -1049,11 +1067,21 @@ static void createTagWithTypeRef (tokenInfo *const token, verilogKind kind, toke
1049
1067
vStringClear (token -> inheritance );
1050
1068
}
1051
1069
1070
+ static void createTagWithTypeRef (tokenInfo * const token , verilogKind kind , tokenInfo * const typeref )
1071
+ {
1072
+ createTagFull (token , kind , ROLE_DEFINITION_INDEX , typeref );
1073
+ }
1074
+
1052
1075
static void createTag (tokenInfo * const token , verilogKind kind )
1053
1076
{
1054
1077
createTagWithTypeRef (token , kind , NULL );
1055
1078
}
1056
1079
1080
+ static void createRefTag (tokenInfo * const token , verilogKind kind , int role )
1081
+ {
1082
+ createTagFull (token , kind , role , NULL );
1083
+ }
1084
+
1057
1085
static int skipBlockName (tokenInfo * const token , int c )
1058
1086
{
1059
1087
if (c == ':' )
@@ -1873,6 +1901,7 @@ static int tagIdsInDataDecl (tokenInfo* token, int c, verilogKind kind)
1873
1901
tokenSaved -> kind = K_MODULE ; // for typeRef field
1874
1902
verbose ("find instance: %s with kind %s\n" , vStringValue (token -> name ), getNameForKind (K_INSTANCE ));
1875
1903
createTagWithTypeRef (token , K_INSTANCE , tokenSaved );
1904
+ createRefTag (tokenSaved , K_MODULE , R_MODULE_DECL );
1876
1905
}
1877
1906
}
1878
1907
c = skipMacro (c , token ); // `ifdef, `else, `endif, etc. (before comma)
0 commit comments