Pass local scope precision from compiler to vvp/etc.
[iverilog.git] / parse.y
blob91f435d5091c1f230e0544f6b2498fb7aa34d673
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 real_variable
195 %type <perm_strings> register_variable_list net_variable_list real_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 expr_mintypmax
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 | attribute_list_opt K_time register_variable_list ';'
373 { pform_set_reg_time($3);
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 | attribute_list_opt K_real real_variable_list ';'
382 { delete $3; }
383 | attribute_list_opt K_realtime real_variable_list ';'
384 { delete $3; }
386 | K_parameter parameter_assign_decl ';'
387 | K_localparam localparam_assign_decl ';'
389 /* Recover from errors that happen within variable lists. Use the
390 trailing semi-colon to resync the parser. */
392 | attribute_list_opt K_reg error ';'
393 { yyerror(@2, "error: syntax error in reg variable list.");
394 yyerrok;
395 if ($1) delete $1;
397 | attribute_list_opt K_integer error ';'
398 { yyerror(@2, "error: syntax error in integer variable list.");
399 yyerrok;
400 if ($1) delete $1;
402 | attribute_list_opt K_time error ';'
403 { yyerror(@2, "error: syntax error in time variable list.");
404 yyerrok;
406 | attribute_list_opt K_real error ';'
407 { yyerror(@2, "error: syntax error in real variable list.");
408 yyerrok;
410 | attribute_list_opt K_realtime error ';'
411 { yyerror(@1, "error: syntax error in realtime variable list.");
412 yyerrok;
414 | K_parameter error ';'
415 { yyerror(@1, "error: syntax error in parameter list.");
416 yyerrok;
418 | K_localparam error ';'
419 { yyerror(@1, "error: syntax error localparam list.");
420 yyerrok;
424 block_item_decls
425 : block_item_decl
426 | block_item_decls block_item_decl
429 block_item_decls_opt
430 : block_item_decls
434 case_item
435 : expression_list_proper ':' statement_or_null
436 { PCase::Item*tmp = new PCase::Item;
437 tmp->expr = *$1;
438 tmp->stat = $3;
439 delete $1;
440 $$ = tmp;
442 | K_default ':' statement_or_null
443 { PCase::Item*tmp = new PCase::Item;
444 tmp->stat = $3;
445 $$ = tmp;
447 | K_default statement_or_null
448 { PCase::Item*tmp = new PCase::Item;
449 tmp->stat = $2;
450 $$ = tmp;
452 | error ':' statement_or_null
453 { yyerror(@1, "error: Incomprehensible case expression.");
454 yyerrok;
458 case_items
459 : case_items case_item
460 { svector<PCase::Item*>*tmp;
461 tmp = new svector<PCase::Item*>(*$1, $2);
462 delete $1;
463 $$ = tmp;
465 | case_item
466 { svector<PCase::Item*>*tmp = new svector<PCase::Item*>(1);
467 (*tmp)[0] = $1;
468 $$ = tmp;
472 charge_strength
473 : '(' K_small ')'
474 | '(' K_medium ')'
475 | '(' K_large ')'
478 charge_strength_opt
479 : charge_strength
483 defparam_assign
484 : heirarchy_identifier '=' expression
485 { PExpr*tmp = $3;
486 if (!pform_expression_is_constant(tmp)) {
487 yyerror(@3, "error: parameter value "
488 "must be constant.");
489 delete tmp;
490 tmp = 0;
492 pform_set_defparam(*$1, $3);
493 delete $1;
497 defparam_assign_list
498 : defparam_assign
499 | range defparam_assign
500 { yyerror(@1, "error: defparam may not include a range.");
501 delete $1;
503 | defparam_assign_list ',' defparam_assign
506 delay1
507 : '#' delay_value_simple
508 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
509 (*tmp)[0] = $2;
510 $$ = tmp;
512 | '#' '(' delay_value ')'
513 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
514 (*tmp)[0] = $3;
515 $$ = tmp;
519 delay3
520 : '#' delay_value_simple
521 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
522 (*tmp)[0] = $2;
523 $$ = tmp;
525 | '#' '(' delay_value ')'
526 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
527 (*tmp)[0] = $3;
528 $$ = tmp;
530 | '#' '(' delay_value ',' delay_value ')'
531 { svector<PExpr*>*tmp = new svector<PExpr*>(2);
532 (*tmp)[0] = $3;
533 (*tmp)[1] = $5;
534 $$ = tmp;
536 | '#' '(' delay_value ',' delay_value ',' delay_value ')'
537 { svector<PExpr*>*tmp = new svector<PExpr*>(3);
538 (*tmp)[0] = $3;
539 (*tmp)[1] = $5;
540 (*tmp)[2] = $7;
541 $$ = tmp;
545 delay3_opt
546 : delay3 { $$ = $1; }
547 | { $$ = 0; }
550 delay_value_list
551 : delay_value
552 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
553 (*tmp)[0] = $1;
554 $$ = tmp;
556 | delay_value_list ',' delay_value
557 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
558 delete $1;
559 $$ = tmp;
563 delay_value
564 : expression
565 { PExpr*tmp = $1;
566 $$ = tmp;
568 | expression ':' expression ':' expression
569 { $$ = pform_select_mtm_expr($1, $3, $5); }
573 delay_value_simple
574 : DEC_NUMBER
575 { verinum*tmp = $1;
576 if (tmp == 0) {
577 yyerror(@1, "internal error: delay.");
578 $$ = 0;
579 } else {
580 $$ = new PENumber(tmp);
581 $$->set_file(@1.text);
582 $$->set_lineno(@1.first_line);
585 | REALTIME
586 { verireal*tmp = $1;
587 if (tmp == 0) {
588 yyerror(@1, "internal error: delay.");
589 $$ = 0;
590 } else {
591 $$ = new PEFNumber(tmp);
592 $$->set_file(@1.text);
593 $$->set_lineno(@1.first_line);
596 | IDENTIFIER
597 { PEIdent*tmp = new PEIdent(lex_strings.make($1));
598 tmp->set_file(@1.text);
599 tmp->set_lineno(@1.first_line);
600 $$ = tmp;
601 delete $1;
605 description
606 : module
607 | udp_primitive
608 | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')'
609 { perm_string tmp3 = lex_strings.make($3);
610 pform_set_type_attrib(tmp3, $5, $7);
611 delete $3;
612 delete $5;
616 drive_strength
617 : '(' dr_strength0 ',' dr_strength1 ')'
618 { $$.str0 = $2.str0;
619 $$.str1 = $4.str1;
621 | '(' dr_strength1 ',' dr_strength0 ')'
622 { $$.str0 = $4.str0;
623 $$.str1 = $2.str1;
625 | '(' dr_strength0 ',' K_highz1 ')'
626 { $$.str0 = $2.str0;
627 $$.str1 = PGate::HIGHZ;
629 | '(' dr_strength1 ',' K_highz0 ')'
630 { $$.str0 = PGate::HIGHZ;
631 $$.str1 = $2.str1;
633 | '(' K_highz1 ',' dr_strength0 ')'
634 { $$.str0 = $4.str0;
635 $$.str1 = PGate::HIGHZ;
637 | '(' K_highz0 ',' dr_strength1 ')'
638 { $$.str0 = PGate::HIGHZ;
639 $$.str1 = $4.str1;
643 drive_strength_opt
644 : drive_strength { $$ = $1; }
645 | { $$.str0 = PGate::STRONG; $$.str1 = PGate::STRONG; }
648 dr_strength0
649 : K_supply0 { $$.str0 = PGate::SUPPLY; }
650 | K_strong0 { $$.str0 = PGate::STRONG; }
651 | K_pull0 { $$.str0 = PGate::PULL; }
652 | K_weak0 { $$.str0 = PGate::WEAK; }
655 dr_strength1
656 : K_supply1 { $$.str1 = PGate::SUPPLY; }
657 | K_strong1 { $$.str1 = PGate::STRONG; }
658 | K_pull1 { $$.str1 = PGate::PULL; }
659 | K_weak1 { $$.str1 = PGate::WEAK; }
662 event_control
663 : '@' heirarchy_identifier
664 { PEIdent*tmpi = new PEIdent(*$2);
665 PEEvent*tmpe = new PEEvent(PEEvent::ANYEDGE, tmpi);
666 PEventStatement*tmps = new PEventStatement(tmpe);
667 tmps->set_file(@1.text);
668 tmps->set_lineno(@1.first_line);
669 $$ = tmps;
670 delete $2;
672 | '@' '(' event_expression_list ')'
673 { PEventStatement*tmp = new PEventStatement(*$3);
674 tmp->set_file(@1.text);
675 tmp->set_lineno(@1.first_line);
676 delete $3;
677 $$ = tmp;
679 | '@' '(' error ')'
680 { yyerror(@1, "error: Malformed event control expression.");
681 $$ = 0;
685 event_expression_list
686 : event_expression
687 { $$ = $1; }
688 | event_expression_list K_or event_expression
689 { svector<PEEvent*>*tmp = new svector<PEEvent*>(*$1, *$3);
690 delete $1;
691 delete $3;
692 $$ = tmp;
694 | event_expression_list ',' event_expression
695 { svector<PEEvent*>*tmp = new svector<PEEvent*>(*$1, *$3);
696 delete $1;
697 delete $3;
698 $$ = tmp;
702 event_expression
703 : K_posedge expression
704 { PEEvent*tmp = new PEEvent(PEEvent::POSEDGE, $2);
705 tmp->set_file(@1.text);
706 tmp->set_lineno(@1.first_line);
707 svector<PEEvent*>*tl = new svector<PEEvent*>(1);
708 (*tl)[0] = tmp;
709 $$ = tl;
711 | K_negedge expression
712 { PEEvent*tmp = new PEEvent(PEEvent::NEGEDGE, $2);
713 tmp->set_file(@1.text);
714 tmp->set_lineno(@1.first_line);
715 svector<PEEvent*>*tl = new svector<PEEvent*>(1);
716 (*tl)[0] = tmp;
717 $$ = tl;
719 | expression
720 { PEEvent*tmp = new PEEvent(PEEvent::ANYEDGE, $1);
721 tmp->set_file(@1.text);
722 tmp->set_lineno(@1.first_line);
723 svector<PEEvent*>*tl = new svector<PEEvent*>(1);
724 (*tl)[0] = tmp;
725 $$ = tl;
729 expression
730 : expr_primary
731 { $$ = $1; }
732 | '+' expr_primary %prec UNARY_PREC
733 { $$ = $2; }
734 | '-' expr_primary %prec UNARY_PREC
735 { PEUnary*tmp = new PEUnary('-', $2);
736 tmp->set_file(@2.text);
737 tmp->set_lineno(@2.first_line);
738 $$ = tmp;
740 | '~' expr_primary %prec UNARY_PREC
741 { PEUnary*tmp = new PEUnary('~', $2);
742 tmp->set_file(@2.text);
743 tmp->set_lineno(@2.first_line);
744 $$ = tmp;
746 | '&' expr_primary %prec UNARY_PREC
747 { PEUnary*tmp = new PEUnary('&', $2);
748 tmp->set_file(@2.text);
749 tmp->set_lineno(@2.first_line);
750 $$ = tmp;
752 | '!' expr_primary %prec UNARY_PREC
753 { PEUnary*tmp = new PEUnary('!', $2);
754 tmp->set_file(@2.text);
755 tmp->set_lineno(@2.first_line);
756 $$ = tmp;
758 | '|' expr_primary %prec UNARY_PREC
759 { PEUnary*tmp = new PEUnary('|', $2);
760 tmp->set_file(@2.text);
761 tmp->set_lineno(@2.first_line);
762 $$ = tmp;
764 | '^' expr_primary %prec UNARY_PREC
765 { PEUnary*tmp = new PEUnary('^', $2);
766 tmp->set_file(@2.text);
767 tmp->set_lineno(@2.first_line);
768 $$ = tmp;
770 | K_NAND expr_primary %prec UNARY_PREC
771 { PEUnary*tmp = new PEUnary('A', $2);
772 tmp->set_file(@2.text);
773 tmp->set_lineno(@2.first_line);
774 $$ = tmp;
776 | K_NOR expr_primary %prec UNARY_PREC
777 { PEUnary*tmp = new PEUnary('N', $2);
778 tmp->set_file(@2.text);
779 tmp->set_lineno(@2.first_line);
780 $$ = tmp;
782 | K_NXOR expr_primary %prec UNARY_PREC
783 { PEUnary*tmp = new PEUnary('X', $2);
784 tmp->set_file(@2.text);
785 tmp->set_lineno(@2.first_line);
786 $$ = tmp;
788 | '!' error %prec UNARY_PREC
789 { yyerror(@1, "error: Operand of unary ! "
790 "is not a primary expression.");
791 $$ = 0;
793 | '^' error %prec UNARY_PREC
794 { yyerror(@1, "error: Operand of reduction ^ "
795 "is not a primary expression.");
796 $$ = 0;
798 | expression '^' expression
799 { PEBinary*tmp = new PEBinary('^', $1, $3);
800 tmp->set_file(@2.text);
801 tmp->set_lineno(@2.first_line);
802 $$ = tmp;
804 | expression K_POW expression
805 { PEBinary*tmp = new PEBinary('p', $1, $3);
806 tmp->set_file(@2.text);
807 tmp->set_lineno(@2.first_line);
808 $$ = tmp;
810 | expression '*' expression
811 { PEBinary*tmp = new PEBinary('*', $1, $3);
812 tmp->set_file(@2.text);
813 tmp->set_lineno(@2.first_line);
814 $$ = tmp;
816 | expression '/' expression
817 { PEBinary*tmp = new PEBinary('/', $1, $3);
818 tmp->set_file(@2.text);
819 tmp->set_lineno(@2.first_line);
820 $$ = tmp;
822 | expression '%' expression
823 { PEBinary*tmp = new PEBinary('%', $1, $3);
824 tmp->set_file(@2.text);
825 tmp->set_lineno(@2.first_line);
826 $$ = tmp;
828 | expression '+' expression
829 { PEBinary*tmp = new PEBinary('+', $1, $3);
830 tmp->set_file(@2.text);
831 tmp->set_lineno(@2.first_line);
832 $$ = tmp;
834 | expression '-' expression
835 { PEBinary*tmp = new PEBinary('-', $1, $3);
836 tmp->set_file(@2.text);
837 tmp->set_lineno(@2.first_line);
838 $$ = tmp;
840 | expression '&' expression
841 { PEBinary*tmp = new PEBinary('&', $1, $3);
842 tmp->set_file(@2.text);
843 tmp->set_lineno(@2.first_line);
844 $$ = tmp;
846 | expression '|' expression
847 { PEBinary*tmp = new PEBinary('|', $1, $3);
848 tmp->set_file(@2.text);
849 tmp->set_lineno(@2.first_line);
850 $$ = tmp;
852 | expression K_NAND expression
853 { PEBinary*tmp = new PEBinary('A', $1, $3);
854 tmp->set_file(@2.text);
855 tmp->set_lineno(@2.first_line);
856 $$ = tmp;
858 | expression K_NOR expression
859 { PEBinary*tmp = new PEBinary('O', $1, $3);
860 tmp->set_file(@2.text);
861 tmp->set_lineno(@2.first_line);
862 $$ = tmp;
864 | expression K_NXOR expression
865 { PEBinary*tmp = new PEBinary('X', $1, $3);
866 tmp->set_file(@2.text);
867 tmp->set_lineno(@2.first_line);
868 $$ = tmp;
870 | expression '<' expression
871 { PEBinary*tmp = new PEBComp('<', $1, $3);
872 tmp->set_file(@2.text);
873 tmp->set_lineno(@2.first_line);
874 $$ = tmp;
876 | expression '>' expression
877 { PEBinary*tmp = new PEBComp('>', $1, $3);
878 tmp->set_file(@2.text);
879 tmp->set_lineno(@2.first_line);
880 $$ = tmp;
882 | expression K_LS expression
883 { PEBinary*tmp = new PEBShift('l', $1, $3);
884 tmp->set_file(@2.text);
885 tmp->set_lineno(@2.first_line);
886 $$ = tmp;
888 | expression K_RS expression
889 { PEBinary*tmp = new PEBShift('r', $1, $3);
890 tmp->set_file(@2.text);
891 tmp->set_lineno(@2.first_line);
892 $$ = tmp;
894 | expression K_RSS expression
895 { PEBinary*tmp = new PEBShift('R', $1, $3);
896 tmp->set_file(@2.text);
897 tmp->set_lineno(@2.first_line);
898 $$ = tmp;
900 | expression K_EQ expression
901 { PEBinary*tmp = new PEBComp('e', $1, $3);
902 tmp->set_file(@2.text);
903 tmp->set_lineno(@2.first_line);
904 $$ = tmp;
906 | expression K_CEQ expression
907 { PEBinary*tmp = new PEBComp('E', $1, $3);
908 tmp->set_file(@2.text);
909 tmp->set_lineno(@2.first_line);
910 $$ = tmp;
912 | expression K_LE expression
913 { PEBinary*tmp = new PEBComp('L', $1, $3);
914 tmp->set_file(@2.text);
915 tmp->set_lineno(@2.first_line);
916 $$ = tmp;
918 | expression K_GE expression
919 { PEBinary*tmp = new PEBComp('G', $1, $3);
920 tmp->set_file(@2.text);
921 tmp->set_lineno(@2.first_line);
922 $$ = tmp;
924 | expression K_NE expression
925 { PEBinary*tmp = new PEBComp('n', $1, $3);
926 tmp->set_file(@2.text);
927 tmp->set_lineno(@2.first_line);
928 $$ = tmp;
930 | expression K_CNE expression
931 { PEBinary*tmp = new PEBComp('N', $1, $3);
932 tmp->set_file(@2.text);
933 tmp->set_lineno(@2.first_line);
934 $$ = tmp;
936 | expression K_LOR expression
937 { PEBinary*tmp = new PEBinary('o', $1, $3);
938 tmp->set_file(@2.text);
939 tmp->set_lineno(@2.first_line);
940 $$ = tmp;
942 | expression K_LAND expression
943 { PEBinary*tmp = new PEBinary('a', $1, $3);
944 tmp->set_file(@2.text);
945 tmp->set_lineno(@2.first_line);
946 $$ = tmp;
948 | expression '?' expression ':' expression
949 { PETernary*tmp = new PETernary($1, $3, $5);
950 tmp->set_file(@2.text);
951 tmp->set_lineno(@2.first_line);
952 $$ = tmp;
956 expr_mintypmax
957 : expression
958 { $$ = $1; }
959 | expression ':' expression ':' expression
960 { switch (min_typ_max_flag) {
961 case MIN:
962 $$ = $1;
963 delete $3;
964 delete $5;
965 break;
966 case TYP:
967 delete $1;
968 $$ = $3;
969 delete $5;
970 break;
971 case MAX:
972 delete $1;
973 delete $3;
974 $$ = $5;
975 break;
981 /* Many contexts take a comma separated list of expressions. Null
982 expressions can happen anywhere in the list, so there are two
983 extra rules in expression_list_with_nuls for parsing and
984 installing those nulls.
986 The expression_list_proper rules do not allow null items in the
987 expression list, so can be used where nul expressions are not allowed. */
989 expression_list_with_nuls
990 : expression_list_with_nuls ',' expression
991 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
992 delete $1;
993 $$ = tmp;
995 | expression
996 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
997 (*tmp)[0] = $1;
998 $$ = tmp;
1001 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
1002 (*tmp)[0] = 0;
1003 $$ = tmp;
1006 | expression_list_with_nuls ','
1007 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, 0);
1008 delete $1;
1009 $$ = tmp;
1013 expression_list_proper
1014 : expression_list_proper ',' expression
1015 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
1016 delete $1;
1017 $$ = tmp;
1019 | expression
1020 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
1021 (*tmp)[0] = $1;
1022 $$ = tmp;
1026 expr_primary
1027 : number
1028 { assert($1);
1029 PENumber*tmp = new PENumber($1);
1030 tmp->set_file(@1.text);
1031 tmp->set_lineno(@1.first_line);
1032 $$ = tmp;
1034 | REALTIME
1035 { PEFNumber*tmp = new PEFNumber($1);
1036 tmp->set_file(@1.text);
1037 tmp->set_lineno(@1.first_line);
1038 $$ = tmp;
1040 | STRING
1041 { PEString*tmp = new PEString($1);
1042 tmp->set_file(@1.text);
1043 tmp->set_lineno(@1.first_line);
1044 $$ = tmp;
1046 | SYSTEM_IDENTIFIER
1047 { perm_string tn = lex_strings.make($1);
1048 PECallFunction*tmp = new PECallFunction(tn);
1049 tmp->set_file(@1.text);
1050 tmp->set_lineno(@1.first_line);
1051 $$ = tmp;
1052 delete $1;
1055 /* The heirarchy_identifier rule matches simple identifiers as well as
1056 indexed arrays and part selects */
1058 | heirarchy_identifier
1059 { PEIdent*tmp = new PEIdent(*$1);
1060 tmp->set_file(@1.text);
1061 tmp->set_lineno(@1.first_line);
1062 $$ = tmp;
1063 delete $1;
1066 /* An identifer followed by an expression list in parentheses is a
1067 function call. If a system identifier, then a system function
1068 call. */
1070 | heirarchy_identifier '(' expression_list_proper ')'
1071 { PECallFunction*tmp = new PECallFunction(*$1, *$3);
1072 tmp->set_file(@1.text);
1073 tmp->set_lineno(@1.first_line);
1074 delete $1;
1075 $$ = tmp;
1077 | SYSTEM_IDENTIFIER '(' expression_list_proper ')'
1078 { perm_string tn = lex_strings.make($1);
1079 PECallFunction*tmp = new PECallFunction(tn, *$3);
1080 tmp->set_file(@1.text);
1081 tmp->set_lineno(@1.first_line);
1082 $$ = tmp;
1085 /* Parenthesized expressions are primaries. */
1087 | '(' expr_mintypmax ')'
1088 { $$ = $2; }
1090 /* Various kinds of concatenation expressions. */
1092 | '{' expression_list_proper '}'
1093 { PEConcat*tmp = new PEConcat(*$2);
1094 tmp->set_file(@1.text);
1095 tmp->set_lineno(@1.first_line);
1096 delete $2;
1097 $$ = tmp;
1099 | '{' expression '{' expression_list_proper '}' '}'
1100 { PExpr*rep = $2;
1101 PEConcat*tmp = new PEConcat(*$4, rep);
1102 tmp->set_file(@1.text);
1103 tmp->set_lineno(@1.first_line);
1104 delete $4;
1105 $$ = tmp;
1107 | '{' expression '{' expression_list_proper '}' error '}'
1108 { PExpr*rep = $2;
1109 PEConcat*tmp = new PEConcat(*$4, rep);
1110 tmp->set_file(@1.text);
1111 tmp->set_lineno(@1.first_line);
1112 delete $4;
1113 $$ = tmp;
1114 yyerror(@5, "error: Syntax error between internal '}' "
1115 "and closing '}' of repeat concatenation.");
1116 yyerrok;
1120 /* A function_item is either a block item (i.e. a reg or integer
1121 declaration) or an input declaration. There are no output or
1122 inout ports. */
1123 function_item
1124 : K_input signed_opt range_opt list_of_identifiers ';'
1125 { svector<PWire*>*tmp
1126 = pform_make_task_ports(NetNet::PINPUT,
1127 IVL_VT_NO_TYPE, $2,
1128 $3, $4,
1129 @1.text, @1.first_line);
1130 $$ = tmp;
1132 | K_output signed_opt range_opt list_of_identifiers ';'
1133 { svector<PWire*>*tmp
1134 = pform_make_task_ports(NetNet::PINPUT,
1135 IVL_VT_NO_TYPE, $2,
1136 $3, $4,
1137 @1.text, @1.first_line);
1138 $$ = tmp;
1139 yyerror(@1, "Functions may not have output ports.");
1141 | K_inout signed_opt range_opt list_of_identifiers ';'
1142 { svector<PWire*>*tmp
1143 = pform_make_task_ports(NetNet::PINPUT,
1144 IVL_VT_NO_TYPE, $2,
1145 $3, $4,
1146 @1.text, @1.first_line);
1147 $$ = tmp;
1148 yyerror(@1, "Functions may not have inout ports.");
1151 /* When the port is an integer, infer a signed vector of the integer
1152 shape. Generate a range to make it work. */
1154 | K_input K_integer list_of_identifiers ';'
1155 { svector<PExpr*>*range_stub
1156 = new svector<PExpr*>(2);
1157 PExpr*re;
1158 re = new PENumber(new verinum(integer_width-1,
1159 integer_width));
1160 (*range_stub)[0] = re;
1161 re = new PENumber(new verinum((uint64_t)0, integer_width));
1162 (*range_stub)[1] = re;
1163 svector<PWire*>*tmp
1164 = pform_make_task_ports(NetNet::PINPUT,
1165 IVL_VT_LOGIC, true,
1166 range_stub, $3,
1167 @1.text, @1.first_line);
1168 $$ = tmp;
1171 /* Ports can be real. */
1173 | K_input K_real list_of_identifiers ';'
1174 { svector<PWire*>*tmp
1175 = pform_make_task_ports(NetNet::PINPUT,
1176 IVL_VT_REAL, false,
1177 0, $3,
1178 @1.text, @1.first_line);
1179 $$ = tmp;
1182 | block_item_decl
1183 { $$ = 0; }
1186 /* A function_item_list only lists the input/output/inout
1187 declarations. The integer and reg declarations are handled in
1188 place, so are not listed. The list builder needs to account for
1189 the possibility that the various parts may be NULL. */
1190 function_item_list
1191 : function_item
1192 { $$ = $1; }
1193 | function_item_list function_item
1194 { if ($1 && $2) {
1195 svector<PWire*>*tmp = new svector<PWire*>(*$1, *$2);
1196 delete $1;
1197 delete $2;
1198 $$ = tmp;
1199 } else if ($1) {
1200 $$ = $1;
1201 } else {
1202 $$ = $2;
1207 /* A gate_instance is a module instantiation or a built in part
1208 type. In any case, the gate has a set of connections to ports. */
1209 gate_instance
1210 : IDENTIFIER '(' expression_list_with_nuls ')'
1211 { lgate*tmp = new lgate;
1212 tmp->name = $1;
1213 tmp->parms = $3;
1214 tmp->file = @1.text;
1215 tmp->lineno = @1.first_line;
1216 delete $1;
1217 $$ = tmp;
1220 | IDENTIFIER range '(' expression_list_with_nuls ')'
1221 { lgate*tmp = new lgate;
1222 svector<PExpr*>*rng = $2;
1223 tmp->name = $1;
1224 tmp->parms = $4;
1225 tmp->range[0] = (*rng)[0];
1226 tmp->range[1] = (*rng)[1];
1227 tmp->file = @1.text;
1228 tmp->lineno = @1.first_line;
1229 delete $1;
1230 delete rng;
1231 $$ = tmp;
1233 | '(' expression_list_with_nuls ')'
1234 { lgate*tmp = new lgate;
1235 tmp->name = "";
1236 tmp->parms = $2;
1237 tmp->file = @1.text;
1238 tmp->lineno = @1.first_line;
1239 $$ = tmp;
1242 /* Degenerate modules can have no ports. */
1244 | IDENTIFIER range
1245 { lgate*tmp = new lgate;
1246 svector<PExpr*>*rng = $2;
1247 tmp->name = $1;
1248 tmp->parms = 0;
1249 tmp->parms_by_name = 0;
1250 tmp->range[0] = (*rng)[0];
1251 tmp->range[1] = (*rng)[1];
1252 tmp->file = @1.text;
1253 tmp->lineno = @1.first_line;
1254 delete $1;
1255 delete rng;
1256 $$ = tmp;
1259 /* Modules can also take ports by port-name expressions. */
1261 | IDENTIFIER '(' port_name_list ')'
1262 { lgate*tmp = new lgate;
1263 tmp->name = $1;
1264 tmp->parms = 0;
1265 tmp->parms_by_name = $3;
1266 tmp->file = @1.text;
1267 tmp->lineno = @1.first_line;
1268 delete $1;
1269 $$ = tmp;
1272 | IDENTIFIER range '(' port_name_list ')'
1273 { lgate*tmp = new lgate;
1274 svector<PExpr*>*rng = $2;
1275 tmp->name = $1;
1276 tmp->parms = 0;
1277 tmp->parms_by_name = $4;
1278 tmp->range[0] = (*rng)[0];
1279 tmp->range[1] = (*rng)[1];
1280 tmp->file = @1.text;
1281 tmp->lineno = @1.first_line;
1282 delete $1;
1283 delete rng;
1284 $$ = tmp;
1288 gate_instance_list
1289 : gate_instance_list ',' gate_instance
1290 { svector<lgate>*tmp1 = $1;
1291 lgate*tmp2 = $3;
1292 svector<lgate>*out = new svector<lgate> (*tmp1, *tmp2);
1293 delete tmp1;
1294 delete tmp2;
1295 $$ = out;
1297 | gate_instance
1298 { svector<lgate>*tmp = new svector<lgate>(1);
1299 (*tmp)[0] = *$1;
1300 delete $1;
1301 $$ = tmp;
1305 gatetype
1306 : K_and { $$ = PGBuiltin::AND; }
1307 | K_nand { $$ = PGBuiltin::NAND; }
1308 | K_or { $$ = PGBuiltin::OR; }
1309 | K_nor { $$ = PGBuiltin::NOR; }
1310 | K_xor { $$ = PGBuiltin::XOR; }
1311 | K_xnor { $$ = PGBuiltin::XNOR; }
1312 | K_buf { $$ = PGBuiltin::BUF; }
1313 | K_bufif0 { $$ = PGBuiltin::BUFIF0; }
1314 | K_bufif1 { $$ = PGBuiltin::BUFIF1; }
1315 | K_not { $$ = PGBuiltin::NOT; }
1316 | K_notif0 { $$ = PGBuiltin::NOTIF0; }
1317 | K_notif1 { $$ = PGBuiltin::NOTIF1; }
1318 | K_nmos { $$ = PGBuiltin::NMOS; }
1319 | K_rnmos { $$ = PGBuiltin::RNMOS; }
1320 | K_pmos { $$ = PGBuiltin::PMOS; }
1321 | K_rpmos { $$ = PGBuiltin::RPMOS; }
1322 | K_cmos { $$ = PGBuiltin::CMOS; }
1323 | K_rcmos { $$ = PGBuiltin::RCMOS; }
1324 | K_tran { $$ = PGBuiltin::TRAN; }
1325 | K_rtran { $$ = PGBuiltin::RTRAN; }
1326 | K_tranif0 { $$ = PGBuiltin::TRANIF0; }
1327 | K_tranif1 { $$ = PGBuiltin::TRANIF1; }
1328 | K_rtranif0 { $$ = PGBuiltin::RTRANIF0; }
1329 | K_rtranif1 { $$ = PGBuiltin::RTRANIF1; }
1333 /* A general identifier is a hierarchical name, with the right most
1334 name the base of the identifier. This rule builds up a
1335 hierarchical name from the left to the right, forming a list of
1336 names. */
1338 heirarchy_identifier
1339 : IDENTIFIER
1340 { $$ = new pform_name_t;
1341 $$->push_back(name_component_t(lex_strings.make($1)));
1342 delete $1;
1344 | heirarchy_identifier '.' IDENTIFIER
1345 { pform_name_t * tmp = $1;
1346 tmp->push_back(name_component_t(lex_strings.make($3)));
1347 delete $3;
1348 $$ = tmp;
1350 | heirarchy_identifier '[' expression ']'
1351 { pform_name_t * tmp = $1;
1352 name_component_t&tail = tmp->back();
1353 index_component_t itmp;
1354 itmp.sel = index_component_t::SEL_BIT;
1355 itmp.msb = $3;
1356 tail.index.push_back(itmp);
1357 $$ = tmp;
1359 | heirarchy_identifier '[' expression ':' expression ']'
1360 { pform_name_t * tmp = $1;
1361 name_component_t&tail = tmp->back();
1362 index_component_t itmp;
1363 itmp.sel = index_component_t::SEL_PART;
1364 itmp.msb = $3;
1365 itmp.lsb = $5;
1366 tail.index.push_back(itmp);
1367 $$ = tmp;
1369 | heirarchy_identifier '[' expression K_PO_POS expression ']'
1370 { pform_name_t * tmp = $1;
1371 name_component_t&tail = tmp->back();
1372 index_component_t itmp;
1373 itmp.sel = index_component_t::SEL_IDX_UP;
1374 itmp.msb = $3;
1375 itmp.lsb = $5;
1376 tail.index.push_back(itmp);
1377 $$ = tmp;
1379 | heirarchy_identifier '[' expression K_PO_NEG expression ']'
1380 { pform_name_t * tmp = $1;
1381 name_component_t&tail = tmp->back();
1382 index_component_t itmp;
1383 itmp.sel = index_component_t::SEL_IDX_DO;
1384 itmp.msb = $3;
1385 itmp.lsb = $5;
1386 tail.index.push_back(itmp);
1387 $$ = tmp;
1391 /* This is a list of identifiers. The result is a list of strings,
1392 each one of the identifiers in the list. These are simple,
1393 non-hierarchical names separated by ',' characters. */
1394 list_of_identifiers
1395 : IDENTIFIER
1396 { $$ = list_from_identifier($1); }
1397 | list_of_identifiers ',' IDENTIFIER
1398 { $$ = list_from_identifier($1, $3); }
1402 /* The list_of_ports and list_of_port_declarations rules are the
1403 port list formats for module ports. The list_of_ports_opt rule is
1404 only used by the module start rule.
1406 The first, the list_of_ports, is the 1364-1995 format, a list of
1407 port names, including .name() syntax.
1409 The list_of_port_declarations the 1364-2001 format, an in-line
1410 declaration of the ports.
1412 In both cases, the list_of_ports and list_of_port_declarations
1413 returns an array of Module::port_t* items that include the name
1414 of the port internally and externally. The actual creation of the
1415 nets/variables is done in the declaration, whether internal to
1416 the port list or in amongst the module items. */
1418 list_of_ports
1419 : port_opt
1420 { svector<Module::port_t*>*tmp
1421 = new svector<Module::port_t*>(1);
1422 (*tmp)[0] = $1;
1423 $$ = tmp;
1425 | list_of_ports ',' port_opt
1426 { svector<Module::port_t*>*tmp
1427 = new svector<Module::port_t*>(*$1, $3);
1428 delete $1;
1429 $$ = tmp;
1433 list_of_port_declarations
1434 : port_declaration
1435 { svector<Module::port_t*>*tmp
1436 = new svector<Module::port_t*>(1);
1437 (*tmp)[0] = $1;
1439 * Uncommenting this makes lopd always fully specified.
1440 * Some wanted an implicit net to not be fully defined.
1442 * pform_set_net_range($1[0].name);
1444 $$ = tmp;
1446 | list_of_port_declarations ',' port_declaration
1447 { svector<Module::port_t*>*tmp
1448 = new svector<Module::port_t*>(*$1, $3);
1449 delete $1;
1451 * Same as above.
1453 * pform_set_net_range($3[0].name);
1455 $$ = tmp;
1457 | list_of_port_declarations ',' IDENTIFIER
1458 { Module::port_t*ptmp;
1459 ptmp = pform_module_port_reference($3, @3.text,
1460 @3.first_line);
1461 svector<Module::port_t*>*tmp
1462 = new svector<Module::port_t*>(*$1, ptmp);
1464 /* Get the port declaration details, the port type
1465 and what not, from context data stored by the
1466 last port_declaration rule. */
1467 pform_module_define_port(@3, $3,
1468 port_declaration_context.port_type,
1469 port_declaration_context.port_net_type,
1470 port_declaration_context.sign_flag,
1471 port_declaration_context.range, 0);
1472 delete $1;
1474 * Same as above.
1476 * pform_set_net_range($3);
1478 $$ = tmp;
1482 port_declaration
1483 : attribute_list_opt
1484 K_input 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::PINPUT,
1489 $3, $4, $5, $1);
1490 port_declaration_context.port_type = NetNet::PINPUT;
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_inout net_type_opt 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::PINOUT,
1504 $3, $4, $5, $1);
1505 port_declaration_context.port_type = NetNet::PINOUT;
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 net_type_opt signed_opt range_opt IDENTIFIER
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;
1524 delete $1;
1525 delete $6;
1526 $$ = ptmp;
1528 | attribute_list_opt
1529 K_output var_type signed_opt range_opt IDENTIFIER
1530 { Module::port_t*ptmp;
1531 ptmp = pform_module_port_reference($6, @2.text,
1532 @2.first_line);
1533 pform_module_define_port(@2, $6, NetNet::POUTPUT,
1534 $3, $4, $5, $1);
1535 port_declaration_context.port_type = NetNet::POUTPUT;
1536 port_declaration_context.port_net_type = $3;
1537 port_declaration_context.sign_flag = $4;
1538 port_declaration_context.range = $5;
1539 delete $1;
1540 delete $6;
1541 $$ = ptmp;
1543 | attribute_list_opt
1544 K_output var_type signed_opt range_opt IDENTIFIER '=' expression
1545 { Module::port_t*ptmp;
1546 ptmp = pform_module_port_reference($6, @2.text,
1547 @2.first_line);
1548 pform_module_define_port(@2, $6, NetNet::POUTPUT,
1549 $3, $4, $5, $1);
1550 port_declaration_context.port_type = NetNet::POUTPUT;
1551 port_declaration_context.port_net_type = $3;
1552 port_declaration_context.sign_flag = $4;
1553 port_declaration_context.range = $5;
1555 if (! pform_expression_is_constant($8))
1556 yyerror(@8, "error: register declaration assignment"
1557 " value must be a constant expression.");
1558 pform_make_reginit(@6, $6, $8);
1560 delete $1;
1561 delete $6;
1562 $$ = ptmp;
1568 net_type_opt
1569 : net_type { $$ = $1; }
1570 | { $$ = NetNet::IMPLICIT; }
1573 signed_opt : K_signed { $$ = true; } | {$$ = false; } ;
1575 /* An lpvalue is the expression that can go on the left side of a
1576 procedural assignment. This rule handles only procedural
1577 assignments. It is more limited then the general expr_primary
1578 rule to reflect the rules for assignment l-values. */
1579 lpvalue
1580 : heirarchy_identifier
1581 { PEIdent*tmp = new PEIdent(*$1);
1582 tmp->set_file(@1.text);
1583 tmp->set_lineno(@1.first_line);
1584 $$ = tmp;
1585 delete $1;
1587 | '{' expression_list_proper '}'
1588 { PEConcat*tmp = new PEConcat(*$2);
1589 tmp->set_file(@1.text);
1590 tmp->set_lineno(@1.first_line);
1591 delete $2;
1592 $$ = tmp;
1597 /* Continuous assignments have a list of individual assignments. */
1599 cont_assign
1600 : lpvalue '=' expression
1601 { svector<PExpr*>*tmp = new svector<PExpr*>(2);
1602 (*tmp)[0] = $1;
1603 (*tmp)[1] = $3;
1604 $$ = tmp;
1608 cont_assign_list
1609 : cont_assign_list ',' cont_assign
1610 { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, *$3);
1611 delete $1;
1612 delete $3;
1613 $$ = tmp;
1615 | cont_assign
1616 { $$ = $1; }
1620 /* This is the global structure of a module. A module in a start
1621 section, with optional ports, then an optional list of module
1622 items, and finally an end marker. */
1624 module : attribute_list_opt module_start IDENTIFIER
1625 { pform_startmodule($3, @2.text, @2.first_line, $1); }
1626 module_parameter_port_list_opt
1627 module_port_list_opt ';'
1628 { pform_module_set_ports($6); }
1629 module_item_list_opt
1630 K_endmodule
1631 { pform_endmodule($3);
1632 delete $3;
1637 module_start : K_module | K_macromodule ;
1639 module_port_list_opt
1640 : '(' list_of_ports ')' { $$ = $2; }
1641 | '(' list_of_port_declarations ')' { $$ = $2; }
1642 | { $$ = 0; }
1645 /* Module declarations include optional ANSII style module parameter
1646 ports. These are simply advance ways to declare parameters, so
1647 that the port declarations may use them. */
1648 module_parameter_port_list_opt
1650 | '#' '(' module_parameter_port_list ')'
1653 module_parameter_port_list
1654 : K_parameter parameter_assign
1655 | module_parameter_port_list ',' parameter_assign
1656 | module_parameter_port_list ',' K_parameter parameter_assign
1659 module_item
1661 /* This rule detects net declarations that possibly include a
1662 primitive type, an optional vector range and signed flag. This
1663 also includes an optional delay set. The values are then applied
1664 to a list of names. If the primitive type is not specified, then
1665 resort to the default type LOGIC. */
1667 : attribute_list_opt net_type
1668 primitive_type_opt signed_opt range_opt
1669 delay3_opt
1670 net_variable_list ';'
1672 { ivl_variable_type_t dtype = $3;
1673 if (dtype == IVL_VT_NO_TYPE)
1674 dtype = IVL_VT_LOGIC;
1675 pform_makewire(@2, $5, $4, $7, $2,
1676 NetNet::NOT_A_PORT, dtype, $1);
1677 if ($6 != 0) {
1678 yyerror(@6, "sorry: net delays not supported.");
1679 delete $6;
1681 if ($1) delete $1;
1684 /* Very similar to the rule above, but this takes a list of
1685 net_decl_assigns, which are <name> = <expr> assignment
1686 declarations. */
1688 | attribute_list_opt net_type
1689 primitive_type_opt signed_opt range_opt
1690 delay3_opt net_decl_assigns ';'
1692 { ivl_variable_type_t dtype = $3;
1693 if (dtype == IVL_VT_NO_TYPE)
1694 dtype = IVL_VT_LOGIC;
1695 pform_makewire(@2, $5, $4, $6,
1696 str_strength, $7, $2, dtype);
1697 if ($1) {
1698 yyerror(@2, "sorry: Attributes not supported "
1699 "on net declaration assignments.");
1700 delete $1;
1704 /* This form doesn't have the range, but does have strengths. This
1705 gives strength to the assignment drivers. */
1707 | attribute_list_opt net_type
1708 primitive_type_opt signed_opt
1709 drive_strength net_decl_assigns ';'
1711 { ivl_variable_type_t dtype = $3;
1712 if (dtype == IVL_VT_NO_TYPE)
1713 dtype = IVL_VT_LOGIC;
1714 pform_makewire(@2, 0, $4, 0, $5, $6, $2, dtype);
1715 if ($1) {
1716 yyerror(@2, "sorry: Attributes not supported "
1717 "on net declaration assignments.");
1718 delete $1;
1722 | K_trireg charge_strength_opt range_opt delay3_opt list_of_identifiers ';'
1723 { yyerror(@1, "sorry: trireg nets not supported.");
1724 delete $3;
1725 delete $4;
1728 | port_type signed_opt range_opt delay3_opt list_of_identifiers ';'
1729 { pform_set_port_type(@1, $5, $3, $2, $1);
1732 /* The next two rules handle Verilog 2001 statements of the form:
1733 input wire signed [h:l] <list>;
1734 This creates the wire and sets the port type all at once. */
1736 | port_type net_type signed_opt range_opt list_of_identifiers ';'
1737 { pform_makewire(@1, $4, $3, $5, $2, $1, IVL_VT_NO_TYPE, 0,
1738 SR_BOTH);
1741 | K_output var_type signed_opt range_opt list_of_identifiers ';'
1742 { pform_makewire(@1, $4, $3, $5, $2, NetNet::POUTPUT,
1743 IVL_VT_NO_TYPE, 0, SR_BOTH);
1746 /* var_type declaration (reg variables) cannot be input or output,
1747 because the port declaration implies an external driver, which
1748 cannot be attached to a reg. These rules catch that error early. */
1750 | K_input var_type signed_opt range_opt list_of_identifiers ';'
1751 { pform_makewire(@1, $4, $3, $5, $2, NetNet::PINPUT,
1752 IVL_VT_NO_TYPE, 0);
1753 yyerror(@2, "error: reg variables cannot be inputs.");
1756 | K_inout var_type signed_opt range_opt list_of_identifiers ';'
1757 { pform_makewire(@1, $4, $3, $5, $2, NetNet::PINOUT,
1758 IVL_VT_NO_TYPE, 0);
1759 yyerror(@2, "error: reg variables cannot be inouts.");
1762 | port_type signed_opt range_opt delay3_opt error ';'
1763 { yyerror(@1, "error: Invalid variable list"
1764 " in port declaration.");
1765 if ($3) delete $3;
1766 if ($4) delete $4;
1767 yyerrok;
1770 /* block_item_decl rule is shared with task blocks and named
1771 begin/end. */
1773 | block_item_decl
1775 /* */
1777 | K_defparam defparam_assign_list ';'
1778 | K_event list_of_identifiers ';'
1779 { pform_make_events($2, @1.text, @1.first_line);
1782 /* Most gate types have an optional drive strength and optional
1783 three-value delay. These rules handle the different cases. */
1785 | attribute_list_opt gatetype gate_instance_list ';'
1786 { pform_makegates($2, str_strength, 0, $3, $1);
1789 | attribute_list_opt gatetype delay3 gate_instance_list ';'
1790 { pform_makegates($2, str_strength, $3, $4, $1);
1793 | attribute_list_opt gatetype drive_strength gate_instance_list ';'
1794 { pform_makegates($2, $3, 0, $4, $1);
1797 | attribute_list_opt gatetype drive_strength delay3 gate_instance_list ';'
1798 { pform_makegates($2, $3, $4, $5, $1);
1801 /* Pullup and pulldown devices cannot have delays, and their
1802 strengths are limited. */
1804 | K_pullup gate_instance_list ';'
1805 { pform_makegates(PGBuiltin::PULLUP, pull_strength, 0,
1806 $2, 0);
1808 | K_pulldown gate_instance_list ';'
1809 { pform_makegates(PGBuiltin::PULLDOWN, pull_strength,
1810 0, $2, 0);
1813 | K_pullup '(' dr_strength1 ')' gate_instance_list ';'
1814 { pform_makegates(PGBuiltin::PULLUP, $3, 0, $5, 0);
1817 | K_pulldown '(' dr_strength0 ')' gate_instance_list ';'
1818 { pform_makegates(PGBuiltin::PULLDOWN, $3, 0, $5, 0);
1821 /* This rule handles instantiations of modules and user defined
1822 primitives. These devices to not have delay lists or strengths,
1823 but then can have parameter lists. */
1825 | attribute_list_opt
1826 IDENTIFIER parameter_value_opt gate_instance_list ';'
1827 { perm_string tmp1 = lex_strings.make($2);
1828 pform_make_modgates(tmp1, $3, $4);
1829 delete $2;
1830 if ($1) delete $1;
1833 | attribute_list_opt
1834 IDENTIFIER parameter_value_opt error ';'
1835 { yyerror(@2, "error: Invalid module instantiation");
1836 if ($1) delete $1;
1839 /* Continuous assignment can have an optional drive strength, then
1840 an optional delay3 that applies to all the assignments in the
1841 cont_assign_list. */
1843 | K_assign drive_strength_opt delay3_opt cont_assign_list ';'
1844 { pform_make_pgassign_list($4, $3, $2, @1.text, @1.first_line); }
1846 /* Always and initial items are behavioral processes. */
1848 | attribute_list_opt K_always statement
1849 { PProcess*tmp = pform_make_behavior(PProcess::PR_ALWAYS,
1850 $3, $1);
1851 tmp->set_file(@2.text);
1852 tmp->set_lineno(@2.first_line);
1854 | attribute_list_opt K_initial statement
1855 { PProcess*tmp = pform_make_behavior(PProcess::PR_INITIAL,
1856 $3, $1);
1857 tmp->set_file(@2.text);
1858 tmp->set_lineno(@2.first_line);
1861 /* The task declaration rule matches the task declaration
1862 header, then pushes the function scope. This causes the
1863 definitions in the task_body to take on the scope of the task
1864 instead of the module. Note that these runs accept for the task
1865 body statement_or_null, although the standard does not allow null
1866 statements in the task body. But we continue to accept it as an
1867 extension. */
1869 | K_task IDENTIFIER ';'
1870 { pform_push_scope($2); }
1871 task_item_list_opt
1872 statement_or_null
1873 K_endtask
1874 { PTask*tmp = new PTask;
1875 perm_string tmp2 = lex_strings.make($2);
1876 tmp->set_file(@1.text);
1877 tmp->set_lineno(@1.first_line);
1878 tmp->set_ports($5);
1879 tmp->set_statement($6);
1880 pform_set_task(tmp2, tmp);
1881 pform_pop_scope();
1882 delete $2;
1885 | K_task IDENTIFIER
1886 { pform_push_scope($2); }
1887 '(' task_port_decl_list ')' ';'
1888 task_item_list_opt
1889 statement_or_null
1890 K_endtask
1891 { PTask*tmp = new PTask;
1892 perm_string tmp2 = lex_strings.make($2);
1893 tmp->set_file(@1.text);
1894 tmp->set_lineno(@1.first_line);
1895 tmp->set_ports($5);
1896 tmp->set_statement($9);
1897 pform_set_task(tmp2, tmp);
1898 pform_pop_scope();
1899 delete $2;
1902 /* The function declaration rule matches the function declaration
1903 header, then pushes the function scope. This causes the
1904 definitions in the func_body to take on the scope of the function
1905 instead of the module. */
1907 | K_function function_range_or_type_opt IDENTIFIER ';'
1908 { pform_push_scope($3); }
1909 function_item_list statement
1910 K_endfunction
1911 { perm_string name = lex_strings.make($3);
1912 PFunction *tmp = new PFunction(name);
1913 tmp->set_file(@1.text);
1914 tmp->set_lineno(@1.first_line);
1915 tmp->set_ports($6);
1916 tmp->set_statement($7);
1917 tmp->set_return($2);
1918 pform_set_function(name, tmp);
1919 pform_pop_scope();
1920 delete $3;
1923 /* A generate region can contain further module items. Actually, it
1924 is supposed to be limited to certain kinds of module items, but
1925 the semantic tests will check that for us. */
1927 | K_generate module_item_list_opt K_endgenerate
1929 | K_genvar list_of_identifiers ';'
1930 { pform_genvars($2); }
1932 | K_for '(' IDENTIFIER '=' expression ';'
1933 expression ';'
1934 IDENTIFIER '=' expression ')'
1935 { pform_start_generate_for(@1, $3, $5, $7, $9, $11); }
1936 generate_block
1937 { pform_endgenerate(); }
1939 | generate_if
1940 generate_block_opt
1941 K_else
1942 { pform_start_generate_else(@1); }
1943 generate_block
1944 { pform_endgenerate(); }
1946 | generate_if
1947 generate_block_opt %prec less_than_K_else
1948 { pform_endgenerate(); }
1950 /* specify blocks are parsed but ignored. */
1952 | K_specify K_endspecify
1953 { /* empty lists are legal syntax. */ }
1955 | K_specify specify_item_list K_endspecify
1959 | K_specify error K_endspecify
1960 { yyerror(@1, "error: syntax error in specify block");
1961 yyerrok;
1964 /* These rules match various errors that the user can type into
1965 module items. These rules try to catch them at a point where a
1966 reasonable error message can be produced. */
1968 | K_module error ';'
1969 { yyerror(@2, "error: missing endmodule or attempt to "
1970 "nest modules.");
1971 pform_error_nested_modules();
1972 yyerrok;
1975 | error ';'
1976 { yyerror(@2, "error: invalid module item.");
1977 yyerrok;
1980 | K_assign error '=' expression ';'
1981 { yyerror(@1, "error: syntax error in left side "
1982 "of continuous assignment.");
1983 yyerrok;
1986 | K_assign error ';'
1987 { yyerror(@1, "error: syntax error in "
1988 "continuous assignment");
1989 yyerrok;
1992 | K_function error K_endfunction
1993 { yyerror(@1, "error: I give up on this "
1994 "function definition.");
1995 yyerrok;
1998 /* These rules are for the Icarus Verilog specific $attribute
1999 extensions. Then catch the parameters of the $attribute keyword. */
2001 | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';'
2002 { perm_string tmp3 = lex_strings.make($3);
2003 perm_string tmp5 = lex_strings.make($5);
2004 pform_set_attrib(tmp3, tmp5, $7);
2005 delete $3;
2006 delete $5;
2008 | KK_attribute '(' error ')' ';'
2009 { yyerror(@1, "error: Malformed $attribute parameter list."); }
2012 generate_if : K_if '(' expression ')' { pform_start_generate_if(@1, $3); }
2014 module_item_list
2015 : module_item_list module_item
2016 | module_item
2019 module_item_list_opt
2020 : module_item_list
2024 /* A generate block is the thing within a generate scheme. It may be
2025 a single module item, an anonymous block of module items, or a
2026 named module item. In all cases, the meat is in the module items
2027 inside, and the processing is done by the module_item rules. We
2028 only need to take note here of the scope name, if any. */
2030 generate_block
2031 : module_item
2032 | K_begin module_item_list_opt K_end
2033 | K_begin ':' IDENTIFIER module_item_list_opt K_end
2034 { pform_generate_block_name($3); }
2037 generate_block_opt : generate_block | ';' ;
2040 /* A net declaration assignment allows the programmer to combine the
2041 net declaration and the continuous assignment into a single
2042 statement.
2044 Note that the continuous assignment statement is generated as a
2045 side effect, and all I pass up is the name of the l-value. */
2047 net_decl_assign
2048 : IDENTIFIER '=' expression
2049 { net_decl_assign_t*tmp = new net_decl_assign_t;
2050 tmp->next = tmp;
2051 tmp->name = $1;
2052 tmp->expr = $3;
2053 $$ = tmp;
2057 net_decl_assigns
2058 : net_decl_assigns ',' net_decl_assign
2059 { net_decl_assign_t*tmp = $1;
2060 $3->next = tmp->next;
2061 tmp->next = $3;
2062 $$ = tmp;
2064 | net_decl_assign
2065 { $$ = $1;
2069 primitive_type
2070 : K_logic { $$ = IVL_VT_LOGIC; }
2071 | K_bool { $$ = IVL_VT_BOOL; }
2072 | K_real { $$ = IVL_VT_REAL; }
2075 primitive_type_opt : primitive_type { $$ = $1; } | { $$ = IVL_VT_NO_TYPE; } ;
2077 net_type
2078 : K_wire { $$ = NetNet::WIRE; }
2079 | K_tri { $$ = NetNet::TRI; }
2080 | K_tri1 { $$ = NetNet::TRI1; }
2081 | K_supply0 { $$ = NetNet::SUPPLY0; }
2082 | K_wand { $$ = NetNet::WAND; }
2083 | K_triand { $$ = NetNet::TRIAND; }
2084 | K_tri0 { $$ = NetNet::TRI0; }
2085 | K_supply1 { $$ = NetNet::SUPPLY1; }
2086 | K_wor { $$ = NetNet::WOR; }
2087 | K_trior { $$ = NetNet::TRIOR; }
2088 | K_wone { $$ = NetNet::WONE; }
2091 var_type
2092 : K_reg { $$ = NetNet::REG; }
2095 /* In this rule we have matched the "parameter" keyword. The rule
2096 generates a type (optional) and a list of assignments. */
2098 parameter_assign_decl
2099 : parameter_assign_list
2100 | range { active_range = $1; active_signed = false; }
2101 parameter_assign_list
2102 { active_range = 0;
2103 active_signed = false;
2105 | K_signed range { active_range = $2; active_signed = true; }
2106 parameter_assign_list
2107 { active_range = 0;
2108 active_signed = false;
2110 | K_integer { active_range = 0; active_signed = true; }
2111 parameter_assign_list
2112 { active_range = 0;
2113 active_signed = false;
2117 parameter_assign_list
2118 : parameter_assign
2119 | parameter_assign_list ',' parameter_assign
2122 parameter_assign
2123 : IDENTIFIER '=' expression
2124 { PExpr*tmp = $3;
2125 if (!pform_expression_is_constant(tmp)) {
2126 yyerror(@3, "error: parameter value "
2127 "must be a constant expression.");
2128 delete tmp;
2129 tmp = 0;
2130 } else {
2131 pform_set_parameter(lex_strings.make($1),
2132 active_signed,
2133 active_range, tmp);
2135 delete $1;
2139 /* Localparam assignments and assignment lists are broken into
2140 separate BNF so that I can call slightly different parameter
2141 handling code. They parse the same as parameters, they just
2142 behave differently when someone tries to override them. */
2144 localparam_assign
2145 : IDENTIFIER '=' expression
2146 { PExpr*tmp = $3;
2147 if (!pform_expression_is_constant(tmp)) {
2148 yyerror(@3, "error: parameter value "
2149 "must be constant.");
2150 delete tmp;
2151 tmp = 0;
2152 } else {
2153 pform_set_localparam(lex_strings.make($1),
2154 active_signed,
2155 active_range, tmp);
2157 delete $1;
2161 localparam_assign_decl
2162 : localparam_assign_list
2163 | range { active_range = $1; active_signed = false; }
2164 localparam_assign_list
2165 { active_range = 0;
2166 active_signed = false;
2168 | K_signed range { active_range = $2; active_signed = true; }
2169 localparam_assign_list
2170 { active_range = 0;
2171 active_signed = false;
2175 localparam_assign_list
2176 : localparam_assign
2177 | localparam_assign_list ',' localparam_assign
2182 /* The parameters of a module instance can be overridden by writing
2183 a list of expressions in a syntax much like a delay list. (The
2184 difference being the list can have any length.) The pform that
2185 attaches the expression list to the module checks that the
2186 expressions are constant.
2188 Although the BNF in IEEE1364-1995 implies that parameter value
2189 lists must be in parentheses, in practice most compilers will
2190 accept simple expressions outside of parentheses if there is only
2191 one value, so I'll accept simple numbers here.
2193 The parameter value by name syntax is OVI enhancement BTF-B06 as
2194 approved by WG1364 on 6/28/1998. */
2196 parameter_value_opt
2197 : '#' '(' expression_list_with_nuls ')'
2198 { struct parmvalue_t*tmp = new struct parmvalue_t;
2199 tmp->by_order = $3;
2200 tmp->by_name = 0;
2201 $$ = tmp;
2203 | '#' '(' parameter_value_byname_list ')'
2204 { struct parmvalue_t*tmp = new struct parmvalue_t;
2205 tmp->by_order = 0;
2206 tmp->by_name = $3;
2207 $$ = tmp;
2209 | '#' DEC_NUMBER
2210 { assert($2);
2211 PENumber*tmp = new PENumber($2);
2212 tmp->set_file(@1.text);
2213 tmp->set_lineno(@1.first_line);
2215 struct parmvalue_t*lst = new struct parmvalue_t;
2216 lst->by_order = new svector<PExpr*>(1);
2217 (*lst->by_order)[0] = tmp;
2218 lst->by_name = 0;
2219 $$ = lst;
2221 | '#' error
2222 { yyerror(@1, "error: syntax error in parameter value "
2223 "assignment list.");
2224 $$ = 0;
2227 { $$ = 0; }
2230 parameter_value_byname
2231 : '.' IDENTIFIER '(' expression ')'
2232 { named_pexpr_t*tmp = new named_pexpr_t;
2233 tmp->name = lex_strings.make($2);
2234 tmp->parm = $4;
2235 free($2);
2236 $$ = tmp;
2238 | '.' IDENTIFIER '(' ')'
2239 { named_pexpr_t*tmp = new named_pexpr_t;
2240 tmp->name = lex_strings.make($2);
2241 tmp->parm = 0;
2242 free($2);
2243 $$ = tmp;
2247 parameter_value_byname_list
2248 : parameter_value_byname
2249 { svector<named_pexpr_t*>*tmp = new svector<named_pexpr_t*>(1);
2250 (*tmp)[0] = $1;
2251 $$ = tmp;
2253 | parameter_value_byname_list ',' parameter_value_byname
2254 { svector<named_pexpr_t*>*tmp =
2255 new svector<named_pexpr_t*>(*$1,$3);
2256 delete $1;
2257 $$ = tmp;
2262 /* The port (of a module) is a fairly complex item. Each port is
2263 handled as a Module::port_t object. A simple port reference has a
2264 name and a PExpr object, but more complex constructs are possible
2265 where the name can be attached to a list of PWire objects.
2267 The port_reference returns a Module::port_t, and so does the
2268 port_reference_list. The port_reference_list may have built up a
2269 list of PWires in the port_t object, but it is still a single
2270 Module::port_t object.
2272 The port rule below takes the built up Module::port_t object and
2273 tweaks its name as needed. */
2275 port
2276 : port_reference
2277 { $$ = $1; }
2279 /* This syntax attaches an external name to the port reference so
2280 that the caller can bind by name to non-trivial port
2281 references. The port_t object gets its PWire from the
2282 port_reference, but its name from the IDENTIFIER. */
2284 | '.' IDENTIFIER '(' port_reference ')'
2285 { Module::port_t*tmp = $4;
2286 tmp->name = lex_strings.make($2);
2287 delete $2;
2288 $$ = tmp;
2291 /* A port can also be a concatenation of port references. In this
2292 case the port does not have a name available to the outside, only
2293 positional parameter passing is possible here. */
2295 | '{' port_reference_list '}'
2296 { Module::port_t*tmp = $2;
2297 tmp->name = perm_string();
2298 $$ = tmp;
2301 /* This attaches a name to a port reference concatenation list so
2302 that parameter passing be name is possible. */
2304 | '.' IDENTIFIER '(' '{' port_reference_list '}' ')'
2305 { Module::port_t*tmp = $5;
2306 tmp->name = lex_strings.make($2);
2307 delete $2;
2308 $$ = tmp;
2312 port_opt
2313 : port { $$ = $1; }
2314 | { $$ = 0; }
2318 /* A port reference is an internal (to the module) name of the port,
2319 possibly with a part of bit select to attach it to specific bits
2320 of a signal fully declared inside the module.
2322 The parser creates a PEIdent for every port reference, even if the
2323 signal is bound to different ports. The elaboration figures out
2324 the mess that this creates. The port_reference (and the
2325 port_reference_list below) puts the port reference PEIdent into the
2326 port_t object to pass it up to the module declaration code. */
2328 port_reference
2330 : IDENTIFIER
2331 { Module::port_t*ptmp;
2332 ptmp = pform_module_port_reference($1, @1.text, @1.first_line);
2333 delete $1;
2334 $$ = ptmp;
2337 | IDENTIFIER '[' expression ':' expression ']'
2338 { if (!pform_expression_is_constant($3)) {
2339 yyerror(@3, "error: msb expression of "
2340 "port part select must be constant.");
2342 if (!pform_expression_is_constant($5)) {
2343 yyerror(@5, "error: lsb expression of "
2344 "port part select must be constant.");
2346 index_component_t itmp;
2347 itmp.sel = index_component_t::SEL_PART;
2348 itmp.msb = $3;
2349 itmp.lsb = $5;
2351 name_component_t ntmp (lex_strings.make($1));
2352 ntmp.index.push_back(itmp);
2354 pform_name_t pname;
2355 pname.push_back(ntmp);
2357 PEIdent*wtmp = new PEIdent(pname);
2358 wtmp->set_file(@1.text);
2359 wtmp->set_lineno(@1.first_line);
2361 Module::port_t*ptmp = new Module::port_t;
2362 ptmp->name = perm_string();
2363 ptmp->expr = svector<PEIdent*>(1);
2364 ptmp->expr[0] = wtmp;
2366 delete $1;
2367 $$ = ptmp;
2370 | IDENTIFIER '[' expression ']'
2371 { if (!pform_expression_is_constant($3)) {
2372 yyerror(@3, "error: port bit select "
2373 "must be constant.");
2375 index_component_t itmp;
2376 itmp.sel = index_component_t::SEL_BIT;
2377 itmp.msb = $3;
2378 itmp.lsb = 0;
2380 name_component_t ntmp (lex_strings.make($1));
2381 ntmp.index.push_back(itmp);
2383 pform_name_t pname;
2384 pname.push_back(ntmp);
2386 PEIdent*tmp = new PEIdent(pname);
2387 tmp->set_file(@1.text);
2388 tmp->set_lineno(@1.first_line);
2390 Module::port_t*ptmp = new Module::port_t;
2391 ptmp->name = perm_string();
2392 ptmp->expr = svector<PEIdent*>(1);
2393 ptmp->expr[0] = tmp;
2394 delete $1;
2395 $$ = ptmp;
2398 | IDENTIFIER '[' error ']'
2399 { yyerror(@1, "error: invalid port bit select");
2400 Module::port_t*ptmp = new Module::port_t;
2401 PEIdent*wtmp = new PEIdent(lex_strings.make($1));
2402 wtmp->set_file(@1.text);
2403 wtmp->set_lineno(@1.first_line);
2404 ptmp->name = lex_strings.make($1);
2405 ptmp->expr = svector<PEIdent*>(1);
2406 ptmp->expr[0] = wtmp;
2407 delete $1;
2408 $$ = ptmp;
2413 port_reference_list
2414 : port_reference
2415 { $$ = $1; }
2416 | port_reference_list ',' port_reference
2417 { Module::port_t*tmp = $1;
2418 tmp->expr = svector<PEIdent*>(tmp->expr, $3->expr);
2419 delete $3;
2420 $$ = tmp;
2424 /* The port_name rule is used with a module is being *instantiated*,
2425 and not when it is being declared. See the port rule if you are
2426 looking for the ports of a module declaration. */
2428 port_name
2429 : '.' IDENTIFIER '(' expression ')'
2430 { named_pexpr_t*tmp = new named_pexpr_t;
2431 tmp->name = lex_strings.make($2);
2432 tmp->parm = $4;
2433 delete $2;
2434 $$ = tmp;
2436 | '.' IDENTIFIER '(' error ')'
2437 { yyerror(@4, "error: invalid port connection expression.");
2438 named_pexpr_t*tmp = new named_pexpr_t;
2439 tmp->name = lex_strings.make($2);
2440 tmp->parm = 0;
2441 delete $2;
2442 $$ = tmp;
2444 | '.' IDENTIFIER '(' ')'
2445 { named_pexpr_t*tmp = new named_pexpr_t;
2446 tmp->name = lex_strings.make($2);
2447 tmp->parm = 0;
2448 delete $2;
2449 $$ = tmp;
2453 port_name_list
2454 : port_name_list ',' port_name
2455 { svector<named_pexpr_t*>*tmp;
2456 tmp = new svector<named_pexpr_t*>(*$1, $3);
2457 delete $1;
2458 $$ = tmp;
2460 | port_name
2461 { svector<named_pexpr_t*>*tmp = new svector<named_pexpr_t*>(1);
2462 (*tmp)[0] = $1;
2463 $$ = tmp;
2467 port_type
2468 : K_input { $$ = NetNet::PINPUT; }
2469 | K_output { $$ = NetNet::POUTPUT; }
2470 | K_inout { $$ = NetNet::PINOUT; }
2473 range
2474 : '[' expression ':' expression ']'
2475 { svector<PExpr*>*tmp = new svector<PExpr*> (2);
2476 if (!pform_expression_is_constant($2))
2477 yyerror(@2, "error: msb of range must be constant.");
2479 (*tmp)[0] = $2;
2481 if (!pform_expression_is_constant($4))
2482 yyerror(@4, "error: lsb of range must be constant.");
2484 (*tmp)[1] = $4;
2486 $$ = tmp;
2490 range_opt
2491 : range
2492 | { $$ = 0; }
2495 /* This is used to express the return type of a function. */
2496 function_range_or_type_opt
2497 : range { $$.range = $1; $$.type = PTF_REG; }
2498 | K_signed range { $$.range = $2; $$.type = PTF_REG_S; }
2499 | K_integer { $$.range = 0; $$.type = PTF_INTEGER; }
2500 | K_real { $$.range = 0; $$.type = PTF_REAL; }
2501 | K_realtime { $$.range = 0; $$.type = PTF_REALTIME; }
2502 | K_time { $$.range = 0; $$.type = PTF_TIME; }
2503 | { $$.range = 0; $$.type = PTF_REG; }
2506 /* The register_variable rule is matched only when I am parsing
2507 variables in a "reg" definition. I therefore know that I am
2508 creating registers and I do not need to let the containing rule
2509 handle it. The register variable list simply packs them together
2510 so that bit ranges can be assigned. */
2511 register_variable
2512 : IDENTIFIER
2513 { pform_makewire(@1, $1, NetNet::REG,
2514 NetNet::NOT_A_PORT,
2515 IVL_VT_NO_TYPE, 0);
2516 $$ = $1;
2518 | IDENTIFIER '=' expression
2519 { pform_makewire(@1, $1, NetNet::REG,
2520 NetNet::NOT_A_PORT,
2521 IVL_VT_NO_TYPE, 0);
2522 if (! pform_expression_is_constant($3))
2523 yyerror(@3, "error: register declaration assignment"
2524 " value must be a constant expression.");
2525 pform_make_reginit(@1, $1, $3);
2526 $$ = $1;
2528 | IDENTIFIER '[' expression ':' expression ']'
2529 { pform_makewire(@1, $1, NetNet::REG,
2530 NetNet::NOT_A_PORT,
2531 IVL_VT_NO_TYPE, 0);
2532 if (! pform_expression_is_constant($3))
2533 yyerror(@3, "error: msb of register range must be constant.");
2534 if (! pform_expression_is_constant($5))
2535 yyerror(@3, "error: lsb of register range must be constant.");
2536 pform_set_reg_idx($1, $3, $5);
2537 $$ = $1;
2541 register_variable_list
2542 : register_variable
2543 { list<perm_string>*tmp = new list<perm_string>;
2544 tmp->push_back(lex_strings.make($1));
2545 $$ = tmp;
2546 delete[]$1;
2548 | register_variable_list ',' register_variable
2549 { list<perm_string>*tmp = $1;
2550 tmp->push_back(lex_strings.make($3));
2551 $$ = tmp;
2552 delete[]$3;
2556 real_variable
2557 : IDENTIFIER
2558 { pform_makewire(@1, $1, NetNet::REG, NetNet::NOT_A_PORT, IVL_VT_REAL, 0);
2559 $$ = $1;
2561 | IDENTIFIER '=' expression
2562 { pform_makewire(@1, $1, NetNet::REG, NetNet::NOT_A_PORT, IVL_VT_REAL, 0);
2563 pform_make_reginit(@1, $1, $3);
2564 $$ = $1;
2568 real_variable_list
2569 : real_variable
2570 { list<perm_string>*tmp = new list<perm_string>;
2571 tmp->push_back(lex_strings.make($1));
2572 $$ = tmp;
2573 delete[]$1;
2575 | real_variable_list ',' real_variable
2576 { list<perm_string>*tmp = $1;
2577 tmp->push_back(lex_strings.make($3));
2578 $$ = tmp;
2579 delete[]$3;
2583 net_variable
2584 : IDENTIFIER
2585 { pform_makewire(@1, $1, NetNet::IMPLICIT,
2586 NetNet::NOT_A_PORT,
2587 IVL_VT_NO_TYPE, 0);
2588 $$ = $1;
2590 | IDENTIFIER '[' expression ':' expression ']'
2591 { pform_makewire(@1, $1, NetNet::IMPLICIT,
2592 NetNet::NOT_A_PORT,
2593 IVL_VT_NO_TYPE, 0);
2594 if (! pform_expression_is_constant($3))
2595 yyerror(@3, "error: msb of net range must be constant.");
2596 if (! pform_expression_is_constant($5))
2597 yyerror(@3, "error: lsb of net range must be constant.");
2598 pform_set_reg_idx($1, $3, $5);
2599 $$ = $1;
2602 net_variable_list
2603 : net_variable
2604 { list<perm_string>*tmp = new list<perm_string>;
2605 tmp->push_back(lex_strings.make($1));
2606 $$ = tmp;
2607 delete[]$1;
2609 | net_variable_list ',' net_variable
2610 { list<perm_string>*tmp = $1;
2611 tmp->push_back(lex_strings.make($3));
2612 $$ = tmp;
2613 delete[]$3;
2617 specify_item
2618 : K_specparam specparam_list ';'
2619 | specify_simple_path_decl ';'
2620 { pform_module_specify_path($1);
2622 | specify_edge_path_decl ';'
2623 { pform_module_specify_path($1);
2625 | K_if '(' expression ')' specify_simple_path_decl ';'
2626 { PSpecPath*tmp = $5;
2627 if (tmp) {
2628 tmp->conditional = true;
2629 tmp->condition = $3;
2631 pform_module_specify_path(tmp);
2633 | K_if '(' expression ')' specify_edge_path_decl ';'
2634 { PSpecPath*tmp = $5;
2635 if (tmp) {
2636 tmp->conditional = true;
2637 tmp->condition = $3;
2639 pform_module_specify_path(tmp);
2641 | K_ifnone specify_simple_path_decl ';'
2642 { PSpecPath*tmp = $2;
2643 if (tmp) {
2644 tmp->conditional = true;
2645 tmp->condition = 0;
2647 pform_module_specify_path(tmp);
2649 | K_Shold '(' spec_reference_event ',' spec_reference_event
2650 ',' delay_value spec_notifier_opt ')' ';'
2651 { delete $7;
2653 | K_Speriod '(' spec_reference_event ',' delay_value
2654 spec_notifier_opt ')' ';'
2655 { delete $5;
2657 | K_Srecovery '(' spec_reference_event ',' spec_reference_event
2658 ',' delay_value spec_notifier_opt ')' ';'
2659 { delete $7;
2661 | K_Ssetup '(' spec_reference_event ',' spec_reference_event
2662 ',' delay_value spec_notifier_opt ')' ';'
2663 { delete $7;
2665 | K_Ssetuphold '(' spec_reference_event ',' spec_reference_event
2666 ',' delay_value ',' delay_value spec_notifier_opt ')' ';'
2667 { delete $7;
2668 delete $9;
2670 | K_Srecrem '(' spec_reference_event ',' spec_reference_event
2671 ',' delay_value ',' delay_value spec_notifier_opt ')' ';'
2672 { delete $7;
2673 delete $9;
2675 | K_Swidth '(' spec_reference_event ',' delay_value ',' expression
2676 spec_notifier_opt ')' ';'
2677 { delete $5;
2678 delete $7;
2680 | K_Swidth '(' spec_reference_event ',' delay_value ')' ';'
2681 { delete $5;
2685 specify_item_list
2686 : specify_item
2687 | specify_item_list specify_item
2690 specify_edge_path_decl
2691 : specify_edge_path '=' '(' delay_value_list ')'
2692 { $$ = pform_assign_path_delay($1, $4); }
2693 | specify_edge_path '=' delay_value_simple
2694 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
2695 (*tmp)[0] = $3;
2696 $$ = pform_assign_path_delay($1, tmp);
2700 edge_operator : K_posedge { $$ = true; } | K_negedge { $$ = false; } ;
2702 specify_edge_path
2703 : '(' specify_path_identifiers spec_polarity
2704 K_EG '(' specify_path_identifiers polarity_operator expression ')' ')'
2705 { int edge_flag = 0;
2706 $$ = pform_make_specify_edge_path(@1, edge_flag, $2, $3, false, $6, $8); }
2707 | '(' edge_operator specify_path_identifiers spec_polarity
2708 K_EG '(' specify_path_identifiers polarity_operator expression ')' ')'
2709 { int edge_flag = $2? 1 : -1;
2710 $$ = pform_make_specify_edge_path(@1, edge_flag, $3, $4, false, $7, $9);}
2711 | '(' specify_path_identifiers spec_polarity
2712 K_SG '(' specify_path_identifiers polarity_operator expression ')' ')'
2713 { int edge_flag = 0;
2714 $$ = pform_make_specify_edge_path(@1, edge_flag, $2, $3, true, $6, $8); }
2715 | '(' edge_operator specify_path_identifiers spec_polarity
2716 K_SG '(' specify_path_identifiers polarity_operator expression ')' ')'
2717 { int edge_flag = $2? 1 : -1;
2718 $$ = pform_make_specify_edge_path(@1, edge_flag, $3, $4, true, $7, $9); }
2721 polarity_operator
2722 : K_PO_POS
2723 | K_PO_NEG
2724 | ':'
2727 specify_simple_path_decl
2728 : specify_simple_path '=' '(' delay_value_list ')'
2729 { $$ = pform_assign_path_delay($1, $4); }
2730 | specify_simple_path '=' delay_value_simple
2731 { svector<PExpr*>*tmp = new svector<PExpr*>(1);
2732 (*tmp)[0] = $3;
2733 $$ = pform_assign_path_delay($1, tmp);
2735 | specify_simple_path '=' '(' error ')'
2736 { yyerror(@2, "Syntax error in delay value list.");
2737 yyerrok;
2738 $$ = 0;
2742 specify_simple_path
2743 : '(' specify_path_identifiers spec_polarity
2744 K_EG specify_path_identifiers ')'
2745 { $$ = pform_make_specify_path(@1, $2, $3, false, $5); }
2746 | '(' specify_path_identifiers spec_polarity
2747 K_SG specify_path_identifiers ')'
2748 { $$ = pform_make_specify_path(@1, $2, $3, true, $5); }
2749 | '(' error ')'
2750 { yyerror(@2, "Invalid simple path");
2751 yyerrok;
2755 specify_path_identifiers
2756 : IDENTIFIER
2757 { list<perm_string>*tmp = new list<perm_string>;
2758 tmp->push_back(lex_strings.make($1));
2759 $$ = tmp;
2760 delete[]$1;
2762 | IDENTIFIER '[' expr_primary ']'
2763 { list<perm_string>*tmp = new list<perm_string>;
2764 tmp->push_back(lex_strings.make($1));
2765 $$ = tmp;
2766 delete[]$1;
2768 | specify_path_identifiers ',' IDENTIFIER
2769 { list<perm_string>*tmp = $1;
2770 tmp->push_back(lex_strings.make($3));
2771 $$ = tmp;
2772 delete[]$3;
2774 | specify_path_identifiers ',' IDENTIFIER '[' expr_primary ']'
2775 { list<perm_string>*tmp = $1;
2776 tmp->push_back(lex_strings.make($3));
2777 $$ = tmp;
2778 delete[]$3;
2782 specparam
2783 : IDENTIFIER '=' expression
2784 { PExpr*tmp = $3;
2785 pform_set_specparam(lex_strings.make($1), tmp);
2786 delete $1;
2788 | IDENTIFIER '=' expression ':' expression ':' expression
2789 { PExpr*tmp = 0;
2790 switch (min_typ_max_flag) {
2791 case MIN:
2792 tmp = $3;
2793 delete $5;
2794 delete $7;
2795 break;
2796 case TYP:
2797 delete $3;
2798 tmp = $5;
2799 delete $7;
2800 break;
2801 case MAX:
2802 delete $3;
2803 delete $5;
2804 tmp = $7;
2805 break;
2807 pform_set_specparam(lex_strings.make($1), tmp);
2808 delete $1;
2810 | PATHPULSE_IDENTIFIER '=' expression
2811 { delete $1;
2812 delete $3;
2814 | PATHPULSE_IDENTIFIER '=' '(' expression ',' expression ')'
2815 { delete $1;
2816 delete $4;
2817 delete $6;
2821 specparam_list
2822 : specparam
2823 | specparam_list ',' specparam
2826 spec_polarity
2827 : '+' { $$ = '+'; }
2828 | '-' { $$ = '-'; }
2829 | { $$ = 0; }
2832 spec_reference_event
2833 : K_posedge expression
2834 { delete $2; }
2835 | K_negedge expression
2836 { delete $2; }
2837 | K_posedge expr_primary K_TAND expression
2838 { delete $2;
2839 delete $4;
2841 | K_negedge expr_primary K_TAND expression
2842 { delete $2;
2843 delete $4;
2845 | K_edge '[' edge_descriptor_list ']' expr_primary K_TAND expression
2846 { delete $5;
2847 delete $7;
2849 | expr_primary K_TAND expression
2850 { delete $1;
2851 delete $3;
2853 | expr_primary
2854 { delete $1; }
2857 /* The edge_descriptor is detected by the lexor as the various
2858 2-letter edge sequences that are supported here. For now, we
2859 don't care what they are, because we do not yet support specify
2860 edge events. */
2861 edge_descriptor_list
2862 : edge_descriptor_list ',' K_edge_descriptor
2863 | K_edge_descriptor
2866 spec_notifier_opt
2867 : /* empty */
2869 | spec_notifier
2872 spec_notifier
2873 : ','
2875 | ',' heirarchy_identifier
2876 { delete $2; }
2877 | spec_notifier ','
2879 | spec_notifier ',' heirarchy_identifier
2880 { delete $3; }
2881 | IDENTIFIER
2882 { delete $1; }
2886 statement
2888 /* assign and deassign statements are procedural code to do
2889 structural assignments, and to turn that structural assignment
2890 off. This stronger then any other assign, but weaker then the
2891 force assignments. */
2893 : K_assign lpvalue '=' expression ';'
2894 { PCAssign*tmp = new PCAssign($2, $4);
2895 tmp->set_file(@1.text);
2896 tmp->set_lineno(@1.first_line);
2897 $$ = tmp;
2900 | K_deassign lpvalue ';'
2901 { PDeassign*tmp = new PDeassign($2);
2902 tmp->set_file(@1.text);
2903 tmp->set_lineno(@1.first_line);
2904 $$ = tmp;
2908 /* Force and release statements are similar to assignments,
2909 syntactically, but they will be elaborated differently. */
2911 | K_force lpvalue '=' expression ';'
2912 { PForce*tmp = new PForce($2, $4);
2913 tmp->set_file(@1.text);
2914 tmp->set_lineno(@1.first_line);
2915 $$ = tmp;
2917 | K_release lpvalue ';'
2918 { PRelease*tmp = new PRelease($2);
2919 tmp->set_file(@1.text);
2920 tmp->set_lineno(@1.first_line);
2921 $$ = tmp;
2924 /* begin-end blocks come in a variety of forms, including named and
2925 anonymous. The named blocks can also carry their own reg
2926 variables, which are placed in the scope created by the block
2927 name. These are handled by pushing the scope name then matching
2928 the declarations. The scope is popped at the end of the block. */
2930 | K_begin statement_list K_end
2931 { PBlock*tmp = new PBlock(PBlock::BL_SEQ, *$2);
2932 tmp->set_file(@1.text);
2933 tmp->set_lineno(@1.first_line);
2934 delete $2;
2935 $$ = tmp;
2937 | K_begin ':' IDENTIFIER
2938 { pform_push_scope($3); }
2939 block_item_decls_opt
2940 statement_list K_end
2941 { pform_pop_scope();
2942 PBlock*tmp = new PBlock(lex_strings.make($3),
2943 PBlock::BL_SEQ, *$6);
2944 tmp->set_file(@1.text);
2945 tmp->set_lineno(@1.first_line);
2946 delete $3;
2947 delete $6;
2948 $$ = tmp;
2950 | K_begin K_end
2951 { PBlock*tmp = new PBlock(PBlock::BL_SEQ);
2952 tmp->set_file(@1.text);
2953 tmp->set_lineno(@1.first_line);
2954 $$ = tmp;
2956 | K_begin ':' IDENTIFIER K_end
2957 { PBlock*tmp = new PBlock(PBlock::BL_SEQ);
2958 tmp->set_file(@1.text);
2959 tmp->set_lineno(@1.first_line);
2960 $$ = tmp;
2962 | K_begin error K_end
2963 { yyerrok; }
2965 /* fork-join blocks are very similar to begin-end blocks. In fact,
2966 from the parser's perspective there is no real difference. All we
2967 need to do is remember that this is a parallel block so that the
2968 code generator can do the right thing. */
2970 | K_fork ':' IDENTIFIER
2971 { pform_push_scope($3); }
2972 block_item_decls_opt
2973 statement_list K_join
2974 { pform_pop_scope();
2975 PBlock*tmp = new PBlock(lex_strings.make($3),
2976 PBlock::BL_PAR, *$6);
2977 tmp->set_file(@1.text);
2978 tmp->set_lineno(@1.first_line);
2979 delete $3;
2980 delete $6;
2981 $$ = tmp;
2983 | K_fork K_join
2984 { PBlock*tmp = new PBlock(PBlock::BL_PAR);
2985 tmp->set_file(@1.text);
2986 tmp->set_lineno(@1.first_line);
2987 $$ = tmp;
2989 | K_fork ':' IDENTIFIER K_join
2990 { PBlock*tmp = new PBlock(PBlock::BL_PAR);
2991 tmp->set_file(@1.text);
2992 tmp->set_lineno(@1.first_line);
2993 delete $3;
2994 $$ = tmp;
2997 | K_disable heirarchy_identifier ';'
2998 { PDisable*tmp = new PDisable(*$2);
2999 tmp->set_file(@1.text);
3000 tmp->set_lineno(@1.first_line);
3001 delete $2;
3002 $$ = tmp;
3004 | K_TRIGGER heirarchy_identifier ';'
3005 { PTrigger*tmp = new PTrigger(*$2);
3006 tmp->set_file(@2.text);
3007 tmp->set_lineno(@2.first_line);
3008 delete $2;
3009 $$ = tmp;
3011 | K_forever statement
3012 { PForever*tmp = new PForever($2);
3013 tmp->set_file(@1.text);
3014 tmp->set_lineno(@1.first_line);
3015 $$ = tmp;
3017 | K_fork statement_list K_join
3018 { PBlock*tmp = new PBlock(PBlock::BL_PAR, *$2);
3019 tmp->set_file(@1.text);
3020 tmp->set_lineno(@1.first_line);
3021 delete $2;
3022 $$ = tmp;
3024 | K_repeat '(' expression ')' statement
3025 { PRepeat*tmp = new PRepeat($3, $5);
3026 tmp->set_file(@1.text);
3027 tmp->set_lineno(@1.first_line);
3028 $$ = tmp;
3030 | K_case '(' expression ')' case_items K_endcase
3031 { PCase*tmp = new PCase(NetCase::EQ, $3, $5);
3032 tmp->set_file(@1.text);
3033 tmp->set_lineno(@1.first_line);
3034 $$ = tmp;
3036 | K_casex '(' expression ')' case_items K_endcase
3037 { PCase*tmp = new PCase(NetCase::EQX, $3, $5);
3038 tmp->set_file(@1.text);
3039 tmp->set_lineno(@1.first_line);
3040 $$ = tmp;
3042 | K_casez '(' expression ')' case_items K_endcase
3043 { PCase*tmp = new PCase(NetCase::EQZ, $3, $5);
3044 tmp->set_file(@1.text);
3045 tmp->set_lineno(@1.first_line);
3046 $$ = tmp;
3048 | K_case '(' expression ')' error K_endcase
3049 { yyerrok; }
3050 | K_casex '(' expression ')' error K_endcase
3051 { yyerrok; }
3052 | K_casez '(' expression ')' error K_endcase
3053 { yyerrok; }
3054 | K_if '(' expression ')' statement_or_null %prec less_than_K_else
3055 { PCondit*tmp = new PCondit($3, $5, 0);
3056 tmp->set_file(@1.text);
3057 tmp->set_lineno(@1.first_line);
3058 $$ = tmp;
3060 | K_if '(' expression ')' statement_or_null K_else statement_or_null
3061 { PCondit*tmp = new PCondit($3, $5, $7);
3062 tmp->set_file(@1.text);
3063 tmp->set_lineno(@1.first_line);
3064 $$ = tmp;
3066 | K_if '(' error ')' statement_or_null %prec less_than_K_else
3067 { yyerror(@1, "error: Malformed conditional expression.");
3068 $$ = $5;
3070 | K_if '(' error ')' statement_or_null K_else statement_or_null
3071 { yyerror(@1, "error: Malformed conditional expression.");
3072 $$ = $5;
3074 | K_for '(' lpvalue '=' expression ';' expression ';'
3075 lpvalue '=' expression ')' statement
3076 { PForStatement*tmp = new PForStatement($3, $5, $7, $9, $11, $13);
3077 tmp->set_file(@1.text);
3078 tmp->set_lineno(@1.first_line);
3079 $$ = tmp;
3081 | K_for '(' lpvalue '=' expression ';' expression ';'
3082 error ')' statement
3083 { $$ = 0;
3084 yyerror(@9, "error: Error in for loop step assignment.");
3086 | K_for '(' lpvalue '=' expression ';' error ';'
3087 lpvalue '=' expression ')' statement
3088 { $$ = 0;
3089 yyerror(@7, "error: Error in for loop condition expression.");
3091 | K_for '(' error ')' statement
3092 { $$ = 0;
3093 yyerror(@3, "error: Incomprehensible for loop.");
3095 | K_while '(' expression ')' statement
3096 { PWhile*tmp = new PWhile($3, $5);
3097 $$ = tmp;
3099 | K_while '(' error ')' statement
3100 { $$ = 0;
3101 yyerror(@3, "error: Error in while loop condition.");
3103 | delay1 statement_or_null
3104 { PExpr*del = (*$1)[0];
3105 assert($1->count() == 1);
3106 PDelayStatement*tmp = new PDelayStatement(del, $2);
3107 tmp->set_file(@1.text);
3108 tmp->set_lineno(@1.first_line);
3109 $$ = tmp;
3111 | event_control statement_or_null
3112 { PEventStatement*tmp = $1;
3113 if (tmp == 0) {
3114 yyerror(@1, "error: Invalid event control.");
3115 $$ = 0;
3116 } else {
3117 tmp->set_statement($2);
3118 $$ = tmp;
3121 | '@' '*' statement_or_null
3122 { PEventStatement*tmp = new PEventStatement;
3123 tmp->set_file(@1.text);
3124 tmp->set_lineno(@1.first_line);
3125 tmp->set_statement($3);
3126 $$ = tmp;
3128 | '@' '(' '*' ')' statement_or_null
3129 { PEventStatement*tmp = new PEventStatement;
3130 tmp->set_file(@1.text);
3131 tmp->set_lineno(@1.first_line);
3132 tmp->set_statement($5);
3133 $$ = tmp;
3135 | lpvalue '=' expression ';'
3136 { PAssign*tmp = new PAssign($1,$3);
3137 tmp->set_file(@1.text);
3138 tmp->set_lineno(@1.first_line);
3139 $$ = tmp;
3141 | error '=' expression ';'
3142 { yyerror(@1, "Syntax in assignment statement l-value.");
3143 yyerrok;
3144 $$ = new PNoop;
3146 | lpvalue K_LE expression ';'
3147 { PAssignNB*tmp = new PAssignNB($1,$3);
3148 tmp->set_file(@1.text);
3149 tmp->set_lineno(@1.first_line);
3150 $$ = tmp;
3152 | error K_LE expression ';'
3153 { yyerror(@1, "Syntax in assignment statement l-value.");
3154 yyerrok;
3155 $$ = new PNoop;
3157 | lpvalue '=' delay1 expression ';'
3158 { assert($3->count() == 1);
3159 PExpr*del = (*$3)[0];
3160 PAssign*tmp = new PAssign($1,del,$4);
3161 tmp->set_file(@1.text);
3162 tmp->set_lineno(@1.first_line);
3163 $$ = tmp;
3165 | lpvalue K_LE delay1 expression ';'
3166 { assert($3->count() == 1);
3167 PExpr*del = (*$3)[0];
3168 PAssignNB*tmp = new PAssignNB($1,del,$4);
3169 tmp->set_file(@1.text);
3170 tmp->set_lineno(@1.first_line);
3171 $$ = tmp;
3173 | lpvalue '=' event_control expression ';'
3174 { PAssign*tmp = new PAssign($1,$3,$4);
3175 tmp->set_file(@1.text);
3176 tmp->set_lineno(@1.first_line);
3177 $$ = tmp;
3179 | lpvalue '=' K_repeat '(' expression ')' event_control expression ';'
3180 { PAssign*tmp = new PAssign($1,$7,$8);
3181 tmp->set_file(@1.text);
3182 tmp->set_lineno(@1.first_line);
3183 yyerror(@3, "sorry: repeat event control not supported.");
3184 delete $5;
3185 $$ = tmp;
3187 | lpvalue K_LE event_control expression ';'
3188 { yyerror(@1, "sorry: Event controls not supported here.");
3189 PAssignNB*tmp = new PAssignNB($1,$4);
3190 tmp->set_file(@1.text);
3191 tmp->set_lineno(@1.first_line);
3192 $$ = tmp;
3194 | lpvalue K_LE K_repeat '(' expression ')' event_control expression ';'
3195 { yyerror(@1, "sorry: Event controls not supported here.");
3196 delete $5;
3197 PAssignNB*tmp = new PAssignNB($1,$8);
3198 tmp->set_file(@1.text);
3199 tmp->set_lineno(@1.first_line);
3200 $$ = tmp;
3202 | K_wait '(' expression ')' statement_or_null
3203 { PEventStatement*tmp;
3204 PEEvent*etmp = new PEEvent(PEEvent::POSITIVE, $3);
3205 tmp = new PEventStatement(etmp);
3206 tmp->set_file(@1.text);
3207 tmp->set_lineno(@1.first_line);
3208 tmp->set_statement($5);
3209 $$ = tmp;
3211 | SYSTEM_IDENTIFIER '(' expression_list_with_nuls ')' ';'
3212 { PCallTask*tmp = new PCallTask(lex_strings.make($1), *$3);
3213 tmp->set_file(@1.text);
3214 tmp->set_lineno(@1.first_line);
3215 delete $1;
3216 delete $3;
3217 $$ = tmp;
3219 | SYSTEM_IDENTIFIER ';'
3220 { svector<PExpr*>pt (0);
3221 PCallTask*tmp = new PCallTask(lex_strings.make($1), pt);
3222 tmp->set_file(@1.text);
3223 tmp->set_lineno(@1.first_line);
3224 delete $1;
3225 $$ = tmp;
3227 | heirarchy_identifier '(' expression_list_proper ')' ';'
3228 { PCallTask*tmp = new PCallTask(*$1, *$3);
3229 tmp->set_file(@1.text);
3230 tmp->set_lineno(@1.first_line);
3231 delete $1;
3232 delete $3;
3233 $$ = tmp;
3236 /* NOTE: The standard doesn't really support an empty argument list
3237 between parentheses, but it seems natural, and people commonly
3238 want it. So accept it explicitly. */
3240 | heirarchy_identifier '(' ')' ';'
3241 { svector<PExpr*>pt (0);
3242 PCallTask*tmp = new PCallTask(*$1, pt);
3243 tmp->set_file(@1.text);
3244 tmp->set_lineno(@1.first_line);
3245 delete $1;
3246 $$ = tmp;
3248 | heirarchy_identifier ';'
3249 { svector<PExpr*>pt (0);
3250 PCallTask*tmp = new PCallTask(*$1, pt);
3251 tmp->set_file(@1.text);
3252 tmp->set_lineno(@1.first_line);
3253 delete $1;
3254 $$ = tmp;
3256 | error ';'
3257 { yyerror(@1, "error: malformed statement");
3258 yyerrok;
3259 $$ = new PNoop;
3263 statement_list
3264 : statement_list statement
3265 { svector<Statement*>*tmp = new svector<Statement*>(*$1, $2);
3266 delete $1;
3267 $$ = tmp;
3269 | statement
3270 { svector<Statement*>*tmp = new svector<Statement*>(1);
3271 (*tmp)[0] = $1;
3272 $$ = tmp;
3276 statement_or_null
3277 : statement
3278 | ';' { $$ = 0; }
3281 /* Task items are, other than the statement, task port items and
3282 other block items. */
3283 task_item
3284 : block_item_decl { $$ = new svector<PWire*>(0); }
3285 | task_port_item { $$ = $1; }
3288 task_port_item
3290 : K_input signed_opt range_opt list_of_identifiers ';'
3291 { svector<PWire*>*tmp
3292 = pform_make_task_ports(NetNet::PINPUT,
3293 IVL_VT_LOGIC, $2,
3294 $3, $4,
3295 @1.text, @1.first_line);
3296 $$ = tmp;
3298 | K_output signed_opt range_opt list_of_identifiers ';'
3299 { svector<PWire*>*tmp
3300 = pform_make_task_ports(NetNet::POUTPUT,
3301 IVL_VT_LOGIC, $2,
3302 $3, $4,
3303 @1.text, @1.first_line);
3304 $$ = tmp;
3306 | K_inout signed_opt range_opt list_of_identifiers ';'
3307 { svector<PWire*>*tmp
3308 = pform_make_task_ports(NetNet::PINOUT,
3309 IVL_VT_LOGIC, $2,
3310 $3, $4,
3311 @1.text, @1.first_line);
3312 $$ = tmp;
3315 /* When the port is an integer, infer a signed vector of the integer
3316 shape. Generate a range to make it work. */
3318 | K_input K_integer list_of_identifiers ';'
3319 { svector<PExpr*>*range_stub
3320 = new svector<PExpr*>(2);
3321 PExpr*re;
3322 re = new PENumber(new verinum(integer_width-1,
3323 integer_width));
3324 (*range_stub)[0] = re;
3325 re = new PENumber(new verinum((uint64_t)0, integer_width));
3326 (*range_stub)[1] = re;
3327 svector<PWire*>*tmp
3328 = pform_make_task_ports(NetNet::PINPUT,
3329 IVL_VT_LOGIC, true,
3330 range_stub, $3,
3331 @1.text, @1.first_line);
3332 $$ = tmp;
3334 | K_output K_integer list_of_identifiers ';'
3335 { svector<PExpr*>*range_stub
3336 = new svector<PExpr*>(2);
3337 PExpr*re;
3338 re = new PENumber(new verinum(integer_width-1,
3339 integer_width));
3340 (*range_stub)[0] = re;
3341 re = new PENumber(new verinum((uint64_t)0, integer_width));
3342 (*range_stub)[1] = re;
3343 svector<PWire*>*tmp
3344 = pform_make_task_ports(NetNet::POUTPUT,
3345 IVL_VT_LOGIC, true,
3346 range_stub, $3,
3347 @1.text, @1.first_line);
3348 $$ = tmp;
3350 | K_inout K_integer list_of_identifiers ';'
3351 { svector<PExpr*>*range_stub
3352 = new svector<PExpr*>(2);
3353 PExpr*re;
3354 re = new PENumber(new verinum(integer_width-1,
3355 integer_width));
3356 (*range_stub)[0] = re;
3357 re = new PENumber(new verinum((uint64_t)0, integer_width));
3358 (*range_stub)[1] = re;
3359 svector<PWire*>*tmp
3360 = pform_make_task_ports(NetNet::PINOUT,
3361 IVL_VT_LOGIC, true,
3362 range_stub, $3,
3363 @1.text, @1.first_line);
3364 $$ = tmp;
3367 /* Ports can be real. */
3369 | K_input K_real list_of_identifiers ';'
3370 { svector<PWire*>*tmp
3371 = pform_make_task_ports(NetNet::PINPUT,
3372 IVL_VT_REAL, false,
3373 0, $3,
3374 @1.text, @1.first_line);
3375 $$ = tmp;
3377 | K_output K_real list_of_identifiers ';'
3378 { svector<PWire*>*tmp
3379 = pform_make_task_ports(NetNet::POUTPUT,
3380 IVL_VT_REAL, true,
3381 0, $3,
3382 @1.text, @1.first_line);
3383 $$ = tmp;
3385 | K_inout K_real list_of_identifiers ';'
3386 { svector<PWire*>*tmp
3387 = pform_make_task_ports(NetNet::PINOUT,
3388 IVL_VT_REAL, true,
3389 0, $3,
3390 @1.text, @1.first_line);
3391 $$ = tmp;
3395 task_item_list
3396 : task_item_list task_item
3397 { svector<PWire*>*tmp = new svector<PWire*>(*$1, *$2);
3398 delete $1;
3399 delete $2;
3400 $$ = tmp;
3402 | task_item
3403 { $$ = $1; }
3406 task_item_list_opt
3407 : task_item_list
3408 { $$ = $1; }
3410 { $$ = 0; }
3413 task_port_decl
3415 : K_input signed_opt range_opt IDENTIFIER
3416 { svector<PWire*>*tmp
3417 = pform_make_task_ports(NetNet::PINPUT,
3418 IVL_VT_LOGIC, $2,
3419 $3, list_from_identifier($4),
3420 @1.text, @1.first_line);
3421 $$ = tmp;
3424 | K_output signed_opt range_opt IDENTIFIER
3425 { svector<PWire*>*tmp
3426 = pform_make_task_ports(NetNet::POUTPUT,
3427 IVL_VT_LOGIC, $2,
3428 $3, list_from_identifier($4),
3429 @1.text, @1.first_line);
3430 $$ = tmp;
3432 | K_inout signed_opt range_opt IDENTIFIER
3433 { svector<PWire*>*tmp
3434 = pform_make_task_ports(NetNet::PINOUT,
3435 IVL_VT_LOGIC, $2,
3436 $3, list_from_identifier($4),
3437 @1.text, @1.first_line);
3438 $$ = tmp;
3441 | K_input K_integer IDENTIFIER
3442 { svector<PExpr*>*range_stub
3443 = new svector<PExpr*>(2);
3444 PExpr*re;
3445 re = new PENumber(new verinum(integer_width-1,
3446 integer_width));
3447 (*range_stub)[0] = re;
3448 re = new PENumber(new verinum((uint64_t)0, integer_width));
3449 (*range_stub)[1] = re;
3450 svector<PWire*>*tmp
3451 = pform_make_task_ports(NetNet::PINPUT,
3452 IVL_VT_LOGIC, true,
3453 range_stub,
3454 list_from_identifier($3),
3455 @1.text, @1.first_line);
3456 $$ = tmp;
3458 | K_output K_integer IDENTIFIER
3459 { svector<PExpr*>*range_stub
3460 = new svector<PExpr*>(2);
3461 PExpr*re;
3462 re = new PENumber(new verinum(integer_width-1,
3463 integer_width));
3464 (*range_stub)[0] = re;
3465 re = new PENumber(new verinum((uint64_t)0, integer_width));
3466 (*range_stub)[1] = re;
3467 svector<PWire*>*tmp
3468 = pform_make_task_ports(NetNet::POUTPUT,
3469 IVL_VT_LOGIC, true,
3470 range_stub,
3471 list_from_identifier($3),
3472 @1.text, @1.first_line);
3473 $$ = tmp;
3475 | K_inout K_integer IDENTIFIER
3476 { svector<PExpr*>*range_stub
3477 = new svector<PExpr*>(2);
3478 PExpr*re;
3479 re = new PENumber(new verinum(integer_width-1,
3480 integer_width));
3481 (*range_stub)[0] = re;
3482 re = new PENumber(new verinum((uint64_t)0, integer_width));
3483 (*range_stub)[1] = re;
3484 svector<PWire*>*tmp
3485 = pform_make_task_ports(NetNet::PINOUT,
3486 IVL_VT_LOGIC, true,
3487 range_stub,
3488 list_from_identifier($3),
3489 @1.text, @1.first_line);
3490 $$ = tmp;
3493 /* Ports can be real. */
3495 | K_input K_real IDENTIFIER
3496 { svector<PWire*>*tmp
3497 = pform_make_task_ports(NetNet::PINPUT,
3498 IVL_VT_REAL, false,
3499 0, list_from_identifier($3),
3500 @1.text, @1.first_line);
3501 $$ = tmp;
3503 | K_output K_real IDENTIFIER
3504 { svector<PWire*>*tmp
3505 = pform_make_task_ports(NetNet::POUTPUT,
3506 IVL_VT_REAL, false,
3507 0, list_from_identifier($3),
3508 @1.text, @1.first_line);
3509 $$ = tmp;
3511 | K_inout K_real IDENTIFIER
3512 { svector<PWire*>*tmp
3513 = pform_make_task_ports(NetNet::PINOUT,
3514 IVL_VT_REAL, false,
3515 0, list_from_identifier($3),
3516 @1.text, @1.first_line);
3517 $$ = tmp;
3521 task_port_decl_list
3522 : task_port_decl_list ',' task_port_decl
3523 { svector<PWire*>*tmp = new svector<PWire*>(*$1, *$3);
3524 delete $1;
3525 delete $3;
3526 $$ = tmp;
3528 | task_port_decl
3529 { $$ = $1; }
3532 udp_body
3533 : K_table { lex_start_table(); }
3534 udp_entry_list
3535 K_endtable { lex_end_table(); $$ = $3; }
3538 udp_entry_list
3539 : udp_comb_entry_list
3540 | udp_sequ_entry_list
3543 udp_comb_entry
3544 : udp_input_list ':' udp_output_sym ';'
3545 { char*tmp = new char[strlen($1)+3];
3546 strcpy(tmp, $1);
3547 char*tp = tmp+strlen(tmp);
3548 *tp++ = ':';
3549 *tp++ = $3;
3550 *tp++ = 0;
3551 delete[]$1;
3552 $$ = tmp;
3556 udp_comb_entry_list
3557 : udp_comb_entry
3558 { list<string>*tmp = new list<string>;
3559 tmp->push_back($1);
3560 delete $1;
3561 $$ = tmp;
3563 | udp_comb_entry_list udp_comb_entry
3564 { list<string>*tmp = $1;
3565 tmp->push_back($2);
3566 delete $2;
3567 $$ = tmp;
3571 udp_sequ_entry_list
3572 : udp_sequ_entry
3573 { list<string>*tmp = new list<string>;
3574 tmp->push_back($1);
3575 delete $1;
3576 $$ = tmp;
3578 | udp_sequ_entry_list udp_sequ_entry
3579 { list<string>*tmp = $1;
3580 tmp->push_back($2);
3581 delete $2;
3582 $$ = tmp;
3586 udp_sequ_entry
3587 : udp_input_list ':' udp_input_sym ':' udp_output_sym ';'
3588 { char*tmp = new char[strlen($1)+5];
3589 strcpy(tmp, $1);
3590 char*tp = tmp+strlen(tmp);
3591 *tp++ = ':';
3592 *tp++ = $3;
3593 *tp++ = ':';
3594 *tp++ = $5;
3595 *tp++ = 0;
3596 $$ = tmp;
3600 udp_initial
3601 : K_initial IDENTIFIER '=' number ';'
3602 { PExpr*etmp = new PENumber($4);
3603 PEIdent*itmp = new PEIdent(lex_strings.make($2));
3604 PAssign*atmp = new PAssign(itmp, etmp);
3605 atmp->set_file(@2.text);
3606 atmp->set_lineno(@2.first_line);
3607 delete $2;
3608 $$ = atmp;
3612 udp_init_opt
3613 : udp_initial { $$ = $1; }
3614 | { $$ = 0; }
3617 udp_input_list
3618 : udp_input_sym
3619 { char*tmp = new char[2];
3620 tmp[0] = $1;
3621 tmp[1] = 0;
3622 $$ = tmp;
3624 | udp_input_list udp_input_sym
3625 { char*tmp = new char[strlen($1)+2];
3626 strcpy(tmp, $1);
3627 char*tp = tmp+strlen(tmp);
3628 *tp++ = $2;
3629 *tp++ = 0;
3630 delete[]$1;
3631 $$ = tmp;
3635 udp_input_sym
3636 : '0' { $$ = '0'; }
3637 | '1' { $$ = '1'; }
3638 | 'x' { $$ = 'x'; }
3639 | '?' { $$ = '?'; }
3640 | 'b' { $$ = 'b'; }
3641 | '*' { $$ = '*'; }
3642 | '%' { $$ = '%'; }
3643 | 'f' { $$ = 'f'; }
3644 | 'F' { $$ = 'F'; }
3645 | 'l' { $$ = 'l'; }
3646 | 'h' { $$ = 'H'; }
3647 | 'B' { $$ = 'B'; }
3648 | 'r' { $$ = 'r'; }
3649 | 'R' { $$ = 'R'; }
3650 | 'M' { $$ = 'M'; }
3651 | 'n' { $$ = 'n'; }
3652 | 'N' { $$ = 'N'; }
3653 | 'p' { $$ = 'p'; }
3654 | 'P' { $$ = 'P'; }
3655 | 'Q' { $$ = 'Q'; }
3656 | 'q' { $$ = 'q'; }
3657 | '_' { $$ = '_'; }
3658 | '+' { $$ = '+'; }
3661 udp_output_sym
3662 : '0' { $$ = '0'; }
3663 | '1' { $$ = '1'; }
3664 | 'x' { $$ = 'x'; }
3665 | '-' { $$ = '-'; }
3668 /* Port declarations create wires for the inputs and the output. The
3669 makes for these ports are scoped within the UDP, so there is no
3670 heirarchy involved. */
3671 udp_port_decl
3672 : K_input list_of_identifiers ';'
3673 { $$ = pform_make_udp_input_ports($2); }
3674 | K_output IDENTIFIER ';'
3675 { pform_name_t pname;
3676 pname.push_back(name_component_t(lex_strings.make($2)));
3677 PWire*pp = new PWire(pname, NetNet::IMPLICIT, NetNet::POUTPUT, IVL_VT_LOGIC);
3678 svector<PWire*>*tmp = new svector<PWire*>(1);
3679 (*tmp)[0] = pp;
3680 $$ = tmp;
3681 delete $2;
3683 | K_reg IDENTIFIER ';'
3684 { pform_name_t pname;
3685 pname.push_back(name_component_t(lex_strings.make($2)));
3686 PWire*pp = new PWire(pname, NetNet::REG, NetNet::PIMPLICIT, IVL_VT_LOGIC);
3687 svector<PWire*>*tmp = new svector<PWire*>(1);
3688 (*tmp)[0] = pp;
3689 $$ = tmp;
3690 delete $2;
3692 | K_reg K_output IDENTIFIER ';'
3693 { pform_name_t pname;
3694 pname.push_back(name_component_t(lex_strings.make($3)));
3695 PWire*pp = new PWire(pname, NetNet::REG, NetNet::POUTPUT, IVL_VT_LOGIC);
3696 svector<PWire*>*tmp = new svector<PWire*>(1);
3697 (*tmp)[0] = pp;
3698 $$ = tmp;
3699 delete $3;
3703 udp_port_decls
3704 : udp_port_decl
3705 { $$ = $1; }
3706 | udp_port_decls udp_port_decl
3707 { svector<PWire*>*tmp = new svector<PWire*>(*$1, *$2);
3708 delete $1;
3709 delete $2;
3710 $$ = tmp;
3714 udp_port_list
3715 : IDENTIFIER
3716 { list<string>*tmp = new list<string>;
3717 tmp->push_back($1);
3718 delete $1;
3719 $$ = tmp;
3721 | udp_port_list ',' IDENTIFIER
3722 { list<string>*tmp = $1;
3723 tmp->push_back($3);
3724 delete $3;
3725 $$ = tmp;
3729 udp_reg_opt: K_reg { $$ = true; } | { $$ = false; };
3731 udp_initial_expr_opt
3732 : '=' expression { $$ = $2; }
3733 | { $$ = 0; }
3736 udp_input_declaration_list
3737 : K_input IDENTIFIER
3738 { list<perm_string>*tmp = new list<perm_string>;
3739 tmp->push_back(lex_strings.make($2));
3740 $$ = tmp;
3741 delete[]$2;
3743 | udp_input_declaration_list ',' K_input IDENTIFIER
3744 { list<perm_string>*tmp = $1;
3745 tmp->push_back(lex_strings.make($4));
3746 $$ = tmp;
3747 delete[]$4;
3751 udp_primitive
3752 /* This is the syntax for primitives that uses the IEEE1364-1995
3753 format. The ports are simply names in the port list, and the
3754 declarations are in the body. */
3756 : K_primitive IDENTIFIER '(' udp_port_list ')' ';'
3757 udp_port_decls
3758 udp_init_opt
3759 udp_body
3760 K_endprimitive
3762 { perm_string tmp2 = lex_strings.make($2);
3763 pform_make_udp(tmp2, $4, $7, $9, $8,
3764 @2.text, @2.first_line);
3765 delete[]$2;
3768 /* This is the syntax for IEEE1364-2001 format definitions. The port
3769 names and declarations are all in the parameter list. */
3771 | K_primitive IDENTIFIER
3772 '(' K_output udp_reg_opt IDENTIFIER udp_initial_expr_opt ','
3773 udp_input_declaration_list ')' ';'
3774 udp_body
3775 K_endprimitive
3777 { perm_string tmp2 = lex_strings.make($2);
3778 perm_string tmp6 = lex_strings.make($6);
3779 pform_make_udp(tmp2, $5, tmp6, $7, $9, $12,
3780 @2.text, @2.first_line);
3781 delete[]$2;
3782 delete[]$6;