Handle nil parameter overrides
[iverilog.git] / parse.y
bloba20b40146cb4ae710f7240e4b203cafe143676fd
2 %{
3 /*
4 * Copyright (c) 1998-2007 Stephen Williams (steve@icarus.com)
6 * This source code is free software; you can redistribute it
7 * and/or modify it in source code form under the terms of the GNU
8 * General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 #ifdef HAVE_CVS_IDENT
22 #ident "$Id: parse.y,v 1.239 2007/06/14 03:50:00 steve Exp $"
23 #endif
25 # include "config.h"
27 # include "parse_misc.h"
28 # include "compiler.h"
29 # include "pform.h"
30 # include "Statement.h"
31 # include "PSpec.h"
32 # include <sstream>
34 class PSpecPath;
36 extern void lex_start_table();
37 extern void lex_end_table();
39 static svector<PExpr*>* active_range = 0;
40 static bool active_signed = false;
42 /* Port declaration lists use this structure for context. */
43 static struct {
44 NetNet::Type port_net_type;
45 NetNet::PortType port_type;
46 bool sign_flag;
47 svector<PExpr*>* range;
48 } port_declaration_context;
50 /* Later version of bison (including 1.35) will not compile in stack
51 extension if the output is compiled with C++ and either the YYSTYPE
52 or YYLTYPE are provided by the source code. However, I can get the
53 old behavior back by defining these symbols. */
54 # define YYSTYPE_IS_TRIVIAL 1
55 # define YYLTYPE_IS_TRIVIAL 1
57 /* Recent version of bison expect that the user supply a
58 YYLLOC_DEFAULT macro that makes up a yylloc value from existing
59 values. I need to supply an explicit version to account for the
60 text field, that otherwise won't be copied. */
61 # define YYLLOC_DEFAULT(Current, Rhs, N) do { \
62 (Current).first_line = (Rhs)[1].first_line; \
63 (Current).first_column = (Rhs)[1].first_column; \
64 (Current).last_line = (Rhs)[N].last_line; \
65 (Current).last_column = (Rhs)[N].last_column; \
66 (Current).text = (Rhs)[1].text; } while (0)
69 * These are some common strength pairs that are used as defaults when
70 * the user is not otherwise specific.
72 const static struct str_pair_t pull_strength = { PGate::PULL, PGate::PULL };
73 const static struct str_pair_t str_strength = { PGate::STRONG, PGate::STRONG };
75 static list<perm_string>* list_from_identifier(char*id)
77 list<perm_string>*tmp = new list<perm_string>;
78 tmp->push_back(lex_strings.make(id));
79 delete id;
80 return tmp;
83 static list<perm_string>* list_from_identifier(list<perm_string>*tmp, char*id)
85 tmp->push_back(lex_strings.make(id));
86 delete id;
87 return tmp;
92 %union {
93 bool flag;
95 char letter;
97 /* text items are C strings allocated by the lexor using
98 strdup. They can be put into lists with the texts type. */
99 char*text;
100 list<perm_string>*perm_strings;
101 pform_name_t*pform_name;
103 hname_t*hier;
105 list<string>*strings;
107 struct str_pair_t drive;
109 PCase::Item*citem;
110 svector<PCase::Item*>*citems;
112 lgate*gate;
113 svector<lgate>*gates;
115 Module::port_t *mport;
116 svector<Module::port_t*>*mports;
118 named_pexpr_t*named_pexpr;
119 svector<named_pexpr_t*>*named_pexprs;
120 struct parmvalue_t*parmvalue;
122 PExpr*expr;
123 svector<PExpr*>*exprs;
125 svector<PEEvent*>*event_expr;
127 NetNet::Type nettype;
128 PGBuiltin::Type gatetype;
129 NetNet::PortType porttype;
130 ivl_variable_type_t datatype;
132 PWire*wire;
133 svector<PWire*>*wires;
135 PEventStatement*event_statement;
136 Statement*statement;
137 svector<Statement*>*statement_list;
139 PTaskFuncArg function_type;
141 net_decl_assign_t*net_decl_assign;
143 verinum* number;
145 verireal* realtime;
147 PSpecPath* specpath;
150 %token <text> IDENTIFIER SYSTEM_IDENTIFIER STRING
151 %token <text> PATHPULSE_IDENTIFIER
152 %token <number> BASED_NUMBER DEC_NUMBER
153 %token <realtime> REALTIME
154 %token K_LE K_GE K_EG K_EQ K_NE K_CEQ K_CNE K_LS K_RS K_RSS K_SG
155 %token K_PO_POS K_PO_NEG K_POW
156 %token K_PSTAR K_STARP
157 %token K_LOR K_LAND K_NAND K_NOR K_NXOR K_TRIGGER
158 %token K_always K_and K_assign K_begin K_bool K_buf K_bufif0 K_bufif1 K_case
159 %token K_casex K_casez K_cmos K_deassign K_default K_defparam K_disable
160 %token K_edge K_edge_descriptor
161 %token K_else K_end K_endcase K_endfunction K_endgenerate K_endmodule
162 %token K_endprimitive K_endspecify K_endtable K_endtask K_event K_for
163 %token K_force K_forever K_fork K_function K_generate K_genvar
164 %token K_highz0 K_highz1 K_if K_ifnone
165 %token K_initial K_inout K_input K_integer K_join K_large K_localparam
166 %token K_logic K_macromodule
167 %token K_medium K_module K_nand K_negedge K_nmos K_nor K_not K_notif0
168 %token K_notif1 K_or K_output K_parameter K_pmos K_posedge K_primitive
169 %token K_pull0 K_pull1 K_pulldown K_pullup K_rcmos K_real K_realtime
170 %token K_reg K_release K_repeat
171 %token K_rnmos K_rpmos K_rtran K_rtranif0 K_rtranif1 K_scalared
172 %token K_signed K_small K_specify
173 %token K_specparam K_strong0 K_strong1 K_supply0 K_supply1 K_table K_task
174 %token K_time K_tran K_tranif0 K_tranif1 K_tri K_tri0 K_tri1 K_triand
175 %token K_trior K_trireg K_vectored K_wait K_wand K_weak0 K_weak1
176 %token K_while K_wire
177 %token K_wone K_wor K_xnor K_xor
178 %token K_Shold K_Speriod K_Srecovery K_Srecrem K_Ssetup K_Swidth K_Ssetuphold
180 %token KK_attribute
182 %type <number> number
183 %type <flag> signed_opt udp_reg_opt edge_operator
184 %type <drive> drive_strength drive_strength_opt dr_strength0 dr_strength1
185 %type <letter> udp_input_sym udp_output_sym
186 %type <text> udp_input_list udp_sequ_entry udp_comb_entry
187 %type <perm_strings> udp_input_declaration_list
188 %type <strings> udp_entry_list udp_comb_entry_list udp_sequ_entry_list
189 %type <strings> udp_body udp_port_list
190 %type <wires> udp_port_decl udp_port_decls
191 %type <statement> udp_initial udp_init_opt
192 %type <expr> udp_initial_expr_opt
194 %type <text> register_variable net_variable
195 %type <perm_strings> register_variable_list net_variable_list list_of_identifiers
197 %type <net_decl_assign> net_decl_assign net_decl_assigns
199 %type <mport> port port_opt port_reference port_reference_list
200 %type <mport> port_declaration
201 %type <mports> list_of_ports module_port_list_opt list_of_port_declarations
203 %type <wires> task_item task_item_list task_item_list_opt
204 %type <wires> task_port_item task_port_decl task_port_decl_list
205 %type <wires> function_item function_item_list
207 %type <named_pexpr> port_name parameter_value_byname
208 %type <named_pexprs> port_name_list parameter_value_byname_list
210 %type <named_pexpr> attribute
211 %type <named_pexprs> attribute_list attribute_list_opt
213 %type <citem> case_item
214 %type <citems> case_items
216 %type <gate> gate_instance
217 %type <gates> gate_instance_list
219 %type <pform_name> heirarchy_identifier
220 %type <expr> expression expr_primary
221 %type <expr> lpvalue
222 %type <expr> delay_value delay_value_simple
223 %type <exprs> delay1 delay3 delay3_opt delay_value_list
224 %type <exprs> expression_list_with_nuls expression_list_proper
225 %type <exprs> cont_assign cont_assign_list
227 %type <exprs> range range_opt
228 %type <nettype> net_type var_type net_type_opt
229 %type <gatetype> gatetype
230 %type <porttype> port_type
231 %type <datatype> primitive_type primitive_type_opt
232 %type <parmvalue> parameter_value_opt
234 %type <function_type> function_range_or_type_opt
235 %type <event_expr> event_expression_list
236 %type <event_expr> event_expression
237 %type <event_statement> event_control
238 %type <statement> statement statement_or_null
239 %type <statement_list> statement_list
241 %type <letter> spec_polarity
242 %type <perm_strings> specify_path_identifiers
244 %type <specpath> specify_simple_path specify_simple_path_decl
245 %type <specpath> specify_edge_path specify_edge_path_decl
247 %token K_TAND
248 %right '?' ':'
249 %left K_LOR
250 %left K_LAND
251 %left '|'
252 %left '^' K_NXOR K_NOR
253 %left '&' K_NAND
254 %left K_EQ K_NE K_CEQ K_CNE
255 %left K_GE K_LE '<' '>'
256 %left K_LS K_RS K_RSS
257 %left '+' '-'
258 %left '*' '/' '%'
259 %left K_POW
260 %left UNARY_PREC
262 /* to resolve dangling else ambiguity. */
263 %nonassoc less_than_K_else
264 %nonassoc K_else
268 /* A degenerate source file can be completely empty. */
269 main : source_file | ;
271 source_file
272 : description
273 | source_file description
276 number : BASED_NUMBER
277 { $$ = $1; }
278 | DEC_NUMBER
279 { $$ = $1; }
280 | DEC_NUMBER BASED_NUMBER
281 { $$ = pform_verinum_with_size($1,$2, @2.text, @2.first_line); }
284 /* Verilog-2001 supports attribute lists, which can be attached to a
285 variety of different objects. The syntax inside the (* *) is a
286 comma separated list of names or names with assigned values. */
287 attribute_list_opt
288 : K_PSTAR attribute_list K_STARP { $$ = $2; }
289 | K_PSTAR K_STARP { $$ = 0; }
290 | { $$ = 0; }
293 attribute_list
294 : attribute_list ',' attribute
295 { svector<named_pexpr_t*>*tmp =
296 new svector<named_pexpr_t*>(*$1,$3);
297 delete $1;
298 $$ = tmp;
300 | attribute
301 { svector<named_pexpr_t*>*tmp = new svector<named_pexpr_t*>(1);
302 (*tmp)[0] = $1;
303 $$ = tmp;
308 attribute
309 : IDENTIFIER
310 { named_pexpr_t*tmp = new named_pexpr_t;
311 tmp->name = lex_strings.make($1);
312 tmp->parm = 0;
313 delete $1;
314 $$ = tmp;
316 | IDENTIFIER '=' expression
317 { PExpr*tmp = $3;
318 if (!pform_expression_is_constant(tmp)) {
319 yyerror(@3, "error: attribute value "
320 "expression must be constant.");
321 delete tmp;
322 tmp = 0;
324 named_pexpr_t*tmp2 = new named_pexpr_t;
325 tmp2->name = lex_strings.make($1);
326 tmp2->parm = tmp;
327 delete $1;
328 $$ = tmp2;
333 /* The block_item_decl is used in function definitions, task
334 definitions, module definitions and named blocks. Wherever a new
335 scope is entered, the source may declare new registers and
336 integers. This rule matches those declarations. The containing
337 rule has presumably set up the scope. */
339 block_item_decl
340 : attribute_list_opt K_reg
341 primitive_type_opt signed_opt range
342 register_variable_list ';'
343 { ivl_variable_type_t dtype = $3;
344 if (dtype == IVL_VT_NO_TYPE)
345 dtype = IVL_VT_LOGIC;
346 pform_set_net_range($6, $5, $4, dtype);
347 if ($1) delete $1;
350 /* This differs from the above pattern only in the absence of the
351 range. This is the rule for a scalar. */
353 | attribute_list_opt K_reg
354 primitive_type_opt signed_opt
355 register_variable_list ';'
356 { ivl_variable_type_t dtype = $3;
357 if (dtype == IVL_VT_NO_TYPE)
358 dtype = IVL_VT_LOGIC;
359 pform_set_net_range($5, 0, $4, dtype);
360 if ($1) delete $1;
363 /* Integer declarations are simpler in that they do not have all the
364 trappings of a general variable declaration. All of that is
365 implicit in the "integer" of the declaratin. */
367 | attribute_list_opt K_integer register_variable_list ';'
368 { pform_set_reg_integer($3);
369 if ($1) delete $1;
372 | K_time register_variable_list ';'
373 { pform_set_reg_time($2);
376 /* real declarations are fairly simple as there is no range of
377 signed flag in the declaration. Create the real as a NetNet::REG
378 with real value. Note that real and realtime are interchangable
379 in this context. */
381 | K_real list_of_identifiers ';'
382 { pform_makewire(@1, 0, true, $2,
383 NetNet::REG,
384 NetNet::NOT_A_PORT,
385 IVL_VT_REAL,
388 | K_realtime list_of_identifiers ';'
389 { pform_makewire(@1, 0, true, $2,
390 NetNet::REG,
391 NetNet::NOT_A_PORT,
392 IVL_VT_REAL,
396 | K_parameter parameter_assign_decl ';'
397 | K_localparam localparam_assign_decl ';'
399 /* Recover from errors that happen within variable lists. Use the
400 trailing semi-colon to resync the parser. */
402 | attribute_list_opt K_reg error ';'
403 { yyerror(@2, "error: syntax error in reg variable list.");
404 yyerrok;
405 if ($1) delete $1;
407 | attribute_list_opt K_integer error ';'
408 { yyerror(@2, "error: syntax error in integer variable list.");
409 yyerrok;
410 if ($1) delete $1;
412 | K_time error ';'
413 { yyerror(@1, "error: syntax error in time variable list.");
414 yyerrok;
416 | K_real error ';'
417 { yyerror(@1, "error: syntax error in real variable list.");
418 yyerrok;
420 | K_realtime error ';'
421 { yyerror(@1, "error: syntax error in realtime variable list.");
422 yyerrok;
424 | K_parameter error ';'
425 { yyerror(@1, "error: syntax error in parameter list.");
426 yyerrok;
428 | K_localparam error ';'
429 { yyerror(@1, "error: syntax error localparam list.");
430 yyerrok;
434 block_item_decls
435 : block_item_decl
436 | block_item_decls block_item_decl
439 block_item_decls_opt
440 : block_item_decls
444 case_item
445 : expression_list_proper ':' statement_or_null
446 { PCase::Item*tmp = new PCase::Item;
447 tmp->expr = *$1;
448 tmp->stat = $3;
449 delete $1;
450 $$ = tmp;
452 | K_default ':' statement_or_null
453 { PCase::Item*tmp = new PCase::Item;
454 tmp->stat = $3;
455 $$ = tmp;
457 | K_default statement_or_null
458 { PCase::Item*tmp = new PCase::Item;
459 tmp->stat = $2;
460 $$ = tmp;
462 | error ':' statement_or_null
463 { yyerror(@1, "error: Incomprehensible case expression.");
464 yyerrok;
468 case_items
469 : case_items case_item
470 { svector<PCase::Item*>*tmp;
471 tmp = new svector<PCase::Item*>(*$1, $2);
472 delete $1;
473 $$ = tmp;
475 | case_item
476 { svector<PCase::Item*>*tmp = new svector<PCase::Item*>(1);
477 (*tmp)[0] = $1;
478 $$ = tmp;
482 charge_strength
483 : '(' K_small ')'
484 | '(' K_medium ')'
485 | '(' K_large ')'
488 charge_strength_opt
489 : charge_strength
493 defparam_assign
494 : heirarchy_identifier '=' expression
495 { PExpr*tmp = $3;
496 if (!pform_expression_is_constant(tmp)) {
497 yyerror(@3, "error: parameter value "
498 "must be constant.");
499 delete tmp;
500 tmp = 0;
502 pform_set_defparam(*$1, $3);
503 delete $1;
507 defparam_assign_list
508 : defparam_assign
509 | range defparam_assign
510 { yyerror(@1, "error: defparam may not include a range.");
511 delete $1;
513 | defparam_assign_list ',' defparam_assign
516 delay1
517 : '#' delay_value_simple
518 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
519 (*tmp)[0] = $2;
520 $$ = tmp;
522 | '#' '(' delay_value ')'
523 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
524 (*tmp)[0] = $3;
525 $$ = tmp;
529 delay3
530 : '#' delay_value_simple
531 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
532 (*tmp)[0] = $2;
533 $$ = tmp;
535 | '#' '(' delay_value ')'
536 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
537 (*tmp)[0] = $3;
538 $$ = tmp;
540 | '#' '(' delay_value ',' delay_value ')'
541 { svector<PExpr*>*tmp = new svector<PExpr*>(2);
542 (*tmp)[0] = $3;
543 (*tmp)[1] = $5;
544 $$ = tmp;
546 | '#' '(' delay_value ',' delay_value ',' delay_value ')'
547 { svector<PExpr*>*tmp = new svector<PExpr*>(3);
548 (*tmp)[0] = $3;
549 (*tmp)[1] = $5;
550 (*tmp)[2] = $7;
551 $$ = tmp;
555 delay3_opt
556 : delay3 { $$ = $1; }
557 | { $$ = 0; }
560 delay_value_list
561 : delay_value
562 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
563 (*tmp)[0] = $1;
564 $$ = tmp;
566 | delay_value_list ',' delay_value
567 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
568 delete $1;
569 $$ = tmp;
573 delay_value
574 : expression
575 { PExpr*tmp = $1;
576 $$ = tmp;
578 | expression ':' expression ':' expression
579 { $$ = pform_select_mtm_expr($1, $3, $5); }
583 delay_value_simple
584 : DEC_NUMBER
585 { verinum*tmp = $1;
586 if (tmp == 0) {
587 yyerror(@1, "internal error: delay.");
588 $$ = 0;
589 } else {
590 $$ = new PENumber(tmp);
591 $$->set_file(@1.text);
592 $$->set_lineno(@1.first_line);
595 | REALTIME
596 { verireal*tmp = $1;
597 if (tmp == 0) {
598 yyerror(@1, "internal error: delay.");
599 $$ = 0;
600 } else {
601 $$ = new PEFNumber(tmp);
602 $$->set_file(@1.text);
603 $$->set_lineno(@1.first_line);
606 | IDENTIFIER
607 { PEIdent*tmp = new PEIdent(lex_strings.make($1));
608 tmp->set_file(@1.text);
609 tmp->set_lineno(@1.first_line);
610 $$ = tmp;
611 delete $1;
615 description
616 : module
617 | udp_primitive
618 | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')'
619 { perm_string tmp3 = lex_strings.make($3);
620 pform_set_type_attrib(tmp3, $5, $7);
621 delete $3;
622 delete $5;
626 drive_strength
627 : '(' dr_strength0 ',' dr_strength1 ')'
628 { $$.str0 = $2.str0;
629 $$.str1 = $4.str1;
631 | '(' dr_strength1 ',' dr_strength0 ')'
632 { $$.str0 = $4.str0;
633 $$.str1 = $2.str1;
635 | '(' dr_strength0 ',' K_highz1 ')'
636 { $$.str0 = $2.str0;
637 $$.str1 = PGate::HIGHZ;
639 | '(' dr_strength1 ',' K_highz0 ')'
640 { $$.str0 = PGate::HIGHZ;
641 $$.str1 = $2.str1;
643 | '(' K_highz1 ',' dr_strength0 ')'
644 { $$.str0 = $4.str0;
645 $$.str1 = PGate::HIGHZ;
647 | '(' K_highz0 ',' dr_strength1 ')'
648 { $$.str0 = PGate::HIGHZ;
649 $$.str1 = $4.str1;
653 drive_strength_opt
654 : drive_strength { $$ = $1; }
655 | { $$.str0 = PGate::STRONG; $$.str1 = PGate::STRONG; }
658 dr_strength0
659 : K_supply0 { $$.str0 = PGate::SUPPLY; }
660 | K_strong0 { $$.str0 = PGate::STRONG; }
661 | K_pull0 { $$.str0 = PGate::PULL; }
662 | K_weak0 { $$.str0 = PGate::WEAK; }
665 dr_strength1
666 : K_supply1 { $$.str1 = PGate::SUPPLY; }
667 | K_strong1 { $$.str1 = PGate::STRONG; }
668 | K_pull1 { $$.str1 = PGate::PULL; }
669 | K_weak1 { $$.str1 = PGate::WEAK; }
672 event_control
673 : '@' heirarchy_identifier
674 { PEIdent*tmpi = new PEIdent(*$2);
675 PEEvent*tmpe = new PEEvent(PEEvent::ANYEDGE, tmpi);
676 PEventStatement*tmps = new PEventStatement(tmpe);
677 tmps->set_file(@1.text);
678 tmps->set_lineno(@1.first_line);
679 $$ = tmps;
680 delete $2;
682 | '@' '(' event_expression_list ')'
683 { PEventStatement*tmp = new PEventStatement(*$3);
684 tmp->set_file(@1.text);
685 tmp->set_lineno(@1.first_line);
686 delete $3;
687 $$ = tmp;
689 | '@' '(' error ')'
690 { yyerror(@1, "error: Malformed event control expression.");
691 $$ = 0;
695 event_expression_list
696 : event_expression
697 { $$ = $1; }
698 | event_expression_list K_or event_expression
699 { svector<PEEvent*>*tmp = new svector<PEEvent*>(*$1, *$3);
700 delete $1;
701 delete $3;
702 $$ = tmp;
704 | event_expression_list ',' event_expression
705 { svector<PEEvent*>*tmp = new svector<PEEvent*>(*$1, *$3);
706 delete $1;
707 delete $3;
708 $$ = tmp;
712 event_expression
713 : K_posedge expression
714 { PEEvent*tmp = new PEEvent(PEEvent::POSEDGE, $2);
715 tmp->set_file(@1.text);
716 tmp->set_lineno(@1.first_line);
717 svector<PEEvent*>*tl = new svector<PEEvent*>(1);
718 (*tl)[0] = tmp;
719 $$ = tl;
721 | K_negedge expression
722 { PEEvent*tmp = new PEEvent(PEEvent::NEGEDGE, $2);
723 tmp->set_file(@1.text);
724 tmp->set_lineno(@1.first_line);
725 svector<PEEvent*>*tl = new svector<PEEvent*>(1);
726 (*tl)[0] = tmp;
727 $$ = tl;
729 | expression
730 { PEEvent*tmp = new PEEvent(PEEvent::ANYEDGE, $1);
731 tmp->set_file(@1.text);
732 tmp->set_lineno(@1.first_line);
733 svector<PEEvent*>*tl = new svector<PEEvent*>(1);
734 (*tl)[0] = tmp;
735 $$ = tl;
739 expression
740 : expr_primary
741 { $$ = $1; }
742 | '+' expr_primary %prec UNARY_PREC
743 { $$ = $2; }
744 | '-' expr_primary %prec UNARY_PREC
745 { PEUnary*tmp = new PEUnary('-', $2);
746 tmp->set_file(@2.text);
747 tmp->set_lineno(@2.first_line);
748 $$ = tmp;
750 | '~' expr_primary %prec UNARY_PREC
751 { PEUnary*tmp = new PEUnary('~', $2);
752 tmp->set_file(@2.text);
753 tmp->set_lineno(@2.first_line);
754 $$ = tmp;
756 | '&' expr_primary %prec UNARY_PREC
757 { PEUnary*tmp = new PEUnary('&', $2);
758 tmp->set_file(@2.text);
759 tmp->set_lineno(@2.first_line);
760 $$ = tmp;
762 | '!' expr_primary %prec UNARY_PREC
763 { PEUnary*tmp = new PEUnary('!', $2);
764 tmp->set_file(@2.text);
765 tmp->set_lineno(@2.first_line);
766 $$ = tmp;
768 | '|' expr_primary %prec UNARY_PREC
769 { PEUnary*tmp = new PEUnary('|', $2);
770 tmp->set_file(@2.text);
771 tmp->set_lineno(@2.first_line);
772 $$ = tmp;
774 | '^' expr_primary %prec UNARY_PREC
775 { PEUnary*tmp = new PEUnary('^', $2);
776 tmp->set_file(@2.text);
777 tmp->set_lineno(@2.first_line);
778 $$ = tmp;
780 | K_NAND expr_primary %prec UNARY_PREC
781 { PEUnary*tmp = new PEUnary('A', $2);
782 tmp->set_file(@2.text);
783 tmp->set_lineno(@2.first_line);
784 $$ = tmp;
786 | K_NOR expr_primary %prec UNARY_PREC
787 { PEUnary*tmp = new PEUnary('N', $2);
788 tmp->set_file(@2.text);
789 tmp->set_lineno(@2.first_line);
790 $$ = tmp;
792 | K_NXOR expr_primary %prec UNARY_PREC
793 { PEUnary*tmp = new PEUnary('X', $2);
794 tmp->set_file(@2.text);
795 tmp->set_lineno(@2.first_line);
796 $$ = tmp;
798 | '!' error %prec UNARY_PREC
799 { yyerror(@1, "error: Operand of unary ! "
800 "is not a primary expression.");
801 $$ = 0;
803 | '^' error %prec UNARY_PREC
804 { yyerror(@1, "error: Operand of reduction ^ "
805 "is not a primary expression.");
806 $$ = 0;
808 | expression '^' expression
809 { PEBinary*tmp = new PEBinary('^', $1, $3);
810 tmp->set_file(@2.text);
811 tmp->set_lineno(@2.first_line);
812 $$ = tmp;
814 | expression K_POW expression
815 { PEBinary*tmp = new PEBinary('p', $1, $3);
816 tmp->set_file(@2.text);
817 tmp->set_lineno(@2.first_line);
818 $$ = tmp;
820 | expression '*' expression
821 { PEBinary*tmp = new PEBinary('*', $1, $3);
822 tmp->set_file(@2.text);
823 tmp->set_lineno(@2.first_line);
824 $$ = tmp;
826 | expression '/' expression
827 { PEBinary*tmp = new PEBinary('/', $1, $3);
828 tmp->set_file(@2.text);
829 tmp->set_lineno(@2.first_line);
830 $$ = tmp;
832 | expression '%' expression
833 { PEBinary*tmp = new PEBinary('%', $1, $3);
834 tmp->set_file(@2.text);
835 tmp->set_lineno(@2.first_line);
836 $$ = tmp;
838 | expression '+' expression
839 { PEBinary*tmp = new PEBinary('+', $1, $3);
840 tmp->set_file(@2.text);
841 tmp->set_lineno(@2.first_line);
842 $$ = tmp;
844 | expression '-' expression
845 { PEBinary*tmp = new PEBinary('-', $1, $3);
846 tmp->set_file(@2.text);
847 tmp->set_lineno(@2.first_line);
848 $$ = tmp;
850 | expression '&' expression
851 { PEBinary*tmp = new PEBinary('&', $1, $3);
852 tmp->set_file(@2.text);
853 tmp->set_lineno(@2.first_line);
854 $$ = tmp;
856 | expression '|' expression
857 { PEBinary*tmp = new PEBinary('|', $1, $3);
858 tmp->set_file(@2.text);
859 tmp->set_lineno(@2.first_line);
860 $$ = tmp;
862 | expression K_NAND expression
863 { PEBinary*tmp = new PEBinary('A', $1, $3);
864 tmp->set_file(@2.text);
865 tmp->set_lineno(@2.first_line);
866 $$ = tmp;
868 | expression K_NOR expression
869 { PEBinary*tmp = new PEBinary('O', $1, $3);
870 tmp->set_file(@2.text);
871 tmp->set_lineno(@2.first_line);
872 $$ = tmp;
874 | expression K_NXOR expression
875 { PEBinary*tmp = new PEBinary('X', $1, $3);
876 tmp->set_file(@2.text);
877 tmp->set_lineno(@2.first_line);
878 $$ = tmp;
880 | expression '<' expression
881 { PEBinary*tmp = new PEBComp('<', $1, $3);
882 tmp->set_file(@2.text);
883 tmp->set_lineno(@2.first_line);
884 $$ = tmp;
886 | expression '>' expression
887 { PEBinary*tmp = new PEBComp('>', $1, $3);
888 tmp->set_file(@2.text);
889 tmp->set_lineno(@2.first_line);
890 $$ = tmp;
892 | expression K_LS expression
893 { PEBinary*tmp = new PEBShift('l', $1, $3);
894 tmp->set_file(@2.text);
895 tmp->set_lineno(@2.first_line);
896 $$ = tmp;
898 | expression K_RS expression
899 { PEBinary*tmp = new PEBShift('r', $1, $3);
900 tmp->set_file(@2.text);
901 tmp->set_lineno(@2.first_line);
902 $$ = tmp;
904 | expression K_RSS expression
905 { PEBinary*tmp = new PEBShift('R', $1, $3);
906 tmp->set_file(@2.text);
907 tmp->set_lineno(@2.first_line);
908 $$ = tmp;
910 | expression K_EQ expression
911 { PEBinary*tmp = new PEBComp('e', $1, $3);
912 tmp->set_file(@2.text);
913 tmp->set_lineno(@2.first_line);
914 $$ = tmp;
916 | expression K_CEQ expression
917 { PEBinary*tmp = new PEBComp('E', $1, $3);
918 tmp->set_file(@2.text);
919 tmp->set_lineno(@2.first_line);
920 $$ = tmp;
922 | expression K_LE expression
923 { PEBinary*tmp = new PEBComp('L', $1, $3);
924 tmp->set_file(@2.text);
925 tmp->set_lineno(@2.first_line);
926 $$ = tmp;
928 | expression K_GE expression
929 { PEBinary*tmp = new PEBComp('G', $1, $3);
930 tmp->set_file(@2.text);
931 tmp->set_lineno(@2.first_line);
932 $$ = tmp;
934 | expression K_NE expression
935 { PEBinary*tmp = new PEBComp('n', $1, $3);
936 tmp->set_file(@2.text);
937 tmp->set_lineno(@2.first_line);
938 $$ = tmp;
940 | expression K_CNE expression
941 { PEBinary*tmp = new PEBComp('N', $1, $3);
942 tmp->set_file(@2.text);
943 tmp->set_lineno(@2.first_line);
944 $$ = tmp;
946 | expression K_LOR expression
947 { PEBinary*tmp = new PEBinary('o', $1, $3);
948 tmp->set_file(@2.text);
949 tmp->set_lineno(@2.first_line);
950 $$ = tmp;
952 | expression K_LAND expression
953 { PEBinary*tmp = new PEBinary('a', $1, $3);
954 tmp->set_file(@2.text);
955 tmp->set_lineno(@2.first_line);
956 $$ = tmp;
958 | expression '?' expression ':' expression
959 { PETernary*tmp = new PETernary($1, $3, $5);
960 tmp->set_file(@2.text);
961 tmp->set_lineno(@2.first_line);
962 $$ = tmp;
967 /* Many contexts take a comma separated list of expressions. Null
968 expressions can happen anywhere in the list, so there are two
969 extra rules in expression_list_with_nuls for parsing and
970 installing those nulls.
972 The expression_list_proper rules do not allow null items in the
973 expression list, so can be used where nul expressions are not allowed. */
975 expression_list_with_nuls
976 : expression_list_with_nuls ',' expression
977 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
978 delete $1;
979 $$ = tmp;
981 | expression
982 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
983 (*tmp)[0] = $1;
984 $$ = tmp;
987 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
988 (*tmp)[0] = 0;
989 $$ = tmp;
992 | expression_list_with_nuls ','
993 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, 0);
994 delete $1;
995 $$ = tmp;
999 expression_list_proper
1000 : expression_list_proper ',' expression
1001 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
1002 delete $1;
1003 $$ = tmp;
1005 | expression
1006 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
1007 (*tmp)[0] = $1;
1008 $$ = tmp;
1012 expr_primary
1013 : number
1014 { assert($1);
1015 PENumber*tmp = new PENumber($1);
1016 tmp->set_file(@1.text);
1017 tmp->set_lineno(@1.first_line);
1018 $$ = tmp;
1020 | REALTIME
1021 { PEFNumber*tmp = new PEFNumber($1);
1022 tmp->set_file(@1.text);
1023 tmp->set_lineno(@1.first_line);
1024 $$ = tmp;
1026 | STRING
1027 { PEString*tmp = new PEString($1);
1028 tmp->set_file(@1.text);
1029 tmp->set_lineno(@1.first_line);
1030 $$ = tmp;
1032 | SYSTEM_IDENTIFIER
1033 { perm_string tn = lex_strings.make($1);
1034 PECallFunction*tmp = new PECallFunction(tn);
1035 tmp->set_file(@1.text);
1036 tmp->set_lineno(@1.first_line);
1037 $$ = tmp;
1038 delete $1;
1041 /* The heirarchy_identifier rule matches simple identifiers as well as
1042 indexed arrays and part selects */
1044 | heirarchy_identifier
1045 { PEIdent*tmp = new PEIdent(*$1);
1046 tmp->set_file(@1.text);
1047 tmp->set_lineno(@1.first_line);
1048 $$ = tmp;
1049 delete $1;
1052 /* An identifer followed by an expression list in parentheses is a
1053 function call. If a system identifier, then a system function
1054 call. */
1056 | heirarchy_identifier '(' expression_list_proper ')'
1057 { PECallFunction*tmp = new PECallFunction(*$1, *$3);
1058 tmp->set_file(@1.text);
1059 tmp->set_lineno(@1.first_line);
1060 delete $1;
1061 $$ = tmp;
1063 | SYSTEM_IDENTIFIER '(' expression_list_proper ')'
1064 { perm_string tn = lex_strings.make($1);
1065 PECallFunction*tmp = new PECallFunction(tn, *$3);
1066 tmp->set_file(@1.text);
1067 tmp->set_lineno(@1.first_line);
1068 $$ = tmp;
1071 /* Parenthesized expressions are primaries. */
1073 | '(' expression ')'
1074 { $$ = $2; }
1076 /* Various kinds of concatenation expressions. */
1078 | '{' expression_list_proper '}'
1079 { PEConcat*tmp = new PEConcat(*$2);
1080 tmp->set_file(@1.text);
1081 tmp->set_lineno(@1.first_line);
1082 delete $2;
1083 $$ = tmp;
1085 | '{' expression '{' expression_list_proper '}' '}'
1086 { PExpr*rep = $2;
1087 PEConcat*tmp = new PEConcat(*$4, rep);
1088 tmp->set_file(@1.text);
1089 tmp->set_lineno(@1.first_line);
1090 delete $4;
1091 $$ = tmp;
1093 | '{' expression '{' expression_list_proper '}' error '}'
1094 { PExpr*rep = $2;
1095 PEConcat*tmp = new PEConcat(*$4, rep);
1096 tmp->set_file(@1.text);
1097 tmp->set_lineno(@1.first_line);
1098 delete $4;
1099 $$ = tmp;
1100 yyerror(@5, "error: Syntax error between internal '}' "
1101 "and closing '}' of repeat concatenation.");
1102 yyerrok;
1106 /* A function_item is either a block item (i.e. a reg or integer
1107 declaration) or an input declaration. There are no output or
1108 inout ports. */
1109 function_item
1110 : K_input signed_opt range_opt list_of_identifiers ';'
1111 { svector<PWire*>*tmp
1112 = pform_make_task_ports(NetNet::PINPUT,
1113 IVL_VT_NO_TYPE, $2,
1114 $3, $4,
1115 @1.text, @1.first_line);
1116 $$ = tmp;
1118 | K_output signed_opt range_opt list_of_identifiers ';'
1119 { svector<PWire*>*tmp
1120 = pform_make_task_ports(NetNet::PINPUT,
1121 IVL_VT_NO_TYPE, $2,
1122 $3, $4,
1123 @1.text, @1.first_line);
1124 $$ = tmp;
1125 yyerror(@1, "Functions may not have output ports.");
1127 | K_inout signed_opt range_opt list_of_identifiers ';'
1128 { svector<PWire*>*tmp
1129 = pform_make_task_ports(NetNet::PINPUT,
1130 IVL_VT_NO_TYPE, $2,
1131 $3, $4,
1132 @1.text, @1.first_line);
1133 $$ = tmp;
1134 yyerror(@1, "Functions may not have inout ports.");
1137 /* When the port is an integer, infer a signed vector of the integer
1138 shape. Generate a range to make it work. */
1140 | K_input K_integer list_of_identifiers ';'
1141 { svector<PExpr*>*range_stub
1142 = new svector<PExpr*>(2);
1143 PExpr*re;
1144 re = new PENumber(new verinum(integer_width-1,
1145 integer_width));
1146 (*range_stub)[0] = re;
1147 re = new PENumber(new verinum((uint64_t)0, integer_width));
1148 (*range_stub)[1] = re;
1149 svector<PWire*>*tmp
1150 = pform_make_task_ports(NetNet::PINPUT,
1151 IVL_VT_LOGIC, true,
1152 range_stub, $3,
1153 @1.text, @1.first_line);
1154 $$ = tmp;
1157 /* Ports can be real. */
1159 | K_input K_real list_of_identifiers ';'
1160 { svector<PWire*>*tmp
1161 = pform_make_task_ports(NetNet::PINPUT,
1162 IVL_VT_REAL, false,
1163 0, $3,
1164 @1.text, @1.first_line);
1165 $$ = tmp;
1168 | block_item_decl
1169 { $$ = 0; }
1172 /* A function_item_list only lists the input/output/inout
1173 declarations. The integer and reg declarations are handled in
1174 place, so are not listed. The list builder needs to account for
1175 the possibility that the various parts may be NULL. */
1176 function_item_list
1177 : function_item
1178 { $$ = $1; }
1179 | function_item_list function_item
1180 { if ($1 && $2) {
1181 svector<PWire*>*tmp = new svector<PWire*>(*$1, *$2);
1182 delete $1;
1183 delete $2;
1184 $$ = tmp;
1185 } else if ($1) {
1186 $$ = $1;
1187 } else {
1188 $$ = $2;
1193 /* A gate_instance is a module instantiation or a built in part
1194 type. In any case, the gate has a set of connections to ports. */
1195 gate_instance
1196 : IDENTIFIER '(' expression_list_with_nuls ')'
1197 { lgate*tmp = new lgate;
1198 tmp->name = $1;
1199 tmp->parms = $3;
1200 tmp->file = @1.text;
1201 tmp->lineno = @1.first_line;
1202 delete $1;
1203 $$ = tmp;
1206 | IDENTIFIER range '(' expression_list_with_nuls ')'
1207 { lgate*tmp = new lgate;
1208 svector<PExpr*>*rng = $2;
1209 tmp->name = $1;
1210 tmp->parms = $4;
1211 tmp->range[0] = (*rng)[0];
1212 tmp->range[1] = (*rng)[1];
1213 tmp->file = @1.text;
1214 tmp->lineno = @1.first_line;
1215 delete $1;
1216 delete rng;
1217 $$ = tmp;
1219 | '(' expression_list_with_nuls ')'
1220 { lgate*tmp = new lgate;
1221 tmp->name = "";
1222 tmp->parms = $2;
1223 tmp->file = @1.text;
1224 tmp->lineno = @1.first_line;
1225 $$ = tmp;
1228 /* Degenerate modules can have no ports. */
1230 | IDENTIFIER range
1231 { lgate*tmp = new lgate;
1232 svector<PExpr*>*rng = $2;
1233 tmp->name = $1;
1234 tmp->parms = 0;
1235 tmp->parms_by_name = 0;
1236 tmp->range[0] = (*rng)[0];
1237 tmp->range[1] = (*rng)[1];
1238 tmp->file = @1.text;
1239 tmp->lineno = @1.first_line;
1240 delete $1;
1241 delete rng;
1242 $$ = tmp;
1245 /* Modules can also take ports by port-name expressions. */
1247 | IDENTIFIER '(' port_name_list ')'
1248 { lgate*tmp = new lgate;
1249 tmp->name = $1;
1250 tmp->parms = 0;
1251 tmp->parms_by_name = $3;
1252 tmp->file = @1.text;
1253 tmp->lineno = @1.first_line;
1254 delete $1;
1255 $$ = tmp;
1258 | IDENTIFIER range '(' port_name_list ')'
1259 { lgate*tmp = new lgate;
1260 svector<PExpr*>*rng = $2;
1261 tmp->name = $1;
1262 tmp->parms = 0;
1263 tmp->parms_by_name = $4;
1264 tmp->range[0] = (*rng)[0];
1265 tmp->range[1] = (*rng)[1];
1266 tmp->file = @1.text;
1267 tmp->lineno = @1.first_line;
1268 delete $1;
1269 delete rng;
1270 $$ = tmp;
1274 gate_instance_list
1275 : gate_instance_list ',' gate_instance
1276 { svector<lgate>*tmp1 = $1;
1277 lgate*tmp2 = $3;
1278 svector<lgate>*out = new svector<lgate> (*tmp1, *tmp2);
1279 delete tmp1;
1280 delete tmp2;
1281 $$ = out;
1283 | gate_instance
1284 { svector<lgate>*tmp = new svector<lgate>(1);
1285 (*tmp)[0] = *$1;
1286 delete $1;
1287 $$ = tmp;
1291 gatetype
1292 : K_and { $$ = PGBuiltin::AND; }
1293 | K_nand { $$ = PGBuiltin::NAND; }
1294 | K_or { $$ = PGBuiltin::OR; }
1295 | K_nor { $$ = PGBuiltin::NOR; }
1296 | K_xor { $$ = PGBuiltin::XOR; }
1297 | K_xnor { $$ = PGBuiltin::XNOR; }
1298 | K_buf { $$ = PGBuiltin::BUF; }
1299 | K_bufif0 { $$ = PGBuiltin::BUFIF0; }
1300 | K_bufif1 { $$ = PGBuiltin::BUFIF1; }
1301 | K_not { $$ = PGBuiltin::NOT; }
1302 | K_notif0 { $$ = PGBuiltin::NOTIF0; }
1303 | K_notif1 { $$ = PGBuiltin::NOTIF1; }
1304 | K_nmos { $$ = PGBuiltin::NMOS; }
1305 | K_rnmos { $$ = PGBuiltin::RNMOS; }
1306 | K_pmos { $$ = PGBuiltin::PMOS; }
1307 | K_rpmos { $$ = PGBuiltin::RPMOS; }
1308 | K_cmos { $$ = PGBuiltin::CMOS; }
1309 | K_rcmos { $$ = PGBuiltin::RCMOS; }
1310 | K_tran { $$ = PGBuiltin::TRAN; }
1311 | K_rtran { $$ = PGBuiltin::RTRAN; }
1312 | K_tranif0 { $$ = PGBuiltin::TRANIF0; }
1313 | K_tranif1 { $$ = PGBuiltin::TRANIF1; }
1314 | K_rtranif0 { $$ = PGBuiltin::RTRANIF0; }
1315 | K_rtranif1 { $$ = PGBuiltin::RTRANIF1; }
1319 /* A general identifier is a hierarchical name, with the right most
1320 name the base of the identifier. This rule builds up a
1321 hierarchical name from the left to the right, forming a list of
1322 names. */
1324 heirarchy_identifier
1325 : IDENTIFIER
1326 { $$ = new pform_name_t;
1327 $$->push_back(name_component_t(lex_strings.make($1)));
1328 delete $1;
1330 | heirarchy_identifier '.' IDENTIFIER
1331 { pform_name_t * tmp = $1;
1332 tmp->push_back(name_component_t(lex_strings.make($3)));
1333 delete $3;
1334 $$ = tmp;
1336 | heirarchy_identifier '[' expression ']'
1337 { pform_name_t * tmp = $1;
1338 name_component_t&tail = tmp->back();
1339 index_component_t itmp;
1340 itmp.sel = index_component_t::SEL_BIT;
1341 itmp.msb = $3;
1342 tail.index.push_back(itmp);
1343 $$ = tmp;
1345 | heirarchy_identifier '[' expression ':' expression ']'
1346 { pform_name_t * tmp = $1;
1347 name_component_t&tail = tmp->back();
1348 index_component_t itmp;
1349 itmp.sel = index_component_t::SEL_PART;
1350 itmp.msb = $3;
1351 itmp.lsb = $5;
1352 tail.index.push_back(itmp);
1353 $$ = tmp;
1355 | heirarchy_identifier '[' expression K_PO_POS expression ']'
1356 { pform_name_t * tmp = $1;
1357 name_component_t&tail = tmp->back();
1358 index_component_t itmp;
1359 itmp.sel = index_component_t::SEL_IDX_UP;
1360 itmp.msb = $3;
1361 itmp.lsb = $5;
1362 tail.index.push_back(itmp);
1363 $$ = tmp;
1365 | heirarchy_identifier '[' expression K_PO_NEG expression ']'
1366 { pform_name_t * tmp = $1;
1367 name_component_t&tail = tmp->back();
1368 index_component_t itmp;
1369 itmp.sel = index_component_t::SEL_IDX_DO;
1370 itmp.msb = $3;
1371 itmp.lsb = $5;
1372 tail.index.push_back(itmp);
1373 $$ = tmp;
1377 /* This is a list of identifiers. The result is a list of strings,
1378 each one of the identifiers in the list. These are simple,
1379 non-hierarchical names separated by ',' characters. */
1380 list_of_identifiers
1381 : IDENTIFIER
1382 { $$ = list_from_identifier($1); }
1383 | list_of_identifiers ',' IDENTIFIER
1384 { $$ = list_from_identifier($1, $3); }
1388 /* The list_of_ports and list_of_port_declarations rules are the
1389 port list formats for module ports. The list_of_ports_opt rule is
1390 only used by the module start rule.
1392 The first, the list_of_ports, is the 1364-1995 format, a list of
1393 port names, including .name() syntax.
1395 The list_of_port_declarations the 1364-2001 format, an in-line
1396 declaration of the ports.
1398 In both cases, the list_of_ports and list_of_port_declarations
1399 returns an array of Module::port_t* items that include the name
1400 of the port internally and externally. The actual creation of the
1401 nets/variables is done in the declaration, whether internal to
1402 the port list or in amongst the module items. */
1404 list_of_ports
1405 : port_opt
1406 { svector<Module::port_t*>*tmp
1407 = new svector<Module::port_t*>(1);
1408 (*tmp)[0] = $1;
1409 $$ = tmp;
1411 | list_of_ports ',' port_opt
1412 { svector<Module::port_t*>*tmp
1413 = new svector<Module::port_t*>(*$1, $3);
1414 delete $1;
1415 $$ = tmp;
1419 list_of_port_declarations
1420 : port_declaration
1421 { svector<Module::port_t*>*tmp
1422 = new svector<Module::port_t*>(1);
1423 (*tmp)[0] = $1;
1424 $$ = tmp;
1426 | list_of_port_declarations ',' port_declaration
1427 { svector<Module::port_t*>*tmp
1428 = new svector<Module::port_t*>(*$1, $3);
1429 delete $1;
1430 $$ = tmp;
1432 | list_of_port_declarations ',' IDENTIFIER
1433 { Module::port_t*ptmp;
1434 ptmp = pform_module_port_reference($3, @3.text,
1435 @3.first_line);
1436 svector<Module::port_t*>*tmp
1437 = new svector<Module::port_t*>(*$1, ptmp);
1439 /* Get the port declaration details, the port type
1440 and what not, from context data stored by the
1441 last port_declaration rule. */
1442 pform_module_define_port(@3, $3,
1443 port_declaration_context.port_type,
1444 port_declaration_context.port_net_type,
1445 port_declaration_context.sign_flag,
1446 port_declaration_context.range, 0);
1447 delete $1;
1448 $$ = tmp;
1452 port_declaration
1453 : attribute_list_opt
1454 K_input net_type_opt signed_opt range_opt IDENTIFIER
1455 { Module::port_t*ptmp;
1456 ptmp = pform_module_port_reference($6, @2.text,
1457 @2.first_line);
1458 pform_module_define_port(@2, $6, NetNet::PINPUT,
1459 $3, $4, $5, $1);
1460 port_declaration_context.port_type = NetNet::PINPUT;
1461 port_declaration_context.port_net_type = $3;
1462 port_declaration_context.sign_flag = $4;
1463 port_declaration_context.range = $5;
1464 delete $1;
1465 delete $6;
1466 $$ = ptmp;
1468 | attribute_list_opt
1469 K_inout net_type_opt signed_opt range_opt IDENTIFIER
1470 { Module::port_t*ptmp;
1471 ptmp = pform_module_port_reference($6, @2.text,
1472 @2.first_line);
1473 pform_module_define_port(@2, $6, NetNet::PINOUT,
1474 $3, $4, $5, $1);
1475 port_declaration_context.port_type = NetNet::PINOUT;
1476 port_declaration_context.port_net_type = $3;
1477 port_declaration_context.sign_flag = $4;
1478 port_declaration_context.range = $5;
1479 delete $1;
1480 delete $6;
1481 $$ = ptmp;
1483 | attribute_list_opt
1484 K_output net_type_opt signed_opt range_opt IDENTIFIER
1485 { Module::port_t*ptmp;
1486 ptmp = pform_module_port_reference($6, @2.text,
1487 @2.first_line);
1488 pform_module_define_port(@2, $6, NetNet::POUTPUT,
1489 $3, $4, $5, $1);
1490 port_declaration_context.port_type = NetNet::POUTPUT;
1491 port_declaration_context.port_net_type = $3;
1492 port_declaration_context.sign_flag = $4;
1493 port_declaration_context.range = $5;
1494 delete $1;
1495 delete $6;
1496 $$ = ptmp;
1498 | attribute_list_opt
1499 K_output var_type signed_opt range_opt IDENTIFIER
1500 { Module::port_t*ptmp;
1501 ptmp = pform_module_port_reference($6, @2.text,
1502 @2.first_line);
1503 pform_module_define_port(@2, $6, NetNet::POUTPUT,
1504 $3, $4, $5, $1);
1505 port_declaration_context.port_type = NetNet::POUTPUT;
1506 port_declaration_context.port_net_type = $3;
1507 port_declaration_context.sign_flag = $4;
1508 port_declaration_context.range = $5;
1509 delete $1;
1510 delete $6;
1511 $$ = ptmp;
1513 | attribute_list_opt
1514 K_output var_type signed_opt range_opt IDENTIFIER '=' expression
1515 { Module::port_t*ptmp;
1516 ptmp = pform_module_port_reference($6, @2.text,
1517 @2.first_line);
1518 pform_module_define_port(@2, $6, NetNet::POUTPUT,
1519 $3, $4, $5, $1);
1520 port_declaration_context.port_type = NetNet::POUTPUT;
1521 port_declaration_context.port_net_type = $3;
1522 port_declaration_context.sign_flag = $4;
1523 port_declaration_context.range = $5;
1525 if (! pform_expression_is_constant($8))
1526 yyerror(@8, "error: register declaration assignment"
1527 " value must be a constant expression.");
1528 pform_make_reginit(@6, $6, $8);
1530 delete $1;
1531 delete $6;
1532 $$ = ptmp;
1538 net_type_opt
1539 : net_type { $$ = $1; }
1540 | { $$ = NetNet::IMPLICIT; }
1543 signed_opt : K_signed { $$ = true; } | {$$ = false; } ;
1545 /* An lpvalue is the expression that can go on the left side of a
1546 procedural assignment. This rule handles only procedural
1547 assignments. It is more limited then the general expr_primary
1548 rule to reflect the rules for assignment l-values. */
1549 lpvalue
1550 : heirarchy_identifier
1551 { PEIdent*tmp = new PEIdent(*$1);
1552 tmp->set_file(@1.text);
1553 tmp->set_lineno(@1.first_line);
1554 $$ = tmp;
1555 delete $1;
1557 | '{' expression_list_proper '}'
1558 { PEConcat*tmp = new PEConcat(*$2);
1559 tmp->set_file(@1.text);
1560 tmp->set_lineno(@1.first_line);
1561 delete $2;
1562 $$ = tmp;
1567 /* Continuous assignments have a list of individual assignments. */
1569 cont_assign
1570 : lpvalue '=' expression
1571 { svector<PExpr*>*tmp = new svector<PExpr*>(2);
1572 (*tmp)[0] = $1;
1573 (*tmp)[1] = $3;
1574 $$ = tmp;
1578 cont_assign_list
1579 : cont_assign_list ',' cont_assign
1580 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, *$3);
1581 delete $1;
1582 delete $3;
1583 $$ = tmp;
1585 | cont_assign
1586 { $$ = $1; }
1590 /* This is the global structure of a module. A module in a start
1591 section, with optional ports, then an optional list of module
1592 items, and finally an end marker. */
1594 module : attribute_list_opt module_start IDENTIFIER
1595 { pform_startmodule($3, @2.text, @2.first_line, $1); }
1596 module_parameter_port_list_opt
1597 module_port_list_opt ';'
1598 { pform_module_set_ports($6); }
1599 module_item_list_opt
1600 K_endmodule
1601 { pform_endmodule($3);
1602 delete $3;
1607 module_start : K_module | K_macromodule ;
1609 module_port_list_opt
1610 : '(' list_of_ports ')' { $$ = $2; }
1611 | '(' list_of_port_declarations ')' { $$ = $2; }
1612 | { $$ = 0; }
1615 /* Module declarations include optional ANSII style module parameter
1616 ports. These are simply advance ways to declare parameters, so
1617 that the port declarations may use them. */
1618 module_parameter_port_list_opt
1620 | '#' '(' module_parameter_port_list ')'
1623 module_parameter_port_list
1624 : K_parameter parameter_assign
1625 | module_parameter_port_list ',' parameter_assign
1626 | module_parameter_port_list ',' K_parameter parameter_assign
1629 module_item
1631 /* This rule detects net declarations that possibly include a
1632 primitive type, an optional vector range and signed flag. This
1633 also includes an optional delay set. The values are then applied
1634 to a list of names. If the primitive type is not specified, then
1635 resort to the default type LOGIC. */
1637 : attribute_list_opt net_type
1638 primitive_type_opt signed_opt range_opt
1639 delay3_opt
1640 net_variable_list ';'
1642 { ivl_variable_type_t dtype = $3;
1643 if (dtype == IVL_VT_NO_TYPE)
1644 dtype = IVL_VT_LOGIC;
1645 pform_makewire(@2, $5, $4, $7, $2,
1646 NetNet::NOT_A_PORT, dtype, $1);
1647 if ($6 != 0) {
1648 yyerror(@6, "sorry: net delays not supported.");
1649 delete $6;
1651 if ($1) delete $1;
1654 /* Very similar to the rule above, but this takes a list of
1655 net_decl_assigns, which are <name> = <expr> assignment
1656 declarations. */
1658 | attribute_list_opt net_type
1659 primitive_type_opt signed_opt range_opt
1660 delay3_opt net_decl_assigns ';'
1662 { ivl_variable_type_t dtype = $3;
1663 if (dtype == IVL_VT_NO_TYPE)
1664 dtype = IVL_VT_LOGIC;
1665 pform_makewire(@2, $5, $4, $6,
1666 str_strength, $7, $2, dtype);
1667 if ($1) {
1668 yyerror(@2, "sorry: Attributes not supported "
1669 "on net declaration assignments.");
1670 delete $1;
1674 /* This form doesn't have the range, but does have strengths. This
1675 gives strength to the assignment drivers. */
1677 | attribute_list_opt net_type
1678 primitive_type_opt signed_opt
1679 drive_strength net_decl_assigns ';'
1681 { ivl_variable_type_t dtype = $3;
1682 if (dtype == IVL_VT_NO_TYPE)
1683 dtype = IVL_VT_LOGIC;
1684 pform_makewire(@2, 0, $4, 0, $5, $6, $2, dtype);
1685 if ($1) {
1686 yyerror(@2, "sorry: Attributes not supported "
1687 "on net declaration assignments.");
1688 delete $1;
1692 | K_trireg charge_strength_opt range_opt delay3_opt list_of_identifiers ';'
1693 { yyerror(@1, "sorry: trireg nets not supported.");
1694 delete $3;
1695 delete $4;
1698 | port_type signed_opt range_opt delay3_opt list_of_identifiers ';'
1699 { pform_set_port_type(@1, $5, $3, $2, $1);
1702 /* The next two rules handle Verilog 2001 statements of the form:
1703 input wire signed [h:l] <list>;
1704 This creates the wire and sets the port type all at once. */
1706 | port_type net_type signed_opt range_opt list_of_identifiers ';'
1707 { pform_makewire(@1, $4, $3, $5, $2, $1, IVL_VT_NO_TYPE, 0);
1710 | K_output var_type signed_opt range_opt list_of_identifiers ';'
1711 { pform_makewire(@1, $4, $3, $5, $2,
1712 NetNet::POUTPUT,
1713 IVL_VT_NO_TYPE, 0);
1716 /* var_type declaration (reg variables) cannot be input or output,
1717 because the port declaration implies an external driver, which
1718 cannot be attached to a reg. These rules catch that error early. */
1720 | K_input var_type signed_opt range_opt list_of_identifiers ';'
1721 { pform_makewire(@1, $4, $3, $5, $2, NetNet::PINPUT,
1722 IVL_VT_NO_TYPE, 0);
1723 yyerror(@2, "error: reg variables cannot be inputs.");
1726 | K_inout var_type signed_opt range_opt list_of_identifiers ';'
1727 { pform_makewire(@1, $4, $3, $5, $2, NetNet::PINOUT,
1728 IVL_VT_NO_TYPE, 0);
1729 yyerror(@2, "error: reg variables cannot be inouts.");
1732 | port_type signed_opt range_opt delay3_opt error ';'
1733 { yyerror(@1, "error: Invalid variable list"
1734 " in port declaration.");
1735 if ($3) delete $3;
1736 if ($4) delete $4;
1737 yyerrok;
1740 /* block_item_decl rule is shared with task blocks and named
1741 begin/end. */
1743 | block_item_decl
1745 /* */
1747 | K_defparam defparam_assign_list ';'
1748 | K_event list_of_identifiers ';'
1749 { pform_make_events($2, @1.text, @1.first_line);
1752 /* Most gate types have an optional drive strength and optional
1753 three-value delay. These rules handle the different cases. */
1755 | attribute_list_opt gatetype gate_instance_list ';'
1756 { pform_makegates($2, str_strength, 0, $3, $1);
1759 | attribute_list_opt gatetype delay3 gate_instance_list ';'
1760 { pform_makegates($2, str_strength, $3, $4, $1);
1763 | attribute_list_opt gatetype drive_strength gate_instance_list ';'
1764 { pform_makegates($2, $3, 0, $4, $1);
1767 | attribute_list_opt gatetype drive_strength delay3 gate_instance_list ';'
1768 { pform_makegates($2, $3, $4, $5, $1);
1771 /* Pullup and pulldown devices cannot have delays, and their
1772 strengths are limited. */
1774 | K_pullup gate_instance_list ';'
1775 { pform_makegates(PGBuiltin::PULLUP, pull_strength, 0,
1776 $2, 0);
1778 | K_pulldown gate_instance_list ';'
1779 { pform_makegates(PGBuiltin::PULLDOWN, pull_strength,
1780 0, $2, 0);
1783 | K_pullup '(' dr_strength1 ')' gate_instance_list ';'
1784 { pform_makegates(PGBuiltin::PULLUP, $3, 0, $5, 0);
1787 | K_pulldown '(' dr_strength0 ')' gate_instance_list ';'
1788 { pform_makegates(PGBuiltin::PULLDOWN, $3, 0, $5, 0);
1791 /* This rule handles instantiations of modules and user defined
1792 primitives. These devices to not have delay lists or strengths,
1793 but then can have parameter lists. */
1795 | attribute_list_opt
1796 IDENTIFIER parameter_value_opt gate_instance_list ';'
1797 { perm_string tmp1 = lex_strings.make($2);
1798 pform_make_modgates(tmp1, $3, $4);
1799 delete $2;
1800 if ($1) delete $1;
1803 | attribute_list_opt
1804 IDENTIFIER parameter_value_opt error ';'
1805 { yyerror(@2, "error: Invalid module instantiation");
1806 if ($1) delete $1;
1809 /* Continuous assignment can have an optional drive strength, then
1810 an optional delay3 that applies to all the assignments in the
1811 cont_assign_list. */
1813 | K_assign drive_strength_opt delay3_opt cont_assign_list ';'
1814 { pform_make_pgassign_list($4, $3, $2, @1.text, @1.first_line); }
1816 /* Always and initial items are behavioral processes. */
1818 | attribute_list_opt K_always statement
1819 { PProcess*tmp = pform_make_behavior(PProcess::PR_ALWAYS,
1820 $3, $1);
1821 tmp->set_file(@2.text);
1822 tmp->set_lineno(@2.first_line);
1824 | attribute_list_opt K_initial statement
1825 { PProcess*tmp = pform_make_behavior(PProcess::PR_INITIAL,
1826 $3, $1);
1827 tmp->set_file(@2.text);
1828 tmp->set_lineno(@2.first_line);
1831 /* The task declaration rule matches the task declaration
1832 header, then pushes the function scope. This causes the
1833 definitions in the task_body to take on the scope of the task
1834 instead of the module. Note that these runs accept for the task
1835 body statement_or_null, although the standard does not allow null
1836 statements in the task body. But we continue to accept it as an
1837 extension. */
1839 | K_task IDENTIFIER ';'
1840 { pform_push_scope($2); }
1841 task_item_list_opt
1842 statement_or_null
1843 K_endtask
1844 { PTask*tmp = new PTask;
1845 perm_string tmp2 = lex_strings.make($2);
1846 tmp->set_file(@1.text);
1847 tmp->set_lineno(@1.first_line);
1848 tmp->set_ports($5);
1849 tmp->set_statement($6);
1850 pform_set_task(tmp2, tmp);
1851 pform_pop_scope();
1852 delete $2;
1855 | K_task IDENTIFIER
1856 { pform_push_scope($2); }
1857 '(' task_port_decl_list ')' ';'
1858 task_item_list_opt
1859 statement_or_null
1860 K_endtask
1861 { PTask*tmp = new PTask;
1862 perm_string tmp2 = lex_strings.make($2);
1863 tmp->set_file(@1.text);
1864 tmp->set_lineno(@1.first_line);
1865 tmp->set_ports($5);
1866 tmp->set_statement($9);
1867 pform_set_task(tmp2, tmp);
1868 pform_pop_scope();
1869 delete $2;
1872 /* The function declaration rule matches the function declaration
1873 header, then pushes the function scope. This causes the
1874 definitions in the func_body to take on the scope of the function
1875 instead of the module. */
1877 | K_function function_range_or_type_opt IDENTIFIER ';'
1878 { pform_push_scope($3); }
1879 function_item_list statement
1880 K_endfunction
1881 { perm_string name = lex_strings.make($3);
1882 PFunction *tmp = new PFunction(name);
1883 tmp->set_file(@1.text);
1884 tmp->set_lineno(@1.first_line);
1885 tmp->set_ports($6);
1886 tmp->set_statement($7);
1887 tmp->set_return($2);
1888 pform_set_function(name, tmp);
1889 pform_pop_scope();
1890 delete $3;
1893 /* A generate region can contain further module items. Actually, it
1894 is supposed to be limited to certain kinds of module items, but
1895 the semantic tests will check that for us. */
1897 | K_generate module_item_list_opt K_endgenerate
1899 | K_genvar list_of_identifiers ';'
1900 { pform_genvars($2); }
1902 | K_for '(' IDENTIFIER '=' expression ';'
1903 expression ';'
1904 IDENTIFIER '=' expression ')'
1905 { pform_start_generate_for(@1, $3, $5, $7, $9, $11); }
1906 generate_block
1907 { pform_endgenerate(); }
1909 | generate_if
1910 generate_block_opt
1911 K_else
1912 { pform_start_generate_else(@1); }
1913 generate_block
1914 { pform_endgenerate(); }
1916 | generate_if
1917 generate_block_opt %prec less_than_K_else
1918 { pform_endgenerate(); }
1920 /* specify blocks are parsed but ignored. */
1922 | K_specify K_endspecify
1923 { /* empty lists are legal syntax. */ }
1925 | K_specify specify_item_list K_endspecify
1929 | K_specify error K_endspecify
1930 { yyerror(@1, "error: syntax error in specify block");
1931 yyerrok;
1934 /* These rules match various errors that the user can type into
1935 module items. These rules try to catch them at a point where a
1936 reasonable error message can be produced. */
1938 | error ';'
1939 { yyerror(@2, "error: invalid module item.");
1940 yyerrok;
1943 | K_assign error '=' expression ';'
1944 { yyerror(@1, "error: syntax error in left side "
1945 "of continuous assignment.");
1946 yyerrok;
1949 | K_assign error ';'
1950 { yyerror(@1, "error: syntax error in "
1951 "continuous assignment");
1952 yyerrok;
1955 | K_function error K_endfunction
1956 { yyerror(@1, "error: I give up on this "
1957 "function definition.");
1958 yyerrok;
1961 /* These rules are for the Icarus Verilog specific $attribute
1962 extensions. Then catch the parameters of the $attribute keyword. */
1964 | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';'
1965 { perm_string tmp3 = lex_strings.make($3);
1966 perm_string tmp5 = lex_strings.make($5);
1967 pform_set_attrib(tmp3, tmp5, $7);
1968 delete $3;
1969 delete $5;
1971 | KK_attribute '(' error ')' ';'
1972 { yyerror(@1, "error: Malformed $attribute parameter list."); }
1975 generate_if : K_if '(' expression ')' { pform_start_generate_if(@1, $3); }
1977 module_item_list
1978 : module_item_list module_item
1979 | module_item
1982 module_item_list_opt
1983 : module_item_list
1987 /* A generate block is the thing within a generate scheme. It may be
1988 a single module item, an anonymous block of module items, or a
1989 named module item. In all cases, the meat is in the module items
1990 inside, and the processing is done by the module_item rules. We
1991 only need to take note here of the scope name, if any. */
1993 generate_block
1994 : module_item
1995 | K_begin module_item_list_opt K_end
1996 | K_begin ':' IDENTIFIER module_item_list_opt K_end
1997 { pform_generate_block_name($3); }
2000 generate_block_opt : generate_block | ';' ;
2003 /* A net declaration assignment allows the programmer to combine the
2004 net declaration and the continuous assignment into a single
2005 statement.
2007 Note that the continuous assignment statement is generated as a
2008 side effect, and all I pass up is the name of the l-value. */
2010 net_decl_assign
2011 : IDENTIFIER '=' expression
2012 { net_decl_assign_t*tmp = new net_decl_assign_t;
2013 tmp->next = tmp;
2014 tmp->name = $1;
2015 tmp->expr = $3;
2016 $$ = tmp;
2020 net_decl_assigns
2021 : net_decl_assigns ',' net_decl_assign
2022 { net_decl_assign_t*tmp = $1;
2023 $3->next = tmp->next;
2024 tmp->next = $3;
2025 $$ = tmp;
2027 | net_decl_assign
2028 { $$ = $1;
2032 primitive_type
2033 : K_logic { $$ = IVL_VT_LOGIC; }
2034 | K_bool { $$ = IVL_VT_BOOL; }
2035 | K_real { $$ = IVL_VT_REAL; }
2038 primitive_type_opt : primitive_type { $$ = $1; } | { $$ = IVL_VT_NO_TYPE; } ;
2040 net_type
2041 : K_wire { $$ = NetNet::WIRE; }
2042 | K_tri { $$ = NetNet::TRI; }
2043 | K_tri1 { $$ = NetNet::TRI1; }
2044 | K_supply0 { $$ = NetNet::SUPPLY0; }
2045 | K_wand { $$ = NetNet::WAND; }
2046 | K_triand { $$ = NetNet::TRIAND; }
2047 | K_tri0 { $$ = NetNet::TRI0; }
2048 | K_supply1 { $$ = NetNet::SUPPLY1; }
2049 | K_wor { $$ = NetNet::WOR; }
2050 | K_trior { $$ = NetNet::TRIOR; }
2051 | K_wone { $$ = NetNet::WONE; }
2054 var_type
2055 : K_reg { $$ = NetNet::REG; }
2058 /* In this rule we have matched the "parameter" keyword. The rule
2059 generates a type (optional) and a list of assignments. */
2061 parameter_assign_decl
2062 : parameter_assign_list
2063 | range { active_range = $1; active_signed = false; }
2064 parameter_assign_list
2065 { active_range = 0;
2066 active_signed = false;
2068 | K_signed range { active_range = $2; active_signed = true; }
2069 parameter_assign_list
2070 { active_range = 0;
2071 active_signed = false;
2073 | K_integer { active_range = 0; active_signed = true; }
2074 parameter_assign_list
2075 { active_range = 0;
2076 active_signed = false;
2080 parameter_assign_list
2081 : parameter_assign
2082 | parameter_assign_list ',' parameter_assign
2085 parameter_assign
2086 : IDENTIFIER '=' expression
2087 { PExpr*tmp = $3;
2088 if (!pform_expression_is_constant(tmp)) {
2089 yyerror(@3, "error: parameter value "
2090 "must be a constant expression.");
2091 delete tmp;
2092 tmp = 0;
2093 } else {
2094 pform_set_parameter(lex_strings.make($1),
2095 active_signed,
2096 active_range, tmp);
2098 delete $1;
2102 /* Localparam assignments and assignment lists are broken into
2103 separate BNF so that I can call slightly different parameter
2104 handling code. They parse the same as parameters, they just
2105 behave differently when someone tries to override them. */
2107 localparam_assign
2108 : IDENTIFIER '=' expression
2109 { PExpr*tmp = $3;
2110 if (!pform_expression_is_constant(tmp)) {
2111 yyerror(@3, "error: parameter value "
2112 "must be constant.");
2113 delete tmp;
2114 tmp = 0;
2115 } else {
2116 pform_set_localparam(lex_strings.make($1),
2117 active_signed,
2118 active_range, tmp);
2120 delete $1;
2124 localparam_assign_decl
2125 : localparam_assign_list
2126 | range { active_range = $1; active_signed = false; }
2127 localparam_assign_list
2128 { active_range = 0;
2129 active_signed = false;
2131 | K_signed range { active_range = $2; active_signed = true; }
2132 localparam_assign_list
2133 { active_range = 0;
2134 active_signed = false;
2138 localparam_assign_list
2139 : localparam_assign
2140 | localparam_assign_list ',' localparam_assign
2145 /* The parameters of a module instance can be overridden by writing
2146 a list of expressions in a syntax much like a delay list. (The
2147 difference being the list can have any length.) The pform that
2148 attaches the expression list to the module checks that the
2149 expressions are constant.
2151 Although the BNF in IEEE1364-1995 implies that parameter value
2152 lists must be in parentheses, in practice most compilers will
2153 accept simple expressions outside of parentheses if there is only
2154 one value, so I'll accept simple numbers here.
2156 The parameter value by name syntax is OVI enhancement BTF-B06 as
2157 approved by WG1364 on 6/28/1998. */
2159 parameter_value_opt
2160 : '#' '(' expression_list_with_nuls ')'
2161 { struct parmvalue_t*tmp = new struct parmvalue_t;
2162 tmp->by_order = $3;
2163 tmp->by_name = 0;
2164 $$ = tmp;
2166 | '#' '(' parameter_value_byname_list ')'
2167 { struct parmvalue_t*tmp = new struct parmvalue_t;
2168 tmp->by_order = 0;
2169 tmp->by_name = $3;
2170 $$ = tmp;
2172 | '#' DEC_NUMBER
2173 { assert($2);
2174 PENumber*tmp = new PENumber($2);
2175 tmp->set_file(@1.text);
2176 tmp->set_lineno(@1.first_line);
2178 struct parmvalue_t*lst = new struct parmvalue_t;
2179 lst->by_order = new svector<PExpr*>(1);
2180 (*lst->by_order)[0] = tmp;
2181 lst->by_name = 0;
2182 $$ = lst;
2184 | '#' error
2185 { yyerror(@1, "error: syntax error in parameter value "
2186 "assignment list.");
2187 $$ = 0;
2190 { $$ = 0; }
2193 parameter_value_byname
2194 : '.' IDENTIFIER '(' expression ')'
2195 { named_pexpr_t*tmp = new named_pexpr_t;
2196 tmp->name = lex_strings.make($2);
2197 tmp->parm = $4;
2198 free($2);
2199 $$ = tmp;
2201 | '.' IDENTIFIER '(' ')'
2202 { named_pexpr_t*tmp = new named_pexpr_t;
2203 tmp->name = lex_strings.make($2);
2204 tmp->parm = 0;
2205 free($2);
2206 $$ = tmp;
2210 parameter_value_byname_list
2211 : parameter_value_byname
2212 { svector<named_pexpr_t*>*tmp = new svector<named_pexpr_t*>(1);
2213 (*tmp)[0] = $1;
2214 $$ = tmp;
2216 | parameter_value_byname_list ',' parameter_value_byname
2217 { svector<named_pexpr_t*>*tmp =
2218 new svector<named_pexpr_t*>(*$1,$3);
2219 delete $1;
2220 $$ = tmp;
2225 /* The port (of a module) is a fairly complex item. Each port is
2226 handled as a Module::port_t object. A simple port reference has a
2227 name and a PExpr object, but more complex constructs are possible
2228 where the name can be attached to a list of PWire objects.
2230 The port_reference returns a Module::port_t, and so does the
2231 port_reference_list. The port_reference_list may have built up a
2232 list of PWires in the port_t object, but it is still a single
2233 Module::port_t object.
2235 The port rule below takes the built up Module::port_t object and
2236 tweaks its name as needed. */
2238 port
2239 : port_reference
2240 { $$ = $1; }
2242 /* This syntax attaches an external name to the port reference so
2243 that the caller can bind by name to non-trivial port
2244 references. The port_t object gets its PWire from the
2245 port_reference, but its name from the IDENTIFIER. */
2247 | '.' IDENTIFIER '(' port_reference ')'
2248 { Module::port_t*tmp = $4;
2249 tmp->name = lex_strings.make($2);
2250 delete $2;
2251 $$ = tmp;
2254 /* A port can also be a concatenation of port references. In this
2255 case the port does not have a name available to the outside, only
2256 positional parameter passing is possible here. */
2258 | '{' port_reference_list '}'
2259 { Module::port_t*tmp = $2;
2260 tmp->name = perm_string();
2261 $$ = tmp;
2264 /* This attaches a name to a port reference concatenation list so
2265 that parameter passing be name is possible. */
2267 | '.' IDENTIFIER '(' '{' port_reference_list '}' ')'
2268 { Module::port_t*tmp = $5;
2269 tmp->name = lex_strings.make($2);
2270 delete $2;
2271 $$ = tmp;
2275 port_opt
2276 : port { $$ = $1; }
2277 | { $$ = 0; }
2281 /* A port reference is an internal (to the module) name of the port,
2282 possibly with a part of bit select to attach it to specific bits
2283 of a signal fully declared inside the module.
2285 The parser creates a PEIdent for every port reference, even if the
2286 signal is bound to different ports. The elaboration figures out
2287 the mess that this creates. The port_reference (and the
2288 port_reference_list below) puts the port reference PEIdent into the
2289 port_t object to pass it up to the module declaration code. */
2291 port_reference
2293 : IDENTIFIER
2294 { Module::port_t*ptmp;
2295 ptmp = pform_module_port_reference($1, @1.text, @1.first_line);
2296 delete $1;
2297 $$ = ptmp;
2300 | IDENTIFIER '[' expression ':' expression ']'
2301 { if (!pform_expression_is_constant($3)) {
2302 yyerror(@3, "error: msb expression of "
2303 "port part select must be constant.");
2305 if (!pform_expression_is_constant($5)) {
2306 yyerror(@5, "error: lsb expression of "
2307 "port part select must be constant.");
2309 index_component_t itmp;
2310 itmp.sel = index_component_t::SEL_PART;
2311 itmp.msb = $3;
2312 itmp.lsb = $5;
2314 name_component_t ntmp (lex_strings.make($1));
2315 ntmp.index.push_back(itmp);
2317 pform_name_t pname;
2318 pname.push_back(ntmp);
2320 PEIdent*wtmp = new PEIdent(pname);
2321 wtmp->set_file(@1.text);
2322 wtmp->set_lineno(@1.first_line);
2324 Module::port_t*ptmp = new Module::port_t;
2325 ptmp->name = perm_string();
2326 ptmp->expr = svector<PEIdent*>(1);
2327 ptmp->expr[0] = wtmp;
2329 delete $1;
2330 $$ = ptmp;
2333 | IDENTIFIER '[' expression ']'
2334 { if (!pform_expression_is_constant($3)) {
2335 yyerror(@3, "error: port bit select "
2336 "must be constant.");
2338 index_component_t itmp;
2339 itmp.sel = index_component_t::SEL_BIT;
2340 itmp.msb = $3;
2341 itmp.lsb = 0;
2343 name_component_t ntmp (lex_strings.make($1));
2344 ntmp.index.push_back(itmp);
2346 pform_name_t pname;
2347 pname.push_back(ntmp);
2349 PEIdent*tmp = new PEIdent(pname);
2350 tmp->set_file(@1.text);
2351 tmp->set_lineno(@1.first_line);
2353 Module::port_t*ptmp = new Module::port_t;
2354 ptmp->name = perm_string();
2355 ptmp->expr = svector<PEIdent*>(1);
2356 ptmp->expr[0] = tmp;
2357 delete $1;
2358 $$ = ptmp;
2361 | IDENTIFIER '[' error ']'
2362 { yyerror(@1, "error: invalid port bit select");
2363 Module::port_t*ptmp = new Module::port_t;
2364 PEIdent*wtmp = new PEIdent(lex_strings.make($1));
2365 wtmp->set_file(@1.text);
2366 wtmp->set_lineno(@1.first_line);
2367 ptmp->name = lex_strings.make($1);
2368 ptmp->expr = svector<PEIdent*>(1);
2369 ptmp->expr[0] = wtmp;
2370 delete $1;
2371 $$ = ptmp;
2376 port_reference_list
2377 : port_reference
2378 { $$ = $1; }
2379 | port_reference_list ',' port_reference
2380 { Module::port_t*tmp = $1;
2381 tmp->expr = svector<PEIdent*>(tmp->expr, $3->expr);
2382 delete $3;
2383 $$ = tmp;
2387 /* The port_name rule is used with a module is being *instantiated*,
2388 and not when it is being declared. See the port rule if you are
2389 looking for the ports of a module declaration. */
2391 port_name
2392 : '.' IDENTIFIER '(' expression ')'
2393 { named_pexpr_t*tmp = new named_pexpr_t;
2394 tmp->name = lex_strings.make($2);
2395 tmp->parm = $4;
2396 delete $2;
2397 $$ = tmp;
2399 | '.' IDENTIFIER '(' error ')'
2400 { yyerror(@4, "error: invalid port connection expression.");
2401 named_pexpr_t*tmp = new named_pexpr_t;
2402 tmp->name = lex_strings.make($2);
2403 tmp->parm = 0;
2404 delete $2;
2405 $$ = tmp;
2407 | '.' IDENTIFIER '(' ')'
2408 { named_pexpr_t*tmp = new named_pexpr_t;
2409 tmp->name = lex_strings.make($2);
2410 tmp->parm = 0;
2411 delete $2;
2412 $$ = tmp;
2416 port_name_list
2417 : port_name_list ',' port_name
2418 { svector<named_pexpr_t*>*tmp;
2419 tmp = new svector<named_pexpr_t*>(*$1, $3);
2420 delete $1;
2421 $$ = tmp;
2423 | port_name
2424 { svector<named_pexpr_t*>*tmp = new svector<named_pexpr_t*>(1);
2425 (*tmp)[0] = $1;
2426 $$ = tmp;
2430 port_type
2431 : K_input { $$ = NetNet::PINPUT; }
2432 | K_output { $$ = NetNet::POUTPUT; }
2433 | K_inout { $$ = NetNet::PINOUT; }
2436 range
2437 : '[' expression ':' expression ']'
2438 { svector<PExpr*>*tmp = new svector<PExpr*> (2);
2439 if (!pform_expression_is_constant($2))
2440 yyerror(@2, "error: msb of range must be constant.");
2442 (*tmp)[0] = $2;
2444 if (!pform_expression_is_constant($4))
2445 yyerror(@4, "error: lsb of range must be constant.");
2447 (*tmp)[1] = $4;
2449 $$ = tmp;
2453 range_opt
2454 : range
2455 | { $$ = 0; }
2458 /* This is used to express the return type of a function. */
2459 function_range_or_type_opt
2460 : range { $$.range = $1; $$.type = PTF_REG; }
2461 | K_signed range { $$.range = $2; $$.type = PTF_REG_S; }
2462 | K_integer { $$.range = 0; $$.type = PTF_INTEGER; }
2463 | K_real { $$.range = 0; $$.type = PTF_REAL; }
2464 | K_realtime { $$.range = 0; $$.type = PTF_REALTIME; }
2465 | K_time { $$.range = 0; $$.type = PTF_TIME; }
2466 | { $$.range = 0; $$.type = PTF_REG; }
2469 /* The register_variable rule is matched only when I am parsing
2470 variables in a "reg" definition. I therefore know that I am
2471 creating registers and I do not need to let the containing rule
2472 handle it. The register variable list simply packs them together
2473 so that bit ranges can be assigned. */
2474 register_variable
2475 : IDENTIFIER
2476 { pform_makewire(@1, $1, NetNet::REG,
2477 NetNet::NOT_A_PORT,
2478 IVL_VT_NO_TYPE, 0);
2479 $$ = $1;
2481 | IDENTIFIER '=' expression
2482 { pform_makewire(@1, $1, NetNet::REG,
2483 NetNet::NOT_A_PORT,
2484 IVL_VT_NO_TYPE, 0);
2485 if (! pform_expression_is_constant($3))
2486 yyerror(@3, "error: register declaration assignment"
2487 " value must be a constant expression.");
2488 pform_make_reginit(@1, $1, $3);
2489 $$ = $1;
2491 | IDENTIFIER '[' expression ':' expression ']'
2492 { pform_makewire(@1, $1, NetNet::REG,
2493 NetNet::NOT_A_PORT,
2494 IVL_VT_NO_TYPE, 0);
2495 if (! pform_expression_is_constant($3))
2496 yyerror(@3, "error: msb of register range must be constant.");
2497 if (! pform_expression_is_constant($5))
2498 yyerror(@3, "error: lsb of register range must be constant.");
2499 pform_set_reg_idx($1, $3, $5);
2500 $$ = $1;
2504 register_variable_list
2505 : register_variable
2506 { list<perm_string>*tmp = new list<perm_string>;
2507 tmp->push_back(lex_strings.make($1));
2508 $$ = tmp;
2509 delete[]$1;
2511 | register_variable_list ',' register_variable
2512 { list<perm_string>*tmp = $1;
2513 tmp->push_back(lex_strings.make($3));
2514 $$ = tmp;
2515 delete[]$3;
2519 net_variable
2520 : IDENTIFIER
2521 { pform_makewire(@1, $1, NetNet::IMPLICIT,
2522 NetNet::NOT_A_PORT,
2523 IVL_VT_NO_TYPE, 0);
2524 $$ = $1;
2526 | IDENTIFIER '[' expression ':' expression ']'
2527 { pform_makewire(@1, $1, NetNet::IMPLICIT,
2528 NetNet::NOT_A_PORT,
2529 IVL_VT_NO_TYPE, 0);
2530 if (! pform_expression_is_constant($3))
2531 yyerror(@3, "error: msb of net range must be constant.");
2532 if (! pform_expression_is_constant($5))
2533 yyerror(@3, "error: lsb of net range must be constant.");
2534 pform_set_reg_idx($1, $3, $5);
2535 $$ = $1;
2538 net_variable_list
2539 : net_variable
2540 { list<perm_string>*tmp = new list<perm_string>;
2541 tmp->push_back(lex_strings.make($1));
2542 $$ = tmp;
2543 delete[]$1;
2545 | net_variable_list ',' net_variable
2546 { list<perm_string>*tmp = $1;
2547 tmp->push_back(lex_strings.make($3));
2548 $$ = tmp;
2549 delete[]$3;
2553 specify_item
2554 : K_specparam specparam_list ';'
2555 | specify_simple_path_decl ';'
2556 { pform_module_specify_path($1);
2558 | specify_edge_path_decl ';'
2559 { pform_module_specify_path($1);
2561 | K_if '(' expression ')' specify_simple_path_decl ';'
2562 { PSpecPath*tmp = $5;
2563 if (tmp) {
2564 tmp->conditional = true;
2565 tmp->condition = $3;
2567 pform_module_specify_path(tmp);
2569 | K_if '(' expression ')' specify_edge_path_decl ';'
2570 { PSpecPath*tmp = $5;
2571 if (tmp) {
2572 tmp->conditional = true;
2573 tmp->condition = $3;
2575 pform_module_specify_path(tmp);
2577 | K_ifnone specify_simple_path_decl ';'
2578 { PSpecPath*tmp = $2;
2579 if (tmp) {
2580 tmp->conditional = true;
2581 tmp->condition = 0;
2583 pform_module_specify_path(tmp);
2585 | K_Shold '(' spec_reference_event ',' spec_reference_event
2586 ',' delay_value spec_notifier_opt ')' ';'
2587 { delete $7;
2589 | K_Speriod '(' spec_reference_event ',' delay_value
2590 spec_notifier_opt ')' ';'
2591 { delete $5;
2593 | K_Srecovery '(' spec_reference_event ',' spec_reference_event
2594 ',' delay_value spec_notifier_opt ')' ';'
2595 { delete $7;
2597 | K_Ssetup '(' spec_reference_event ',' spec_reference_event
2598 ',' delay_value spec_notifier_opt ')' ';'
2599 { delete $7;
2601 | K_Ssetuphold '(' spec_reference_event ',' spec_reference_event
2602 ',' delay_value ',' delay_value spec_notifier_opt ')' ';'
2603 { delete $7;
2604 delete $9;
2606 | K_Srecrem '(' spec_reference_event ',' spec_reference_event
2607 ',' delay_value ',' delay_value spec_notifier_opt ')' ';'
2608 { delete $7;
2609 delete $9;
2611 | K_Swidth '(' spec_reference_event ',' delay_value ',' expression
2612 spec_notifier_opt ')' ';'
2613 { delete $5;
2614 delete $7;
2616 | K_Swidth '(' spec_reference_event ',' delay_value ')' ';'
2617 { delete $5;
2621 specify_item_list
2622 : specify_item
2623 | specify_item_list specify_item
2626 specify_edge_path_decl
2627 : specify_edge_path '=' '(' delay_value_list ')'
2628 { $$ = pform_assign_path_delay($1, $4); }
2629 | specify_edge_path '=' delay_value_simple
2630 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
2631 (*tmp)[0] = $3;
2632 $$ = pform_assign_path_delay($1, tmp);
2636 edge_operator : K_posedge { $$ = true; } | K_negedge { $$ = false; } ;
2638 specify_edge_path
2639 : '(' specify_path_identifiers spec_polarity
2640 K_EG '(' specify_path_identifiers polarity_operator expression ')' ')'
2641 { int edge_flag = 0;
2642 $$ = pform_make_specify_edge_path(@1, edge_flag, $2, $3, false, $6, $8); }
2643 | '(' edge_operator specify_path_identifiers spec_polarity
2644 K_EG '(' specify_path_identifiers polarity_operator expression ')' ')'
2645 { int edge_flag = $2? 1 : -1;
2646 $$ = pform_make_specify_edge_path(@1, edge_flag, $3, $4, false, $7, $9);}
2647 | '(' specify_path_identifiers spec_polarity
2648 K_SG '(' specify_path_identifiers polarity_operator expression ')' ')'
2649 { int edge_flag = 0;
2650 $$ = pform_make_specify_edge_path(@1, edge_flag, $2, $3, true, $6, $8); }
2651 | '(' edge_operator specify_path_identifiers spec_polarity
2652 K_SG '(' specify_path_identifiers polarity_operator expression ')' ')'
2653 { int edge_flag = $2? 1 : -1;
2654 $$ = pform_make_specify_edge_path(@1, edge_flag, $3, $4, true, $7, $9); }
2657 polarity_operator
2658 : K_PO_POS
2659 | K_PO_NEG
2660 | ':'
2663 specify_simple_path_decl
2664 : specify_simple_path '=' '(' delay_value_list ')'
2665 { $$ = pform_assign_path_delay($1, $4); }
2666 | specify_simple_path '=' delay_value_simple
2667 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
2668 (*tmp)[0] = $3;
2669 $$ = pform_assign_path_delay($1, tmp);
2671 | specify_simple_path '=' '(' error ')'
2672 { yyerror(@2, "Syntax error in delay value list.");
2673 yyerrok;
2674 $$ = 0;
2678 specify_simple_path
2679 : '(' specify_path_identifiers spec_polarity
2680 K_EG specify_path_identifiers ')'
2681 { $$ = pform_make_specify_path(@1, $2, $3, false, $5); }
2682 | '(' specify_path_identifiers spec_polarity
2683 K_SG specify_path_identifiers ')'
2684 { $$ = pform_make_specify_path(@1, $2, $3, true, $5); }
2685 | '(' error ')'
2686 { yyerror(@2, "Invalid simple path");
2687 yyerrok;
2691 specify_path_identifiers
2692 : IDENTIFIER
2693 { list<perm_string>*tmp = new list<perm_string>;
2694 tmp->push_back(lex_strings.make($1));
2695 $$ = tmp;
2696 delete[]$1;
2698 | IDENTIFIER '[' expr_primary ']'
2699 { list<perm_string>*tmp = new list<perm_string>;
2700 tmp->push_back(lex_strings.make($1));
2701 $$ = tmp;
2702 delete[]$1;
2704 | specify_path_identifiers ',' IDENTIFIER
2705 { list<perm_string>*tmp = $1;
2706 tmp->push_back(lex_strings.make($3));
2707 $$ = tmp;
2708 delete[]$3;
2710 | specify_path_identifiers ',' IDENTIFIER '[' expr_primary ']'
2711 { list<perm_string>*tmp = $1;
2712 tmp->push_back(lex_strings.make($3));
2713 $$ = tmp;
2714 delete[]$3;
2718 specparam
2719 : IDENTIFIER '=' expression
2720 { PExpr*tmp = $3;
2721 pform_set_specparam(lex_strings.make($1), tmp);
2722 delete $1;
2724 | IDENTIFIER '=' expression ':' expression ':' expression
2725 { PExpr*tmp = 0;
2726 switch (min_typ_max_flag) {
2727 case MIN:
2728 tmp = $3;
2729 delete $5;
2730 delete $7;
2731 break;
2732 case TYP:
2733 delete $3;
2734 tmp = $5;
2735 delete $7;
2736 break;
2737 case MAX:
2738 delete $3;
2739 delete $5;
2740 tmp = $7;
2741 break;
2743 pform_set_specparam(lex_strings.make($1), tmp);
2744 delete $1;
2746 | PATHPULSE_IDENTIFIER '=' expression
2747 { delete $1;
2748 delete $3;
2750 | PATHPULSE_IDENTIFIER '=' '(' expression ',' expression ')'
2751 { delete $1;
2752 delete $4;
2753 delete $6;
2757 specparam_list
2758 : specparam
2759 | specparam_list ',' specparam
2762 spec_polarity
2763 : '+' { $$ = '+'; }
2764 | '-' { $$ = '-'; }
2765 | { $$ = 0; }
2768 spec_reference_event
2769 : K_posedge expression
2770 { delete $2; }
2771 | K_negedge expression
2772 { delete $2; }
2773 | K_posedge expr_primary K_TAND expression
2774 { delete $2;
2775 delete $4;
2777 | K_negedge expr_primary K_TAND expression
2778 { delete $2;
2779 delete $4;
2781 | K_edge '[' edge_descriptor_list ']' expr_primary K_TAND expression
2782 { delete $5;
2783 delete $7;
2785 | expr_primary K_TAND expression
2786 { delete $1;
2787 delete $3;
2789 | expr_primary
2790 { delete $1; }
2793 /* The edge_descriptor is detected by the lexor as the various
2794 2-letter edge sequences that are supported here. For now, we
2795 don't care what they are, because we do not yet support specify
2796 edge events. */
2797 edge_descriptor_list
2798 : edge_descriptor_list ',' K_edge_descriptor
2799 | K_edge_descriptor
2802 spec_notifier_opt
2803 : /* empty */
2805 | spec_notifier
2808 spec_notifier
2809 : ','
2811 | ',' heirarchy_identifier
2812 { delete $2; }
2813 | spec_notifier ','
2815 | spec_notifier ',' heirarchy_identifier
2816 { delete $3; }
2817 | IDENTIFIER
2818 { delete $1; }
2822 statement
2824 /* assign and deassign statements are procedural code to do
2825 structural assignments, and to turn that structural assignment
2826 off. This stronger then any other assign, but weaker then the
2827 force assignments. */
2829 : K_assign lpvalue '=' expression ';'
2830 { PCAssign*tmp = new PCAssign($2, $4);
2831 tmp->set_file(@1.text);
2832 tmp->set_lineno(@1.first_line);
2833 $$ = tmp;
2836 | K_deassign lpvalue ';'
2837 { PDeassign*tmp = new PDeassign($2);
2838 tmp->set_file(@1.text);
2839 tmp->set_lineno(@1.first_line);
2840 $$ = tmp;
2844 /* Force and release statements are similar to assignments,
2845 syntactically, but they will be elaborated differently. */
2847 | K_force lpvalue '=' expression ';'
2848 { PForce*tmp = new PForce($2, $4);
2849 tmp->set_file(@1.text);
2850 tmp->set_lineno(@1.first_line);
2851 $$ = tmp;
2853 | K_release lpvalue ';'
2854 { PRelease*tmp = new PRelease($2);
2855 tmp->set_file(@1.text);
2856 tmp->set_lineno(@1.first_line);
2857 $$ = tmp;
2860 /* begin-end blocks come in a variety of forms, including named and
2861 anonymous. The named blocks can also carry their own reg
2862 variables, which are placed in the scope created by the block
2863 name. These are handled by pushing the scope name then matching
2864 the declarations. The scope is popped at the end of the block. */
2866 | K_begin statement_list K_end
2867 { PBlock*tmp = new PBlock(PBlock::BL_SEQ, *$2);
2868 tmp->set_file(@1.text);
2869 tmp->set_lineno(@1.first_line);
2870 delete $2;
2871 $$ = tmp;
2873 | K_begin ':' IDENTIFIER
2874 { pform_push_scope($3); }
2875 block_item_decls_opt
2876 statement_list K_end
2877 { pform_pop_scope();
2878 PBlock*tmp = new PBlock(lex_strings.make($3),
2879 PBlock::BL_SEQ, *$6);
2880 tmp->set_file(@1.text);
2881 tmp->set_lineno(@1.first_line);
2882 delete $3;
2883 delete $6;
2884 $$ = tmp;
2886 | K_begin K_end
2887 { PBlock*tmp = new PBlock(PBlock::BL_SEQ);
2888 tmp->set_file(@1.text);
2889 tmp->set_lineno(@1.first_line);
2890 $$ = tmp;
2892 | K_begin ':' IDENTIFIER K_end
2893 { PBlock*tmp = new PBlock(PBlock::BL_SEQ);
2894 tmp->set_file(@1.text);
2895 tmp->set_lineno(@1.first_line);
2896 $$ = tmp;
2898 | K_begin error K_end
2899 { yyerrok; }
2901 /* fork-join blocks are very similar to begin-end blocks. In fact,
2902 from the parser's perspective there is no real difference. All we
2903 need to do is remember that this is a parallel block so that the
2904 code generator can do the right thing. */
2906 | K_fork ':' IDENTIFIER
2907 { pform_push_scope($3); }
2908 block_item_decls_opt
2909 statement_list K_join
2910 { pform_pop_scope();
2911 PBlock*tmp = new PBlock(lex_strings.make($3),
2912 PBlock::BL_PAR, *$6);
2913 tmp->set_file(@1.text);
2914 tmp->set_lineno(@1.first_line);
2915 delete $3;
2916 delete $6;
2917 $$ = tmp;
2919 | K_fork K_join
2920 { PBlock*tmp = new PBlock(PBlock::BL_PAR);
2921 tmp->set_file(@1.text);
2922 tmp->set_lineno(@1.first_line);
2923 $$ = tmp;
2925 | K_fork ':' IDENTIFIER K_join
2926 { PBlock*tmp = new PBlock(PBlock::BL_PAR);
2927 tmp->set_file(@1.text);
2928 tmp->set_lineno(@1.first_line);
2929 delete $3;
2930 $$ = tmp;
2933 | K_disable heirarchy_identifier ';'
2934 { PDisable*tmp = new PDisable(*$2);
2935 tmp->set_file(@1.text);
2936 tmp->set_lineno(@1.first_line);
2937 delete $2;
2938 $$ = tmp;
2940 | K_TRIGGER heirarchy_identifier ';'
2941 { PTrigger*tmp = new PTrigger(*$2);
2942 tmp->set_file(@2.text);
2943 tmp->set_lineno(@2.first_line);
2944 delete $2;
2945 $$ = tmp;
2947 | K_forever statement
2948 { PForever*tmp = new PForever($2);
2949 tmp->set_file(@1.text);
2950 tmp->set_lineno(@1.first_line);
2951 $$ = tmp;
2953 | K_fork statement_list K_join
2954 { PBlock*tmp = new PBlock(PBlock::BL_PAR, *$2);
2955 tmp->set_file(@1.text);
2956 tmp->set_lineno(@1.first_line);
2957 delete $2;
2958 $$ = tmp;
2960 | K_repeat '(' expression ')' statement
2961 { PRepeat*tmp = new PRepeat($3, $5);
2962 tmp->set_file(@1.text);
2963 tmp->set_lineno(@1.first_line);
2964 $$ = tmp;
2966 | K_case '(' expression ')' case_items K_endcase
2967 { PCase*tmp = new PCase(NetCase::EQ, $3, $5);
2968 tmp->set_file(@1.text);
2969 tmp->set_lineno(@1.first_line);
2970 $$ = tmp;
2972 | K_casex '(' expression ')' case_items K_endcase
2973 { PCase*tmp = new PCase(NetCase::EQX, $3, $5);
2974 tmp->set_file(@1.text);
2975 tmp->set_lineno(@1.first_line);
2976 $$ = tmp;
2978 | K_casez '(' expression ')' case_items K_endcase
2979 { PCase*tmp = new PCase(NetCase::EQZ, $3, $5);
2980 tmp->set_file(@1.text);
2981 tmp->set_lineno(@1.first_line);
2982 $$ = tmp;
2984 | K_case '(' expression ')' error K_endcase
2985 { yyerrok; }
2986 | K_casex '(' expression ')' error K_endcase
2987 { yyerrok; }
2988 | K_casez '(' expression ')' error K_endcase
2989 { yyerrok; }
2990 | K_if '(' expression ')' statement_or_null %prec less_than_K_else
2991 { PCondit*tmp = new PCondit($3, $5, 0);
2992 tmp->set_file(@1.text);
2993 tmp->set_lineno(@1.first_line);
2994 $$ = tmp;
2996 | K_if '(' expression ')' statement_or_null K_else statement_or_null
2997 { PCondit*tmp = new PCondit($3, $5, $7);
2998 tmp->set_file(@1.text);
2999 tmp->set_lineno(@1.first_line);
3000 $$ = tmp;
3002 | K_if '(' error ')' statement_or_null %prec less_than_K_else
3003 { yyerror(@1, "error: Malformed conditional expression.");
3004 $$ = $5;
3006 | K_if '(' error ')' statement_or_null K_else statement_or_null
3007 { yyerror(@1, "error: Malformed conditional expression.");
3008 $$ = $5;
3010 | K_for '(' lpvalue '=' expression ';' expression ';'
3011 lpvalue '=' expression ')' statement
3012 { PForStatement*tmp = new PForStatement($3, $5, $7, $9, $11, $13);
3013 tmp->set_file(@1.text);
3014 tmp->set_lineno(@1.first_line);
3015 $$ = tmp;
3017 | K_for '(' lpvalue '=' expression ';' expression ';'
3018 error ')' statement
3019 { $$ = 0;
3020 yyerror(@9, "error: Error in for loop step assignment.");
3022 | K_for '(' lpvalue '=' expression ';' error ';'
3023 lpvalue '=' expression ')' statement
3024 { $$ = 0;
3025 yyerror(@7, "error: Error in for loop condition expression.");
3027 | K_for '(' error ')' statement
3028 { $$ = 0;
3029 yyerror(@3, "error: Incomprehensible for loop.");
3031 | K_while '(' expression ')' statement
3032 { PWhile*tmp = new PWhile($3, $5);
3033 $$ = tmp;
3035 | K_while '(' error ')' statement
3036 { $$ = 0;
3037 yyerror(@3, "error: Error in while loop condition.");
3039 | delay1 statement_or_null
3040 { PExpr*del = (*$1)[0];
3041 assert($1->count() == 1);
3042 PDelayStatement*tmp = new PDelayStatement(del, $2);
3043 tmp->set_file(@1.text);
3044 tmp->set_lineno(@1.first_line);
3045 $$ = tmp;
3047 | event_control statement_or_null
3048 { PEventStatement*tmp = $1;
3049 if (tmp == 0) {
3050 yyerror(@1, "error: Invalid event control.");
3051 $$ = 0;
3052 } else {
3053 tmp->set_statement($2);
3054 $$ = tmp;
3057 | '@' '*' statement_or_null
3058 { PEventStatement*tmp = new PEventStatement;
3059 tmp->set_file(@1.text);
3060 tmp->set_lineno(@1.first_line);
3061 tmp->set_statement($3);
3062 $$ = tmp;
3064 | '@' '(' '*' ')' statement_or_null
3065 { PEventStatement*tmp = new PEventStatement;
3066 tmp->set_file(@1.text);
3067 tmp->set_lineno(@1.first_line);
3068 tmp->set_statement($5);
3069 $$ = tmp;
3071 | lpvalue '=' expression ';'
3072 { PAssign*tmp = new PAssign($1,$3);
3073 tmp->set_file(@1.text);
3074 tmp->set_lineno(@1.first_line);
3075 $$ = tmp;
3077 | error '=' expression ';'
3078 { yyerror(@1, "Syntax in assignment statement l-value.");
3079 yyerrok;
3080 $$ = new PNoop;
3082 | lpvalue K_LE expression ';'
3083 { PAssignNB*tmp = new PAssignNB($1,$3);
3084 tmp->set_file(@1.text);
3085 tmp->set_lineno(@1.first_line);
3086 $$ = tmp;
3088 | error K_LE expression ';'
3089 { yyerror(@1, "Syntax in assignment statement l-value.");
3090 yyerrok;
3091 $$ = new PNoop;
3093 | lpvalue '=' delay1 expression ';'
3094 { assert($3->count() == 1);
3095 PExpr*del = (*$3)[0];
3096 PAssign*tmp = new PAssign($1,del,$4);
3097 tmp->set_file(@1.text);
3098 tmp->set_lineno(@1.first_line);
3099 $$ = tmp;
3101 | lpvalue K_LE delay1 expression ';'
3102 { assert($3->count() == 1);
3103 PExpr*del = (*$3)[0];
3104 PAssignNB*tmp = new PAssignNB($1,del,$4);
3105 tmp->set_file(@1.text);
3106 tmp->set_lineno(@1.first_line);
3107 $$ = tmp;
3109 | lpvalue '=' event_control expression ';'
3110 { PAssign*tmp = new PAssign($1,$3,$4);
3111 tmp->set_file(@1.text);
3112 tmp->set_lineno(@1.first_line);
3113 $$ = tmp;
3115 | lpvalue '=' K_repeat '(' expression ')' event_control expression ';'
3116 { PAssign*tmp = new PAssign($1,$7,$8);
3117 tmp->set_file(@1.text);
3118 tmp->set_lineno(@1.first_line);
3119 yyerror(@3, "sorry: repeat event control not supported.");
3120 delete $5;
3121 $$ = tmp;
3123 | lpvalue K_LE event_control expression ';'
3124 { yyerror(@1, "sorry: Event controls not supported here.");
3125 PAssignNB*tmp = new PAssignNB($1,$4);
3126 tmp->set_file(@1.text);
3127 tmp->set_lineno(@1.first_line);
3128 $$ = tmp;
3130 | lpvalue K_LE K_repeat '(' expression ')' event_control expression ';'
3131 { yyerror(@1, "sorry: Event controls not supported here.");
3132 delete $5;
3133 PAssignNB*tmp = new PAssignNB($1,$8);
3134 tmp->set_file(@1.text);
3135 tmp->set_lineno(@1.first_line);
3136 $$ = tmp;
3138 | K_wait '(' expression ')' statement_or_null
3139 { PEventStatement*tmp;
3140 PEEvent*etmp = new PEEvent(PEEvent::POSITIVE, $3);
3141 tmp = new PEventStatement(etmp);
3142 tmp->set_file(@1.text);
3143 tmp->set_lineno(@1.first_line);
3144 tmp->set_statement($5);
3145 $$ = tmp;
3147 | SYSTEM_IDENTIFIER '(' expression_list_with_nuls ')' ';'
3148 { PCallTask*tmp = new PCallTask(lex_strings.make($1), *$3);
3149 tmp->set_file(@1.text);
3150 tmp->set_lineno(@1.first_line);
3151 delete $1;
3152 delete $3;
3153 $$ = tmp;
3155 | SYSTEM_IDENTIFIER ';'
3156 { svector<PExpr*>pt (0);
3157 PCallTask*tmp = new PCallTask(lex_strings.make($1), pt);
3158 tmp->set_file(@1.text);
3159 tmp->set_lineno(@1.first_line);
3160 delete $1;
3161 $$ = tmp;
3163 | heirarchy_identifier '(' expression_list_proper ')' ';'
3164 { PCallTask*tmp = new PCallTask(*$1, *$3);
3165 tmp->set_file(@1.text);
3166 tmp->set_lineno(@1.first_line);
3167 delete $1;
3168 delete $3;
3169 $$ = tmp;
3172 /* NOTE: The standard doesn't really support an empty argument list
3173 between parentheses, but it seems natural, and people commonly
3174 want it. So accept it explicitly. */
3176 | heirarchy_identifier '(' ')' ';'
3177 { svector<PExpr*>pt (0);
3178 PCallTask*tmp = new PCallTask(*$1, pt);
3179 tmp->set_file(@1.text);
3180 tmp->set_lineno(@1.first_line);
3181 delete $1;
3182 $$ = tmp;
3184 | heirarchy_identifier ';'
3185 { svector<PExpr*>pt (0);
3186 PCallTask*tmp = new PCallTask(*$1, pt);
3187 tmp->set_file(@1.text);
3188 tmp->set_lineno(@1.first_line);
3189 delete $1;
3190 $$ = tmp;
3192 | error ';'
3193 { yyerror(@1, "error: malformed statement");
3194 yyerrok;
3195 $$ = new PNoop;
3199 statement_list
3200 : statement_list statement
3201 { svector<Statement*>*tmp = new svector<Statement*>(*$1, $2);
3202 delete $1;
3203 $$ = tmp;
3205 | statement
3206 { svector<Statement*>*tmp = new svector<Statement*>(1);
3207 (*tmp)[0] = $1;
3208 $$ = tmp;
3212 statement_or_null
3213 : statement
3214 | ';' { $$ = 0; }
3217 /* Task items are, other than the statement, task port items and
3218 other block items. */
3219 task_item
3220 : block_item_decl { $$ = new svector<PWire*>(0); }
3221 | task_port_item { $$ = $1; }
3224 task_port_item
3226 : K_input signed_opt range_opt list_of_identifiers ';'
3227 { svector<PWire*>*tmp
3228 = pform_make_task_ports(NetNet::PINPUT,
3229 IVL_VT_LOGIC, $2,
3230 $3, $4,
3231 @1.text, @1.first_line);
3232 $$ = tmp;
3234 | K_output signed_opt range_opt list_of_identifiers ';'
3235 { svector<PWire*>*tmp
3236 = pform_make_task_ports(NetNet::POUTPUT,
3237 IVL_VT_LOGIC, $2,
3238 $3, $4,
3239 @1.text, @1.first_line);
3240 $$ = tmp;
3242 | K_inout signed_opt range_opt list_of_identifiers ';'
3243 { svector<PWire*>*tmp
3244 = pform_make_task_ports(NetNet::PINOUT,
3245 IVL_VT_LOGIC, $2,
3246 $3, $4,
3247 @1.text, @1.first_line);
3248 $$ = tmp;
3251 /* When the port is an integer, infer a signed vector of the integer
3252 shape. Generate a range to make it work. */
3254 | K_input K_integer list_of_identifiers ';'
3255 { svector<PExpr*>*range_stub
3256 = new svector<PExpr*>(2);
3257 PExpr*re;
3258 re = new PENumber(new verinum(integer_width-1,
3259 integer_width));
3260 (*range_stub)[0] = re;
3261 re = new PENumber(new verinum((uint64_t)0, integer_width));
3262 (*range_stub)[1] = re;
3263 svector<PWire*>*tmp
3264 = pform_make_task_ports(NetNet::PINPUT,
3265 IVL_VT_LOGIC, true,
3266 range_stub, $3,
3267 @1.text, @1.first_line);
3268 $$ = tmp;
3270 | K_output K_integer list_of_identifiers ';'
3271 { svector<PExpr*>*range_stub
3272 = new svector<PExpr*>(2);
3273 PExpr*re;
3274 re = new PENumber(new verinum(integer_width-1,
3275 integer_width));
3276 (*range_stub)[0] = re;
3277 re = new PENumber(new verinum((uint64_t)0, integer_width));
3278 (*range_stub)[1] = re;
3279 svector<PWire*>*tmp
3280 = pform_make_task_ports(NetNet::POUTPUT,
3281 IVL_VT_LOGIC, true,
3282 range_stub, $3,
3283 @1.text, @1.first_line);
3284 $$ = tmp;
3286 | K_inout K_integer list_of_identifiers ';'
3287 { svector<PExpr*>*range_stub
3288 = new svector<PExpr*>(2);
3289 PExpr*re;
3290 re = new PENumber(new verinum(integer_width-1,
3291 integer_width));
3292 (*range_stub)[0] = re;
3293 re = new PENumber(new verinum((uint64_t)0, integer_width));
3294 (*range_stub)[1] = re;
3295 svector<PWire*>*tmp
3296 = pform_make_task_ports(NetNet::PINOUT,
3297 IVL_VT_LOGIC, true,
3298 range_stub, $3,
3299 @1.text, @1.first_line);
3300 $$ = tmp;
3303 /* Ports can be real. */
3305 | K_input K_real list_of_identifiers ';'
3306 { svector<PWire*>*tmp
3307 = pform_make_task_ports(NetNet::PINPUT,
3308 IVL_VT_REAL, false,
3309 0, $3,
3310 @1.text, @1.first_line);
3311 $$ = tmp;
3313 | K_output K_real list_of_identifiers ';'
3314 { svector<PWire*>*tmp
3315 = pform_make_task_ports(NetNet::POUTPUT,
3316 IVL_VT_REAL, true,
3317 0, $3,
3318 @1.text, @1.first_line);
3319 $$ = tmp;
3321 | K_inout K_real list_of_identifiers ';'
3322 { svector<PWire*>*tmp
3323 = pform_make_task_ports(NetNet::PINOUT,
3324 IVL_VT_REAL, true,
3325 0, $3,
3326 @1.text, @1.first_line);
3327 $$ = tmp;
3331 task_item_list
3332 : task_item_list task_item
3333 { svector<PWire*>*tmp = new svector<PWire*>(*$1, *$2);
3334 delete $1;
3335 delete $2;
3336 $$ = tmp;
3338 | task_item
3339 { $$ = $1; }
3342 task_item_list_opt
3343 : task_item_list
3344 { $$ = $1; }
3346 { $$ = 0; }
3349 task_port_decl
3351 : K_input signed_opt range_opt IDENTIFIER
3352 { svector<PWire*>*tmp
3353 = pform_make_task_ports(NetNet::PINPUT,
3354 IVL_VT_LOGIC, $2,
3355 $3, list_from_identifier($4),
3356 @1.text, @1.first_line);
3357 $$ = tmp;
3360 | K_output signed_opt range_opt IDENTIFIER
3361 { svector<PWire*>*tmp
3362 = pform_make_task_ports(NetNet::POUTPUT,
3363 IVL_VT_LOGIC, $2,
3364 $3, list_from_identifier($4),
3365 @1.text, @1.first_line);
3366 $$ = tmp;
3368 | K_inout signed_opt range_opt IDENTIFIER
3369 { svector<PWire*>*tmp
3370 = pform_make_task_ports(NetNet::PINOUT,
3371 IVL_VT_LOGIC, $2,
3372 $3, list_from_identifier($4),
3373 @1.text, @1.first_line);
3374 $$ = tmp;
3377 | K_input K_integer IDENTIFIER
3378 { svector<PExpr*>*range_stub
3379 = new svector<PExpr*>(2);
3380 PExpr*re;
3381 re = new PENumber(new verinum(integer_width-1,
3382 integer_width));
3383 (*range_stub)[0] = re;
3384 re = new PENumber(new verinum((uint64_t)0, integer_width));
3385 (*range_stub)[1] = re;
3386 svector<PWire*>*tmp
3387 = pform_make_task_ports(NetNet::PINPUT,
3388 IVL_VT_LOGIC, true,
3389 range_stub,
3390 list_from_identifier($3),
3391 @1.text, @1.first_line);
3392 $$ = tmp;
3394 | K_output K_integer IDENTIFIER
3395 { svector<PExpr*>*range_stub
3396 = new svector<PExpr*>(2);
3397 PExpr*re;
3398 re = new PENumber(new verinum(integer_width-1,
3399 integer_width));
3400 (*range_stub)[0] = re;
3401 re = new PENumber(new verinum((uint64_t)0, integer_width));
3402 (*range_stub)[1] = re;
3403 svector<PWire*>*tmp
3404 = pform_make_task_ports(NetNet::POUTPUT,
3405 IVL_VT_LOGIC, true,
3406 range_stub,
3407 list_from_identifier($3),
3408 @1.text, @1.first_line);
3409 $$ = tmp;
3411 | K_inout K_integer IDENTIFIER
3412 { svector<PExpr*>*range_stub
3413 = new svector<PExpr*>(2);
3414 PExpr*re;
3415 re = new PENumber(new verinum(integer_width-1,
3416 integer_width));
3417 (*range_stub)[0] = re;
3418 re = new PENumber(new verinum((uint64_t)0, integer_width));
3419 (*range_stub)[1] = re;
3420 svector<PWire*>*tmp
3421 = pform_make_task_ports(NetNet::PINOUT,
3422 IVL_VT_LOGIC, true,
3423 range_stub,
3424 list_from_identifier($3),
3425 @1.text, @1.first_line);
3426 $$ = tmp;
3429 /* Ports can be real. */
3431 | K_input K_real IDENTIFIER
3432 { svector<PWire*>*tmp
3433 = pform_make_task_ports(NetNet::PINPUT,
3434 IVL_VT_REAL, false,
3435 0, list_from_identifier($3),
3436 @1.text, @1.first_line);
3437 $$ = tmp;
3439 | K_output K_real IDENTIFIER
3440 { svector<PWire*>*tmp
3441 = pform_make_task_ports(NetNet::POUTPUT,
3442 IVL_VT_REAL, false,
3443 0, list_from_identifier($3),
3444 @1.text, @1.first_line);
3445 $$ = tmp;
3447 | K_inout K_real IDENTIFIER
3448 { svector<PWire*>*tmp
3449 = pform_make_task_ports(NetNet::PINOUT,
3450 IVL_VT_REAL, false,
3451 0, list_from_identifier($3),
3452 @1.text, @1.first_line);
3453 $$ = tmp;
3457 task_port_decl_list
3458 : task_port_decl_list ',' task_port_decl
3459 { svector<PWire*>*tmp = new svector<PWire*>(*$1, *$3);
3460 delete $1;
3461 delete $3;
3462 $$ = tmp;
3464 | task_port_decl
3465 { $$ = $1; }
3468 udp_body
3469 : K_table { lex_start_table(); }
3470 udp_entry_list
3471 K_endtable { lex_end_table(); $$ = $3; }
3474 udp_entry_list
3475 : udp_comb_entry_list
3476 | udp_sequ_entry_list
3479 udp_comb_entry
3480 : udp_input_list ':' udp_output_sym ';'
3481 { char*tmp = new char[strlen($1)+3];
3482 strcpy(tmp, $1);
3483 char*tp = tmp+strlen(tmp);
3484 *tp++ = ':';
3485 *tp++ = $3;
3486 *tp++ = 0;
3487 delete[]$1;
3488 $$ = tmp;
3492 udp_comb_entry_list
3493 : udp_comb_entry
3494 { list<string>*tmp = new list<string>;
3495 tmp->push_back($1);
3496 delete $1;
3497 $$ = tmp;
3499 | udp_comb_entry_list udp_comb_entry
3500 { list<string>*tmp = $1;
3501 tmp->push_back($2);
3502 delete $2;
3503 $$ = tmp;
3507 udp_sequ_entry_list
3508 : udp_sequ_entry
3509 { list<string>*tmp = new list<string>;
3510 tmp->push_back($1);
3511 delete $1;
3512 $$ = tmp;
3514 | udp_sequ_entry_list udp_sequ_entry
3515 { list<string>*tmp = $1;
3516 tmp->push_back($2);
3517 delete $2;
3518 $$ = tmp;
3522 udp_sequ_entry
3523 : udp_input_list ':' udp_input_sym ':' udp_output_sym ';'
3524 { char*tmp = new char[strlen($1)+5];
3525 strcpy(tmp, $1);
3526 char*tp = tmp+strlen(tmp);
3527 *tp++ = ':';
3528 *tp++ = $3;
3529 *tp++ = ':';
3530 *tp++ = $5;
3531 *tp++ = 0;
3532 $$ = tmp;
3536 udp_initial
3537 : K_initial IDENTIFIER '=' number ';'
3538 { PExpr*etmp = new PENumber($4);
3539 PEIdent*itmp = new PEIdent(lex_strings.make($2));
3540 PAssign*atmp = new PAssign(itmp, etmp);
3541 atmp->set_file(@2.text);
3542 atmp->set_lineno(@2.first_line);
3543 delete $2;
3544 $$ = atmp;
3548 udp_init_opt
3549 : udp_initial { $$ = $1; }
3550 | { $$ = 0; }
3553 udp_input_list
3554 : udp_input_sym
3555 { char*tmp = new char[2];
3556 tmp[0] = $1;
3557 tmp[1] = 0;
3558 $$ = tmp;
3560 | udp_input_list udp_input_sym
3561 { char*tmp = new char[strlen($1)+2];
3562 strcpy(tmp, $1);
3563 char*tp = tmp+strlen(tmp);
3564 *tp++ = $2;
3565 *tp++ = 0;
3566 delete[]$1;
3567 $$ = tmp;
3571 udp_input_sym
3572 : '0' { $$ = '0'; }
3573 | '1' { $$ = '1'; }
3574 | 'x' { $$ = 'x'; }
3575 | '?' { $$ = '?'; }
3576 | 'b' { $$ = 'b'; }
3577 | '*' { $$ = '*'; }
3578 | '%' { $$ = '%'; }
3579 | 'f' { $$ = 'f'; }
3580 | 'F' { $$ = 'F'; }
3581 | 'l' { $$ = 'l'; }
3582 | 'h' { $$ = 'H'; }
3583 | 'B' { $$ = 'B'; }
3584 | 'r' { $$ = 'r'; }
3585 | 'R' { $$ = 'R'; }
3586 | 'M' { $$ = 'M'; }
3587 | 'n' { $$ = 'n'; }
3588 | 'N' { $$ = 'N'; }
3589 | 'p' { $$ = 'p'; }
3590 | 'P' { $$ = 'P'; }
3591 | 'Q' { $$ = 'Q'; }
3592 | 'q' { $$ = 'q'; }
3593 | '_' { $$ = '_'; }
3594 | '+' { $$ = '+'; }
3597 udp_output_sym
3598 : '0' { $$ = '0'; }
3599 | '1' { $$ = '1'; }
3600 | 'x' { $$ = 'x'; }
3601 | '-' { $$ = '-'; }
3604 /* Port declarations create wires for the inputs and the output. The
3605 makes for these ports are scoped within the UDP, so there is no
3606 heirarchy involved. */
3607 udp_port_decl
3608 : K_input list_of_identifiers ';'
3609 { $$ = pform_make_udp_input_ports($2); }
3610 | K_output IDENTIFIER ';'
3611 { pform_name_t pname;
3612 pname.push_back(name_component_t(lex_strings.make($2)));
3613 PWire*pp = new PWire(pname, NetNet::IMPLICIT, NetNet::POUTPUT, IVL_VT_LOGIC);
3614 svector<PWire*>*tmp = new svector<PWire*>(1);
3615 (*tmp)[0] = pp;
3616 $$ = tmp;
3617 delete $2;
3619 | K_reg IDENTIFIER ';'
3620 { pform_name_t pname;
3621 pname.push_back(name_component_t(lex_strings.make($2)));
3622 PWire*pp = new PWire(pname, NetNet::REG, NetNet::PIMPLICIT, IVL_VT_LOGIC);
3623 svector<PWire*>*tmp = new svector<PWire*>(1);
3624 (*tmp)[0] = pp;
3625 $$ = tmp;
3626 delete $2;
3628 | K_reg K_output IDENTIFIER ';'
3629 { pform_name_t pname;
3630 pname.push_back(name_component_t(lex_strings.make($3)));
3631 PWire*pp = new PWire(pname, NetNet::REG, NetNet::POUTPUT, IVL_VT_LOGIC);
3632 svector<PWire*>*tmp = new svector<PWire*>(1);
3633 (*tmp)[0] = pp;
3634 $$ = tmp;
3635 delete $3;
3639 udp_port_decls
3640 : udp_port_decl
3641 { $$ = $1; }
3642 | udp_port_decls udp_port_decl
3643 { svector<PWire*>*tmp = new svector<PWire*>(*$1, *$2);
3644 delete $1;
3645 delete $2;
3646 $$ = tmp;
3650 udp_port_list
3651 : IDENTIFIER
3652 { list<string>*tmp = new list<string>;
3653 tmp->push_back($1);
3654 delete $1;
3655 $$ = tmp;
3657 | udp_port_list ',' IDENTIFIER
3658 { list<string>*tmp = $1;
3659 tmp->push_back($3);
3660 delete $3;
3661 $$ = tmp;
3665 udp_reg_opt: K_reg { $$ = true; } | { $$ = false; };
3667 udp_initial_expr_opt
3668 : '=' expression { $$ = $2; }
3669 | { $$ = 0; }
3672 udp_input_declaration_list
3673 : K_input IDENTIFIER
3674 { list<perm_string>*tmp = new list<perm_string>;
3675 tmp->push_back(lex_strings.make($2));
3676 $$ = tmp;
3677 delete[]$2;
3679 | udp_input_declaration_list ',' K_input IDENTIFIER
3680 { list<perm_string>*tmp = $1;
3681 tmp->push_back(lex_strings.make($4));
3682 $$ = tmp;
3683 delete[]$4;
3687 udp_primitive
3688 /* This is the syntax for primitives that uses the IEEE1364-1995
3689 format. The ports are simply names in the port list, and the
3690 declarations are in the body. */
3692 : K_primitive IDENTIFIER '(' udp_port_list ')' ';'
3693 udp_port_decls
3694 udp_init_opt
3695 udp_body
3696 K_endprimitive
3698 { perm_string tmp2 = lex_strings.make($2);
3699 pform_make_udp(tmp2, $4, $7, $9, $8,
3700 @2.text, @2.first_line);
3701 delete[]$2;
3704 /* This is the syntax for IEEE1364-2001 format definitions. The port
3705 names and declarations are all in the parameter list. */
3707 | K_primitive IDENTIFIER
3708 '(' K_output udp_reg_opt IDENTIFIER udp_initial_expr_opt ','
3709 udp_input_declaration_list ')' ';'
3710 udp_body
3711 K_endprimitive
3713 { perm_string tmp2 = lex_strings.make($2);
3714 perm_string tmp6 = lex_strings.make($6);
3715 pform_make_udp(tmp2, $5, tmp6, $7, $9, $12,
3716 @2.text, @2.first_line);
3717 delete[]$2;
3718 delete[]$6;