Skip to content

Commit 36e5169

Browse files
authored
Recognize some basic specify blocks and ignore them (#309)
* Add parser support for specify blocks and specparam Treated like regular parameters, and so ignored * Add regression test * Apply PR feedback * missed the verilog_lang
1 parent c11bb38 commit 36e5169

File tree

6 files changed

+50
-1
lines changed

6 files changed

+50
-1
lines changed

test/regression_vars.tcl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,13 @@ record_sta_tests {
152152
package_require
153153
path_group_names
154154
prima3
155+
report_checks_sorted
155156
report_checks_src_attr
156157
report_json1
157158
report_json2
158159
suppress_msg
159160
verilog_attribute
160-
report_checks_sorted
161+
verilog_specify
161162
}
162163

163164
define_test_group fast [group_tests all]

test/verilog_specify.ok

Whitespace-only changes.

test/verilog_specify.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# try to load verilog language file
2+
read_verilog verilog_specify.v

test/verilog_specify.v

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
module counter(clk, reset, in, out);
3+
input clk;
4+
output out;
5+
input reset;
6+
input in;
7+
wire mid;
8+
9+
parameter PARAM1=1;
10+
parameter PARAM2="test";
11+
12+
specify
13+
specparam SPARAM1=2;
14+
specparam SPARAM2="test2";
15+
endspecify
16+
17+
defparam _1415_.PARAM2 = 1;
18+
19+
20+
endmodule

verilog/VerilogLex.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ output { return token::OUTPUT; }
132132
parameter { return token::PARAMETER; }
133133
defparam { return token::DEFPARAM; }
134134
reg { return token::REG; }
135+
specify { return token::SPECIFY; }
136+
endspecify { return token::ENDSPECIFY; }
137+
specparam { return token::SPECPARAM; }
135138
supply0 { return token::SUPPLY0; }
136139
supply1 { return token::SUPPLY1; }
137140
tri { return token::TRI; }

verilog/VerilogParse.yy

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ sta::VerilogParse::error(const location_type &loc,
8383
}
8484

8585
%token INT CONSTANT ID STRING MODULE ENDMODULE ASSIGN PARAMETER DEFPARAM
86+
%token SPECIFY ENDSPECIFY SPECPARAM
8687
%token WIRE WAND WOR TRI INPUT OUTPUT INOUT SUPPLY1 SUPPLY0 REG
8788
%token ATTR_OPEN ATTR_CLOSED
8889

@@ -99,6 +100,8 @@ sta::VerilogParse::error(const location_type &loc,
99100
%type <stmt> stmt declaration instance parameter parameter_dcls parameter_dcl
100101
%type <stmt> defparam param_values param_value port_dcl
101102
%type <stmt_seq> stmts stmt_seq net_assignments continuous_assign port_dcls
103+
%type <stmt> specify_block
104+
%type <stmt_seq> specify_stmts
102105
%type <assign> net_assignment
103106
%type <dcl_arg> dcl_arg
104107
%type <dcl_arg_seq> dcl_args
@@ -232,6 +235,7 @@ stmt:
232235
| defparam
233236
| declaration
234237
| instance
238+
| specify_block
235239
| error ';'
236240
{ yyerrok; $$ = nullptr; }
237241
;
@@ -240,6 +244,25 @@ stmt_seq:
240244
continuous_assign
241245
;
242246

247+
/* specify blocks are used by some comercial tools to convey macro timing
248+
* and other metadata.
249+
* Their presence is not forbidden in structural verilog, this is a placeholder
250+
* that just ignores them and allows verilog processing to proceed
251+
* <<TODO>> if someone in the future wants implement support for timing info
252+
* via specify blocks, implement proper parsing here
253+
*/
254+
specify_block:
255+
SPECIFY specify_stmts ENDSPECIFY
256+
{ $$ = nullptr; }
257+
;
258+
259+
specify_stmts:
260+
SPECPARAM parameter_dcl ';'
261+
{ $$ = nullptr; }
262+
| specify_stmts SPECPARAM parameter_dcl ';'
263+
{ $$ = nullptr; }
264+
;
265+
243266
/* Parameters are parsed and ignored. */
244267
parameter:
245268
PARAMETER parameter_dcls ';'

0 commit comments

Comments
 (0)