Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | %{ |
2 | /* |
||
3 | * $Header: C:/cvsroot/Vert03/acf_src/acf_yacc.y,v 1.1.1.1 2003/11/04 23:34:58 mjames Exp $ *//* |
||
4 | * |
||
5 | * $Log: acf_yacc.y,v $ |
||
6 | * Revision 1.1.1.1 2003/11/04 23:34:58 mjames |
||
7 | * Imported into local repositrory |
||
8 | * |
||
9 | * Revision 1.38 2002/12/06 23:28:04 mjames |
||
10 | * Corrected locations where GND was being a |
||
11 | * reserved word and in fact was legal as pin/port ident |
||
12 | * |
||
13 | * Also error checked problems of duplicate idents appearing |
||
14 | * |
||
15 | * Revision 1.37 2002/10/02 18:45:23 MJAMES |
||
16 | * use routed_net member in place of net member when jumpers are processed |
||
17 | * |
||
18 | * Revision 1.36 2002/09/30 13:25:31 MJAMES |
||
19 | * Upgraded nets to include 'lhs_expression' being the range on the |
||
20 | * left hand side of a signal connection to a port |
||
21 | * |
||
22 | * std_logic_vector (0) <= std_logic , on a port of a chip |
||
23 | * |
||
24 | * Revision 1.35 2002/09/16 11:02:44 mjames |
||
25 | * Added some of the generic string types to the input parser. |
||
26 | * |
||
27 | * Revision 1.34 2002/09/09 10:14:58 mjames |
||
28 | * Modified expression parser to match CC as previous one was |
||
29 | * broken |
||
30 | * |
||
31 | * Revision 1.33 2002/08/23 14:21:54 mjames |
||
32 | * Added the <VHDL> string keyword. |
||
33 | * |
||
34 | * Revision 1.32 2002/08/19 14:31:26 mjames |
||
35 | * Removed an incompatibility with env_string generics where the output |
||
36 | * of Vertical caused an error under some circumstances. |
||
37 | * |
||
38 | * Revision 1.31 2002/08/14 12:00:15 mjames |
||
39 | * cleaned up on end of file code |
||
40 | * |
||
41 | * Revision 1.30 2002/08/06 12:54:14 mjames |
||
42 | * Merge in from latest version |
||
43 | * |
||
44 | * |
||
45 | * Revision 1.32 2002/03/22 16:16:28 mjames |
||
46 | * Modifications to undo over-zealous checking of |
||
47 | * current chip even in incorrect scenarios. |
||
48 | * |
||
49 | * Revision 1.31 2002/03/19 11:59:34 mjames |
||
50 | * Applying paranoid programming to the use of current_chip pointer |
||
51 | * as there were some address exceptions created in cases of missing |
||
52 | * components being instantiated in VHDL |
||
53 | * |
||
54 | * Revision 1.30 2002/03/08 11:53:57 mjames |
||
55 | * Corrected verilog module instance code |
||
56 | * |
||
57 | * Revision 1.29 2002/01/16 22:02:36 mjames |
||
58 | * Prevented coredumps while reading Verilog file |
||
59 | * s.g. Should permit further analysis of added |
||
60 | * requirements for complete Verilog reading |
||
61 | * |
||
62 | * Revision 1.28 2002/01/16 10:06:19 mjames |
||
63 | * Added package definitions to VHDL syntax |
||
64 | * According to report by John Marquis |
||
65 | * |
||
66 | * Revision 1.27 2002/01/03 16:39:17 mjames |
||
67 | * Removed unused rule causing coredump |
||
68 | * |
||
69 | * Revision 1.26 2001/12/13 22:12:15 mjames |
||
70 | * Vertical now supports nested include database files |
||
71 | * This allows wrappers around 'pure' VHDL or Verilog files |
||
72 | * |
||
73 | * Revision 1.25 2001/12/11 21:29:56 mjames |
||
74 | * Verilog syntax now read in by Vertical allows pin templates |
||
75 | * defined by Certify to be used. |
||
76 | * |
||
77 | * Revision 1.24 2001/11/30 22:47:37 mjames |
||
78 | * small corrections |
||
79 | * |
||
80 | * Revision 1.23 2001/11/30 22:21:19 mjames |
||
81 | * Modifying Verilog reading syntax to accept valid code. |
||
82 | * |
||
83 | * Revision 1.22 2001/11/19 09:46:14 mjames |
||
84 | * Semicolons missing: caused error with byacc |
||
85 | * |
||
86 | * Revision 1.21 2001/10/31 22:19:57 mjames |
||
87 | * Tidying up problematical comments caused by CVS |
||
88 | * 'intelligent' comment guessing |
||
89 | * |
||
90 | * Revision 1.20 2001/10/31 16:27:25 mjames |
||
91 | * Added a datastructure to hide regular expression information from programs. |
||
92 | * Changed call to regexec to indicate 0 subexpressions to be matched |
||
93 | * rather than a number dependent on strlen(string) which was wrong. |
||
94 | * |
||
95 | * Revision 1.19 2001/10/02 20:55:37 mjames |
||
96 | * Moved documentation about code to main program module. |
||
97 | * |
||
98 | * Revision 1.18 2001/09/21 14:13:10 mjames |
||
99 | * Corrected the creation of chip pinouts from VHDL source so that both |
||
100 | * ENTITY and COMPONENT port declarations assign a pin identifier that is |
||
101 | * the same as the pin name. Otherwise templating does not work, to create |
||
102 | * pin identifiers for a PCB |
||
103 | * |
||
104 | * Revision 1.17 2001/08/31 09:36:54 mjames |
||
105 | * removed DOS line endings |
||
106 | * |
||
107 | * Revision 1.16 2001/07/09 09:36:30 mjames |
||
108 | * Amending the syntax and end of file behaviour to allow Quartus pin fit files |
||
109 | * to be read . |
||
110 | * They are harder to read because they are not block structured. The end of file is used as a marker. Vertical has been persuaded to handle end of file events properly. |
||
111 | * |
||
112 | * Revision 1.15 2001/07/06 12:50:36 mjames |
||
113 | * Added the ability to read in Quartus pinfit files |
||
114 | * |
||
115 | * Revision 1.14 2001/07/05 15:12:37 MJAMES |
||
116 | * Amended to read Quartus pin files. not fully working |
||
117 | * |
||
118 | * Revision 1.13 2001/06/07 11:59:05 MJAMES |
||
119 | * Strange GCC optimiser error on line 1172. Changed code to trap possible error that |
||
120 | * should not happen anyway: probably a PII optimiser bug. |
||
121 | * |
||
122 | * Revision 1.12 2001/06/06 14:46:03 mjames |
||
123 | * Added further Verilog support. |
||
124 | * Corrected write ext command to not require additional argument. |
||
125 | * Added write quartus for creation of a pinfit file relevant to Quartus |
||
126 | * |
||
127 | * Revision 1.11 2001/06/06 12:10:26 mjames |
||
128 | * Move from HPUX |
||
129 | * |
||
130 | * Revision 1.10 2001/04/30 13:31:44 Administrator |
||
131 | * Started to add in Verilog parsing |
||
132 | * |
||
133 | * |
||
134 | * Revision 1.1 96/01/04 10:18:07 10:18:07 mjames (Mike James) |
||
135 | * Initial revision |
||
136 | * |
||
137 | * */ |
||
138 | #include <stdio.h> |
||
139 | #include <string.h> |
||
140 | #include <stdlib.h> |
||
141 | #include <ctype.h> |
||
142 | |||
143 | #include "vertcl_main.h" |
||
144 | #include "expression.h" |
||
145 | #include "generic.h" |
||
146 | #include "database.h" |
||
147 | #include "routing.h" |
||
148 | #include "cmdparse.h" |
||
149 | #include "cmdlog.h" |
||
150 | #include "jumpering.h" |
||
151 | #include "unrouted.h" |
||
152 | #include "lx_support.h" |
||
153 | #include "equivalent.h" |
||
154 | #include "acf_lex_ext.h" |
||
155 | |||
156 | |||
157 | #define YYERROR_VERBOSE |
||
158 | |||
159 | |||
160 | int lineno; |
||
161 | |||
162 | /* Structure to hold a set of identifiers for later processing */ |
||
163 | |||
164 | struct str * y_first = NULL, * y1_first=NULL; |
||
165 | struct str * y_last = NULL, * y1_last =NULL ; |
||
166 | int id_count = 0; |
||
167 | |||
168 | |||
169 | #ident "@(#)$Header: C:/cvsroot/Vert03/acf_src/acf_yacc.y,v 1.1.1.1 2003/11/04 23:34:58 mjames Exp $" |
||
170 | |||
171 | static socket_t * current_chip, * current_comp; |
||
172 | static node_t * current_node, * current_comp_node; |
||
173 | static net_t * current_net; |
||
174 | static net_t ** current_list; |
||
175 | |||
176 | /* used in net joining in the YACC parser */ |
||
177 | static net_t ** join_context; |
||
178 | static JoinMode_t join_mode; |
||
179 | static net_t * top_net; |
||
180 | |||
181 | static vhdl_t * vhdl; |
||
182 | static generic_info_t ** generic_context; |
||
183 | |||
184 | |||
185 | |||
186 | static equivalent_node_set_t * curr_equiv_list; |
||
187 | |||
188 | static char curr_pin_name[MAXIDLEN]; |
||
189 | static char curr_pin_ident[MAXIDLEN]; |
||
190 | static int curr_pin_dir; |
||
191 | static int curr_pin_group; |
||
192 | |||
193 | static generic_info_t info[1]; /* this is a local scratch area */ |
||
194 | |||
195 | /* handed back to the command line expression parser */ |
||
196 | |||
197 | static char * rename_pin_string; |
||
198 | |||
199 | static char text_buff[MAXIDLEN]; |
||
200 | |||
201 | |||
202 | void process_tdf_pins(struct str * s); |
||
203 | |||
204 | int inside_block = 0; |
||
205 | |||
206 | extern void exit_lex_block(void); /* means to return LEX to initial state */ |
||
207 | |||
208 | extern void create_pins_or_signals(void); |
||
209 | /* is the current component instance running implicit or explicit |
||
210 | port mapping ? */ |
||
211 | typedef enum { UNKNOWN,IMPLICIT,EXPLICIT } port_map_method; |
||
212 | port_map_method curr_comp_port_map; |
||
213 | |||
214 | %} |
||
215 | |||
216 | |||
217 | |||
218 | |||
219 | %union { char * string; |
||
220 | int integer; |
||
221 | generic_info_t * range ; |
||
222 | expression_t * exp; }; |
||
223 | |||
224 | |||
225 | %token FILEMODE CMDMODE |
||
226 | %token CHIP BEGIN_TOK END DEVICE |
||
227 | %token COMPONENTS WIRED_NETS CONN |
||
228 | %token END_CONN JOINED_NETS ALIAS JUMPER RENAME_PINS |
||
229 | %token TEMPLATE FIX_LOCATION LOCATION UNROUTED ROUTED NAMED |
||
230 | %token ASSIGN SIG_ASSIGN CONNECTED ROUTE_FLAGS DECLARATION INSTANCE |
||
231 | %token AHDL VERILOG SUBDESIGN OPEN BOOLEAN TRUE FALSE |
||
232 | %token TO DOWNTO GENERIC RANGE INTEGER NATURAL CONSTANT |
||
233 | %token VHDL PORT ENTITY IS COMPONENT MAP ARCHITECTURE OF |
||
234 | %token EQUIVALENT TO_POW ASIGNAL MODULE ENDMODULE LIBRARY USE ALL |
||
235 | %token PACKAGE FOR PROCESS |
||
236 | %token ASSIGNED AN WIRE GND GND_RES_IO GND_RES_IN VCC |
||
237 | %token ATTRIBUTE ENV_STRING STRING SHL SHR EQ_EQ N_EQ LOG_AND LOG_OR |
||
238 | %token QUOTE VHDL_CONN |
||
239 | |||
240 | %token <string> QUOTED_STRING |
||
241 | %token <string> TXT_STRING |
||
242 | %token <string> NUM_STRING |
||
243 | %token <integer> PINDIR |
||
244 | %token <string> VCC |
||
245 | %token <string> GND |
||
246 | %type <integer> generic_pindir_opt |
||
247 | %type <exp> expr |
||
248 | %type <exp> primary_expr |
||
249 | %type <exp> add_expr |
||
250 | %type <exp> mult_expr |
||
251 | %type <exp> shift_expr |
||
252 | %type <exp> relational_expr |
||
253 | %type <exp> equality_expr |
||
254 | %type <exp> and_expr |
||
255 | %type <exp> exor_expr |
||
256 | %type <exp> or_expr |
||
257 | %type <exp> logand_expr |
||
258 | %type <exp> logor_expr |
||
259 | %type <exp> cond_expr |
||
260 | %type <exp> expr1 |
||
261 | %type <exp> bus_range |
||
262 | %type <string> astring |
||
263 | %type <string> netname |
||
264 | %type <string> vhdl_lib_member_select |
||
265 | %type <exp> opt_integer |
||
266 | %type <exp> opt_bus_range |
||
267 | %type <exp> verilog_bus_expr |
||
268 | %type <exp> colon_expr |
||
269 | %type <exp> vhdl_type_default_value_opt |
||
270 | %type <exp> vhdl_port_map_slice_opt |
||
271 | %type <exp> simple_range_expr |
||
272 | |||
273 | %left UMINUS '~' |
||
274 | %left '(' |
||
275 | %% |
||
276 | |||
277 | |||
278 | /* two grammars present, one is vertical .acfp file, |
||
279 | the other is from the command line. Eventually these two grammars |
||
280 | will be merged */ |
||
281 | |||
282 | file : FILEMODE objects |
||
283 | | CMDMODE cmd_objects; |
||
284 | |||
285 | /************************************************************************/ |
||
286 | /* COMMAND MODE GRAMMAR */ |
||
287 | /************************************************************************/ |
||
288 | |||
289 | cmd_objects : cmd_objects cmd_object |
||
290 | | cmd_object |
||
291 | ; |
||
292 | |||
293 | cmd_object : bus_range { cmd_expression = $1; } |
||
294 | ; |
||
295 | |||
296 | |||
297 | /************************************************************************/ |
||
298 | /* FILE MODE GRAMMAR */ |
||
299 | /************************************************************************/ |
||
300 | |||
301 | |||
302 | objects : objects object |
||
303 | | object |
||
304 | ; |
||
305 | |||
306 | object : chip_decl |
||
307 | | components_decl |
||
308 | | template_decl |
||
309 | | joined_decl |
||
310 | | nets_decl |
||
311 | | rename_pins_block |
||
312 | | global_generic_decl |
||
313 | | vhdl_region |
||
314 | | verilog_region |
||
315 | | ahdl_region |
||
316 | | |
||
317 | ; |
||
318 | |||
319 | /****************************************************************/ |
||
320 | /* all string types */ |
||
321 | |||
322 | astring : QUOTED_STRING { $$=$1; } |
||
323 | | TXT_STRING { $$=$1; } |
||
324 | | NUM_STRING { $$=$1; }; |
||
325 | |||
326 | /****************************************************************/ |
||
327 | /* beginning finding the chip declaration */ |
||
328 | /****************************************************************/ |
||
329 | chip_decl : chip_id_decl chip_body; |
||
330 | |||
331 | chip_body : BEGIN_TOK flex_chip_body |
||
332 | | ASSIGNED apex_chip_body |
||
333 | ; |
||
334 | |||
335 | /******************************************************************/ |
||
336 | /* old style FLEX/acfp CHIP declaration */ |
||
337 | |||
338 | flex_chip_body : chip_info_lines |
||
339 | pin_declarations |
||
340 | pin_equivalences |
||
341 | END end_item { |
||
342 | free_lex_strings(); |
||
343 | exit_lex_block(); |
||
344 | current_chip = NULL;} |
||
345 | ; |
||
346 | |||
347 | chip_id_decl : CHIP astring |
||
348 | { id_count = 0; /* used in pin ID lists */ |
||
349 | current_chip=find_socket(Name,$2,Create,&socket_head); |
||
350 | /* current_chip is unlikely to be null .. but */ |
||
351 | if (current_chip) |
||
352 | { |
||
353 | current_chip->is_template = 0; |
||
354 | current_chip->parent_template_ref = NULL; |
||
355 | current_chip->route_flags = 0; |
||
356 | /* ensure_socket_ident(current_chip); */ |
||
357 | |||
358 | if(ISNULLSTR(current_chip->identifier)) |
||
359 | { |
||
360 | socket_t * test = find_socket(Ident,$2,Search,&socket_head); |
||
361 | if (!test) |
||
362 | set_socket(current_chip,Ident,$2); |
||
363 | else |
||
364 | { |
||
365 | Log(LOG_ERROR,"-- ERROR :name '%s' clashes with another ID in CHIP declaration\n",$2); |
||
366 | set_socket(current_chip,Ident,"name clashes with another chip ident in CHIP declaration"); |
||
367 | } |
||
368 | } |
||
369 | } |
||
370 | }; |
||
371 | |||
372 | chip_info_lines : chip_info_lines chip_info_line |
||
373 | | chip_info_line |
||
374 | | /* nothing */ |
||
375 | ; |
||
376 | |||
377 | chip_info_line : device_declaration |
||
378 | | route_flags_info |
||
379 | | routing_status |
||
380 | | chip_generic_decl; |
||
381 | |||
382 | device_declaration : DEVICE '=' astring end_item |
||
383 | { if(current_chip) |
||
384 | set_socket(current_chip,Type,$3); |
||
385 | }; |
||
386 | |||
387 | pin_equivalences : pin_equivalence pin_equivalences |
||
388 | | pin_equivalence |
||
389 | | /* nothing */ |
||
390 | ; |
||
391 | |||
392 | /* gap : NL gap |
||
393 | | NL |
||
394 | | |
||
395 | ; |
||
396 | */ |
||
397 | |||
398 | end_item : ';' ; |
||
399 | |||
400 | routing_status : UNROUTED end_item |
||
401 | ; |
||
402 | |||
403 | /* routing flags are used in fasttrack routing */ |
||
404 | route_flags_info : ROUTE_FLAGS '=' route_flag_value end_item |
||
405 | ; |
||
406 | |||
407 | route_flag_value : NUM_STRING { if(current_chip) |
||
408 | convert_num($1,¤t_chip->route_flags); }; |
||
409 | |||
410 | /****************************************************************/ |
||
411 | /* these patterns are shared between CHIP and TEMPLATE . |
||
412 | A flag is set in the form of chip_context to slightly modify |
||
413 | undesirable behaviour */ |
||
414 | |||
415 | pin_declarations : pin_declarations pin_declaration |
||
416 | | pin_declaration |
||
417 | | |
||
418 | ; |
||
419 | |||
420 | pin_declaration : name_part ':' pin_rest end_item |
||
421 | ; |
||
422 | |||
423 | /* if the chip pin is given a name in the template , suppress it. It |
||
424 | will attempt to link the template to a real net if the pin has a name */ |
||
425 | |||
426 | name_part : netname { char * s ; |
||
427 | s = make_string($1,&y_first,&y_last); |
||
428 | |||
429 | strcpy(curr_pin_name,"Still_Using_pin_name_somewhere"); |
||
430 | curr_pin_dir = NONE; /* default bidirectional */ |
||
431 | if(ISNULLSTR(s))/* the null strings tell acfread that the pin exists and */ |
||
432 | current_list = &routed_list ;/* available for routing */ |
||
433 | else |
||
434 | current_list = &unrouted_list ; |
||
435 | }; |
||
436 | |||
437 | pin_rest : pin_dir pin_group '=' pin_ident vhdl_type_opt |
||
438 | | UNROUTED /* no action */ |
||
439 | | LOCATION '=' astring /* no action */ |
||
440 | ; |
||
441 | |||
442 | pin_dir : PINDIR { curr_pin_dir = $1; } |
||
443 | ; |
||
444 | |||
445 | pin_group : '(' NUM_STRING ')' { convert_num($2,&curr_pin_group); } |
||
446 | | /* nothing */ { curr_pin_group = 0; }; |
||
447 | |||
448 | pin_ident : netname { strcpy(curr_pin_ident,$1); }; |
||
449 | |||
450 | /***********************************************************************************/ |
||
451 | /* APEX handler */ |
||
452 | apex_chip_body : apex_device_declaration |
||
453 | apex_info_lines ; |
||
454 | |||
455 | apex_device_declaration : TO AN astring apex_speed_grade |
||
456 | { if(current_chip) |
||
457 | set_socket(current_chip,Type,$3); |
||
458 | }; |
||
459 | |||
460 | apex_speed_grade : '-' NUM_STRING { generic_info_t info; |
||
461 | char * sbuff = malloc(strlen($2)+2); |
||
462 | sprintf(sbuff,"-%s",$2); |
||
463 | info.expr = compile_string(sbuff); |
||
464 | free(sbuff); |
||
465 | info.name = "speed_grade"; |
||
466 | info.typename = "string"; |
||
467 | info.g_type = IS_DECLARATION_DIRECTIVE; |
||
468 | if(current_chip) |
||
469 | set_generic_value(¤t_chip->generics,&info); |
||
470 | } |
||
471 | | /* nothing */ |
||
472 | ; |
||
473 | |||
474 | apex_info_lines : apex_info_lines apex_info_line |
||
475 | | apex_info_line; |
||
476 | |||
477 | apex_info_line : GND ':' astring more_colons { /* ground pin .. no op */ } |
||
478 | | GND_RES_IO ':' astring more_colons { /* reserved pin .. no op */ } |
||
479 | | GND_RES_IN ':' astring more_colons { /* reserved pin .. no op */ } |
||
480 | | VCC ':' astring ':' NUM_STRING { /* power pin .. no op */ } |
||
481 | | VCC ':' astring more_colons { /* as this pattern shows.. power pin .. no op */ } |
||
482 | | TXT_STRING ':' astring more_colons {/*printf("ignore pin %s at %s\n",$1,$3);*//* reserved pin .. no op */ } |
||
483 | | TXT_STRING ':' astring ':' PINDIR ':' astring ':' { current_list = &unrouted_list ; |
||
484 | make_string($1,&y_first,&y_last); |
||
485 | /*printf("pin %s at %s\n",$1,$3);*/ |
||
486 | strcpy(curr_pin_ident,$3); |
||
487 | curr_pin_dir = $5; |
||
488 | vhdl = default_vhdl_datatype; |
||
489 | create_pins_or_signals(); |
||
490 | } |
||
491 | |||
492 | | TXT_STRING '[' expr ']' ':' astring ':' PINDIR ':' astring ':' { current_list = &unrouted_list ; |
||
493 | make_string($1,&y_first,&y_last); |
||
494 | /*printf("pin %s at %s\n",$1,$3);*/ |
||
495 | vhdl = calloc(1,sizeof(vhdl_t)); |
||
496 | vhdl->is_vector = 1; |
||
497 | vhdl->expr = $3; |
||
498 | strcpy(curr_pin_ident,$6); |
||
499 | curr_pin_dir = $8; |
||
500 | /* vhdl = default_vhdl_datatype; */ |
||
501 | create_pins_or_signals(); |
||
502 | } |
||
503 | ; |
||
504 | |||
505 | more_colons : ':' more_colons |
||
506 | | ':' |
||
507 | ; |
||
508 | |||
509 | /************************************************************************************/ |
||
510 | |||
511 | /* begin to recognise the possible VHDL syntax for a VHDL type */ |
||
512 | |||
513 | /* this declaration is where the pin type is purely optional in ACFP files */ |
||
514 | vhdl_type_opt : ':' vhdl_type |
||
515 | | /* nothing */ { /* use a default type if none given */ |
||
516 | vhdl = default_vhdl_datatype; |
||
517 | create_pins_or_signals(); |
||
518 | } ;/* altering define pin to take a pointer to VHDL type */ |
||
519 | |||
520 | |||
521 | /* this declaration is a 'pure' VHDL that can be used in VHDL chunks */ |
||
522 | vhdl_type : astring vhdl_type_default_value_opt { /* single bit types */ |
||
523 | vhdl = (vhdl_t *)calloc(1,sizeof(vhdl_t)); |
||
524 | if(vhdl){ |
||
525 | vhdl->basetype = allocstr($1); |
||
526 | vhdl->is_vector = 0; |
||
527 | vhdl->is_downto = 0; |
||
528 | vhdl->expr = NULL; |
||
529 | vhdl->default_expr = $2;/* added default assignment expression */ |
||
530 | create_pins_or_signals(); |
||
531 | } |
||
532 | } |
||
533 | | astring '(' bus_range ')' vhdl_type_default_value_opt { /* vhdl vector types */ |
||
534 | vhdl = (vhdl_t *)calloc(1,sizeof(vhdl_t)); |
||
535 | if(vhdl){ |
||
536 | vhdl->basetype = allocstr($1); |
||
537 | vhdl->is_vector = 1; /* not known for sure yet */ |
||
538 | vhdl->is_downto = 0; |
||
539 | vhdl->expr = $3; |
||
540 | vhdl->default_expr = $5;/* added default assignment expression */ |
||
541 | create_pins_or_signals(); |
||
542 | } |
||
543 | #if defined DEBUG_EXPRESSION |
||
544 | print_msg_expression(stdout,"seen bus ",$3); |
||
545 | #endif |
||
546 | |||
547 | } |
||
548 | | INTEGER vhdl_type_default_value_opt { /* added Nov 2000 */ |
||
549 | vhdl = (vhdl_t *)calloc(1,sizeof(vhdl_t)); |
||
550 | if(vhdl){ |
||
551 | vhdl->basetype = "integer"; |
||
552 | vhdl->is_vector = 0; /* not known for sure yet */ |
||
553 | vhdl->is_downto = 0; |
||
554 | vhdl->expr = NULL; |
||
555 | vhdl->default_expr = $2;/* added default assignment expression */ |
||
556 | create_pins_or_signals(); |
||
557 | } |
||
558 | } |
||
559 | | INTEGER RANGE simple_range_expr vhdl_type_default_value_opt { /* added Nov 2000 */ |
||
560 | vhdl = (vhdl_t *)calloc(1,sizeof(vhdl_t)); |
||
561 | if(vhdl){ |
||
562 | vhdl->basetype = "integer range"; |
||
563 | vhdl->decl_expr = $3; |
||
564 | vhdl->is_vector = 0; /* not known for sure yet */ |
||
565 | vhdl->is_downto = 0; |
||
566 | vhdl->expr = NULL; |
||
567 | vhdl->default_expr = $4;/* added default assignment expression */ |
||
568 | create_pins_or_signals(); |
||
569 | } |
||
570 | } |
||
571 | | NATURAL vhdl_type_default_value_opt { /* added Nov 2000 */ |
||
572 | vhdl = (vhdl_t *)calloc(1,sizeof(vhdl_t)); |
||
573 | if(vhdl){ |
||
574 | vhdl->basetype = "natural"; |
||
575 | vhdl->is_vector = 0; /* not known for sure yet */ |
||
576 | vhdl->is_downto = 0; |
||
577 | vhdl->expr = NULL; |
||
578 | vhdl->default_expr = $2;/* added default assignment expression */ |
||
579 | create_pins_or_signals(); |
||
580 | } |
||
581 | } |
||
582 | | NATURAL RANGE simple_range_expr vhdl_type_default_value_opt { /* added Nov 2000 */ |
||
583 | vhdl = (vhdl_t *)calloc(1,sizeof(vhdl_t)); |
||
584 | if(vhdl){ |
||
585 | vhdl->basetype = "natural range"; |
||
586 | vhdl->decl_expr = $3; |
||
587 | vhdl->is_vector = 0; /* not known for sure yet */ |
||
588 | vhdl->is_downto = 0; |
||
589 | vhdl->expr = $3; |
||
590 | vhdl->default_expr = $4;/* added default assignment expression */ |
||
591 | create_pins_or_signals(); |
||
592 | } |
||
593 | } |
||
594 | | BOOLEAN vhdl_type_default_value_opt { /* added May 2001 */ |
||
595 | vhdl = (vhdl_t *)calloc(1,sizeof(vhdl_t)); |
||
596 | if(vhdl){ |
||
597 | vhdl->basetype = "boolean"; |
||
598 | vhdl->is_vector = 0; /* not known for sure yet */ |
||
599 | vhdl->is_downto = 0; |
||
600 | vhdl->expr = NULL; |
||
601 | vhdl->default_expr = $2;/* added default assignment expression */ |
||
602 | create_pins_or_signals(); |
||
603 | } |
||
604 | }; |
||
605 | |||
606 | vhdl_type_default_value_opt : ASSIGN bus_range { $$ = $2; /* printf("found default assign\n");*/ } |
||
607 | | /* nothing */ { $$ = NULL; } |
||
608 | ; |
||
609 | |||
610 | |||
611 | /* general generic stuff */ |
||
612 | |||
613 | bus_range : expr1 |
||
614 | | expr |
||
615 | ; |
||
616 | |||
617 | /* an expression of type range at top level is allowed */ |
||
618 | expr1 : simple_range_expr { |
||
619 | $$ = $1; |
||
620 | } |
||
621 | |QUOTED_STRING { |
||
622 | $$ = compile_string($1); |
||
623 | } |
||
624 | |||
625 | | QUOTE astring QUOTE{ |
||
626 | $$ = compile_char($2[0]); |
||
627 | } |
||
628 | ; |
||
629 | |||
630 | simple_range_expr : expr TO expr { |
||
631 | $$ = compile_expression(TO,$1,$3); |
||
632 | |||
633 | } |
||
634 | | expr DOWNTO expr { |
||
635 | $$ = compile_expression(DOWNTO,$1,$3); |
||
636 | } |
||
637 | ; |
||
638 | |||
639 | |||
640 | /* an expression calculator that will use the generics |
||
641 | attached to the current chip to work out the values */ |
||
642 | primary_expr :'(' expr ')' |
||
643 | { |
||
644 | $$ = compile_expression('(',$2,NULL); |
||
645 | } |
||
646 | | '~' expr %prec UMINUS |
||
647 | { |
||
648 | $$ = compile_expression('~',$2,NULL); |
||
649 | } |
||
650 | | '-' expr %prec UMINUS |
||
651 | { |
||
652 | $$ = compile_expression(UMINUS,$2,NULL); |
||
653 | } |
||
654 | |||
655 | | NUM_STRING { int t; |
||
656 | convert_num($1,&t); |
||
657 | $$ = compile_constant_string(t,$1); |
||
658 | } |
||
659 | | TXT_STRING |
||
660 | { |
||
661 | $$ = compile_reference($1); |
||
662 | } |
||
663 | | TRUE { |
||
664 | $$=compile_constant_string(1,"true"); /* should really respect boolean type */ |
||
665 | } |
||
666 | | FALSE { |
||
667 | $$=compile_constant_string(0,"false"); |
||
668 | } |
||
669 | ; |
||
670 | |||
671 | mult_expr : primary_expr |
||
672 | { |
||
673 | $$ = $1; |
||
674 | } |
||
675 | | mult_expr '*' primary_expr |
||
676 | { |
||
677 | $$ = compile_expression('*',$1,$3); |
||
678 | } |
||
679 | | mult_expr '/' primary_expr |
||
680 | { |
||
681 | $$ = compile_expression('/',$1,$3); |
||
682 | } |
||
683 | | mult_expr '%' primary_expr |
||
684 | { |
||
685 | $$ = compile_expression('%',$1,$3); |
||
686 | } |
||
687 | | mult_expr TO_POW primary_expr { |
||
688 | $$ = compile_expression(TO_POW,$1,$3); |
||
689 | } |
||
690 | ; |
||
691 | |||
692 | |||
693 | |||
694 | add_expr : mult_expr |
||
695 | { |
||
696 | $$ = $1; |
||
697 | } |
||
698 | | add_expr '+' mult_expr |
||
699 | { |
||
700 | $$ = compile_expression('+',$1,$3); |
||
701 | } |
||
702 | | add_expr '-' mult_expr |
||
703 | { |
||
704 | $$ = compile_expression('-',$1,$3); |
||
705 | } |
||
706 | ; |
||
707 | |||
708 | shift_expr : add_expr |
||
709 | { |
||
710 | $$ = $1; |
||
711 | } |
||
712 | | shift_expr SHL add_expr |
||
713 | { |
||
714 | $$ = compile_expression(SHL,$1,$3); |
||
715 | } |
||
716 | | shift_expr SHR add_expr |
||
717 | { |
||
718 | $$ = compile_expression(SHR,$1,$3); |
||
719 | } |
||
720 | ; |
||
721 | |||
722 | |||
723 | relational_expr : shift_expr |
||
724 | { |
||
725 | $$ = $1; |
||
726 | } |
||
727 | | relational_expr '>' shift_expr |
||
728 | { |
||
729 | $$ = compile_expression('>',$1,$3); |
||
730 | } |
||
731 | | relational_expr '<' shift_expr |
||
732 | { |
||
733 | $$ = compile_expression('<',$1,$3); |
||
734 | } |
||
735 | ; |
||
736 | |||
737 | |||
738 | equality_expr : relational_expr |
||
739 | { |
||
740 | $$ = $1; |
||
741 | } |
||
742 | | equality_expr EQ_EQ relational_expr |
||
743 | { |
||
744 | $$ = compile_expression(EQ_EQ,$1,$3); |
||
745 | } |
||
746 | | equality_expr N_EQ relational_expr |
||
747 | { |
||
748 | $$ = compile_expression(N_EQ,$1,$3); |
||
749 | } |
||
750 | ; |
||
751 | |||
752 | |||
753 | and_expr : equality_expr |
||
754 | { |
||
755 | $$ = $1; |
||
756 | } |
||
757 | | and_expr '&' equality_expr |
||
758 | { |
||
759 | $$ = compile_expression('&',$1,$3); |
||
760 | } |
||
761 | ; |
||
762 | |||
763 | |||
764 | exor_expr : and_expr |
||
765 | { |
||
766 | $$ = $1; |
||
767 | } |
||
768 | | exor_expr '^' and_expr |
||
769 | { |
||
770 | $$ = compile_expression('^',$1,$3); |
||
771 | } |
||
772 | ; |
||
773 | |||
774 | |||
775 | or_expr : exor_expr |
||
776 | { |
||
777 | $$ = $1; |
||
778 | } |
||
779 | | or_expr '|' or_expr |
||
780 | { |
||
781 | $$ = compile_expression('|',$1,$3); |
||
782 | } |
||
783 | ; |
||
784 | |||
785 | |||
786 | logand_expr: or_expr |
||
787 | { |
||
788 | $$ = $1; |
||
789 | } |
||
790 | | logand_expr LOG_AND or_expr |
||
791 | { |
||
792 | $$ = compile_expression(LOG_AND,$1,$3); |
||
793 | } |
||
794 | ; |
||
795 | |||
796 | logor_expr : logand_expr |
||
797 | { |
||
798 | $$ = $1; |
||
799 | } |
||
800 | | logor_expr LOG_OR logand_expr |
||
801 | { |
||
802 | $$ = compile_expression(LOG_OR,$1,$3); |
||
803 | } |
||
804 | ; |
||
805 | |||
806 | |||
807 | cond_expr : logor_expr '?' colon_expr |
||
808 | { |
||
809 | $$ = compile_expression('?',$1,$3); |
||
810 | } |
||
811 | ; |
||
812 | |||
813 | |||
814 | colon_expr : expr ':' expr |
||
815 | { /* change from cond_expr on rhs */ |
||
816 | $$ = compile_expression(':',$1,$3); |
||
817 | }; |
||
818 | |||
819 | expr : cond_expr |
||
820 | { |
||
821 | $$ = $1; |
||
822 | } |
||
823 | | logor_expr |
||
824 | { |
||
825 | $$ = $1; |
||
826 | } |
||
827 | ; |
||
828 | |||
829 | /**************************************************************************/ |
||
830 | /* pin equivalence Declarations */ |
||
831 | /**************************************************************************/ |
||
832 | |||
833 | |||
834 | pin_equivalence : EQUIVALENT { curr_equiv_list = begin_equivalent_pins(); } |
||
835 | '(' equivalent_pins ')' |
||
836 | end_item { if(current_chip) |
||
837 | check_equivalent_pins(current_chip,curr_equiv_list); } |
||
838 | ; |
||
839 | |||
840 | equivalent_pins : equivalent_pin end_item equivalent_pins |
||
841 | | equivalent_pin |
||
842 | | /* nothing */ |
||
843 | ; |
||
844 | |||
845 | equivalent_pin : astring { if(current_chip) |
||
846 | add_equivalent_pin( current_chip,curr_equiv_list,$1); }; |
||
847 | |||
848 | |||
849 | |||
850 | |||
851 | |||
852 | /**************************************************************************/ |
||
853 | /* VHDL Block Declarations */ |
||
854 | /**************************************************************************/ |
||
855 | vhdl_region : VHDL |
||
856 | vhdl_blocks |
||
857 | END end_item { exit_lex_block(); free_lex_strings(); } |
||
858 | ; |
||
859 | |||
860 | vhdl_blocks : vhdl_blocks vhdl_block |
||
861 | | vhdl_block |
||
862 | ; |
||
863 | |||
864 | /* now includes the idea of a VHDL architecture as the equivalent of a template */ |
||
865 | vhdl_block : vhdl_chip_decl |
||
866 | | vhdl_architecture |
||
867 | | vhdl_package_decl /* but not a package body... */ |
||
868 | | vhdl_library_decl |
||
869 | | vhdl_use_decl |
||
870 | | /* nothing */ |
||
871 | ; |
||
872 | |||
873 | /**************************************************************************/ |
||
874 | /* VHDL Chip Entity Declaration */ |
||
875 | /**************************************************************************/ |
||
876 | vhdl_chip_decl : ENTITY hdl_entityname_decl IS { |
||
877 | Log(LOG_GENERAL, |
||
878 | "(line %d) Using ENTITY declaration for %s : prefer to use COMPONENT\n",lineno,current_chip->type); |
||
879 | } |
||
880 | vhdl_generic_decl_opt |
||
881 | vhdl_port_decl_opt |
||
882 | END TXT_STRING end_item { |
||
883 | current_chip = NULL; }; |
||
884 | |||
885 | /* this shared with verilog */ |
||
886 | |||
887 | hdl_entityname_decl : TXT_STRING |
||
888 | { |
||
889 | current_chip=find_socket(Name,$1,Create,&socket_head); |
||
890 | if(current_chip) |
||
891 | { |
||
892 | current_chip->is_template = 0; |
||
893 | current_chip->parent_template_ref = NULL; |
||
894 | current_chip->route_flags = 0; |
||
895 | |||
896 | set_socket(current_chip,Type,$1); |
||
897 | if(ISNULLSTR(current_chip->identifier)) |
||
898 | set_socket(current_chip,Ident,$1); |
||
899 | if(ISNULLSTR(current_chip->type)) |
||
900 | set_socket(current_chip,Type,$1); |
||
901 | generic_context = ¤t_chip->generics; |
||
902 | curr_pin_ident[0] = 0; /* use the signal name instead if this string is empty */ |
||
903 | } |
||
904 | }; |
||
905 | |||
906 | vhdl_generic_decl_opt : vhdl_generic_decl |
||
907 | | /* nothing */ ; |
||
908 | |||
909 | /* the generic information here shares the standard generic declaration |
||
910 | from the ACFp declaration */ |
||
911 | vhdl_generic_decl : GENERIC '(' { if (current_chip) |
||
912 | generic_context = ¤t_chip->generics; } |
||
913 | generic_defn_lines |
||
914 | ')' end_item |
||
915 | ; |
||
916 | |||
917 | |||
918 | /**************************************************************/ |
||
919 | /* port list */ |
||
920 | /**************************************************************/ |
||
921 | |||
922 | vhdl_port_decl_opt : vhdl_port_decl |
||
923 | | /* nothing */ |
||
924 | ; |
||
925 | |||
926 | vhdl_port_decl : PORT '(' vhdl_port_list ')' end_item; |
||
927 | |||
928 | vhdl_port_list : vhdl_port_list end_item vhdl_port_item |
||
929 | | vhdl_port_item |
||
930 | | /* nothing */ |
||
931 | ; |
||
932 | |||
933 | |||
934 | /* the VHDL Port item , inherits the pin_dir from a standard chip declaration |
||
935 | and the vhdl type extraction from the generic type declaration |
||
936 | */ |
||
937 | vhdl_port_item : vhdl_name_list ':' pin_dir vhdl_type |
||
938 | vhdl_assign_opt {if(current_chip) |
||
939 | create_nodes_from_refs(current_chip,0); }; |
||
940 | |||
941 | |||
942 | vhdl_name_list : vhdl_name_list ',' hdl_name_part |
||
943 | | hdl_name_part |
||
944 | ; |
||
945 | /* null the pin identifier to allow for creation of an ident in define_pin |
||
946 | */ |
||
947 | /* this is a pin on a component declaration */ |
||
948 | hdl_name_part : netname { |
||
949 | char * s = make_string($1,&y_first,&y_last); |
||
950 | if(current_chip) |
||
951 | { |
||
952 | curr_pin_dir = NONE; /* default bidirectional */ |
||
953 | if(current_chip->is_template ==1 || |
||
954 | (ISNULLSTR(s) && id_count ==0))/* the null strings tell acfread that the pin exists and */ |
||
955 | current_list = &routed_list ;/* available for routing */ |
||
956 | else |
||
957 | current_list = &unrouted_list ; |
||
958 | id_count++; |
||
959 | } |
||
960 | }; |
||
961 | |||
962 | |||
963 | |||
964 | vhdl_assign_opt : ASSIGN expr |
||
965 | | /* nothing */ |
||
966 | ; |
||
967 | |||
968 | |||
969 | |||
970 | /***********************************************************************/ |
||
971 | /* VHDL Architecture Declaration */ |
||
972 | /***********************************************************************/ |
||
973 | vhdl_architecture : ARCHITECTURE astring OF astring IS |
||
974 | vhdl_architecture_declarations |
||
975 | BEGIN_TOK |
||
976 | vhdl_architecture_body_items |
||
977 | END astring end_item; |
||
978 | |||
979 | vhdl_architecture_declarations: vhdl_architecture_declarations vhdl_architecture_decl |
||
980 | | vhdl_architecture_decl |
||
981 | | /* nothing */ |
||
982 | ; |
||
983 | |||
984 | vhdl_architecture_decl : vhdl_component_decl |
||
985 | | vhdl_constant_decl |
||
986 | | vhdl_signal_decl |
||
987 | | vhdl_configuration_decl |
||
988 | ; |
||
989 | /**********************************************************************/ |
||
990 | /* VHDL Package Declaration */ |
||
991 | /**********************************************************************/ |
||
992 | |||
993 | vhdl_package_decl : PACKAGE package_name IS |
||
994 | vhdl_package_declarations |
||
995 | END astring end_item ; |
||
996 | |||
997 | package_name : astring { Log(LOG_GENERAL,"-- (line %d) package %s being read\n",lineno,$1); }; |
||
998 | |||
999 | |||
1000 | vhdl_package_declarations: vhdl_package_declarations vhdl_package_decl_item |
||
1001 | | vhdl_package_decl_item |
||
1002 | | /* nothing */ |
||
1003 | ; |
||
1004 | |||
1005 | vhdl_package_decl_item : vhdl_component_decl |
||
1006 | | vhdl_constant_decl |
||
1007 | | vhdl_signal_decl |
||
1008 | | vhdl_configuration_decl |
||
1009 | ; |
||
1010 | |||
1011 | /***********************************************************************/ |
||
1012 | /* VHDL Component Declaration */ |
||
1013 | /***********************************************************************/ |
||
1014 | vhdl_component_decl: COMPONENT |
||
1015 | hdl_compname_decl |
||
1016 | vhdl_generic_decl_opt |
||
1017 | vhdl_port_decl_opt |
||
1018 | END COMPONENT |
||
1019 | end_item { if(current_chip) |
||
1020 | create_nodes_from_refs(current_chip,0); |
||
1021 | current_chip = NULL; }; |
||
1022 | hdl_compname_decl : TXT_STRING |
||
1023 | { |
||
1024 | current_chip=find_socket(Name,$1,Create,&template_head); |
||
1025 | if(current_chip) |
||
1026 | { |
||
1027 | current_chip->is_template = 1;/* components look like templates */ |
||
1028 | current_chip->parent_template_ref = NULL; |
||
1029 | current_chip->route_flags = 0; |
||
1030 | ensure_socket_ident(current_chip); |
||
1031 | set_socket(current_chip,Type,$1); /* socket name is also a type */ |
||
1032 | generic_context = ¤t_chip->generics; |
||
1033 | } |
||
1034 | }; |
||
1035 | |||
1036 | |||
1037 | /***********************************************************************/ |
||
1038 | /* VHDL Constant Declaration */ |
||
1039 | /***********************************************************************/ |
||
1040 | |||
1041 | vhdl_constant_decl : CONSTANT { generic_context = & global_generics; } |
||
1042 | generic_defn_text end_item; |
||
1043 | |||
1044 | /***********************************************************************/ |
||
1045 | /* VHDL Signal Declaration */ |
||
1046 | /***********************************************************************/ |
||
1047 | |||
1048 | |||
1049 | vhdl_signal_decl : ASIGNAL { id_count = 0 ; y_first = NULL;y_last = NULL; } |
||
1050 | hdl_signal_names ':' vhdl_type |
||
1051 | |||
1052 | /* { char buf[200]; |
||
1053 | printf("... type='%s'\n",decode_vhdl_type(buf,vhdl)); |
||
1054 | } |
||
1055 | */ |
||
1056 | end_item; |
||
1057 | |||
1058 | |||
1059 | /* collect together all of the signal names that share the type declaration */ |
||
1060 | |||
1061 | hdl_signal_names : hdl_signal_names ',' hdl_signal_name |
||
1062 | | hdl_signal_name |
||
1063 | ; |
||
1064 | |||
1065 | hdl_signal_name : astring { |
||
1066 | /* y_first is defined as null so we do not create any |
||
1067 | |||
1068 | pins (as they do not belong to any particular chip) */ |
||
1069 | #if defined DEBUG_EXPRESSION |
||
1070 | printf("making sig name %s\n",$1); |
||
1071 | #endif |
||
1072 | make_string($1,&y1_first,&y1_last); |
||
1073 | id_count++; |
||
1074 | }; |
||
1075 | |||
1076 | /***********************************************************************/ |
||
1077 | /* VHDL Configuration Declaration */ |
||
1078 | /***********************************************************************/ |
||
1079 | /* for <scope> ':' <component> use entity <library>.<entity>(<architecture>) */ |
||
1080 | /* for ALL : draw USE ENTITY work.draw(rtl); */ |
||
1081 | |||
1082 | vhdl_configuration_decl : FOR |
||
1083 | vhdl_lib_member_select ':' astring USE ENTITY |
||
1084 | astring '.' astring '(' astring ')' ';' |
||
1085 | { Log(LOG_GENERAL,"-- (line %d) for %s: %s use entity %s.%s(%s);\n",lineno,$2,$4,$7,$9,$11); }; |
||
1086 | |||
1087 | /* code currently omitted */ |
||
1088 | |||
1089 | /***********************************************************************/ |
||
1090 | /* VHDL Architecture body items */ |
||
1091 | /***********************************************************************/ |
||
1092 | vhdl_architecture_body_items: vhdl_architecture_body_items vhdl_architecture_body_item |
||
1093 | | vhdl_architecture_body_item |
||
1094 | | /* nothing */ |
||
1095 | ; |
||
1096 | |||
1097 | vhdl_architecture_body_item : vhdl_concurrent_assignment |
||
1098 | | vhdl_component_instance |
||
1099 | ; |
||
1100 | |||
1101 | |||
1102 | |||
1103 | /************************************************************************/ |
||
1104 | /* VHDL Component Instantiation */ |
||
1105 | /************************************************************************/ |
||
1106 | |||
1107 | /* this code now sets up all unused ports to be bound to signals of the |
||
1108 | same name as the ports (makes setting up simple architectures using |
||
1109 | Vertical shorthand easier */ |
||
1110 | |||
1111 | vhdl_component_instance : vhdl_inst_comp_binding |
||
1112 | vhdl_inst_generic_map |
||
1113 | vhdl_inst_port_map end_item { |
||
1114 | if(current_comp && current_chip) { /* scan for unused nodes */ |
||
1115 | current_comp_node = current_comp->nodes; |
||
1116 | while(current_comp_node) { |
||
1117 | if (current_comp_node->in_use == 0) { |
||
1118 | /* hookup to an unroutd signal */ |
||
1119 | define_pin(&unrouted_list, |
||
1120 | current_chip, |
||
1121 | current_comp_node->name, |
||
1122 | current_comp_node->pindir, |
||
1123 | current_comp_node->pin_group, |
||
1124 | current_comp_node->identifier, |
||
1125 | current_comp_node->vhdltype, |
||
1126 | NULL); |
||
1127 | } |
||
1128 | |||
1129 | current_comp_node =current_comp_node->sktnext; |
||
1130 | } |
||
1131 | } |
||
1132 | current_chip = NULL; } ; |
||
1133 | |||
1134 | |||
1135 | vhdl_inst_comp_binding : TXT_STRING ':' TXT_STRING { |
||
1136 | current_comp=find_socket(Type,$3,Search,&template_head); |
||
1137 | if(!current_comp) { |
||
1138 | Log(LOG_ERROR, |
||
1139 | "-- (line %d) No component of type %s can be found\n",lineno,$3); |
||
1140 | current_chip = NULL; |
||
1141 | } |
||
1142 | else { |
||
1143 | current_chip=find_socket(Ident,$1,Create,&socket_head); |
||
1144 | if(current_chip) { |
||
1145 | /* setup the current chip */ |
||
1146 | current_chip->is_template =0 ; |
||
1147 | current_chip->parent_template_ref = NULL; |
||
1148 | current_chip->route_flags = 0; |
||
1149 | set_socket(current_chip,Name,""); /* socket has no name */ |
||
1150 | |||
1151 | set_socket(current_chip,Type,$3); /* socket has a type */ |
||
1152 | current_comp_node = current_comp->nodes; |
||
1153 | while(current_comp_node) { |
||
1154 | current_comp_node->in_use = 0; /* clear in use/duplicate use flags */ |
||
1155 | current_comp_node=current_comp_node->sktnext; |
||
1156 | } |
||
1157 | current_comp_node = current_comp->nodes; |
||
1158 | |||
1159 | curr_comp_port_map = UNKNOWN; |
||
1160 | } |
||
1161 | } |
||
1162 | }; |
||
1163 | |||
1164 | |||
1165 | vhdl_inst_generic_map : GENERIC MAP { if(current_chip) |
||
1166 | { |
||
1167 | generic_context = ¤t_chip->generics; |
||
1168 | } |
||
1169 | else |
||
1170 | { |
||
1171 | generic_context = NULL; |
||
1172 | } |
||
1173 | } |
||
1174 | '(' vhdl_gen_map_list ')' |
||
1175 | | |
||
1176 | ; |
||
1177 | |||
1178 | vhdl_inst_port_map : PORT MAP '(' vhdl_port_map_list ')' |
||
1179 | | |
||
1180 | ; |
||
1181 | /**************************************************************************/ |
||
1182 | |||
1183 | vhdl_gen_map_list : vhdl_gen_map_list ',' vhdl_gen_map |
||
1184 | | vhdl_gen_map |
||
1185 | ; |
||
1186 | /* generics can only be mapped explicitly : change to bus_range as valid expression */ |
||
1187 | vhdl_gen_map: astring CONNECTED bus_range { |
||
1188 | info->name = $1; |
||
1189 | /* info->valuename = NULL; */ |
||
1190 | info->typename = NULL; |
||
1191 | info->expr = $3 ; |
||
1192 | info->valid = 0; |
||
1193 | set_generic_value(generic_context,info); |
||
1194 | }; |
||
1195 | |||
1196 | |||
1197 | |||
1198 | /**************************************************************************/ |
||
1199 | |||
1200 | vhdl_port_map_list : vhdl_port_map_list ',' vhdl_port_map |
||
1201 | | vhdl_port_map |
||
1202 | ; |
||
1203 | |||
1204 | |||
1205 | /* +++++++++++++++++ this is where a bus range can be given on LHS !! */ |
||
1206 | vhdl_port_map : astring vhdl_port_map_slice_opt CONNECTED rename_new_name { |
||
1207 | if(current_chip && current_comp) |
||
1208 | { |
||
1209 | if (curr_comp_port_map == IMPLICIT) |
||
1210 | Log(LOG_ERROR,"-- (line %d) Attempting use of mixed explicit and implicit port maps\n",lineno); |
||
1211 | else { |
||
1212 | curr_comp_port_map = EXPLICIT; |
||
1213 | current_comp_node = find_node(current_comp, |
||
1214 | Name, |
||
1215 | $1, |
||
1216 | Search); |
||
1217 | if(current_comp_node) { |
||
1218 | current_comp_node ->lhs_expr = $2; /* try2*/ |
||
1219 | if(current_comp_node->in_use == 0) { |
||
1220 | current_comp_node->in_use = 1; |
||
1221 | define_pin(&unrouted_list, |
||
1222 | current_chip, |
||
1223 | current_comp_node->name, |
||
1224 | current_comp_node->pindir, |
||
1225 | current_comp_node->pin_group, |
||
1226 | current_comp_node->identifier, |
||
1227 | current_comp_node->vhdltype, |
||
1228 | current_comp_node->lhs_expr); |
||
1229 | rename_unrouted_pin_socket(current_chip,$1,rename_pin_string,vhdl); |
||
1230 | } |
||
1231 | else |
||
1232 | Log(LOG_ERROR,"# (line %d) Error, port '%s.%s' already used\n", |
||
1233 | lineno, |
||
1234 | current_chip->identifier,$1); |
||
1235 | } |
||
1236 | else |
||
1237 | Log(LOG_ERROR,"# (line %d) Error : cannot find port '%s.%s' \n", |
||
1238 | lineno, |
||
1239 | current_chip->identifier,$1); |
||
1240 | } |
||
1241 | } |
||
1242 | } |
||
1243 | | astring vhdl_port_map_slice_opt CONNECTED OPEN { |
||
1244 | if(current_chip && current_comp) |
||
1245 | { |
||
1246 | if (curr_comp_port_map == IMPLICIT) |
||
1247 | Log(LOG_ERROR,"-- (line %d) Attempting use of mixed explicit and implicit port maps\n",lineno); |
||
1248 | else { |
||
1249 | curr_comp_port_map = EXPLICIT; |
||
1250 | current_comp_node = find_node(current_comp, |
||
1251 | Name, |
||
1252 | $1, |
||
1253 | Search); |
||
1254 | |||
1255 | if(current_comp_node) { |
||
1256 | current_comp_node ->lhs_expr = $2; /* try2*/ |
||
1257 | if(current_comp_node->in_use == 0) { |
||
1258 | current_comp_node->in_use = 1; |
||
1259 | } |
||
1260 | else |
||
1261 | Log(LOG_ERROR,"# (line %d) Error, port '%s.%s' already used\n", |
||
1262 | lineno, |
||
1263 | current_chip->identifier,$1); |
||
1264 | } |
||
1265 | else |
||
1266 | Log(LOG_ERROR,"# (line %d) Error : cannot find port '%s.%s' \n", |
||
1267 | lineno, |
||
1268 | current_chip->identifier,$1); |
||
1269 | } |
||
1270 | } |
||
1271 | } |
||
1272 | | rename_new_name vhdl_port_map_slice_opt { |
||
1273 | if(current_chip && current_comp) |
||
1274 | { |
||
1275 | if (curr_comp_port_map == EXPLICIT) |
||
1276 | Log(LOG_ERROR,"-- (line %d) Attempting use of mixed explicit and implicit port maps\n",lineno); |
||
1277 | else { |
||
1278 | curr_comp_port_map = IMPLICIT; |
||
1279 | if(current_comp_node) { |
||
1280 | current_comp_node->in_use = 1; |
||
1281 | |||
1282 | current_comp_node ->lhs_expr = $2; /* try2*/ |
||
1283 | define_pin(&unrouted_list, |
||
1284 | current_chip, |
||
1285 | current_comp_node->name, |
||
1286 | current_comp_node->pindir, |
||
1287 | current_comp_node->pin_group, |
||
1288 | current_comp_node->identifier, |
||
1289 | current_comp_node->vhdltype, |
||
1290 | current_comp_node ->lhs_expr); |
||
1291 | |||
1292 | rename_unrouted_pin_socket(current_chip,current_comp_node->name, |
||
1293 | rename_pin_string,vhdl); |
||
1294 | if(vhdl != default_vhdl_datatype) |
||
1295 | { |
||
1296 | free(vhdl); |
||
1297 | } |
||
1298 | current_comp_node =current_comp_node->sktnext; |
||
1299 | } |
||
1300 | else |
||
1301 | Log(LOG_ERROR, |
||
1302 | "-- (line %d) Run out of pins while attempting implicit port map with '%s'\n", |
||
1303 | lineno, |
||
1304 | rename_pin_string); |
||
1305 | } |
||
1306 | } |
||
1307 | } |
||
1308 | | OPEN { /* tag open ports */ |
||
1309 | if(current_chip && current_comp) |
||
1310 | { |
||
1311 | |||
1312 | if (curr_comp_port_map == EXPLICIT) |
||
1313 | Log(LOG_ERROR,"-- (line %d) Attempting use of mixed explicit and implicit port maps\n",lineno); |
||
1314 | else { |
||
1315 | curr_comp_port_map = IMPLICIT; |
||
1316 | if(current_comp_node) { |
||
1317 | current_comp_node->in_use = 1; |
||
1318 | current_comp_node ->lhs_expr = NULL; /* try2*/ |
||
1319 | |||
1320 | current_comp_node =current_comp_node->sktnext; |
||
1321 | } |
||
1322 | else |
||
1323 | Log(LOG_ERROR, |
||
1324 | "-- (line %d) Run out of pins while attempting implicit port map with '%s'\n", |
||
1325 | lineno, |
||
1326 | rename_pin_string); |
||
1327 | } |
||
1328 | } |
||
1329 | } |
||
1330 | ; |
||
1331 | |||
1332 | /**************************************************************************/ |
||
1333 | /* Pin bus slicing */ |
||
1334 | /**************************************************************************/ |
||
1335 | vhdl_port_map_slice_opt : '(' bus_range ')' |
||
1336 | { /* vhdl vector types */ |
||
1337 | $$ = $2; |
||
1338 | printf("Seen a slice of a bus ..\n"); |
||
1339 | } |
||
1340 | | /* nothing */ { |
||
1341 | $$ = NULL; |
||
1342 | } |
||
1343 | ; |
||
1344 | |||
1345 | /**************************************************************************/ |
||
1346 | /* VHDL concurrent assignment */ |
||
1347 | /**************************************************************************/ |
||
1348 | vhdl_concurrent_assignment : astring SIG_ASSIGN astring end_item |
||
1349 | { |
||
1350 | /* try using Alias on routed list to represent |
||
1351 | signal assignment */ |
||
1352 | Log(LOG_GENERAL,"-- (line %d) Seen concurrent assignment %s\n",lineno,$1); |
||
1353 | join_context = &unrouted_list; |
||
1354 | top_net = find_net(join_context,Ident,$1,Search); |
||
1355 | if(!top_net) /* Net cannot be created here , must exist already */ |
||
1356 | { |
||
1357 | Log(LOG_ERROR,"# (line %d) ERROR : Cannot locate net '%s'\n",lineno,$3); |
||
1358 | } |
||
1359 | else |
||
1360 | { |
||
1361 | if(top_net->how_joined != NotJoined) |
||
1362 | { |
||
1363 | /* trap attempts to jumper extend a non-jumper net */ |
||
1364 | Log(LOG_ERROR,"# (line %d) ERROR : Net '%s' already connected, cannot connect to another\n", |
||
1365 | lineno, |
||
1366 | top_net->identifier); |
||
1367 | } |
||
1368 | printf(" additional net found '%s'\n",$3); |
||
1369 | current_net = find_net(join_context,Ident,$3,Search); |
||
1370 | if(!current_net) |
||
1371 | { |
||
1372 | Log(LOG_ERROR,"# (line %d) ERROR : Cannot locate net '%s'\n",lineno,$3); |
||
1373 | } |
||
1374 | else |
||
1375 | { |
||
1376 | if(current_net == top_net) |
||
1377 | { |
||
1378 | Log(LOG_ERROR,"# (line %d) ERROR : Cannot assign '%s' to itself\n",lineno,$1); |
||
1379 | } |
||
1380 | else |
||
1381 | { |
||
1382 | /* mark this as a net referred to by net name */ |
||
1383 | top_net->vhdl_connect_net = current_net; |
||
1384 | } |
||
1385 | } |
||
1386 | }; |
||
1387 | }; |
||
1388 | |||
1389 | /**************************************************************************/ |
||
1390 | /* VHDL Library Block Declaration */ |
||
1391 | /**************************************************************************/ |
||
1392 | vhdl_library_decl : LIBRARY vhdl_library_list ';'; |
||
1393 | |||
1394 | vhdl_library_list : vhdl_library_name ',' vhdl_library_list |
||
1395 | | vhdl_library_name |
||
1396 | ; |
||
1397 | |||
1398 | vhdl_library_name : astring { Log(LOG_GENERAL,"-- (line %d) library %s;\n",lineno,$1);} ; |
||
1399 | |||
1400 | /**************************************************************************/ |
||
1401 | /* VHDL USE Block Declaration */ |
||
1402 | /**************************************************************************/ |
||
1403 | |||
1404 | vhdl_use_decl : USE vhdl_lib_members ';'; |
||
1405 | |||
1406 | vhdl_lib_members : vhdl_lib_member ',' vhdl_lib_members |
||
1407 | | vhdl_lib_member ; |
||
1408 | |||
1409 | /* modified to allow library members to be all of a library not just a single package */ |
||
1410 | vhdl_lib_member : astring '.' astring '.' vhdl_lib_member_select { Log(LOG_GENERAL,"-- use %s.%s.%s;\n",$1,$3,$5); } |
||
1411 | | astring '.' vhdl_lib_member_select { Log(LOG_GENERAL,"-- use %s.%s;\n",$1,$3); } |
||
1412 | ; |
||
1413 | |||
1414 | |||
1415 | vhdl_lib_member_select : ALL { $$="All"; } |
||
1416 | | astring { $$=$1; } |
||
1417 | ; |
||
1418 | |||
1419 | /* code currently omitted */ |
||
1420 | |||
1421 | /**************************************************************************/ |
||
1422 | /* Verilog Block Declarations */ |
||
1423 | /**************************************************************************/ |
||
1424 | verilog_region : VERILOG |
||
1425 | verilog_blocks |
||
1426 | END end_item { exit_lex_block(); free_lex_strings(); } |
||
1427 | ; |
||
1428 | |||
1429 | verilog_blocks : verilog_blocks verilog_block |
||
1430 | | verilog_block |
||
1431 | ; |
||
1432 | |||
1433 | /* */ |
||
1434 | verilog_block : verilog_module_decl |
||
1435 | | verilog_toplevel_decl |
||
1436 | | /* nothing */ |
||
1437 | ; |
||
1438 | |||
1439 | /**************************************************************************/ |
||
1440 | /* verilog module declaration */ |
||
1441 | /**************************************************************************/ |
||
1442 | |||
1443 | |||
1444 | /* this is not complete : need to look : If there is an endmodule we |
||
1445 | have a component declaration : if it has a body then it is a |
||
1446 | top level */ |
||
1447 | /* assuming we have a component */ |
||
1448 | /* need to check if name is duplicate but not assign to list unless */ |
||
1449 | /* it is definitely a component : for now , top level entities */ |
||
1450 | /* do not own netlists !! */ |
||
1451 | |||
1452 | verilog_module_header : MODULE hdl_compname_decl verilog_port_list |
||
1453 | verilog_pindir_block ; |
||
1454 | |||
1455 | /* toplevel contains structure */ |
||
1456 | verilog_toplevel_decl : verilog_module_header verilog_module_body ENDMODULE { current_chip = NULL; }; |
||
1457 | |||
1458 | verilog_module_decl : verilog_module_header ENDMODULE { current_chip = NULL;} ; |
||
1459 | |||
1460 | |||
1461 | /* wrong place as we need to know all about the types of wires within the port list */ |
||
1462 | verilog_port_list : '(' verilog_ports ')' ';' { if(current_chip) |
||
1463 | create_nodes_from_refs(current_chip,0); } |
||
1464 | verilog_pindir_block |
||
1465 | |/* nothing */ ; |
||
1466 | |||
1467 | verilog_ports : verilog_ports ',' verilog_port |
||
1468 | | verilog_port |
||
1469 | | /* no ports */ ; |
||
1470 | |||
1471 | /* port has no datatype on it : k&R C style */ |
||
1472 | verilog_port : /* hdl_signal_name */ hdl_name_part { create_pins_or_signals(); }; |
||
1473 | |||
1474 | verilog_bus_expr : '[' expr ']' { vhdl = calloc(1,sizeof(vhdl_t)); |
||
1475 | vhdl->is_vector = 1; |
||
1476 | vhdl->expr = $2; } |
||
1477 | | '[' expr ':' expr ']' { vhdl = calloc(1,sizeof(vhdl_t)); |
||
1478 | vhdl->is_vector = 1; |
||
1479 | vhdl->expr = compile_expression(DOWNTO,$2,$4); } |
||
1480 | | /* blank */ { vhdl = calloc(1,sizeof(vhdl_t)); *vhdl=*default_vhdl_datatype; }; |
||
1481 | |||
1482 | |||
1483 | /**********************************************************************/ |
||
1484 | /* if it doesnt have a body its a declaration : needs fixing ! */ |
||
1485 | /* currently need read_on / read_off declarations */ |
||
1486 | verilog_module_body : verilog_wires_block |
||
1487 | verilog_module_instance_block |
||
1488 | ; |
||
1489 | |||
1490 | /**********************************************************************/ |
||
1491 | verilog_pindir_block : verilog_pindir_block verilog_pindir_decl |
||
1492 | | verilog_pindir_decl |
||
1493 | | /* nothing */ |
||
1494 | ; |
||
1495 | |||
1496 | /* inout [3:0] gr for example */ |
||
1497 | verilog_pindir_decl : pin_dir { |
||
1498 | id_count = 0 ; y1_first = NULL;y1_last = NULL; } verilog_bus_expr hdl_signal_names |
||
1499 | ';' { if(current_chip) |
||
1500 | create_nodes_from_refs(current_chip,0); }; |
||
1501 | |||
1502 | |||
1503 | |||
1504 | /**********************************************************************/ |
||
1505 | verilog_wires_block : verilog_wires_decl verilog_wires_block |
||
1506 | | verilog_wires_decl |
||
1507 | | /* nothing */ |
||
1508 | ; |
||
1509 | |||
1510 | |||
1511 | verilog_wires_decl : verilog_wire_start |
||
1512 | verilog_bus_expr |
||
1513 | hdl_signal_names |
||
1514 | verilog_wire_end ; |
||
1515 | |||
1516 | verilog_wire_start : WIRE { id_count = 0 ; y_first = NULL;y_last = NULL; }; |
||
1517 | |||
1518 | |||
1519 | verilog_wire_end : ';' { if(current_chip) |
||
1520 | create_nodes_from_refs(current_chip,0); }; |
||
1521 | |||
1522 | /**********************************************************************/ |
||
1523 | /* verilog instance declarations */ |
||
1524 | /**********************************************************************/ |
||
1525 | verilog_module_instance_block : verilog_module_instances; |
||
1526 | |||
1527 | verilog_module_instances: verilog_module_instances verilog_module_instance |
||
1528 | | verilog_module_instance |
||
1529 | | /* nothing */; |
||
1530 | |||
1531 | |||
1532 | verilog_module_instance: astring astring '(' verilog_port_map_list ')' ';' { |
||
1533 | current_comp=find_socket(Type,$1,Search,&template_head); |
||
1534 | |||
1535 | if(!current_comp) { |
||
1536 | Log(LOG_ERROR, |
||
1537 | "-- (line %d) No component of type %s can be found : creating an instance\n",lineno,$1); current_chip = NULL; |
||
1538 | } |
||
1539 | else { |
||
1540 | current_chip=find_socket(Ident,$2,Create,&socket_head); |
||
1541 | if(current_chip) { |
||
1542 | /* setup the current chip */ |
||
1543 | current_chip->template_socket = current_comp; |
||
1544 | current_chip->is_template =0 ; |
||
1545 | current_chip->parent_template_ref = NULL; |
||
1546 | current_chip->route_flags = 0; |
||
1547 | set_socket(current_chip,Name,""); /* socket has no name */ |
||
1548 | |||
1549 | set_socket(current_chip,Type,$1); /* socket has a type */ |
||
1550 | current_comp_node = current_comp->nodes; |
||
1551 | while(current_comp_node) { |
||
1552 | current_comp_node->in_use = 0; /* clear in use/duplicate use flags */ |
||
1553 | current_comp_node=current_comp_node->sktnext; |
||
1554 | } |
||
1555 | current_comp_node = current_comp->nodes; |
||
1556 | |||
1557 | curr_comp_port_map = UNKNOWN; |
||
1558 | } |
||
1559 | } |
||
1560 | }; |
||
1561 | |||
1562 | |||
1563 | /**********************************************************************/ |
||
1564 | /* the declaration may contain nothing or a list */ |
||
1565 | /**********************************************************************/ |
||
1566 | verilog_port_map_list : verilog_port_maps | /* nothing */; |
||
1567 | |||
1568 | |||
1569 | verilog_port_maps : verilog_port_maps ',' verilog_port_map |
||
1570 | | verilog_port_map ; |
||
1571 | |||
1572 | |||
1573 | verilog_port_map : '.' astring '(' astring verilog_bus_expr ')' { |
||
1574 | /* strip off the pin_ prefix */ |
||
1575 | if(current_comp) { |
||
1576 | current_comp_node = find_node(current_comp, |
||
1577 | Name, |
||
1578 | $2, |
||
1579 | Create); /* was 'search' */ |
||
1580 | } |
||
1581 | |||
1582 | if(current_chip && current_comp_node) { |
||
1583 | if(current_comp_node->in_use == 0) { |
||
1584 | current_comp_node->in_use = 1; |
||
1585 | current_comp_node->lhs_expr = NULL; |
||
1586 | define_pin(&unrouted_list, |
||
1587 | current_chip, |
||
1588 | current_comp_node->name, |
||
1589 | current_comp_node->pindir, |
||
1590 | current_comp_node->pin_group, |
||
1591 | current_comp_node->identifier, |
||
1592 | current_comp_node->vhdltype, |
||
1593 | current_comp_node->lhs_expr); |
||
1594 | rename_unrouted_pin_socket(current_chip,$2,rename_pin_string,vhdl); |
||
1595 | } |
||
1596 | else |
||
1597 | Log(LOG_ERROR,"# (line %d) Error, port '%s.%s' already used\n", |
||
1598 | lineno, |
||
1599 | current_chip->identifier,$2); |
||
1600 | } |
||
1601 | else |
||
1602 | { |
||
1603 | if(!current_chip) |
||
1604 | { |
||
1605 | Log(LOG_ERROR,"# (line %d) Error no chip in context for port '%s'\n",lineno,$2); |
||
1606 | } |
||
1607 | else |
||
1608 | { |
||
1609 | Log(LOG_ERROR,"# (line %d) Error : cannot find port '%s.%s' \n", |
||
1610 | lineno, |
||
1611 | current_chip->identifier,$2); |
||
1612 | } |
||
1613 | } |
||
1614 | } |
||
1615 | |||
1616 | | '.' astring '(' ')' { |
||
1617 | current_comp_node = find_node(current_comp, |
||
1618 | Name, |
||
1619 | $2, |
||
1620 | Search); |
||
1621 | if(current_chip && current_comp_node) { |
||
1622 | if(current_comp_node->in_use == 0) { |
||
1623 | current_comp_node->in_use = 1; |
||
1624 | } |
||
1625 | else |
||
1626 | Log(LOG_ERROR,"# (line %d) Error, port '%s.%s' already used\n", |
||
1627 | lineno, |
||
1628 | current_chip->identifier,$2); |
||
1629 | } |
||
1630 | else |
||
1631 | { |
||
1632 | if(!current_chip) |
||
1633 | { |
||
1634 | Log(LOG_ERROR,"# (line %d) Error no chip in context for port '%s'\n",lineno,$2); |
||
1635 | } |
||
1636 | else |
||
1637 | { |
||
1638 | Log(LOG_ERROR,"# (line %d) Error : cannot find port '%s.%s' \n", |
||
1639 | lineno, |
||
1640 | current_chip->identifier,$2); |
||
1641 | } |
||
1642 | } |
||
1643 | } |
||
1644 | ; |
||
1645 | |||
1646 | /**************************************************************************/ |
||
1647 | /* ACFP generics : either global or device specific */ |
||
1648 | /**************************************************************************/ |
||
1649 | global_generic_decl : |
||
1650 | GENERIC { generic_context = &global_generics; } |
||
1651 | generic_defn_lines |
||
1652 | END end_item { exit_lex_block(); free_lex_strings(); } |
||
1653 | ; |
||
1654 | |||
1655 | chip_generic_decl : |
||
1656 | GENERIC { if(current_chip) |
||
1657 | generic_context = ¤t_chip->generics; } |
||
1658 | generic_defn_lines |
||
1659 | END end_item |
||
1660 | ; |
||
1661 | |||
1662 | |||
1663 | generic_defn_lines : generic_defn_lines end_item generic_defn_text |
||
1664 | | generic_defn_text |
||
1665 | | /* nothing */ |
||
1666 | ; |
||
1667 | |||
1668 | /* added to allow more complete VHDL syntax */ |
||
1669 | generic_const_opt : CONSTANT |
||
1670 | | /* nothing */ |
||
1671 | ; |
||
1672 | |||
1673 | generic_pindir_opt : PINDIR { $$= $1; } |
||
1674 | | /* nothing */ { $$= INPUT; } |
||
1675 | ; |
||
1676 | |||
1677 | |||
1678 | generic_defn_text : generic_const_opt generic_defn_name_list ':' generic_pindir_opt generic_defn_type ; |
||
1679 | |||
1680 | generic_defn_name_list : generic_defn_name_list ',' generic_defn_name |
||
1681 | | generic_defn_name ; |
||
1682 | |||
1683 | generic_defn_name : astring { make_string($1,&y_first,&y_last); }; |
||
1684 | |||
1685 | |||
1686 | |||
1687 | generic_defn_type : INTEGER opt_integer { |
||
1688 | struct str * s; |
||
1689 | s = y_first; |
||
1690 | while(s) { |
||
1691 | info->name = s->dat; |
||
1692 | info->typename = NULL; |
||
1693 | info->g_type = IS_INTEGER; |
||
1694 | info->expr = copy_expression($2,current_chip) ; /* ok allocated elsewhere */ |
||
1695 | info->valid = 0; |
||
1696 | /* generic is tagged for elaboration */ |
||
1697 | info->is_component_generic = current_chip? current_chip->is_template:0; |
||
1698 | set_generic_value(generic_context,info); |
||
1699 | s = s?s->next:s; /* bizarre gcc 2.95 problem */ |
||
1700 | } |
||
1701 | free_strings(&y_first,&y_last);} |
||
1702 | | BOOLEAN opt_integer { |
||
1703 | struct str * s; |
||
1704 | s = y_first; |
||
1705 | while(s) { |
||
1706 | info->name = s->dat; |
||
1707 | info->typename = NULL; |
||
1708 | info->g_type = IS_BOOLEAN; |
||
1709 | info->expr = copy_expression($2,current_chip) ; /* ok allocated elsewhere */ |
||
1710 | info->valid = 0; |
||
1711 | /* generic is tagged for elaboration */ |
||
1712 | info->is_component_generic = current_chip? current_chip->is_template:0; |
||
1713 | set_generic_value(generic_context,info); |
||
1714 | s = s?s->next:s; /* bizarre gcc 2.95 problem */ |
||
1715 | } |
||
1716 | free_strings(&y_first,&y_last);} |
||
1717 | | INTEGER RANGE opt_bus_range { |
||
1718 | struct str * s; |
||
1719 | s = y_first; |
||
1720 | while(s) { |
||
1721 | info->name = s->dat; |
||
1722 | info->g_type = $3->opcode; |
||
1723 | info->typename = NULL; |
||
1724 | info->expr = copy_expression($3,current_chip) ; |
||
1725 | info->valid = 0; |
||
1726 | info->is_component_generic = current_chip?current_chip->is_template:0; |
||
1727 | set_generic_value(generic_context,info); |
||
1728 | s = s->next; |
||
1729 | } |
||
1730 | free_strings(&y_first,&y_last); |
||
1731 | } |
||
1732 | | DECLARATION { text_buff[0]='\0'; } |
||
1733 | assign_words { |
||
1734 | struct str * s; |
||
1735 | s = y_first; |
||
1736 | while(s) { |
||
1737 | |||
1738 | info->name = s->dat; |
||
1739 | info->typename = "declaration"; |
||
1740 | info->g_type = IS_DECLARATION_DIRECTIVE; |
||
1741 | info->expr = compile_string(text_buff); |
||
1742 | set_generic_value(generic_context,info); |
||
1743 | s = s->next; |
||
1744 | } |
||
1745 | free_strings(&y_first,&y_last); |
||
1746 | } |
||
1747 | |||
1748 | | INSTANCE { text_buff[0]='\0'; } |
||
1749 | assign_words { |
||
1750 | struct str * s; |
||
1751 | s = y_first; |
||
1752 | while(s) { |
||
1753 | |||
1754 | info->name = s->dat; |
||
1755 | info->typename = "instance"; |
||
1756 | info->g_type = IS_INSTANCE_DIRECTIVE; |
||
1757 | info->expr = compile_string(text_buff); |
||
1758 | set_generic_value(generic_context,info); |
||
1759 | s = s->next; |
||
1760 | } |
||
1761 | free_strings(&y_first,&y_last);} |
||
1762 | | STRING { text_buff[0]='\0'; } |
||
1763 | assign_words { |
||
1764 | struct str * s; |
||
1765 | s = y_first; |
||
1766 | while(s) { |
||
1767 | |||
1768 | info->name = s->dat; |
||
1769 | info->typename = "string"; |
||
1770 | info->g_type = IS_STRING; /* environment value : string */ |
||
1771 | info->expr = compile_string(text_buff); |
||
1772 | set_generic_value(generic_context,info); |
||
1773 | s = s->next; |
||
1774 | } |
||
1775 | free_strings(&y_first,&y_last);} |
||
1776 | | ENV_STRING { text_buff[0]='\0'; } |
||
1777 | assign_words { |
||
1778 | struct str * s; |
||
1779 | s = y_first; |
||
1780 | while(s) { |
||
1781 | |||
1782 | info->name = s->dat; |
||
1783 | info->typename = "env_string"; |
||
1784 | info->g_type = IS_ENV_VAL; /* environment value : string */ |
||
1785 | info->expr = compile_string(text_buff); |
||
1786 | set_generic_value(generic_context,info); |
||
1787 | s = s->next; |
||
1788 | } |
||
1789 | free_strings(&y_first,&y_last);} |
||
1790 | |||
1791 | /* setting up the attribute in a database file */ |
||
1792 | |||
1793 | | ATTRIBUTE opt_integer { |
||
1794 | struct str * s; |
||
1795 | s = y_first; |
||
1796 | while(s) { |
||
1797 | info->name = s->dat; |
||
1798 | info->typename = NULL; |
||
1799 | info->g_type = IS_ATTRIBUTE; |
||
1800 | info->expr = copy_expression($2,current_chip) ; /* ok allocated elsewhere */ |
||
1801 | info->valid = 0; |
||
1802 | /* generic is tagged for elaboration */ |
||
1803 | info->is_component_generic = current_chip? current_chip->is_template:0; |
||
1804 | set_generic_value(generic_context,info); |
||
1805 | s=s->next; |
||
1806 | } |
||
1807 | free_strings(&y_first,&y_last);} |
||
1808 | ; |
||
1809 | |||
1810 | opt_integer : ASSIGN expr { info->g_class= DEFINED; $$ = $2; } |
||
1811 | | /* nothing */ { info->g_class= DEFAULT; $$ = compile_constant(0); } |
||
1812 | ; |
||
1813 | |||
1814 | opt_bus_range : ASSIGN bus_range { info->g_class= DEFINED;$$ = $2; } |
||
1815 | | /*nothing */ { expression_t * tmp; |
||
1816 | info->g_class= DEFAULT; |
||
1817 | tmp = compile_constant(0); |
||
1818 | $$ = compile_expression(TO,tmp,tmp);} |
||
1819 | ; |
||
1820 | |||
1821 | |||
1822 | assign_words : ASSIGN several_words |
||
1823 | | /* nothing */; |
||
1824 | |||
1825 | |||
1826 | /* pattern for picking up several space delimited words */ |
||
1827 | several_words : word several_words |
||
1828 | | word |
||
1829 | ; |
||
1830 | |||
1831 | /* add a space if this int the first string */ |
||
1832 | word : astring { if(text_buff[0]) strcat(text_buff," "); strcat(text_buff,$1); }; |
||
1833 | |||
1834 | |||
1835 | /*****************************************************************************/ |
||
1836 | |||
1837 | components_decl : COMPONENTS |
||
1838 | BEGIN_TOK |
||
1839 | comp_defn_lines |
||
1840 | END end_item { exit_lex_block(); free_lex_strings(); } |
||
1841 | ; |
||
1842 | |||
1843 | |||
1844 | comp_defn_lines : comp_defn_lines comp_defn_line |
||
1845 | | comp_defn_line |
||
1846 | | |
||
1847 | ; |
||
1848 | |||
1849 | comp_defn_line : chip_ident ':' chip_name chip_type chip_value end_item |
||
1850 | ; |
||
1851 | |||
1852 | chip_ident : astring { current_chip = find_socket(Ident,$1,Create,&socket_head); |
||
1853 | }; |
||
1854 | |||
1855 | chip_name : astring { if(current_chip) |
||
1856 | set_socket(current_chip,Name,$1); }; |
||
1857 | |||
1858 | chip_type : astring { if(current_chip) |
||
1859 | set_socket(current_chip,Type,$1); }; |
||
1860 | |||
1861 | chip_value : astring { if(current_chip) |
||
1862 | set_socket(current_chip,Value,$1); |
||
1863 | /* printf("Set up id %s \n",current_chip->identifier); */ |
||
1864 | }; |
||
1865 | |||
1866 | /************************************************************************/ |
||
1867 | /* joining of net declarations jumpers=wired nets alias=unrouted nets */ |
||
1868 | joined_decl : JOINED_NETS |
||
1869 | BEGIN_TOK |
||
1870 | join_decls |
||
1871 | END end_item { exit_lex_block(); free_lex_strings(); } |
||
1872 | ; |
||
1873 | |||
1874 | join_decls : join_decls join_decl |
||
1875 | | join_decl |
||
1876 | | |
||
1877 | ; |
||
1878 | |||
1879 | /* root_net is the one net that will continue to exist after the join. |
||
1880 | Its properties will be kept , name and identifier */ |
||
1881 | |||
1882 | |||
1883 | join_decl : alias_part root_net '=' '(' joined_nets ')' end_item |
||
1884 | | CONN astring astring { Log(LOG_GENERAL, |
||
1885 | "# (line %d) Connecting all nodes on SOckets '%s' and '%s'\n", |
||
1886 | lineno, |
||
1887 | $2 ,$3); /* this creates all possible connections between two ID's */ |
||
1888 | create_all_jumpers($2,$3);} end_item |
||
1889 | | VHDL_CONN vhdl_concurrent_assignment |
||
1890 | ; |
||
1891 | |||
1892 | |||
1893 | |||
1894 | alias_part : ALIAS { join_context = &unrouted_list;join_mode = Aliased; |
||
1895 | create_unrouted_list(); |
||
1896 | } |
||
1897 | | JUMPER { join_context = &routed_list; join_mode = Jumpered;} |
||
1898 | | { join_context = &routed_list; join_mode = Jumpered;} |
||
1899 | ; |
||
1900 | |||
1901 | root_net : netname {/* printf("root net found '%s'\n",$1); */ |
||
1902 | top_net = find_net(join_context,Ident,$1,Search); |
||
1903 | if(top_net) { |
||
1904 | if(top_net->how_joined == NotJoined) { |
||
1905 | /* trap attempts to jumper extend a non-jumper net */ |
||
1906 | Log(LOG_ERROR,"# (line %d) ERROR : Net '%s' already exists, cannot create jumper\n", |
||
1907 | lineno, |
||
1908 | top_net->identifier); |
||
1909 | top_net = NULL; |
||
1910 | } |
||
1911 | else { |
||
1912 | Log(LOG_ERROR,"# Warning : %s net '%s' already exists, net is being extended from %d nodes\n", |
||
1913 | lineno, |
||
1914 | top_net->how_joined == Jumpered ? "Jumpered" : "Aliased", |
||
1915 | top_net->identifier,top_net->nodecount); |
||
1916 | /* if the net is already in existence, it will have nodes */ |
||
1917 | } |
||
1918 | |||
1919 | } |
||
1920 | else { |
||
1921 | top_net = find_net(join_context,Ident,$1,Create); |
||
1922 | top_net->how_joined = join_mode; |
||
1923 | top_net->vhdltype = default_vhdl_datatype; |
||
1924 | /* printf(" Join mode - %d\n",join_mode); */ |
||
1925 | } |
||
1926 | /* top_net->name = top_net->identifier; */ |
||
1927 | |||
1928 | printf("TOP NET = %s \n",top_net->identifier); |
||
1929 | |||
1930 | |||
1931 | }; |
||
1932 | |||
1933 | |||
1934 | |||
1935 | joined_nets : joined_nets joined_net |
||
1936 | | joined_net |
||
1937 | ; |
||
1938 | |||
1939 | joined_net : single_net end_item |
||
1940 | | jumper_node end_item |
||
1941 | ; |
||
1942 | |||
1943 | single_net : netname { /* printf(" additional net found '%s'\n",$1); */ |
||
1944 | if (top_net) { |
||
1945 | current_net = find_net(join_context,Ident,$1,Search); |
||
1946 | if(!current_net) |
||
1947 | Log(LOG_ERROR,"# (line %d) ERROR : Cannot locate net '%s'\n",lineno,$1); |
||
1948 | else { |
||
1949 | if(current_net == top_net) |
||
1950 | Log(LOG_ERROR,"# (line %d) ERROR : Cannot jumper '%s' to itself\n",lineno,$1); |
||
1951 | else { |
||
1952 | |||
1953 | /* mark this as a net referred to by net name */ |
||
1954 | current_net->external_node = NULL; |
||
1955 | transfer_net_to_subnet(join_context, |
||
1956 | top_net, current_net); |
||
1957 | } |
||
1958 | } |
||
1959 | }; |
||
1960 | }; |
||
1961 | |||
1962 | /* this looks for the net that a node is on : this will be a Jumper connection */ |
||
1963 | jumper_node : netname '(' astring ')' { |
||
1964 | if( top_net) { |
||
1965 | |||
1966 | |||
1967 | |||
1968 | /* find socket that node is connected to*/ |
||
1969 | current_chip = find_socket(Ident,$1,Search,&socket_head); |
||
1970 | if (!current_chip) |
||
1971 | Log(LOG_ERROR,"-- (line %d) Cannot locate socket '%s'\n",lineno,$1); |
||
1972 | else { |
||
1973 | /* find node itself */ |
||
1974 | current_node = find_node(current_chip,Ident,$3,Search); |
||
1975 | if (!current_node) |
||
1976 | Log(LOG_ERROR,"-- (line %d) Cannot locate node '%s(%s)'\n",lineno,$1,$3); |
||
1977 | else { |
||
1978 | /* use net that node is on */ |
||
1979 | if(!current_node->routed_net) |
||
1980 | Log(LOG_ERROR,"-- (line %d) Cannot locate net for node '%s(%s)'\n",lineno,$1,$3); |
||
1981 | else |
||
1982 | if (current_node->routed_net->list_ref == &routed_list) |
||
1983 | { |
||
1984 | /* mark this as a net referred to by node ID not net name */ |
||
1985 | /* printf("Current net is %s : node is %s(%s)\n",current_node->routed_net->identifier,current_chip->identifier,current_node->identifier); */ |
||
1986 | if (transfer_net_to_subnet(join_context,top_net, current_node->routed_net)) |
||
1987 | { |
||
1988 | current_node->routed_net->external_node = current_node; |
||
1989 | } |
||
1990 | else |
||
1991 | { |
||
1992 | Log(LOG_ERROR,"-- (line %d) jumper foulup with net referred to by %s(%s)\n",lineno,$1,$3); |
||
1993 | } |
||
1994 | } |
||
1995 | else |
||
1996 | Log(LOG_ERROR,"-- (line %d) node '%s(%s)' is on %s: not routed list\n", |
||
1997 | lineno,$1,$3,decode_which_list(current_node->routed_net->list_ref)); |
||
1998 | |||
1999 | } |
||
2000 | } |
||
2001 | } |
||
2002 | }; |
||
2003 | |||
2004 | |||
2005 | /* new stuff Feb 1997 ******************************************************************** */ |
||
2006 | /* this can be replaced by VHDL component instances within an architecture |
||
2007 | block Sep 2000 */ |
||
2008 | rename_pins_block : RENAME_PINS |
||
2009 | BEGIN_TOK |
||
2010 | rename_pin_decls |
||
2011 | END end_item { exit_lex_block(); free_lex_strings(); } |
||
2012 | ; |
||
2013 | |||
2014 | |||
2015 | rename_pin_decls : rename_pin_decls rename_pin_decl |
||
2016 | | rename_pin_decl |
||
2017 | ; |
||
2018 | |||
2019 | |||
2020 | |||
2021 | rename_pin_decl : rename_new_name '=' '(' rename_pin_items ')' end_item; |
||
2022 | |||
2023 | rename_new_name : netname { rename_pin_string = $1; |
||
2024 | vhdl = default_vhdl_datatype;} |
||
2025 | | netname '(' bus_range ')' { rename_pin_string = $1; |
||
2026 | vhdl = calloc(1,sizeof(vhdl_t)); |
||
2027 | /* acquire datatype later */ |
||
2028 | vhdl->expr = $3; |
||
2029 | vhdl->is_vector =1; |
||
2030 | vhdl->valid = 0; |
||
2031 | } |
||
2032 | ; |
||
2033 | |||
2034 | rename_pin_items : rename_pin_items rename_pin_item |
||
2035 | | rename_pin_item |
||
2036 | ; |
||
2037 | |||
2038 | rename_pin_item : astring '.' astring end_item { |
||
2039 | rename_unrouted_pin($1,$3,rename_pin_string,vhdl); |
||
2040 | } |
||
2041 | | /* nothing */ |
||
2042 | ; |
||
2043 | |||
2044 | |||
2045 | |||
2046 | |||
2047 | /************************************************************************/ |
||
2048 | /* net declarations : as predefined by either wiring or previous passes */ |
||
2049 | |||
2050 | |||
2051 | nets_decl : WIRED_NETS { current_list = &routed_list ; } |
||
2052 | BEGIN_TOK |
||
2053 | connection_block |
||
2054 | END end_item { exit_lex_block(); } |
||
2055 | ; |
||
2056 | |||
2057 | |||
2058 | |||
2059 | connection_block : connection_block connection_block_item |
||
2060 | | connection_block_item |
||
2061 | ; |
||
2062 | |||
2063 | connection_block_item : routed_decl |
||
2064 | | unrouted_decl |
||
2065 | | named_decl |
||
2066 | | conn_decls |
||
2067 | | /* nothing */ |
||
2068 | ; |
||
2069 | |||
2070 | |||
2071 | routed_decl : ROUTED { current_list = &routed_list ; } |
||
2072 | ; |
||
2073 | |||
2074 | unrouted_decl: UNROUTED { current_list = &unrouted_list ; } |
||
2075 | ; |
||
2076 | |||
2077 | named_decl : NAMED { Log(LOG_GENERAL,"-- (line %d) Netlist contains NAMED block,converting signals to ROUTED as its more useful\n",lineno); |
||
2078 | current_list = &routed_list ; } |
||
2079 | ; |
||
2080 | |||
2081 | |||
2082 | conn_decls : conn_decls conn_decl |
||
2083 | | conn_decl |
||
2084 | ; |
||
2085 | |||
2086 | /* in here we can add mentions of other net attibutes */ |
||
2087 | conn_decl : CONN conn_ident conn_name last_route_status end_item |
||
2088 | nodelist |
||
2089 | END_CONN { free_lex_strings(); } end_item |
||
2090 | ; |
||
2091 | |||
2092 | conn_ident : netname { current_net = find_net(current_list,Ident,$1,Create); |
||
2093 | }; |
||
2094 | |||
2095 | |||
2096 | |||
2097 | |||
2098 | conn_name : astring { set_net(current_net,Name,$1); |
||
2099 | }; |
||
2100 | |||
2101 | |||
2102 | last_route_status : astring { set_net(current_net,How_Routed,$1); |
||
2103 | }; |
||
2104 | |||
2105 | nodelist : nodelist net_node |
||
2106 | | net_node |
||
2107 | | |
||
2108 | ; |
||
2109 | |||
2110 | net_node : skt_id '(' node_id ')' fix_loc_part force_pin_dir node_group end_item |
||
2111 | ; |
||
2112 | |||
2113 | |||
2114 | /* if a pin direction is given in the pin list then the pin is forced to |
||
2115 | be an input or an output. |
||
2116 | The reference to the node has its pin direction set the same as |
||
2117 | the fixed pin direction if it is a fixed pin. */ |
||
2118 | /* the null added in order to define no pin name alias at present */ |
||
2119 | force_pin_dir : PINDIR { connect_node_net(NULL,current_node,current_net,$1,default_vhdl_datatype,NULL,NULL); |
||
2120 | /* these set the actual pin up */ |
||
2121 | current_node->fixed_pin = ($1 != BIDIR); |
||
2122 | current_node->pindir = $1; |
||
2123 | if(current_list == &routed_list) |
||
2124 | current_node->routed_net= current_net; |
||
2125 | } |
||
2126 | |||
2127 | /* no direction, must be dont care direction */ |
||
2128 | | /* nothing*/ { connect_node_net(NULL,current_node,current_net,BIDIR,default_vhdl_datatype,NULL,NULL); |
||
2129 | /* this sets the actual pin up */ |
||
2130 | current_node->fixed_pin = 0; |
||
2131 | current_node->pindir = BIDIR; |
||
2132 | if(current_list == &routed_list) |
||
2133 | current_node->routed_net= current_net; } |
||
2134 | ; |
||
2135 | |||
2136 | |||
2137 | skt_id : astring { current_chip = find_socket(Ident,$1,Create, |
||
2138 | &socket_head); |
||
2139 | }; |
||
2140 | |||
2141 | node_id : netname { if(current_chip) |
||
2142 | current_node = find_node(current_chip,Ident,$1,Create); } |
||
2143 | ; |
||
2144 | |||
2145 | |||
2146 | |||
2147 | /* we can try and force unrouted nets referring to this pin to be fixed to it */ |
||
2148 | fix_loc_part : FIX_LOCATION { current_node->fix_location = 1; |
||
2149 | current_net->has_fix_location = 1; } |
||
2150 | | /* nothing */ { current_node->fix_location = 0; } |
||
2151 | ; |
||
2152 | |||
2153 | |||
2154 | node_group : '(' NUM_STRING ')' { convert_num($2,¤t_node->pin_group); } |
||
2155 | | /* nothing */ |
||
2156 | ; |
||
2157 | |||
2158 | |||
2159 | /************************************************************/ |
||
2160 | /* Netname is a catch all for special names that are now picked up |
||
2161 | separately by the lex parser for some special cases */ |
||
2162 | |||
2163 | netname : VCC { $$=$1; } |
||
2164 | | GND { $$=$1; } |
||
2165 | | astring { $$=$1; }; |
||
2166 | |||
2167 | |||
2168 | |||
2169 | |||
2170 | |||
2171 | |||
2172 | /*************************************************************************/ |
||
2173 | /* The definition of a template that fixes pins as inputs, outputs or */ |
||
2174 | /* configuration pins or pin groups */ |
||
2175 | /*************************************************************************/ |
||
2176 | /* The basic template is just like a chip delcaration */ |
||
2177 | /* remembering to convert all of the pin name references |
||
2178 | to actual pins on the template */ |
||
2179 | |||
2180 | template_decl: template_id_decl |
||
2181 | BEGIN_TOK |
||
2182 | template_info_lines |
||
2183 | pin_declarations |
||
2184 | pin_equivalences |
||
2185 | |||
2186 | END end_item { if(current_chip) |
||
2187 | { |
||
2188 | create_nodes_from_refs(current_chip,0); |
||
2189 | Log(LOG_GENERAL,"-- (line %d) Template '%s' created\n", |
||
2190 | lineno, |
||
2191 | current_chip->type); |
||
2192 | if (current_chip->parent_template_ref ) |
||
2193 | Log(LOG_GENERAL,"-- as alias to '%s'\n", |
||
2194 | current_chip->parent_template_ref->type); |
||
2195 | exit_lex_block() ; |
||
2196 | free_lex_strings(); |
||
2197 | } |
||
2198 | } |
||
2199 | ; |
||
2200 | |||
2201 | template_id_decl: TEMPLATE template_name ; |
||
2202 | |||
2203 | template_name : astring { |
||
2204 | current_chip=find_socket(Type,$1,Create,&template_head); |
||
2205 | if(current_chip) |
||
2206 | current_chip->is_template = 1; }; |
||
2207 | |||
2208 | |||
2209 | template_info_lines : template_info_lines template_info_line |
||
2210 | | template_info_line |
||
2211 | ; |
||
2212 | |||
2213 | template_info_line : chip_generic_decl |
||
2214 | | alias_to_another_template |
||
2215 | | /* blank */ |
||
2216 | ; |
||
2217 | /* this allows one template to say it is the Alias of another template */ |
||
2218 | |||
2219 | alias_to_another_template : ALIAS astring end_item { |
||
2220 | if (current_chip && current_chip->parent_template_ref) { |
||
2221 | |||
2222 | Log(LOG_ERROR, |
||
2223 | "-- (line %d) chip '%s' already alias of '%s'\n", |
||
2224 | lineno, |
||
2225 | $2,current_chip->parent_template_ref->type); |
||
2226 | } |
||
2227 | else { |
||
2228 | socket_t* original_chip = find_socket(Type,$2,Search,&template_head); |
||
2229 | if(!original_chip) { |
||
2230 | Log(LOG_ERROR, |
||
2231 | "-- (line %d) Cannot find original template for alias '%s'\n",lineno,$2); |
||
2232 | } |
||
2233 | else { |
||
2234 | if(current_chip) |
||
2235 | { |
||
2236 | current_chip->parent_template_ref = original_chip; |
||
2237 | current_chip->nodes = original_chip->nodes; |
||
2238 | current_chip->lastnode = original_chip->lastnode; |
||
2239 | current_chip->equivalent_node_set = original_chip->equivalent_node_set; |
||
2240 | } |
||
2241 | } |
||
2242 | } |
||
2243 | }; |
||
2244 | /* end alias stuff */ |
||
2245 | /*************************************************************************/ |
||
2246 | /* Extensions to syntax to read TDF files */ |
||
2247 | /**************************************************************************/ |
||
2248 | /*AHDL Chip Declarations */ |
||
2249 | /**************************************************************************/ |
||
2250 | ahdl_region : AHDL |
||
2251 | ahdl_chip_decls |
||
2252 | END end_item { exit_lex_block(); free_lex_strings(); } |
||
2253 | ; |
||
2254 | |||
2255 | ahdl_chip_decls : ahdl_chip_decl ahdl_chip_decls |
||
2256 | | ahdl_chip_decl |
||
2257 | ; |
||
2258 | |||
2259 | ahdl_chip_decl : ahdl_entityname_decl |
||
2260 | | ahdl_port_decl |
||
2261 | | /* nothing */ |
||
2262 | ; |
||
2263 | |||
2264 | ahdl_entityname_decl : SUBDESIGN TXT_STRING |
||
2265 | { |
||
2266 | current_chip=find_socket(Name,$2,Create,&socket_head); |
||
2267 | if(current_chip) |
||
2268 | { |
||
2269 | current_chip->is_template = 0; |
||
2270 | current_chip->parent_template_ref = NULL; |
||
2271 | current_chip->route_flags = 0; |
||
2272 | ensure_socket_ident(current_chip); |
||
2273 | set_socket(current_chip,Type,"AHDL"); |
||
2274 | generic_context = ¤t_chip->generics; |
||
2275 | } |
||
2276 | }; |
||
2277 | |||
2278 | |||
2279 | |||
2280 | /* mandatory port list */ |
||
2281 | ahdl_port_decl : '(' ahdl_port_list ')'; |
||
2282 | |||
2283 | ahdl_port_list : ahdl_port_list end_item ahdl_port_item |
||
2284 | | ahdl_port_item |
||
2285 | | /* nothing */ |
||
2286 | ; |
||
2287 | |||
2288 | |||
2289 | /* the AHDL Port item , inherits the pin_dir from a standard chip declaration |
||
2290 | and the vhdl type extraction from the generic type declaration |
||
2291 | */ |
||
2292 | ahdl_port_item : ahdl_name_list ':' pin_dir { |
||
2293 | process_tdf_pins(y_first); |
||
2294 | free_strings(&y_first,&y_last); |
||
2295 | } ; |
||
2296 | |||
2297 | |||
2298 | |||
2299 | |||
2300 | |||
2301 | ahdl_name_list : ahdl_name_list ',' ahdl_name_part |
||
2302 | | ahdl_name_part ; |
||
2303 | |||
2304 | /* null the pin identifier to allow for creation of an ident in define_pin */ |
||
2305 | ahdl_name_part : astring { |
||
2306 | char * s = make_string($1,&y_first,&y_last); |
||
2307 | curr_pin_ident[0] = '\0'; |
||
2308 | curr_pin_dir = NONE; /* default bidirectional */ |
||
2309 | if(ISNULLSTR(s) && id_count ==0)/* the null strings tell acfread that the pin exists and */ |
||
2310 | current_list = &routed_list ;/* available for routing */ |
||
2311 | else |
||
2312 | current_list = &unrouted_list ; |
||
2313 | id_count++; |
||
2314 | }; |
||
2315 | |||
2316 | |||
2317 | |||
2318 | |||
2319 | %% |
||
2320 | |||
2321 | /* defining lineno at top of code so it is in scope */ |
||
2322 | |||
2323 | int errorseen = 0; |
||
2324 | |||
2325 | #if defined IS_HPUX |
||
2326 | extern unsigned char * yytext[]; |
||
2327 | #else |
||
2328 | extern char * yytext; |
||
2329 | #endif |
||
2330 | |||
2331 | extern FILE * yyin; |
||
2332 | |||
2333 | |||
2334 | |||
2335 | void process_tdf_pins(struct str * s) { |
||
2336 | char * basename; |
||
2337 | vhdl_t * defvhdl; |
||
2338 | int is_vec,idx=0,l,hi=0,lo=0; |
||
2339 | int numeric ; |
||
2340 | |||
2341 | basename = NULL; |
||
2342 | is_vec = 0; |
||
2343 | while(s) { |
||
2344 | l = strlen(s->dat); |
||
2345 | if(l){ |
||
2346 | /* name ends in underscore, this forces mapping |
||
2347 | name_nn_ --> vector entry name(nn) */ |
||
2348 | numeric = 0; |
||
2349 | |||
2350 | l--; |
||
2351 | if(s->dat[l] =='_'){ |
||
2352 | l--; |
||
2353 | numeric = 1; |
||
2354 | while(l>=0 && s->dat[l] != '_') |
||
2355 | if(!isdigit(s->dat[l--])) |
||
2356 | numeric = 0; |
||
2357 | if(l>= 0 && s->dat[l]=='_' && numeric) |
||
2358 | /* we have found a valid vector element entry */ |
||
2359 | idx = atoi(s->dat+l+1); |
||
2360 | } |
||
2361 | /* we know if its numeric it is probably a vector element */ |
||
2362 | |||
2363 | if(numeric && (!basename || strncmp(basename,s->dat,l)==0) ) { |
||
2364 | if(!is_vec) { |
||
2365 | /* if it is the first one then save a reference */ |
||
2366 | hi =idx; |
||
2367 | lo =idx; |
||
2368 | basename = s->dat; |
||
2369 | basename[l] = 0; |
||
2370 | is_vec=1; |
||
2371 | } |
||
2372 | else { |
||
2373 | if(idx>hi)hi =idx; |
||
2374 | if(idx<lo)lo =idx; |
||
2375 | |||
2376 | } |
||
2377 | } |
||
2378 | else { |
||
2379 | if (is_vec) { |
||
2380 | defvhdl = calloc(1,sizeof(vhdl_t)); |
||
2381 | *defvhdl = *default_vhdl_bustype; |
||
2382 | defvhdl->expr = compile_expression(DOWNTO, |
||
2383 | compile_constant(hi), |
||
2384 | compile_constant(lo)); |
||
2385 | #if defined DEBUG_EXPRESSION |
||
2386 | printf("Data bus '%s' h=%d l=%d\n",basename,hi,lo); |
||
2387 | #endif |
||
2388 | /* defvhdl.is_vector = defvhdl.low!=defvhdl.high; */ |
||
2389 | /* single bit or bus */ |
||
2390 | define_pin(current_list, |
||
2391 | current_chip, |
||
2392 | basename, |
||
2393 | curr_pin_dir, |
||
2394 | curr_pin_group, |
||
2395 | curr_pin_ident, |
||
2396 | defvhdl, |
||
2397 | NULL) ; |
||
2398 | basename = NULL; |
||
2399 | is_vec = 0; |
||
2400 | } |
||
2401 | else { |
||
2402 | #if defined DEBUG_EXPRESSION |
||
2403 | printf("Pin '%s'\n",s->dat); |
||
2404 | #endif |
||
2405 | define_pin(current_list, |
||
2406 | current_chip, |
||
2407 | s->dat, |
||
2408 | curr_pin_dir, |
||
2409 | curr_pin_group, |
||
2410 | curr_pin_ident, |
||
2411 | default_vhdl_datatype,NULL) ; |
||
2412 | } |
||
2413 | } |
||
2414 | |||
2415 | |||
2416 | } /* if l */ |
||
2417 | s=s->next; |
||
2418 | } /* while s */ |
||
2419 | } |
||
2420 | |||
2421 | |||
2422 | /* function used in definition of ports or signals of a |
||
2423 | particular type */ |
||
2424 | |||
2425 | void create_pins_or_signals(void) { |
||
2426 | struct str * s; |
||
2427 | s = y_first; |
||
2428 | |||
2429 | /* function called in define_pin context */ |
||
2430 | |||
2431 | while(s) { |
||
2432 | #if defined DEBUG_EXPRESSION |
||
2433 | printf("define pin %s,",s->dat); |
||
2434 | #endif |
||
2435 | define_pin(current_list, |
||
2436 | current_chip, |
||
2437 | s->dat, |
||
2438 | curr_pin_dir, |
||
2439 | curr_pin_group, |
||
2440 | /* if known use curr_pin_ident */ |
||
2441 | curr_pin_ident[0] ? curr_pin_ident : s->dat, |
||
2442 | copy_vhdl(vhdl,current_chip), |
||
2443 | NULL) ; |
||
2444 | s=s->next; |
||
2445 | } |
||
2446 | #if defined DEBUG_EXPRESSION |
||
2447 | printf("\n"); |
||
2448 | #endif |
||
2449 | /* function is called in define signal context. */ |
||
2450 | s = y1_first; |
||
2451 | while(s) { |
||
2452 | net_t * net; |
||
2453 | #if defined DEBUG_EXPRESSION |
||
2454 | printf("define signal %s\n",s->dat); |
||
2455 | #endif |
||
2456 | net = find_net(&unrouted_list,Ident,s->dat,Create); |
||
2457 | if(net) { |
||
2458 | net->type_defined = 1; /* we have defined the correct datatype */ |
||
2459 | net->vhdltype = copy_vhdl(vhdl,NULL); /* ???? do we need malloc/copy here */ |
||
2460 | /* as all signals defined at the same time share the memory for |
||
2461 | type declaration */ |
||
2462 | } |
||
2463 | s=s->next; |
||
2464 | } |
||
2465 | #if defined DEBUG_EXPRESSION |
||
2466 | printf("\n"); |
||
2467 | #endif |
||
2468 | |||
2469 | |||
2470 | if(y1_first) |
||
2471 | free_strings(&y1_first,&y1_last); |
||
2472 | |||
2473 | if(y_first) |
||
2474 | free_strings(&y_first,&y_last); |
||
2475 | id_count = 0; |
||
2476 | } |
||
2477 | |||
2478 |