Skip to content

Commit cdd707e

Browse files
authored
Merge pull request #1314 from diffblue/verilog-config-grammar
SystemVerilog: grammar for `config` declarations
2 parents 1f5b445 + 423b955 commit cdd707e

File tree

2 files changed

+85
-5
lines changed

2 files changed

+85
-5
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
basic_config1.sv
33
--module top
4-
^EXIT=0$
4+
^EXIT=10$
55
^SIGNAL=0$
66
--
77
^warning: ignoring
88
--
9-
This does not parse.

src/verilog/parser.y

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,8 +1050,79 @@ non_port_module_item:
10501050
// A.1.5 Configuration source text
10511051

10521052
config_declaration:
1053-
TOK_CONFIG TOK_ENDCONFIG
1054-
;
1053+
TOK_CONFIG config_identifier ';'
1054+
local_parameter_declaration_opt
1055+
design_statement
1056+
config_rule_statement_opt
1057+
TOK_ENDCONFIG config_identifier_opt
1058+
;
1059+
1060+
local_parameter_declaration_opt:
1061+
/* Optional */
1062+
| local_parameter_declaration ';'
1063+
;
1064+
1065+
design_statement:
1066+
TOK_DESIGN design_identifier ';'
1067+
;
1068+
1069+
design_identifier:
1070+
cell_identifier
1071+
| library_identifier '.' cell_identifier
1072+
;
1073+
1074+
config_rule_statement_opt:
1075+
/* Optional */
1076+
| config_rule_statement
1077+
;
1078+
1079+
config_rule_statement:
1080+
default_clause liblist_clause ';'
1081+
| inst_clause liblist_clause ';'
1082+
| inst_clause use_clause ';'
1083+
| cell_clause liblist_clause ';'
1084+
| cell_clause use_clause ';'
1085+
;
1086+
1087+
default_clause: TOK_DEFAULT;
1088+
1089+
inst_clause: TOK_INSTANCE inst_name;
1090+
1091+
inst_name: topmodule_identifier dot_instance_identifier_brace;
1092+
1093+
dot_instance_identifier_brace:
1094+
/* Optional */
1095+
| dot_instance_identifier_brace '.' instance_identifier
1096+
;
1097+
1098+
cell_clause:
1099+
TOK_CELL cell_identifier
1100+
| TOK_CELL library_identifier cell_identifier
1101+
;
1102+
1103+
liblist_clause: TOK_LIBLIST library_identifier_brace;
1104+
1105+
library_identifier_brace:
1106+
/* Optional */
1107+
| library_identifier_brace library_identifier
1108+
;
1109+
1110+
use_clause:
1111+
TOK_USE cell_identifier colon_config_opt
1112+
| TOK_USE library_identifier '.' cell_identifier colon_config_opt
1113+
| TOK_USE '#' '(' named_parameter_assignment_brace ')' colon_config_opt
1114+
| TOK_USE library_identifier '.' cell_identifier '#' '(' named_parameter_assignment_brace ')' colon_config_opt
1115+
;
1116+
1117+
colon_config_opt:
1118+
/* Optional */
1119+
| TOK_COLON TOK_CONFIG
1120+
;
1121+
1122+
config_identifier_opt:
1123+
/* Optional */
1124+
| TOK_COLON config_identifier
1125+
;
10551126

10561127
bind_directive:
10571128
TOK_BIND
@@ -4543,6 +4614,8 @@ non_type_identifier: TOK_NON_TYPE_IDENTIFIER
45434614

45444615
block_identifier: TOK_NON_TYPE_IDENTIFIER;
45454616

4617+
cell_identifier: TOK_NON_TYPE_IDENTIFIER;
4618+
45464619
class_identifier: TOK_CLASS_IDENTIFIER
45474620
{
45484621
init($$, ID_verilog_class_type);
@@ -4552,6 +4625,8 @@ class_identifier: TOK_CLASS_IDENTIFIER
45524625
}
45534626
;
45544627

4628+
config_identifier: TOK_NON_TYPE_IDENTIFIER;
4629+
45554630
constraint_identifier: TOK_NON_TYPE_IDENTIFIER;
45564631

45574632
edge_identifier: identifier;
@@ -4563,10 +4638,14 @@ genvar_identifier: identifier;
45634638
hierarchical_parameter_identifier: hierarchical_identifier
45644639
;
45654640

4641+
instance_identifier: TOK_NON_TYPE_IDENTIFIER;
4642+
45664643
interface_identifier: TOK_NON_TYPE_IDENTIFIER;
45674644

45684645
module_identifier: TOK_NON_TYPE_IDENTIFIER;
45694646

4647+
topmodule_identifier: TOK_NON_TYPE_IDENTIFIER;
4648+
45704649
endmodule_identifier_opt:
45714650
/* Optional */
45724651
| TOK_COLON module_identifier
@@ -4596,6 +4675,8 @@ port_identifier: identifier;
45964675
ps_covergroup_identifier:
45974676
;
45984677

4678+
library_identifier: TOK_NON_TYPE_IDENTIFIER;
4679+
45994680
memory_identifier: identifier;
46004681

46014682
member_identifier: identifier;

0 commit comments

Comments
 (0)