Match parsed IOPATH to cell and modpath to be annotated.
[iverilog.git] / vpi / sdf_parse.y
blob3afe61c3e1e02c14c6a25605712fc91ad699a452
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;
40 %token K_ABSOLUTE K_CELL K_CELLTYPE K_DATE K_DELAYFILE K_DELAY K_DESIGN
41 %token K_DIVIDER K_INCREMENT K_INSTANCE K_IOPATH
42 %token K_PROCESS K_PROGRAM K_SDFVERSION K_TEMPERATURE K_TIMESCALE
43 %token K_VENDOR K_VERSION K_VOLTAGE
45 %token <string_val> QSTRING IDENTIFIER
46 %token <real_val> REAL_NUMBER
47 %token <int_val> INTEGER
49 %type <string_val> celltype
50 %type <string_val> cell_instance
51 %type <string_val> hierarchical_identifier
52 %type <string_val> port port_instance port_spec
56 source_file
57 : '(' K_DELAYFILE sdf_header_list cell_list ')'
60 sdf_header_list
61 : sdf_header_list sdf_header_item
62 | sdf_header_item
65 sdf_header_item
66 : sdfversion
67 | design_name
68 | date
69 | vendor
70 | program_name
71 | program_version
72 | hierarchy_divider
73 | voltage
74 | process
75 | temperature
76 | time_scale
79 sdfversion
80 : '(' K_SDFVERSION QSTRING ')'
81 { free($3);
85 design_name
86 : '(' K_DESIGN QSTRING ')'
87 { vpi_printf("SDF Design: %s\n", $3);
88 free($3);
92 date
93 : '(' K_DATE QSTRING ')'
94 { vpi_printf("SDF Date: %s\n", $3);
95 free($3);
99 vendor : '(' K_VENDOR QSTRING ')'
100 { vpi_printf("SDF Vendor: %s\n", $3);
101 free($3);
105 program_name : '(' K_PROGRAM QSTRING ')'
106 { vpi_printf("SDF Program: %s\n", $3);
107 free($3);
111 program_version : '(' K_VERSION QSTRING ')'
112 { vpi_printf("SDF Program Version: %s\n", $3);
113 free($3);
117 hierarchy_divider
118 : '(' K_DIVIDER '.' ')' { use_hchar = '.'; }
119 | '(' K_DIVIDER '/' ')' { use_hchar = '/'; }
122 voltage
123 : '(' K_VOLTAGE rtriple ')'
124 | '(' K_VOLTAGE signed_real_number ')'
127 process : '(' K_PROCESS QSTRING ')'
128 { vpi_printf("SDF Process: %s\n", $3);
129 free($3);
133 temperature
134 : '(' K_TEMPERATURE rtriple ')'
135 | '(' K_TEMPERATURE signed_real_number ')'
138 time_scale
139 : '(' K_TIMESCALE REAL_NUMBER IDENTIFIER ')'
140 { vpi_printf("SDF TIMESCALE : %f%s\n", $3, $4);
141 free($4);
145 cell_list
146 : cell_list cell
147 | cell
150 cell
151 : '(' K_CELL celltype cell_instance
152 { sdf_select_instance($3, $4); /* find the instance in the design */}
153 timing_spec_list
155 { free($3);
156 free($4); }
157 | '(' K_CELL error ')'
158 { vpi_printf("%s:%d: Syntax error in CELL\n",
159 sdf_parse_path, @2.first_line); }
162 celltype
163 : '(' K_CELLTYPE QSTRING ')'
164 { $$ = $3; }
167 cell_instance
168 : '(' K_INSTANCE hierarchical_identifier ')'
169 { $$ = $3; }
170 | '(' K_INSTANCE '*' ')'
171 { $$ = 0; }
174 timing_spec_list
175 : timing_spec_list timing_spec
176 | timing_spec
179 timing_spec
180 : '(' K_DELAY deltype_list ')'
181 | '(' K_DELAY error ')'
182 { vpi_printf("%s:%d: Syntax error in CELL DELAY SPEC\n",
183 sdf_parse_path, @2.first_line); }
186 deltype_list
187 : deltype_list deltype
188 | deltype
191 deltype
192 : '(' K_ABSOLUTE del_def_list ')'
193 | '(' K_INCREMENT del_def_list ')'
194 | '(' error ')'
195 { vpi_printf("%s:%d: Invalid/malformed delay type\n",
196 sdf_parse_path, @1.first_line); }
199 del_def_list
200 : del_def_list del_def
201 | del_def
204 del_def
205 : '(' K_IOPATH port_spec port_instance delval_list ')'
206 { sdf_iopath_delays($3, $4);
207 free($3);
208 free($4);
210 | '(' K_IOPATH error ')'
211 { vpi_printf("%s:%d: Invalid/malformed IOPATH\n",
212 sdf_parse_path, @2.first_line); }
215 port_spec
216 : port_instance
217 /* | port_edge */
220 port_instance
221 : port { $$ = $1; }
224 port
225 : hierarchical_identifier
226 { $$ = $1; }
227 /* | hierarchical_identifier '[' INTEGER ']' */
230 delval_list
231 : delval_list delval
232 | delval
235 delval
236 : rvalue
237 | '(' rvalue rvalue ')'
238 | '(' rvalue rvalue rvalue ')'
241 rvalue
242 : '(' signed_real_number ')'
243 | '(' rtriple ')'
246 hierarchical_identifier
247 : IDENTIFIER
248 { $$ = $1; }
251 rtriple
252 : signed_real_number ':' signed_real_number ':' signed_real_number
255 signed_real_number
256 : REAL_NUMBER
257 | '+' REAL_NUMBER
258 | '-' REAL_NUMBER
263 void yyerror(const char*msg)
265 fprintf(stderr, "SDF ERROR: %s\n", msg);