Handle comments
[iverilog.git] / vpi / sdf_parse.y
blob74c451ea7ca997543f9ec68af204d47eb91b76a1
2 %{
3 /*
4 * Copyright (c) 1998-2007 Stephen Williams (steve@icarus.com)
6 * This source code is free software; you can redistribute it
7 * and/or modify it in source code form under the terms of the GNU
8 * General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 extern int sdflex(void);
23 static void yyerror(const char*msg);
24 # include "vpi_user.h"
25 # include "sdf_parse_priv.h"
26 # include "sdf_priv.h"
27 # include <stdio.h>
29 /* This is the hierarchy separator to use. */
30 static char use_hchar = '.';
34 %union {
35 unsigned long int_val;
36 double real_val;
37 char* string_val;
39 struct sdf_delval_list_s delval_list;
42 %token K_ABSOLUTE K_CELL K_CELLTYPE K_DATE K_DELAYFILE K_DELAY K_DESIGN
43 %token K_DIVIDER K_INCREMENT K_INSTANCE K_IOPATH
44 %token K_PROCESS K_PROGRAM K_SDFVERSION K_TEMPERATURE K_TIMESCALE
45 %token K_VENDOR K_VERSION K_VOLTAGE
47 %token <string_val> QSTRING IDENTIFIER
48 %token <real_val> REAL_NUMBER
49 %token <int_val> INTEGER
51 %type <string_val> celltype
52 %type <string_val> cell_instance
53 %type <string_val> hierarchical_identifier
54 %type <string_val> port port_instance port_spec
56 %type <real_val> rvalue rtriple signed_real_number
57 %type <real_val> delval
59 %type <delval_list> delval_list
63 source_file
64 : '(' K_DELAYFILE sdf_header_list cell_list ')'
65 | '(' K_DELAYFILE error ')'
66 { vpi_printf("%s:%d:SDF ERROR: Invalid DELAYFILE format\n",
67 sdf_parse_path, @2.first_line);
71 sdf_header_list
72 : sdf_header_list sdf_header_item
73 | sdf_header_item
76 sdf_header_item
77 : sdfversion
78 | design_name
79 | date
80 | vendor
81 | program_name
82 | program_version
83 | hierarchy_divider
84 | voltage
85 | process
86 | temperature
87 | time_scale
90 sdfversion
91 : '(' K_SDFVERSION QSTRING ')'
92 { free($3);
96 design_name
97 : '(' K_DESIGN QSTRING ')'
98 { if (sdf_flag_inform) vpi_printf("%s:%d:SDF INFO: Design: %s\n",
99 sdf_parse_path, @2.first_line, $3);
100 free($3);
104 date
105 : '(' K_DATE QSTRING ')'
106 { if (sdf_flag_inform) vpi_printf("%s:%d:SDF INFO: Date: %s\n",
107 sdf_parse_path, @2.first_line, $3);
108 free($3);
112 vendor
113 : '(' K_VENDOR QSTRING ')'
114 { if (sdf_flag_inform) vpi_printf("%s:%d:SDF INFO: Vendor: %s\n",
115 sdf_parse_path, @2.first_line, $3);
116 free($3);
120 program_name
121 : '(' K_PROGRAM QSTRING ')'
122 { if (sdf_flag_inform) vpi_printf("%s:%d:SDF INFO: Program: %s\n",
123 sdf_parse_path, @2.first_line, $3);
124 free($3);
128 program_version
129 : '(' K_VERSION QSTRING ')'
130 { if (sdf_flag_inform) vpi_printf("%s:%d:SDF INFO: Program Version: %s\n",
131 sdf_parse_path, @2.first_line, $3);
132 free($3);
136 hierarchy_divider
137 : '(' K_DIVIDER '.' ')' { use_hchar = '.'; }
138 | '(' K_DIVIDER '/' ')' { use_hchar = '/'; }
141 voltage
142 : '(' K_VOLTAGE rtriple ')'
143 | '(' K_VOLTAGE signed_real_number ')'
146 process
147 : '(' K_PROCESS QSTRING ')'
148 { if (sdf_flag_inform) vpi_printf("%s:%d:SDF INFO: Process: %s\n",
149 sdf_parse_path, @2.first_line, $3);
150 free($3);
154 temperature
155 : '(' K_TEMPERATURE rtriple ')'
156 | '(' K_TEMPERATURE signed_real_number ')'
159 time_scale
160 : '(' K_TIMESCALE REAL_NUMBER IDENTIFIER ')'
161 { if (sdf_flag_inform) vpi_printf("%s:%d:SDF INFO: TIMESCALE : %f%s\n",
162 sdf_parse_path, @2.first_line, $3, $4);
163 free($4);
167 cell_list
168 : cell_list cell
169 | cell
172 cell
173 : '(' K_CELL celltype cell_instance
174 { sdf_select_instance($3, $4); /* find the instance in the design */}
175 timing_spec_list
177 { free($3);
178 free($4); }
179 | '(' K_CELL error ')'
180 { vpi_printf("%s:%d: Syntax error in CELL\n",
181 sdf_parse_path, @2.first_line); }
184 celltype
185 : '(' K_CELLTYPE QSTRING ')'
186 { $$ = $3; }
189 cell_instance
190 : '(' K_INSTANCE hierarchical_identifier ')'
191 { $$ = $3; }
192 | '(' K_INSTANCE '*' ')'
193 { $$ = 0; }
196 timing_spec_list
197 : timing_spec_list timing_spec
198 | timing_spec
201 timing_spec
202 : '(' K_DELAY deltype_list ')'
203 | '(' K_DELAY error ')'
204 { vpi_printf("%s:%d: Syntax error in CELL DELAY SPEC\n",
205 sdf_parse_path, @2.first_line); }
208 deltype_list
209 : deltype_list deltype
210 | deltype
213 deltype
214 : '(' K_ABSOLUTE del_def_list ')'
215 | '(' K_INCREMENT del_def_list ')'
216 | '(' error ')'
217 { vpi_printf("%s:%d: Invalid/malformed delay type\n",
218 sdf_parse_path, @1.first_line); }
221 del_def_list
222 : del_def_list del_def
223 | del_def
226 del_def
227 : '(' K_IOPATH port_spec port_instance delval_list ')'
228 { sdf_iopath_delays($3, $4, &$5);
229 free($3);
230 free($4);
232 | '(' K_IOPATH error ')'
233 { vpi_printf("%s:%d: Invalid/malformed IOPATH\n",
234 sdf_parse_path, @2.first_line); }
237 port_spec
238 : port_instance
239 /* | port_edge */
242 port_instance
243 : port { $$ = $1; }
246 port
247 : hierarchical_identifier
248 { $$ = $1; }
249 /* | hierarchical_identifier '[' INTEGER ']' */
252 delval_list
253 : delval_list delval
254 { int idx;
255 $$.count = $1.count;
256 for (idx = 0 ; idx < $$.count ; idx += 1)
257 $$.val[idx] = $1.val[idx];
258 if ($$.count < 12) {
259 $$.val[$$.count] = $2;
260 $$.count += 1;
263 | delval
264 { $$.count = 1;
265 $$.val[0] = $1;
269 delval
270 : rvalue
271 { $$ = $1; }
272 | '(' rvalue rvalue ')'
273 { $$ = $2;
274 vpi_printf("%s:%d: SDF WARNING: Pulse rejection limits ignored\n",
275 sdf_parse_path, @3.first_line);
277 | '(' rvalue rvalue rvalue ')'
278 { $$ = $2;
279 vpi_printf("%s:%d: SDF WARNING: Pulse rejection limits ignored\n",
280 sdf_parse_path, @3.first_line);
284 rvalue
285 : '(' signed_real_number ')'
286 { $$ = $2; }
287 | '(' rtriple ')'
288 { $$ = $2; }
291 hierarchical_identifier
292 : IDENTIFIER
293 { $$ = $1; }
296 rtriple
297 : signed_real_number ':' signed_real_number ':' signed_real_number
298 { $$ = $3; /* XXXX Assume typical value. */ }
301 signed_real_number
302 : REAL_NUMBER { $$ = $1; }
303 | '+' REAL_NUMBER { $$ = $2; }
304 | '-' REAL_NUMBER { $$ = -$2; }
309 void yyerror(const char*msg)
311 vpi_printf("%s:SDF ERROR: Too many errors: %s\n", sdf_parse_path, msg);