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)
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"
29 /* This is the hierarchy separator to use. */
30 static char use_hchar
= '.';
35 unsigned long int_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
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
);
72 : sdf_header_list sdf_header_item
91 : '(' K_SDFVERSION QSTRING
')'
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);
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);
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);
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);
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);
137 : '(' K_DIVIDER
'.' ')' { use_hchar
= '.'; }
138 |
'(' K_DIVIDER
'/' ')' { use_hchar
= '/'; }
142 : '(' K_VOLTAGE rtriple
')'
143 |
'(' K_VOLTAGE signed_real_number
')'
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);
155 : '(' K_TEMPERATURE rtriple
')'
156 |
'(' K_TEMPERATURE signed_real_number
')'
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);
173 : '(' K_CELL celltype cell_instance
174 { sdf_select_instance
($3, $4); /* find the instance in the design */}
179 |
'(' K_CELL
error ')'
180 { vpi_printf
("%s:%d: Syntax error in CELL\n",
181 sdf_parse_path
, @
2.first_line
); }
185 : '(' K_CELLTYPE QSTRING
')'
190 : '(' K_INSTANCE hierarchical_identifier
')'
192 |
'(' K_INSTANCE
'*' ')'
197 : timing_spec_list 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
); }
209 : deltype_list deltype
214 : '(' K_ABSOLUTE del_def_list
')'
215 |
'(' K_INCREMENT del_def_list
')'
217 { vpi_printf
("%s:%d: Invalid/malformed delay type\n",
218 sdf_parse_path
, @
1.first_line
); }
222 : del_def_list del_def
227 : '(' K_IOPATH port_spec port_instance delval_list
')'
228 { sdf_iopath_delays
($3, $4, &$5);
232 |
'(' K_IOPATH
error ')'
233 { vpi_printf
("%s:%d: Invalid/malformed IOPATH\n",
234 sdf_parse_path
, @
2.first_line
); }
247 : hierarchical_identifier
249 /* | hierarchical_identifier '[' INTEGER ']' */
256 for
(idx
= 0 ; idx
< $$.count
; idx
+= 1)
257 $$.val
[idx
] = $1.val
[idx
];
259 $$.val
[$$.count
] = $2;
272 |
'(' rvalue rvalue
')'
274 vpi_printf
("%s:%d: SDF WARNING: Pulse rejection limits ignored\n",
275 sdf_parse_path
, @
3.first_line
);
277 |
'(' rvalue rvalue rvalue
')'
279 vpi_printf
("%s:%d: SDF WARNING: Pulse rejection limits ignored\n",
280 sdf_parse_path
, @
3.first_line
);
285 : '(' signed_real_number
')'
291 hierarchical_identifier
297 : signed_real_number
':' signed_real_number
':' signed_real_number
298 { $$
= $3; /* XXXX Assume typical value. */ }
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
);