4 * Copyright (c) 1998-2007 Stephen Williams (steve@icarus.com)
6 * This source code is free software; you can redistribute it
7 * and/or modify it in source code form under the terms of the GNU
8 * General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 #ident "$Id: parse.y,v 1.239 2007/06/14 03:50:00 steve Exp $"
27 # include "parse_misc.h"
28 # include "compiler.h"
30 # include "Statement.h"
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. */
44 NetNet
::Type port_net_type
;
45 NetNet
::PortType port_type
;
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
));
83 static list
<perm_string
>* list_from_identifier
(list
<perm_string
>*tmp
, char*id
)
85 tmp
->push_back
(lex_strings.make
(id
));
97 /* text items are C strings allocated by the lexor using
98 strdup. They can be put into lists with the texts type. */
100 list
<perm_string
>*perm_strings
;
101 pform_name_t
*pform_name
;
105 list
<string>*strings
;
107 struct str_pair_t drive
;
110 svector
<PCase
::Item
*>*citems
;
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
;
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
;
133 svector
<PWire
*>*wires
;
135 PEventStatement
*event_statement
;
137 svector
<Statement
*>*statement_list
;
139 PTaskFuncArg function_type
;
141 net_decl_assign_t
*net_decl_assign
;
148 list
<index_component_t
> *dimensions
;
151 %token
<text
> IDENTIFIER SYSTEM_IDENTIFIER STRING
152 %token
<text
> PATHPULSE_IDENTIFIER
153 %token
<number
> BASED_NUMBER DEC_NUMBER
154 %token
<realtime
> REALTIME
155 %token K_LE K_GE K_EG K_EQ K_NE K_CEQ K_CNE K_LS K_RS K_RSS K_SG
156 %token K_PO_POS K_PO_NEG K_POW
157 %token K_PSTAR K_STARP
158 %token K_LOR K_LAND K_NAND K_NOR K_NXOR K_TRIGGER
159 %token K_always K_and K_assign K_begin K_bool K_buf K_bufif0 K_bufif1 K_case
160 %token K_casex K_casez K_cmos K_deassign K_default K_defparam K_disable
161 %token K_edge K_edge_descriptor
162 %token K_else K_end K_endcase K_endfunction K_endgenerate K_endmodule
163 %token K_endprimitive K_endspecify K_endtable K_endtask K_event K_for
164 %token K_force K_forever K_fork K_function K_generate K_genvar
165 %token K_highz0 K_highz1 K_if K_ifnone
166 %token K_initial K_inout K_input K_integer K_join K_large K_localparam
167 %token K_logic K_macromodule
168 %token K_medium K_module K_nand K_negedge K_nmos K_nor K_not K_notif0
169 %token K_notif1 K_or K_output K_parameter K_pmos K_posedge K_primitive
170 %token K_pull0 K_pull1 K_pulldown K_pullup K_rcmos K_real K_realtime
171 %token K_reg K_release K_repeat
172 %token K_rnmos K_rpmos K_rtran K_rtranif0 K_rtranif1 K_scalared
173 %token K_signed K_small K_specify
174 %token K_specparam K_strong0 K_strong1 K_supply0 K_supply1 K_table K_task
175 %token K_time K_tran K_tranif0 K_tranif1 K_tri K_tri0 K_tri1 K_triand
176 %token K_trior K_trireg K_vectored K_wait K_wand K_weak0 K_weak1
177 %token K_while K_wire
178 %token K_wone K_wor K_xnor K_xor
179 %token K_Shold K_Speriod K_Srecovery K_Srecrem K_Ssetup K_Swidth K_Ssetuphold
183 %type
<number
> number
184 %type
<flag
> signed_opt udp_reg_opt edge_operator
185 %type
<drive
> drive_strength drive_strength_opt dr_strength0 dr_strength1
186 %type
<letter
> udp_input_sym udp_output_sym
187 %type
<text
> udp_input_list udp_sequ_entry udp_comb_entry
188 %type
<perm_strings
> udp_input_declaration_list
189 %type
<strings
> udp_entry_list udp_comb_entry_list udp_sequ_entry_list
190 %type
<strings
> udp_body udp_port_list
191 %type
<wires
> udp_port_decl udp_port_decls
192 %type
<statement
> udp_initial udp_init_opt
193 %type
<expr
> udp_initial_expr_opt
195 %type
<text
> register_variable net_variable real_variable
196 %type
<perm_strings
> register_variable_list net_variable_list real_variable_list list_of_identifiers
198 %type
<net_decl_assign
> net_decl_assign net_decl_assigns
200 %type
<mport
> port port_opt port_reference port_reference_list
201 %type
<mport
> port_declaration
202 %type
<mports
> list_of_ports module_port_list_opt list_of_port_declarations
204 %type
<wires
> task_item task_item_list task_item_list_opt
205 %type
<wires
> task_port_item task_port_decl task_port_decl_list
206 %type
<wires
> function_item function_item_list
208 %type
<named_pexpr
> port_name parameter_value_byname
209 %type
<named_pexprs
> port_name_list parameter_value_byname_list
211 %type
<named_pexpr
> attribute
212 %type
<named_pexprs
> attribute_list attribute_list_opt
214 %type
<citem
> case_item
215 %type
<citems
> case_items
217 %type
<gate
> gate_instance
218 %type
<gates
> gate_instance_list
220 %type
<pform_name
> heirarchy_identifier
221 %type
<expr
> expression expr_primary expr_mintypmax
223 %type
<expr
> delay_value delay_value_simple
224 %type
<exprs
> delay1 delay3 delay3_opt delay_value_list
225 %type
<exprs
> expression_list_with_nuls expression_list_proper
226 %type
<exprs
> cont_assign cont_assign_list
228 %type
<exprs
> range range_opt
229 %type
<dimensions
> dimensions_opt dimensions
230 %type
<nettype
> net_type var_type net_type_opt
231 %type
<gatetype
> gatetype
232 %type
<porttype
> port_type
233 %type
<datatype
> primitive_type primitive_type_opt
234 %type
<parmvalue
> parameter_value_opt
236 %type
<function_type
> function_range_or_type_opt
237 %type
<event_expr
> event_expression_list
238 %type
<event_expr
> event_expression
239 %type
<event_statement
> event_control
240 %type
<statement
> statement statement_or_null
241 %type
<statement_list
> statement_list
243 %type
<letter
> spec_polarity
244 %type
<perm_strings
> specify_path_identifiers
246 %type
<specpath
> specify_simple_path specify_simple_path_decl
247 %type
<specpath
> specify_edge_path specify_edge_path_decl
254 %left
'^' K_NXOR K_NOR
256 %left K_EQ K_NE K_CEQ K_CNE
257 %left K_GE K_LE
'<' '>'
258 %left K_LS K_RS K_RSS
264 /* to resolve dangling else ambiguity. */
265 %nonassoc less_than_K_else
270 /* A degenerate source file can be completely empty. */
271 main
: source_file |
;
275 | source_file description
278 number
: BASED_NUMBER
279 { $$
= $1; based_size
= 0;}
281 { $$
= $1; based_size
= 0;}
282 | DEC_NUMBER BASED_NUMBER
283 { $$
= pform_verinum_with_size
($1,$2, @
2.text
, @
2.first_line
);
287 /* Verilog-2001 supports attribute lists, which can be attached to a
288 variety of different objects. The syntax inside the (* *) is a
289 comma separated list of names or names with assigned values. */
291 : K_PSTAR attribute_list K_STARP
{ $$
= $2; }
292 | K_PSTAR K_STARP
{ $$
= 0; }
297 : attribute_list
',' attribute
298 { svector
<named_pexpr_t
*>*tmp
=
299 new svector
<named_pexpr_t
*>(*$1,$3);
304 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
313 { named_pexpr_t
*tmp
= new named_pexpr_t
;
314 tmp
->name
= lex_strings.make
($1);
319 | IDENTIFIER
'=' expression
321 if
(!pform_expression_is_constant
(tmp
)) {
322 yyerror(@
3, "error: attribute value "
323 "expression must be constant.");
327 named_pexpr_t
*tmp2
= new named_pexpr_t
;
328 tmp2
->name
= lex_strings.make
($1);
336 /* The block_item_decl is used in function definitions, task
337 definitions, module definitions and named blocks. Wherever a new
338 scope is entered, the source may declare new registers and
339 integers. This rule matches those declarations. The containing
340 rule has presumably set up the scope. */
343 : attribute_list_opt K_reg
344 primitive_type_opt signed_opt range
345 register_variable_list
';'
346 { ivl_variable_type_t dtype
= $3;
347 if
(dtype
== IVL_VT_NO_TYPE
)
348 dtype
= IVL_VT_LOGIC
;
349 pform_set_net_range
($6, $5, $4, dtype
);
353 /* This differs from the above pattern only in the absence of the
354 range. This is the rule for a scalar. */
356 | attribute_list_opt K_reg
357 primitive_type_opt signed_opt
358 register_variable_list
';'
359 { ivl_variable_type_t dtype
= $3;
360 if
(dtype
== IVL_VT_NO_TYPE
)
361 dtype
= IVL_VT_LOGIC
;
362 pform_set_net_range
($5, 0, $4, dtype
);
366 /* Integer declarations are simpler in that they do not have all the
367 trappings of a general variable declaration. All of that is
368 implicit in the "integer" of the declaratin. */
370 | attribute_list_opt K_integer register_variable_list
';'
371 { pform_set_reg_integer
($3);
375 | attribute_list_opt K_time register_variable_list
';'
376 { pform_set_reg_time
($3);
379 /* real declarations are fairly simple as there is no range of
380 signed flag in the declaration. Create the real as a NetNet::REG
381 with real value. Note that real and realtime are interchangable
384 | attribute_list_opt K_real real_variable_list
';'
386 | attribute_list_opt K_realtime real_variable_list
';'
389 | K_parameter parameter_assign_decl
';'
390 | K_localparam localparam_assign_decl
';'
392 /* Recover from errors that happen within variable lists. Use the
393 trailing semi-colon to resync the parser. */
395 | attribute_list_opt K_reg
error ';'
396 { yyerror(@
2, "error: syntax error in reg variable list.");
400 | attribute_list_opt K_integer
error ';'
401 { yyerror(@
2, "error: syntax error in integer variable list.");
405 | attribute_list_opt K_time
error ';'
406 { yyerror(@
2, "error: syntax error in time variable list.");
409 | attribute_list_opt K_real
error ';'
410 { yyerror(@
2, "error: syntax error in real variable list.");
413 | attribute_list_opt K_realtime
error ';'
414 { yyerror(@
1, "error: syntax error in realtime variable list.");
417 | K_parameter
error ';'
418 { yyerror(@
1, "error: syntax error in parameter list.");
421 | K_localparam
error ';'
422 { yyerror(@
1, "error: syntax error localparam list.");
429 | block_item_decls block_item_decl
438 : expression_list_proper
':' statement_or_null
439 { PCase
::Item
*tmp
= new PCase
::Item
;
445 | K_default
':' statement_or_null
446 { PCase
::Item
*tmp
= new PCase
::Item
;
450 | K_default statement_or_null
451 { PCase
::Item
*tmp
= new PCase
::Item
;
455 |
error ':' statement_or_null
456 { yyerror(@
1, "error: Incomprehensible case expression.");
462 : case_items case_item
463 { svector
<PCase
::Item
*>*tmp
;
464 tmp
= new svector
<PCase
::Item
*>(*$1, $2);
469 { svector
<PCase
::Item
*>*tmp
= new svector
<PCase
::Item
*>(1);
487 : heirarchy_identifier
'=' expression
489 if
(!pform_expression_is_constant
(tmp
)) {
490 yyerror(@
3, "error: parameter value "
491 "must be constant.");
495 pform_set_defparam
(*$1, $3);
502 | range defparam_assign
503 { yyerror(@
1, "error: defparam may not include a range.");
506 | defparam_assign_list
',' defparam_assign
510 : '#' delay_value_simple
511 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
515 |
'#' '(' delay_value
')'
516 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
523 : '#' delay_value_simple
524 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
528 |
'#' '(' delay_value
')'
529 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
533 |
'#' '(' delay_value
',' delay_value
')'
534 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
539 |
'#' '(' delay_value
',' delay_value
',' delay_value
')'
540 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(3);
549 : delay3
{ $$
= $1; }
555 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
559 | delay_value_list
',' delay_value
560 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
571 | expression
':' expression
':' expression
572 { $$
= pform_select_mtm_expr
($1, $3, $5); }
580 yyerror(@
1, "internal error: delay.");
583 $$
= new PENumber
(tmp
);
584 $$
->set_file
(@
1.text
);
585 $$
->set_lineno
(@
1.first_line
);
591 yyerror(@
1, "internal error: delay.");
594 $$
= new PEFNumber
(tmp
);
595 $$
->set_file
(@
1.text
);
596 $$
->set_lineno
(@
1.first_line
);
600 { PEIdent
*tmp
= new PEIdent
(lex_strings.make
($1));
601 tmp
->set_file
(@
1.text
);
602 tmp
->set_lineno
(@
1.first_line
);
611 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')'
612 { perm_string tmp3
= lex_strings.make
($3);
613 pform_set_type_attrib
(tmp3
, $5, $7);
620 : '(' dr_strength0
',' dr_strength1
')'
624 |
'(' dr_strength1
',' dr_strength0
')'
628 |
'(' dr_strength0
',' K_highz1
')'
630 $$.str1
= PGate
::HIGHZ
;
632 |
'(' dr_strength1
',' K_highz0
')'
633 { $$.str0
= PGate
::HIGHZ
;
636 |
'(' K_highz1
',' dr_strength0
')'
638 $$.str1
= PGate
::HIGHZ
;
640 |
'(' K_highz0
',' dr_strength1
')'
641 { $$.str0
= PGate
::HIGHZ
;
647 : drive_strength
{ $$
= $1; }
648 |
{ $$.str0
= PGate
::STRONG
; $$.str1
= PGate
::STRONG
; }
652 : K_supply0
{ $$.str0
= PGate
::SUPPLY
; }
653 | K_strong0
{ $$.str0
= PGate
::STRONG
; }
654 | K_pull0
{ $$.str0
= PGate
::PULL
; }
655 | K_weak0
{ $$.str0
= PGate
::WEAK
; }
659 : K_supply1
{ $$.str1
= PGate
::SUPPLY
; }
660 | K_strong1
{ $$.str1
= PGate
::STRONG
; }
661 | K_pull1
{ $$.str1
= PGate
::PULL
; }
662 | K_weak1
{ $$.str1
= PGate
::WEAK
; }
666 : '@' heirarchy_identifier
667 { PEIdent
*tmpi
= new PEIdent
(*$2);
668 PEEvent
*tmpe
= new PEEvent
(PEEvent
::ANYEDGE
, tmpi
);
669 PEventStatement
*tmps
= new PEventStatement
(tmpe
);
670 tmps
->set_file
(@
1.text
);
671 tmps
->set_lineno
(@
1.first_line
);
675 |
'@' '(' event_expression_list
')'
676 { PEventStatement
*tmp
= new PEventStatement
(*$3);
677 tmp
->set_file
(@
1.text
);
678 tmp
->set_lineno
(@
1.first_line
);
683 { yyerror(@
1, "error: Malformed event control expression.");
688 event_expression_list
691 | event_expression_list K_or event_expression
692 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
697 | event_expression_list
',' event_expression
698 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
706 : K_posedge expression
707 { PEEvent
*tmp
= new PEEvent
(PEEvent
::POSEDGE
, $2);
708 tmp
->set_file
(@
1.text
);
709 tmp
->set_lineno
(@
1.first_line
);
710 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
714 | K_negedge expression
715 { PEEvent
*tmp
= new PEEvent
(PEEvent
::NEGEDGE
, $2);
716 tmp
->set_file
(@
1.text
);
717 tmp
->set_lineno
(@
1.first_line
);
718 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
723 { PEEvent
*tmp
= new PEEvent
(PEEvent
::ANYEDGE
, $1);
724 tmp
->set_file
(@
1.text
);
725 tmp
->set_lineno
(@
1.first_line
);
726 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
735 |
'+' expr_primary %prec UNARY_PREC
737 |
'-' expr_primary %prec UNARY_PREC
738 { PEUnary
*tmp
= new PEUnary
('-', $2);
739 tmp
->set_file
(@
2.text
);
740 tmp
->set_lineno
(@
2.first_line
);
743 |
'~' expr_primary %prec UNARY_PREC
744 { PEUnary
*tmp
= new PEUnary
('~', $2);
745 tmp
->set_file
(@
2.text
);
746 tmp
->set_lineno
(@
2.first_line
);
749 |
'&' expr_primary %prec UNARY_PREC
750 { PEUnary
*tmp
= new PEUnary
('&', $2);
751 tmp
->set_file
(@
2.text
);
752 tmp
->set_lineno
(@
2.first_line
);
755 |
'!' expr_primary %prec UNARY_PREC
756 { PEUnary
*tmp
= new PEUnary
('!', $2);
757 tmp
->set_file
(@
2.text
);
758 tmp
->set_lineno
(@
2.first_line
);
761 |
'|' expr_primary %prec UNARY_PREC
762 { PEUnary
*tmp
= new PEUnary
('|', $2);
763 tmp
->set_file
(@
2.text
);
764 tmp
->set_lineno
(@
2.first_line
);
767 |
'^' expr_primary %prec UNARY_PREC
768 { PEUnary
*tmp
= new PEUnary
('^', $2);
769 tmp
->set_file
(@
2.text
);
770 tmp
->set_lineno
(@
2.first_line
);
773 | K_NAND expr_primary %prec UNARY_PREC
774 { PEUnary
*tmp
= new PEUnary
('A', $2);
775 tmp
->set_file
(@
2.text
);
776 tmp
->set_lineno
(@
2.first_line
);
779 | K_NOR expr_primary %prec UNARY_PREC
780 { PEUnary
*tmp
= new PEUnary
('N', $2);
781 tmp
->set_file
(@
2.text
);
782 tmp
->set_lineno
(@
2.first_line
);
785 | K_NXOR expr_primary %prec UNARY_PREC
786 { PEUnary
*tmp
= new PEUnary
('X', $2);
787 tmp
->set_file
(@
2.text
);
788 tmp
->set_lineno
(@
2.first_line
);
791 |
'!' error %prec UNARY_PREC
792 { yyerror(@
1, "error: Operand of unary ! "
793 "is not a primary expression.");
796 |
'^' error %prec UNARY_PREC
797 { yyerror(@
1, "error: Operand of reduction ^ "
798 "is not a primary expression.");
801 | expression
'^' expression
802 { PEBinary
*tmp
= new PEBinary
('^', $1, $3);
803 tmp
->set_file
(@
2.text
);
804 tmp
->set_lineno
(@
2.first_line
);
807 | expression K_POW expression
808 { PEBinary
*tmp
= new PEBinary
('p', $1, $3);
809 tmp
->set_file
(@
2.text
);
810 tmp
->set_lineno
(@
2.first_line
);
813 | expression
'*' expression
814 { PEBinary
*tmp
= new PEBinary
('*', $1, $3);
815 tmp
->set_file
(@
2.text
);
816 tmp
->set_lineno
(@
2.first_line
);
819 | expression
'/' expression
820 { PEBinary
*tmp
= new PEBinary
('/', $1, $3);
821 tmp
->set_file
(@
2.text
);
822 tmp
->set_lineno
(@
2.first_line
);
825 | expression
'%' expression
826 { PEBinary
*tmp
= new PEBinary
('%', $1, $3);
827 tmp
->set_file
(@
2.text
);
828 tmp
->set_lineno
(@
2.first_line
);
831 | expression
'+' expression
832 { PEBinary
*tmp
= new PEBinary
('+', $1, $3);
833 tmp
->set_file
(@
2.text
);
834 tmp
->set_lineno
(@
2.first_line
);
837 | expression
'-' expression
838 { PEBinary
*tmp
= new PEBinary
('-', $1, $3);
839 tmp
->set_file
(@
2.text
);
840 tmp
->set_lineno
(@
2.first_line
);
843 | expression
'&' expression
844 { PEBinary
*tmp
= new PEBinary
('&', $1, $3);
845 tmp
->set_file
(@
2.text
);
846 tmp
->set_lineno
(@
2.first_line
);
849 | expression
'|' expression
850 { PEBinary
*tmp
= new PEBinary
('|', $1, $3);
851 tmp
->set_file
(@
2.text
);
852 tmp
->set_lineno
(@
2.first_line
);
855 | expression K_NAND expression
856 { PEBinary
*tmp
= new PEBinary
('A', $1, $3);
857 tmp
->set_file
(@
2.text
);
858 tmp
->set_lineno
(@
2.first_line
);
861 | expression K_NOR expression
862 { PEBinary
*tmp
= new PEBinary
('O', $1, $3);
863 tmp
->set_file
(@
2.text
);
864 tmp
->set_lineno
(@
2.first_line
);
867 | expression K_NXOR expression
868 { PEBinary
*tmp
= new PEBinary
('X', $1, $3);
869 tmp
->set_file
(@
2.text
);
870 tmp
->set_lineno
(@
2.first_line
);
873 | expression
'<' expression
874 { PEBinary
*tmp
= new PEBComp
('<', $1, $3);
875 tmp
->set_file
(@
2.text
);
876 tmp
->set_lineno
(@
2.first_line
);
879 | expression
'>' expression
880 { PEBinary
*tmp
= new PEBComp
('>', $1, $3);
881 tmp
->set_file
(@
2.text
);
882 tmp
->set_lineno
(@
2.first_line
);
885 | expression K_LS expression
886 { PEBinary
*tmp
= new PEBShift
('l', $1, $3);
887 tmp
->set_file
(@
2.text
);
888 tmp
->set_lineno
(@
2.first_line
);
891 | expression K_RS expression
892 { PEBinary
*tmp
= new PEBShift
('r', $1, $3);
893 tmp
->set_file
(@
2.text
);
894 tmp
->set_lineno
(@
2.first_line
);
897 | expression K_RSS expression
898 { PEBinary
*tmp
= new PEBShift
('R', $1, $3);
899 tmp
->set_file
(@
2.text
);
900 tmp
->set_lineno
(@
2.first_line
);
903 | expression K_EQ expression
904 { PEBinary
*tmp
= new PEBComp
('e', $1, $3);
905 tmp
->set_file
(@
2.text
);
906 tmp
->set_lineno
(@
2.first_line
);
909 | expression K_CEQ expression
910 { PEBinary
*tmp
= new PEBComp
('E', $1, $3);
911 tmp
->set_file
(@
2.text
);
912 tmp
->set_lineno
(@
2.first_line
);
915 | expression K_LE expression
916 { PEBinary
*tmp
= new PEBComp
('L', $1, $3);
917 tmp
->set_file
(@
2.text
);
918 tmp
->set_lineno
(@
2.first_line
);
921 | expression K_GE expression
922 { PEBinary
*tmp
= new PEBComp
('G', $1, $3);
923 tmp
->set_file
(@
2.text
);
924 tmp
->set_lineno
(@
2.first_line
);
927 | expression K_NE expression
928 { PEBinary
*tmp
= new PEBComp
('n', $1, $3);
929 tmp
->set_file
(@
2.text
);
930 tmp
->set_lineno
(@
2.first_line
);
933 | expression K_CNE expression
934 { PEBinary
*tmp
= new PEBComp
('N', $1, $3);
935 tmp
->set_file
(@
2.text
);
936 tmp
->set_lineno
(@
2.first_line
);
939 | expression K_LOR expression
940 { PEBinary
*tmp
= new PEBinary
('o', $1, $3);
941 tmp
->set_file
(@
2.text
);
942 tmp
->set_lineno
(@
2.first_line
);
945 | expression K_LAND expression
946 { PEBinary
*tmp
= new PEBinary
('a', $1, $3);
947 tmp
->set_file
(@
2.text
);
948 tmp
->set_lineno
(@
2.first_line
);
951 | expression
'?' expression
':' expression
952 { PETernary
*tmp
= new PETernary
($1, $3, $5);
953 tmp
->set_file
(@
2.text
);
954 tmp
->set_lineno
(@
2.first_line
);
962 | expression
':' expression
':' expression
963 { switch
(min_typ_max_flag
) {
984 /* Many contexts take a comma separated list of expressions. Null
985 expressions can happen anywhere in the list, so there are two
986 extra rules in expression_list_with_nuls for parsing and
987 installing those nulls.
989 The expression_list_proper rules do not allow null items in the
990 expression list, so can be used where nul expressions are not allowed. */
992 expression_list_with_nuls
993 : expression_list_with_nuls
',' expression
994 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
999 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1004 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1009 | expression_list_with_nuls
','
1010 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, 0);
1016 expression_list_proper
1017 : expression_list_proper
',' expression
1018 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
1023 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1032 PENumber
*tmp
= new PENumber
($1);
1033 tmp
->set_file
(@
1.text
);
1034 tmp
->set_lineno
(@
1.first_line
);
1038 { PEFNumber
*tmp
= new PEFNumber
($1);
1039 tmp
->set_file
(@
1.text
);
1040 tmp
->set_lineno
(@
1.first_line
);
1044 { PEString
*tmp
= new PEString
($1);
1045 tmp
->set_file
(@
1.text
);
1046 tmp
->set_lineno
(@
1.first_line
);
1050 { perm_string tn
= lex_strings.make
($1);
1051 PECallFunction
*tmp
= new PECallFunction
(tn
);
1052 tmp
->set_file
(@
1.text
);
1053 tmp
->set_lineno
(@
1.first_line
);
1058 /* The heirarchy_identifier rule matches simple identifiers as well as
1059 indexed arrays and part selects */
1061 | heirarchy_identifier
1062 { PEIdent
*tmp
= new PEIdent
(*$1);
1063 tmp
->set_file
(@
1.text
);
1064 tmp
->set_lineno
(@
1.first_line
);
1069 /* An identifer followed by an expression list in parentheses is a
1070 function call. If a system identifier, then a system function
1073 | heirarchy_identifier
'(' expression_list_proper
')'
1074 { PECallFunction
*tmp
= new PECallFunction
(*$1, *$3);
1075 tmp
->set_file
(@
1.text
);
1076 tmp
->set_lineno
(@
1.first_line
);
1080 | SYSTEM_IDENTIFIER
'(' expression_list_proper
')'
1081 { perm_string tn
= lex_strings.make
($1);
1082 PECallFunction
*tmp
= new PECallFunction
(tn
, *$3);
1083 tmp
->set_file
(@
1.text
);
1084 tmp
->set_lineno
(@
1.first_line
);
1088 /* Parenthesized expressions are primaries. */
1090 |
'(' expr_mintypmax
')'
1093 /* Various kinds of concatenation expressions. */
1095 |
'{' expression_list_proper
'}'
1096 { PEConcat
*tmp
= new PEConcat
(*$2);
1097 tmp
->set_file
(@
1.text
);
1098 tmp
->set_lineno
(@
1.first_line
);
1102 |
'{' expression
'{' expression_list_proper
'}' '}'
1104 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1105 tmp
->set_file
(@
1.text
);
1106 tmp
->set_lineno
(@
1.first_line
);
1110 |
'{' expression
'{' expression_list_proper
'}' error '}'
1112 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1113 tmp
->set_file
(@
1.text
);
1114 tmp
->set_lineno
(@
1.first_line
);
1117 yyerror(@
5, "error: Syntax error between internal '}' "
1118 "and closing '}' of repeat concatenation.");
1123 /* A function_item is either a block item (i.e. a reg or integer
1124 declaration) or an input declaration. There are no output or
1127 : K_input signed_opt range_opt list_of_identifiers
';'
1128 { svector
<PWire
*>*tmp
1129 = pform_make_task_ports
(NetNet
::PINPUT
,
1132 @
1.text
, @
1.first_line
);
1135 | K_output signed_opt range_opt list_of_identifiers
';'
1136 { svector
<PWire
*>*tmp
1137 = pform_make_task_ports
(NetNet
::PINPUT
,
1140 @
1.text
, @
1.first_line
);
1142 yyerror(@
1, "Functions may not have output ports.");
1144 | K_inout signed_opt range_opt list_of_identifiers
';'
1145 { svector
<PWire
*>*tmp
1146 = pform_make_task_ports
(NetNet
::PINPUT
,
1149 @
1.text
, @
1.first_line
);
1151 yyerror(@
1, "Functions may not have inout ports.");
1154 /* When the port is an integer, infer a signed vector of the integer
1155 shape. Generate a range to make it work. */
1157 | K_input K_integer list_of_identifiers
';'
1158 { svector
<PExpr
*>*range_stub
1159 = new svector
<PExpr
*>(2);
1161 re
= new PENumber
(new verinum
(integer_width
-1,
1163 (*range_stub
)[0] = re
;
1164 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
1165 (*range_stub
)[1] = re
;
1167 = pform_make_task_ports
(NetNet
::PINPUT
,
1170 @
1.text
, @
1.first_line
);
1174 /* Ports can be real. */
1176 | K_input K_real list_of_identifiers
';'
1177 { svector
<PWire
*>*tmp
1178 = pform_make_task_ports
(NetNet
::PINPUT
,
1181 @
1.text
, @
1.first_line
);
1189 /* A function_item_list only lists the input/output/inout
1190 declarations. The integer and reg declarations are handled in
1191 place, so are not listed. The list builder needs to account for
1192 the possibility that the various parts may be NULL. */
1196 | function_item_list function_item
1198 svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
1210 /* A gate_instance is a module instantiation or a built in part
1211 type. In any case, the gate has a set of connections to ports. */
1213 : IDENTIFIER
'(' expression_list_with_nuls
')'
1214 { lgate
*tmp
= new lgate
;
1217 tmp
->file
= @
1.text
;
1218 tmp
->lineno
= @
1.first_line
;
1223 | IDENTIFIER range
'(' expression_list_with_nuls
')'
1224 { lgate
*tmp
= new lgate
;
1225 svector
<PExpr
*>*rng
= $2;
1228 tmp
->range
[0] = (*rng
)[0];
1229 tmp
->range
[1] = (*rng
)[1];
1230 tmp
->file
= @
1.text
;
1231 tmp
->lineno
= @
1.first_line
;
1236 |
'(' expression_list_with_nuls
')'
1237 { lgate
*tmp
= new lgate
;
1240 tmp
->file
= @
1.text
;
1241 tmp
->lineno
= @
1.first_line
;
1245 /* Degenerate modules can have no ports. */
1248 { lgate
*tmp
= new lgate
;
1249 svector
<PExpr
*>*rng
= $2;
1252 tmp
->parms_by_name
= 0;
1253 tmp
->range
[0] = (*rng
)[0];
1254 tmp
->range
[1] = (*rng
)[1];
1255 tmp
->file
= @
1.text
;
1256 tmp
->lineno
= @
1.first_line
;
1262 /* Modules can also take ports by port-name expressions. */
1264 | IDENTIFIER
'(' port_name_list
')'
1265 { lgate
*tmp
= new lgate
;
1268 tmp
->parms_by_name
= $3;
1269 tmp
->file
= @
1.text
;
1270 tmp
->lineno
= @
1.first_line
;
1275 | IDENTIFIER range
'(' port_name_list
')'
1276 { lgate
*tmp
= new lgate
;
1277 svector
<PExpr
*>*rng
= $2;
1280 tmp
->parms_by_name
= $4;
1281 tmp
->range
[0] = (*rng
)[0];
1282 tmp
->range
[1] = (*rng
)[1];
1283 tmp
->file
= @
1.text
;
1284 tmp
->lineno
= @
1.first_line
;
1292 : gate_instance_list
',' gate_instance
1293 { svector
<lgate
>*tmp1
= $1;
1295 svector
<lgate
>*out
= new svector
<lgate
> (*tmp1
, *tmp2
);
1301 { svector
<lgate
>*tmp
= new svector
<lgate
>(1);
1309 : K_and
{ $$
= PGBuiltin
::AND
; }
1310 | K_nand
{ $$
= PGBuiltin
::NAND
; }
1311 | K_or
{ $$
= PGBuiltin
::OR
; }
1312 | K_nor
{ $$
= PGBuiltin
::NOR
; }
1313 | K_xor
{ $$
= PGBuiltin
::XOR
; }
1314 | K_xnor
{ $$
= PGBuiltin
::XNOR
; }
1315 | K_buf
{ $$
= PGBuiltin
::BUF
; }
1316 | K_bufif0
{ $$
= PGBuiltin
::BUFIF0
; }
1317 | K_bufif1
{ $$
= PGBuiltin
::BUFIF1
; }
1318 | K_not
{ $$
= PGBuiltin
::NOT
; }
1319 | K_notif0
{ $$
= PGBuiltin
::NOTIF0
; }
1320 | K_notif1
{ $$
= PGBuiltin
::NOTIF1
; }
1321 | K_nmos
{ $$
= PGBuiltin
::NMOS
; }
1322 | K_rnmos
{ $$
= PGBuiltin
::RNMOS
; }
1323 | K_pmos
{ $$
= PGBuiltin
::PMOS
; }
1324 | K_rpmos
{ $$
= PGBuiltin
::RPMOS
; }
1325 | K_cmos
{ $$
= PGBuiltin
::CMOS
; }
1326 | K_rcmos
{ $$
= PGBuiltin
::RCMOS
; }
1327 | K_tran
{ $$
= PGBuiltin
::TRAN
; }
1328 | K_rtran
{ $$
= PGBuiltin
::RTRAN
; }
1329 | K_tranif0
{ $$
= PGBuiltin
::TRANIF0
; }
1330 | K_tranif1
{ $$
= PGBuiltin
::TRANIF1
; }
1331 | K_rtranif0
{ $$
= PGBuiltin
::RTRANIF0
; }
1332 | K_rtranif1
{ $$
= PGBuiltin
::RTRANIF1
; }
1336 /* A general identifier is a hierarchical name, with the right most
1337 name the base of the identifier. This rule builds up a
1338 hierarchical name from the left to the right, forming a list of
1341 heirarchy_identifier
1343 { $$
= new pform_name_t
;
1344 $$
->push_back
(name_component_t
(lex_strings.make
($1)));
1347 | heirarchy_identifier
'.' IDENTIFIER
1348 { pform_name_t
* tmp
= $1;
1349 tmp
->push_back
(name_component_t
(lex_strings.make
($3)));
1353 | heirarchy_identifier
'[' expression
']'
1354 { pform_name_t
* tmp
= $1;
1355 name_component_t
&tail
= tmp
->back
();
1356 index_component_t itmp
;
1357 itmp.sel
= index_component_t
::SEL_BIT
;
1359 tail.index.push_back
(itmp
);
1362 | heirarchy_identifier
'[' expression
':' expression
']'
1363 { pform_name_t
* tmp
= $1;
1364 name_component_t
&tail
= tmp
->back
();
1365 index_component_t itmp
;
1366 itmp.sel
= index_component_t
::SEL_PART
;
1369 tail.index.push_back
(itmp
);
1372 | heirarchy_identifier
'[' expression K_PO_POS expression
']'
1373 { pform_name_t
* tmp
= $1;
1374 name_component_t
&tail
= tmp
->back
();
1375 index_component_t itmp
;
1376 itmp.sel
= index_component_t
::SEL_IDX_UP
;
1379 tail.index.push_back
(itmp
);
1382 | heirarchy_identifier
'[' expression K_PO_NEG expression
']'
1383 { pform_name_t
* tmp
= $1;
1384 name_component_t
&tail
= tmp
->back
();
1385 index_component_t itmp
;
1386 itmp.sel
= index_component_t
::SEL_IDX_DO
;
1389 tail.index.push_back
(itmp
);
1394 /* This is a list of identifiers. The result is a list of strings,
1395 each one of the identifiers in the list. These are simple,
1396 non-hierarchical names separated by ',' characters. */
1399 { $$
= list_from_identifier
($1); }
1400 | list_of_identifiers
',' IDENTIFIER
1401 { $$
= list_from_identifier
($1, $3); }
1405 /* The list_of_ports and list_of_port_declarations rules are the
1406 port list formats for module ports. The list_of_ports_opt rule is
1407 only used by the module start rule.
1409 The first, the list_of_ports, is the 1364-1995 format, a list of
1410 port names, including .name() syntax.
1412 The list_of_port_declarations the 1364-2001 format, an in-line
1413 declaration of the ports.
1415 In both cases, the list_of_ports and list_of_port_declarations
1416 returns an array of Module::port_t* items that include the name
1417 of the port internally and externally. The actual creation of the
1418 nets/variables is done in the declaration, whether internal to
1419 the port list or in amongst the module items. */
1423 { svector
<Module
::port_t
*>*tmp
1424 = new svector
<Module
::port_t
*>(1);
1428 | list_of_ports
',' port_opt
1429 { svector
<Module
::port_t
*>*tmp
1430 = new svector
<Module
::port_t
*>(*$1, $3);
1436 list_of_port_declarations
1438 { svector
<Module
::port_t
*>*tmp
1439 = new svector
<Module
::port_t
*>(1);
1442 * Uncommenting this makes lopd always fully specified.
1443 * Some wanted an implicit net to not be fully defined.
1445 * pform_set_net_range($1[0].name);
1449 | list_of_port_declarations
',' port_declaration
1450 { svector
<Module
::port_t
*>*tmp
1451 = new svector
<Module
::port_t
*>(*$1, $3);
1456 * pform_set_net_range($3[0].name);
1460 | list_of_port_declarations
',' IDENTIFIER
1461 { Module
::port_t
*ptmp
;
1462 ptmp
= pform_module_port_reference
($3, @
3.text
,
1464 svector
<Module
::port_t
*>*tmp
1465 = new svector
<Module
::port_t
*>(*$1, ptmp
);
1467 /* Get the port declaration details, the port type
1468 and what not, from context data stored by the
1469 last port_declaration rule. */
1470 pform_module_define_port
(@
3, $3,
1471 port_declaration_context.port_type
,
1472 port_declaration_context.port_net_type
,
1473 port_declaration_context.sign_flag
,
1474 port_declaration_context.range
, 0);
1479 * pform_set_net_range($3);
1486 : attribute_list_opt
1487 K_input net_type_opt signed_opt range_opt IDENTIFIER
1488 { Module
::port_t
*ptmp
;
1489 ptmp
= pform_module_port_reference
($6, @
2.text
,
1491 pform_module_define_port
(@
2, $6, NetNet
::PINPUT
,
1493 port_declaration_context.port_type
= NetNet
::PINPUT
;
1494 port_declaration_context.port_net_type
= $3;
1495 port_declaration_context.sign_flag
= $4;
1496 port_declaration_context.range
= $5;
1501 | attribute_list_opt
1502 K_inout net_type_opt signed_opt range_opt IDENTIFIER
1503 { Module
::port_t
*ptmp
;
1504 ptmp
= pform_module_port_reference
($6, @
2.text
,
1506 pform_module_define_port
(@
2, $6, NetNet
::PINOUT
,
1508 port_declaration_context.port_type
= NetNet
::PINOUT
;
1509 port_declaration_context.port_net_type
= $3;
1510 port_declaration_context.sign_flag
= $4;
1511 port_declaration_context.range
= $5;
1516 | attribute_list_opt
1517 K_output net_type_opt signed_opt range_opt IDENTIFIER
1518 { Module
::port_t
*ptmp
;
1519 ptmp
= pform_module_port_reference
($6, @
2.text
,
1521 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1523 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1524 port_declaration_context.port_net_type
= $3;
1525 port_declaration_context.sign_flag
= $4;
1526 port_declaration_context.range
= $5;
1531 | attribute_list_opt
1532 K_output var_type signed_opt range_opt IDENTIFIER
1533 { Module
::port_t
*ptmp
;
1534 ptmp
= pform_module_port_reference
($6, @
2.text
,
1536 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1538 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1539 port_declaration_context.port_net_type
= $3;
1540 port_declaration_context.sign_flag
= $4;
1541 port_declaration_context.range
= $5;
1546 | attribute_list_opt
1547 K_output var_type signed_opt range_opt IDENTIFIER
'=' expression
1548 { Module
::port_t
*ptmp
;
1549 ptmp
= pform_module_port_reference
($6, @
2.text
,
1551 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1553 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1554 port_declaration_context.port_net_type
= $3;
1555 port_declaration_context.sign_flag
= $4;
1556 port_declaration_context.range
= $5;
1558 if
(! pform_expression_is_constant
($8))
1559 yyerror(@
8, "error: register declaration assignment"
1560 " value must be a constant expression.");
1561 pform_make_reginit
(@
6, $6, $8);
1572 : net_type
{ $$
= $1; }
1573 |
{ $$
= NetNet
::IMPLICIT
; }
1576 signed_opt
: K_signed
{ $$
= true
; } |
{$$
= false
; } ;
1578 /* An lpvalue is the expression that can go on the left side of a
1579 procedural assignment. This rule handles only procedural
1580 assignments. It is more limited then the general expr_primary
1581 rule to reflect the rules for assignment l-values. */
1583 : heirarchy_identifier
1584 { PEIdent
*tmp
= new PEIdent
(*$1);
1585 tmp
->set_file
(@
1.text
);
1586 tmp
->set_lineno
(@
1.first_line
);
1590 |
'{' expression_list_proper
'}'
1591 { PEConcat
*tmp
= new PEConcat
(*$2);
1592 tmp
->set_file
(@
1.text
);
1593 tmp
->set_lineno
(@
1.first_line
);
1600 /* Continuous assignments have a list of individual assignments. */
1603 : lpvalue
'=' expression
1604 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
1612 : cont_assign_list
',' cont_assign
1613 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, *$3);
1623 /* This is the global structure of a module. A module in a start
1624 section, with optional ports, then an optional list of module
1625 items, and finally an end marker. */
1627 module
: attribute_list_opt module_start IDENTIFIER
1628 { pform_startmodule
($3, @
2.text
, @
2.first_line
, $1); }
1629 module_parameter_port_list_opt
1630 module_port_list_opt
';'
1631 { pform_module_set_ports
($6); }
1632 module_item_list_opt
1634 { pform_endmodule
($3);
1640 module_start
: K_module | K_macromodule
;
1642 module_port_list_opt
1643 : '(' list_of_ports
')' { $$
= $2; }
1644 |
'(' list_of_port_declarations
')' { $$
= $2; }
1648 /* Module declarations include optional ANSII style module parameter
1649 ports. These are simply advance ways to declare parameters, so
1650 that the port declarations may use them. */
1651 module_parameter_port_list_opt
1653 |
'#' '(' module_parameter_port_list
')'
1656 module_parameter_port_list
1657 : K_parameter parameter_assign
1658 | module_parameter_port_list
',' parameter_assign
1659 | module_parameter_port_list
',' K_parameter parameter_assign
1664 /* This rule detects net declarations that possibly include a
1665 primitive type, an optional vector range and signed flag. This
1666 also includes an optional delay set. The values are then applied
1667 to a list of names. If the primitive type is not specified, then
1668 resort to the default type LOGIC. */
1670 : attribute_list_opt net_type
1671 primitive_type_opt signed_opt range_opt
1673 net_variable_list
';'
1675 { ivl_variable_type_t dtype
= $3;
1676 if
(dtype
== IVL_VT_NO_TYPE
)
1677 dtype
= IVL_VT_LOGIC
;
1678 pform_makewire
(@
2, $5, $4, $7, $2,
1679 NetNet
::NOT_A_PORT
, dtype
, $1);
1681 yyerror(@
6, "sorry: net delays not supported.");
1687 /* Very similar to the rule above, but this takes a list of
1688 net_decl_assigns, which are <name> = <expr> assignment
1691 | attribute_list_opt net_type
1692 primitive_type_opt signed_opt range_opt
1693 delay3_opt net_decl_assigns
';'
1695 { ivl_variable_type_t dtype
= $3;
1696 if
(dtype
== IVL_VT_NO_TYPE
)
1697 dtype
= IVL_VT_LOGIC
;
1698 pform_makewire
(@
2, $5, $4, $6,
1699 str_strength
, $7, $2, dtype
);
1701 yyerror(@
2, "sorry: Attributes not supported "
1702 "on net declaration assignments.");
1707 /* This form doesn't have the range, but does have strengths. This
1708 gives strength to the assignment drivers. */
1710 | attribute_list_opt net_type
1711 primitive_type_opt signed_opt
1712 drive_strength net_decl_assigns
';'
1714 { ivl_variable_type_t dtype
= $3;
1715 if
(dtype
== IVL_VT_NO_TYPE
)
1716 dtype
= IVL_VT_LOGIC
;
1717 pform_makewire
(@
2, 0, $4, 0, $5, $6, $2, dtype
);
1719 yyerror(@
2, "sorry: Attributes not supported "
1720 "on net declaration assignments.");
1725 | K_trireg charge_strength_opt range_opt delay3_opt list_of_identifiers
';'
1726 { yyerror(@
1, "sorry: trireg nets not supported.");
1731 | port_type signed_opt range_opt delay3_opt list_of_identifiers
';'
1732 { pform_set_port_type
(@
1, $5, $3, $2, $1);
1735 /* The next two rules handle Verilog 2001 statements of the form:
1736 input wire signed [h:l] <list>;
1737 This creates the wire and sets the port type all at once. */
1739 | port_type net_type signed_opt range_opt list_of_identifiers
';'
1740 { pform_makewire
(@
1, $4, $3, $5, $2, $1, IVL_VT_NO_TYPE
, 0,
1744 | K_output var_type signed_opt range_opt list_of_identifiers
';'
1745 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::POUTPUT
,
1746 IVL_VT_NO_TYPE
, 0, SR_BOTH
);
1749 /* var_type declaration (reg variables) cannot be input or output,
1750 because the port declaration implies an external driver, which
1751 cannot be attached to a reg. These rules catch that error early. */
1753 | K_input var_type signed_opt range_opt list_of_identifiers
';'
1754 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINPUT
,
1756 yyerror(@
2, "error: reg variables cannot be inputs.");
1759 | K_inout var_type signed_opt range_opt list_of_identifiers
';'
1760 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINOUT
,
1762 yyerror(@
2, "error: reg variables cannot be inouts.");
1765 | port_type signed_opt range_opt delay3_opt
error ';'
1766 { yyerror(@
1, "error: Invalid variable list"
1767 " in port declaration.");
1773 /* block_item_decl rule is shared with task blocks and named
1780 | K_defparam defparam_assign_list
';'
1781 | K_event list_of_identifiers
';'
1782 { pform_make_events
($2, @
1.text
, @
1.first_line
);
1785 /* Most gate types have an optional drive strength and optional
1786 three-value delay. These rules handle the different cases. */
1788 | attribute_list_opt gatetype gate_instance_list
';'
1789 { pform_makegates
($2, str_strength
, 0, $3, $1);
1792 | attribute_list_opt gatetype delay3 gate_instance_list
';'
1793 { pform_makegates
($2, str_strength
, $3, $4, $1);
1796 | attribute_list_opt gatetype drive_strength gate_instance_list
';'
1797 { pform_makegates
($2, $3, 0, $4, $1);
1800 | attribute_list_opt gatetype drive_strength delay3 gate_instance_list
';'
1801 { pform_makegates
($2, $3, $4, $5, $1);
1804 /* Pullup and pulldown devices cannot have delays, and their
1805 strengths are limited. */
1807 | K_pullup gate_instance_list
';'
1808 { pform_makegates
(PGBuiltin
::PULLUP
, pull_strength
, 0,
1811 | K_pulldown gate_instance_list
';'
1812 { pform_makegates
(PGBuiltin
::PULLDOWN
, pull_strength
,
1816 | K_pullup
'(' dr_strength1
')' gate_instance_list
';'
1817 { pform_makegates
(PGBuiltin
::PULLUP
, $3, 0, $5, 0);
1820 | K_pulldown
'(' dr_strength0
')' gate_instance_list
';'
1821 { pform_makegates
(PGBuiltin
::PULLDOWN
, $3, 0, $5, 0);
1824 /* This rule handles instantiations of modules and user defined
1825 primitives. These devices to not have delay lists or strengths,
1826 but then can have parameter lists. */
1828 | attribute_list_opt
1829 IDENTIFIER parameter_value_opt gate_instance_list
';'
1830 { perm_string tmp1
= lex_strings.make
($2);
1831 pform_make_modgates
(tmp1
, $3, $4);
1836 | attribute_list_opt
1837 IDENTIFIER parameter_value_opt
error ';'
1838 { yyerror(@
2, "error: Invalid module instantiation");
1842 /* Continuous assignment can have an optional drive strength, then
1843 an optional delay3 that applies to all the assignments in the
1844 cont_assign_list. */
1846 | K_assign drive_strength_opt delay3_opt cont_assign_list
';'
1847 { pform_make_pgassign_list
($4, $3, $2, @
1.text
, @
1.first_line
); }
1849 /* Always and initial items are behavioral processes. */
1851 | attribute_list_opt K_always statement
1852 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_ALWAYS
,
1854 tmp
->set_file
(@
2.text
);
1855 tmp
->set_lineno
(@
2.first_line
);
1857 | attribute_list_opt K_initial statement
1858 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_INITIAL
,
1860 tmp
->set_file
(@
2.text
);
1861 tmp
->set_lineno
(@
2.first_line
);
1864 /* The task declaration rule matches the task declaration
1865 header, then pushes the function scope. This causes the
1866 definitions in the task_body to take on the scope of the task
1867 instead of the module. Note that these runs accept for the task
1868 body statement_or_null, although the standard does not allow null
1869 statements in the task body. But we continue to accept it as an
1872 | K_task IDENTIFIER
';'
1873 { pform_push_scope
($2); }
1877 { PTask
*tmp
= new PTask
;
1878 perm_string tmp2
= lex_strings.make
($2);
1879 tmp
->set_file
(@
1.text
);
1880 tmp
->set_lineno
(@
1.first_line
);
1882 tmp
->set_statement
($6);
1883 pform_set_task
(tmp2
, tmp
);
1889 { pform_push_scope
($2); }
1890 '(' task_port_decl_list
')' ';'
1894 { PTask
*tmp
= new PTask
;
1895 perm_string tmp2
= lex_strings.make
($2);
1896 tmp
->set_file
(@
1.text
);
1897 tmp
->set_lineno
(@
1.first_line
);
1899 tmp
->set_statement
($9);
1900 pform_set_task
(tmp2
, tmp
);
1905 /* The function declaration rule matches the function declaration
1906 header, then pushes the function scope. This causes the
1907 definitions in the func_body to take on the scope of the function
1908 instead of the module. */
1910 | K_function function_range_or_type_opt IDENTIFIER
';'
1911 { pform_push_scope
($3); }
1912 function_item_list statement
1914 { perm_string name
= lex_strings.make
($3);
1915 PFunction
*tmp
= new PFunction
(name
);
1916 tmp
->set_file
(@
1.text
);
1917 tmp
->set_lineno
(@
1.first_line
);
1919 tmp
->set_statement
($7);
1920 tmp
->set_return
($2);
1921 pform_set_function
(name
, tmp
);
1926 /* A generate region can contain further module items. Actually, it
1927 is supposed to be limited to certain kinds of module items, but
1928 the semantic tests will check that for us. */
1930 | K_generate module_item_list_opt K_endgenerate
1932 | K_genvar list_of_identifiers
';'
1933 { pform_genvars
($2); }
1935 | K_for
'(' IDENTIFIER
'=' expression
';'
1937 IDENTIFIER
'=' expression
')'
1938 { pform_start_generate_for
(@
1, $3, $5, $7, $9, $11); }
1940 { pform_endgenerate
(); }
1945 { pform_start_generate_else
(@
1); }
1947 { pform_endgenerate
(); }
1950 generate_block_opt %prec less_than_K_else
1951 { pform_endgenerate
(); }
1953 /* specify blocks are parsed but ignored. */
1955 | K_specify K_endspecify
1956 { /* empty lists are legal syntax. */ }
1958 | K_specify specify_item_list K_endspecify
1962 | K_specify
error K_endspecify
1963 { yyerror(@
1, "error: syntax error in specify block");
1967 /* These rules match various errors that the user can type into
1968 module items. These rules try to catch them at a point where a
1969 reasonable error message can be produced. */
1971 | K_module
error ';'
1972 { yyerror(@
2, "error: missing endmodule or attempt to "
1974 pform_error_nested_modules
();
1979 { yyerror(@
2, "error: invalid module item.");
1983 | K_assign
error '=' expression
';'
1984 { yyerror(@
1, "error: syntax error in left side "
1985 "of continuous assignment.");
1989 | K_assign
error ';'
1990 { yyerror(@
1, "error: syntax error in "
1991 "continuous assignment");
1995 | K_function
error K_endfunction
1996 { yyerror(@
1, "error: I give up on this "
1997 "function definition.");
2001 /* These rules are for the Icarus Verilog specific $attribute
2002 extensions. Then catch the parameters of the $attribute keyword. */
2004 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')' ';'
2005 { perm_string tmp3
= lex_strings.make
($3);
2006 perm_string tmp5
= lex_strings.make
($5);
2007 pform_set_attrib
(tmp3
, tmp5
, $7);
2011 | KK_attribute
'(' error ')' ';'
2012 { yyerror(@
1, "error: Malformed $attribute parameter list."); }
2015 generate_if
: K_if
'(' expression
')' { pform_start_generate_if
(@
1, $3); }
2018 : module_item_list module_item
2022 module_item_list_opt
2027 /* A generate block is the thing within a generate scheme. It may be
2028 a single module item, an anonymous block of module items, or a
2029 named module item. In all cases, the meat is in the module items
2030 inside, and the processing is done by the module_item rules. We
2031 only need to take note here of the scope name, if any. */
2035 | K_begin module_item_list_opt K_end
2036 | K_begin
':' IDENTIFIER module_item_list_opt K_end
2037 { pform_generate_block_name
($3); }
2040 generate_block_opt
: generate_block |
';' ;
2043 /* A net declaration assignment allows the programmer to combine the
2044 net declaration and the continuous assignment into a single
2047 Note that the continuous assignment statement is generated as a
2048 side effect, and all I pass up is the name of the l-value. */
2051 : IDENTIFIER
'=' expression
2052 { net_decl_assign_t
*tmp
= new net_decl_assign_t
;
2061 : net_decl_assigns
',' net_decl_assign
2062 { net_decl_assign_t
*tmp
= $1;
2063 $3->next
= tmp
->next
;
2073 : K_logic
{ $$
= IVL_VT_LOGIC
; }
2074 | K_bool
{ $$
= IVL_VT_BOOL
; }
2075 | K_real
{ $$
= IVL_VT_REAL
; }
2078 primitive_type_opt
: primitive_type
{ $$
= $1; } |
{ $$
= IVL_VT_NO_TYPE
; } ;
2081 : K_wire
{ $$
= NetNet
::WIRE
; }
2082 | K_tri
{ $$
= NetNet
::TRI
; }
2083 | K_tri1
{ $$
= NetNet
::TRI1
; }
2084 | K_supply0
{ $$
= NetNet
::SUPPLY0
; }
2085 | K_wand
{ $$
= NetNet
::WAND
; }
2086 | K_triand
{ $$
= NetNet
::TRIAND
; }
2087 | K_tri0
{ $$
= NetNet
::TRI0
; }
2088 | K_supply1
{ $$
= NetNet
::SUPPLY1
; }
2089 | K_wor
{ $$
= NetNet
::WOR
; }
2090 | K_trior
{ $$
= NetNet
::TRIOR
; }
2091 | K_wone
{ $$
= NetNet
::WONE
; }
2095 : K_reg
{ $$
= NetNet
::REG
; }
2098 /* In this rule we have matched the "parameter" keyword. The rule
2099 generates a type (optional) and a list of assignments. */
2101 parameter_assign_decl
2102 : parameter_assign_list
2103 | range
{ active_range
= $1; active_signed
= false
; }
2104 parameter_assign_list
2106 active_signed
= false
;
2108 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2109 parameter_assign_list
2111 active_signed
= false
;
2113 | K_integer
{ active_range
= 0; active_signed
= true
; }
2114 parameter_assign_list
2116 active_signed
= false
;
2120 parameter_assign_list
2122 | parameter_assign_list
',' parameter_assign
2126 : IDENTIFIER
'=' expression
2128 if
(!pform_expression_is_constant
(tmp
)) {
2129 yyerror(@
3, "error: parameter value "
2130 "must be a constant expression.");
2134 pform_set_parameter
(lex_strings.make
($1),
2142 /* Localparam assignments and assignment lists are broken into
2143 separate BNF so that I can call slightly different parameter
2144 handling code. They parse the same as parameters, they just
2145 behave differently when someone tries to override them. */
2148 : IDENTIFIER
'=' expression
2150 if
(!pform_expression_is_constant
(tmp
)) {
2151 yyerror(@
3, "error: parameter value "
2152 "must be constant.");
2156 pform_set_localparam
(lex_strings.make
($1),
2164 localparam_assign_decl
2165 : localparam_assign_list
2166 | range
{ active_range
= $1; active_signed
= false
; }
2167 localparam_assign_list
2169 active_signed
= false
;
2171 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2172 localparam_assign_list
2174 active_signed
= false
;
2178 localparam_assign_list
2180 | localparam_assign_list
',' localparam_assign
2185 /* The parameters of a module instance can be overridden by writing
2186 a list of expressions in a syntax much like a delay list. (The
2187 difference being the list can have any length.) The pform that
2188 attaches the expression list to the module checks that the
2189 expressions are constant.
2191 Although the BNF in IEEE1364-1995 implies that parameter value
2192 lists must be in parentheses, in practice most compilers will
2193 accept simple expressions outside of parentheses if there is only
2194 one value, so I'll accept simple numbers here.
2196 The parameter value by name syntax is OVI enhancement BTF-B06 as
2197 approved by WG1364 on 6/28/1998. */
2200 : '#' '(' expression_list_with_nuls
')'
2201 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2206 |
'#' '(' parameter_value_byname_list
')'
2207 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2214 PENumber
*tmp
= new PENumber
($2);
2215 tmp
->set_file
(@
1.text
);
2216 tmp
->set_lineno
(@
1.first_line
);
2218 struct parmvalue_t
*lst
= new
struct parmvalue_t
;
2219 lst
->by_order
= new svector
<PExpr
*>(1);
2220 (*lst
->by_order
)[0] = tmp
;
2225 { yyerror(@
1, "error: syntax error in parameter value "
2226 "assignment list.");
2233 parameter_value_byname
2234 : '.' IDENTIFIER
'(' expression
')'
2235 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2236 tmp
->name
= lex_strings.make
($2);
2241 |
'.' IDENTIFIER
'(' ')'
2242 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2243 tmp
->name
= lex_strings.make
($2);
2250 parameter_value_byname_list
2251 : parameter_value_byname
2252 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2256 | parameter_value_byname_list
',' parameter_value_byname
2257 { svector
<named_pexpr_t
*>*tmp
=
2258 new svector
<named_pexpr_t
*>(*$1,$3);
2265 /* The port (of a module) is a fairly complex item. Each port is
2266 handled as a Module::port_t object. A simple port reference has a
2267 name and a PExpr object, but more complex constructs are possible
2268 where the name can be attached to a list of PWire objects.
2270 The port_reference returns a Module::port_t, and so does the
2271 port_reference_list. The port_reference_list may have built up a
2272 list of PWires in the port_t object, but it is still a single
2273 Module::port_t object.
2275 The port rule below takes the built up Module::port_t object and
2276 tweaks its name as needed. */
2282 /* This syntax attaches an external name to the port reference so
2283 that the caller can bind by name to non-trivial port
2284 references. The port_t object gets its PWire from the
2285 port_reference, but its name from the IDENTIFIER. */
2287 |
'.' IDENTIFIER
'(' port_reference
')'
2288 { Module
::port_t
*tmp
= $4;
2289 tmp
->name
= lex_strings.make
($2);
2294 /* A port can also be a concatenation of port references. In this
2295 case the port does not have a name available to the outside, only
2296 positional parameter passing is possible here. */
2298 |
'{' port_reference_list
'}'
2299 { Module
::port_t
*tmp
= $2;
2300 tmp
->name
= perm_string
();
2304 /* This attaches a name to a port reference concatenation list so
2305 that parameter passing be name is possible. */
2307 |
'.' IDENTIFIER
'(' '{' port_reference_list
'}' ')'
2308 { Module
::port_t
*tmp
= $5;
2309 tmp
->name
= lex_strings.make
($2);
2321 /* A port reference is an internal (to the module) name of the port,
2322 possibly with a part of bit select to attach it to specific bits
2323 of a signal fully declared inside the module.
2325 The parser creates a PEIdent for every port reference, even if the
2326 signal is bound to different ports. The elaboration figures out
2327 the mess that this creates. The port_reference (and the
2328 port_reference_list below) puts the port reference PEIdent into the
2329 port_t object to pass it up to the module declaration code. */
2334 { Module
::port_t
*ptmp
;
2335 ptmp
= pform_module_port_reference
($1, @
1.text
, @
1.first_line
);
2340 | IDENTIFIER
'[' expression
':' expression
']'
2341 { if
(!pform_expression_is_constant
($3)) {
2342 yyerror(@
3, "error: msb expression of "
2343 "port part select must be constant.");
2345 if
(!pform_expression_is_constant
($5)) {
2346 yyerror(@
5, "error: lsb expression of "
2347 "port part select must be constant.");
2349 index_component_t itmp
;
2350 itmp.sel
= index_component_t
::SEL_PART
;
2354 name_component_t ntmp
(lex_strings.make
($1));
2355 ntmp.index.push_back
(itmp
);
2358 pname.push_back
(ntmp
);
2360 PEIdent
*wtmp
= new PEIdent
(pname
);
2361 wtmp
->set_file
(@
1.text
);
2362 wtmp
->set_lineno
(@
1.first_line
);
2364 Module
::port_t
*ptmp
= new Module
::port_t
;
2365 ptmp
->name
= perm_string
();
2366 ptmp
->expr
= svector
<PEIdent
*>(1);
2367 ptmp
->expr
[0] = wtmp
;
2373 | IDENTIFIER
'[' expression
']'
2374 { if
(!pform_expression_is_constant
($3)) {
2375 yyerror(@
3, "error: port bit select "
2376 "must be constant.");
2378 index_component_t itmp
;
2379 itmp.sel
= index_component_t
::SEL_BIT
;
2383 name_component_t ntmp
(lex_strings.make
($1));
2384 ntmp.index.push_back
(itmp
);
2387 pname.push_back
(ntmp
);
2389 PEIdent
*tmp
= new PEIdent
(pname
);
2390 tmp
->set_file
(@
1.text
);
2391 tmp
->set_lineno
(@
1.first_line
);
2393 Module
::port_t
*ptmp
= new Module
::port_t
;
2394 ptmp
->name
= perm_string
();
2395 ptmp
->expr
= svector
<PEIdent
*>(1);
2396 ptmp
->expr
[0] = tmp
;
2401 | IDENTIFIER
'[' error ']'
2402 { yyerror(@
1, "error: invalid port bit select");
2403 Module
::port_t
*ptmp
= new Module
::port_t
;
2404 PEIdent
*wtmp
= new PEIdent
(lex_strings.make
($1));
2405 wtmp
->set_file
(@
1.text
);
2406 wtmp
->set_lineno
(@
1.first_line
);
2407 ptmp
->name
= lex_strings.make
($1);
2408 ptmp
->expr
= svector
<PEIdent
*>(1);
2409 ptmp
->expr
[0] = wtmp
;
2419 | port_reference_list
',' port_reference
2420 { Module
::port_t
*tmp
= $1;
2421 tmp
->expr
= svector
<PEIdent
*>(tmp
->expr
, $3->expr
);
2427 /* The port_name rule is used with a module is being *instantiated*,
2428 and not when it is being declared. See the port rule if you are
2429 looking for the ports of a module declaration. */
2432 : '.' IDENTIFIER
'(' expression
')'
2433 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2434 tmp
->name
= lex_strings.make
($2);
2439 |
'.' IDENTIFIER
'(' error ')'
2440 { yyerror(@
4, "error: invalid port connection expression.");
2441 named_pexpr_t
*tmp
= new named_pexpr_t
;
2442 tmp
->name
= lex_strings.make
($2);
2447 |
'.' IDENTIFIER
'(' ')'
2448 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2449 tmp
->name
= lex_strings.make
($2);
2457 : port_name_list
',' port_name
2458 { svector
<named_pexpr_t
*>*tmp
;
2459 tmp
= new svector
<named_pexpr_t
*>(*$1, $3);
2464 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2471 : K_input
{ $$
= NetNet
::PINPUT
; }
2472 | K_output
{ $$
= NetNet
::POUTPUT
; }
2473 | K_inout
{ $$
= NetNet
::PINOUT
; }
2477 : '[' expression
':' expression
']'
2478 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*> (2);
2479 if
(!pform_expression_is_constant
($2))
2480 yyerror(@
2, "error: msb of range must be constant.");
2484 if
(!pform_expression_is_constant
($4))
2485 yyerror(@
4, "error: lsb of range must be constant.");
2499 | dimensions
{ $$
= $1; }
2502 : '[' expression
':' expression
']'
2503 { list
<index_component_t
> *tmp
= new list
<index_component_t
>;
2504 index_component_t index
;
2505 if
(!pform_expression_is_constant
($2))
2506 yyerror(@
2, "error: left array address must be "
2509 if
(!pform_expression_is_constant
($4))
2510 yyerror(@
4, "error: right array address must be "
2513 tmp
->push_back
(index
);
2516 | dimensions
'[' expression
':' expression
']'
2517 { list
<index_component_t
> *tmp
= $1;
2518 index_component_t index
;
2519 if
(!pform_expression_is_constant
($3))
2520 yyerror(@
3, "error: left array address must be "
2523 if
(!pform_expression_is_constant
($5))
2524 yyerror(@
5, "error: right array address must be "
2527 tmp
->push_back
(index
);
2531 /* This is used to express the return type of a function. */
2532 function_range_or_type_opt
2533 : range
{ $$.range
= $1; $$.type
= PTF_REG
; }
2534 | K_signed range
{ $$.range
= $2; $$.type
= PTF_REG_S
; }
2535 | K_integer
{ $$.range
= 0; $$.type
= PTF_INTEGER
; }
2536 | K_real
{ $$.range
= 0; $$.type
= PTF_REAL
; }
2537 | K_realtime
{ $$.range
= 0; $$.type
= PTF_REALTIME
; }
2538 | K_time
{ $$.range
= 0; $$.type
= PTF_TIME
; }
2539 |
{ $$.range
= 0; $$.type
= PTF_REG
; }
2542 /* The register_variable rule is matched only when I am parsing
2543 variables in a "reg" definition. I therefore know that I am
2544 creating registers and I do not need to let the containing rule
2545 handle it. The register variable list simply packs them together
2546 so that bit ranges can be assigned. */
2548 : IDENTIFIER dimensions_opt
2549 { pform_makewire
(@
1, $1, NetNet
::REG
,
2550 NetNet
::NOT_A_PORT
, IVL_VT_NO_TYPE
, 0);
2552 index_component_t index
;
2553 if
($2->size
() > 1) {
2554 yyerror(@
2, "sorry: only 1 dimensional arrays "
2555 "are currently supported.");
2557 index
= $2->front
();
2558 pform_set_reg_idx
($1, index.msb
, index.lsb
);
2563 | IDENTIFIER
'=' expression
2564 { pform_makewire
(@
1, $1, NetNet
::REG
,
2567 if
(! pform_expression_is_constant
($3))
2568 yyerror(@
3, "error: register declaration assignment"
2569 " value must be a constant expression.");
2570 pform_make_reginit
(@
1, $1, $3);
2575 register_variable_list
2577 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2578 tmp
->push_back
(lex_strings.make
($1));
2582 | register_variable_list
',' register_variable
2583 { list
<perm_string
>*tmp
= $1;
2584 tmp
->push_back
(lex_strings.make
($3));
2591 : IDENTIFIER dimensions_opt
2592 { pform_makewire
(@
1, $1, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2594 yyerror(@
2, "sorry: real variables do not currently support arrays.");
2599 | IDENTIFIER
'=' expression
2600 { pform_makewire
(@
1, $1, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2601 pform_make_reginit
(@
1, $1, $3);
2608 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2609 tmp
->push_back
(lex_strings.make
($1));
2613 | real_variable_list
',' real_variable
2614 { list
<perm_string
>*tmp
= $1;
2615 tmp
->push_back
(lex_strings.make
($3));
2622 : IDENTIFIER dimensions_opt
2623 { pform_makewire
(@
1, $1, NetNet
::IMPLICIT
,
2624 NetNet
::NOT_A_PORT
, IVL_VT_NO_TYPE
, 0);
2626 index_component_t index
;
2627 if
($2->size
() > 1) {
2628 yyerror(@
2, "sorry: only 1 dimensional arrays "
2629 "are currently supported.");
2631 index
= $2->front
();
2632 pform_set_reg_idx
($1, index.msb
, index.lsb
);
2640 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2641 tmp
->push_back
(lex_strings.make
($1));
2645 | net_variable_list
',' net_variable
2646 { list
<perm_string
>*tmp
= $1;
2647 tmp
->push_back
(lex_strings.make
($3));
2654 : K_specparam specparam_list
';'
2655 | specify_simple_path_decl
';'
2656 { pform_module_specify_path
($1);
2658 | specify_edge_path_decl
';'
2659 { pform_module_specify_path
($1);
2661 | K_if
'(' expression
')' specify_simple_path_decl
';'
2662 { PSpecPath
*tmp
= $5;
2664 tmp
->conditional
= true
;
2665 tmp
->condition
= $3;
2667 pform_module_specify_path
(tmp
);
2669 | K_if
'(' expression
')' specify_edge_path_decl
';'
2670 { PSpecPath
*tmp
= $5;
2672 tmp
->conditional
= true
;
2673 tmp
->condition
= $3;
2675 pform_module_specify_path
(tmp
);
2677 | K_ifnone specify_simple_path_decl
';'
2678 { PSpecPath
*tmp
= $2;
2680 tmp
->conditional
= true
;
2683 pform_module_specify_path
(tmp
);
2685 | K_Shold
'(' spec_reference_event
',' spec_reference_event
2686 ',' delay_value spec_notifier_opt
')' ';'
2689 | K_Speriod
'(' spec_reference_event
',' delay_value
2690 spec_notifier_opt
')' ';'
2693 | K_Srecovery
'(' spec_reference_event
',' spec_reference_event
2694 ',' delay_value spec_notifier_opt
')' ';'
2697 | K_Ssetup
'(' spec_reference_event
',' spec_reference_event
2698 ',' delay_value spec_notifier_opt
')' ';'
2701 | K_Ssetuphold
'(' spec_reference_event
',' spec_reference_event
2702 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2706 | K_Srecrem
'(' spec_reference_event
',' spec_reference_event
2707 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2711 | K_Swidth
'(' spec_reference_event
',' delay_value
',' expression
2712 spec_notifier_opt
')' ';'
2716 | K_Swidth
'(' spec_reference_event
',' delay_value
')' ';'
2723 | specify_item_list specify_item
2726 specify_edge_path_decl
2727 : specify_edge_path
'=' '(' delay_value_list
')'
2728 { $$
= pform_assign_path_delay
($1, $4); }
2729 | specify_edge_path
'=' delay_value_simple
2730 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2732 $$
= pform_assign_path_delay
($1, tmp
);
2736 edge_operator
: K_posedge
{ $$
= true
; } | K_negedge
{ $$
= false
; } ;
2739 : '(' specify_path_identifiers spec_polarity
2740 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2741 { int edge_flag
= 0;
2742 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, false
, $6, $8); }
2743 |
'(' edge_operator specify_path_identifiers spec_polarity
2744 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2745 { int edge_flag
= $2?
1 : -1;
2746 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, false
, $7, $9);}
2747 |
'(' specify_path_identifiers spec_polarity
2748 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2749 { int edge_flag
= 0;
2750 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, true
, $6, $8); }
2751 |
'(' edge_operator specify_path_identifiers spec_polarity
2752 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2753 { int edge_flag
= $2?
1 : -1;
2754 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, true
, $7, $9); }
2763 specify_simple_path_decl
2764 : specify_simple_path
'=' '(' delay_value_list
')'
2765 { $$
= pform_assign_path_delay
($1, $4); }
2766 | specify_simple_path
'=' delay_value_simple
2767 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2769 $$
= pform_assign_path_delay
($1, tmp
);
2771 | specify_simple_path
'=' '(' error ')'
2772 { yyerror(@
2, "Syntax error in delay value list.");
2779 : '(' specify_path_identifiers spec_polarity
2780 K_EG specify_path_identifiers
')'
2781 { $$
= pform_make_specify_path
(@
1, $2, $3, false
, $5); }
2782 |
'(' specify_path_identifiers spec_polarity
2783 K_SG specify_path_identifiers
')'
2784 { $$
= pform_make_specify_path
(@
1, $2, $3, true
, $5); }
2786 { yyerror(@
2, "Invalid simple path");
2791 specify_path_identifiers
2793 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2794 tmp
->push_back
(lex_strings.make
($1));
2798 | IDENTIFIER
'[' expr_primary
']'
2799 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2800 tmp
->push_back
(lex_strings.make
($1));
2804 | specify_path_identifiers
',' IDENTIFIER
2805 { list
<perm_string
>*tmp
= $1;
2806 tmp
->push_back
(lex_strings.make
($3));
2810 | specify_path_identifiers
',' IDENTIFIER
'[' expr_primary
']'
2811 { list
<perm_string
>*tmp
= $1;
2812 tmp
->push_back
(lex_strings.make
($3));
2819 : IDENTIFIER
'=' expression
2821 pform_set_specparam
(lex_strings.make
($1), tmp
);
2824 | IDENTIFIER
'=' expression
':' expression
':' expression
2826 switch
(min_typ_max_flag
) {
2843 pform_set_specparam
(lex_strings.make
($1), tmp
);
2846 | PATHPULSE_IDENTIFIER
'=' expression
2850 | PATHPULSE_IDENTIFIER
'=' '(' expression
',' expression
')'
2859 | specparam_list
',' specparam
2868 spec_reference_event
2869 : K_posedge expression
2871 | K_negedge expression
2873 | K_posedge expr_primary K_TAND expression
2877 | K_negedge expr_primary K_TAND expression
2881 | K_edge
'[' edge_descriptor_list
']' expr_primary K_TAND expression
2885 | expr_primary K_TAND expression
2893 /* The edge_descriptor is detected by the lexor as the various
2894 2-letter edge sequences that are supported here. For now, we
2895 don't care what they are, because we do not yet support specify
2897 edge_descriptor_list
2898 : edge_descriptor_list
',' K_edge_descriptor
2911 |
',' heirarchy_identifier
2915 | spec_notifier
',' heirarchy_identifier
2924 /* assign and deassign statements are procedural code to do
2925 structural assignments, and to turn that structural assignment
2926 off. This stronger then any other assign, but weaker then the
2927 force assignments. */
2929 : K_assign lpvalue
'=' expression
';'
2930 { PCAssign
*tmp
= new PCAssign
($2, $4);
2931 tmp
->set_file
(@
1.text
);
2932 tmp
->set_lineno
(@
1.first_line
);
2936 | K_deassign lpvalue
';'
2937 { PDeassign
*tmp
= new PDeassign
($2);
2938 tmp
->set_file
(@
1.text
);
2939 tmp
->set_lineno
(@
1.first_line
);
2944 /* Force and release statements are similar to assignments,
2945 syntactically, but they will be elaborated differently. */
2947 | K_force lpvalue
'=' expression
';'
2948 { PForce
*tmp
= new PForce
($2, $4);
2949 tmp
->set_file
(@
1.text
);
2950 tmp
->set_lineno
(@
1.first_line
);
2953 | K_release lpvalue
';'
2954 { PRelease
*tmp
= new PRelease
($2);
2955 tmp
->set_file
(@
1.text
);
2956 tmp
->set_lineno
(@
1.first_line
);
2960 /* begin-end blocks come in a variety of forms, including named and
2961 anonymous. The named blocks can also carry their own reg
2962 variables, which are placed in the scope created by the block
2963 name. These are handled by pushing the scope name then matching
2964 the declarations. The scope is popped at the end of the block. */
2966 | K_begin statement_list K_end
2967 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
, *$2);
2968 tmp
->set_file
(@
1.text
);
2969 tmp
->set_lineno
(@
1.first_line
);
2973 | K_begin
':' IDENTIFIER
2974 { pform_push_scope
($3); }
2975 block_item_decls_opt
2976 statement_list K_end
2977 { pform_pop_scope
();
2978 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
2979 PBlock
::BL_SEQ
, *$6);
2980 tmp
->set_file
(@
1.text
);
2981 tmp
->set_lineno
(@
1.first_line
);
2987 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2988 tmp
->set_file
(@
1.text
);
2989 tmp
->set_lineno
(@
1.first_line
);
2992 | K_begin
':' IDENTIFIER K_end
2993 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2994 tmp
->set_file
(@
1.text
);
2995 tmp
->set_lineno
(@
1.first_line
);
2998 | K_begin
error K_end
3001 /* fork-join blocks are very similar to begin-end blocks. In fact,
3002 from the parser's perspective there is no real difference. All we
3003 need to do is remember that this is a parallel block so that the
3004 code generator can do the right thing. */
3006 | K_fork
':' IDENTIFIER
3007 { pform_push_scope
($3); }
3008 block_item_decls_opt
3009 statement_list K_join
3010 { pform_pop_scope
();
3011 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
3012 PBlock
::BL_PAR
, *$6);
3013 tmp
->set_file
(@
1.text
);
3014 tmp
->set_lineno
(@
1.first_line
);
3020 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
3021 tmp
->set_file
(@
1.text
);
3022 tmp
->set_lineno
(@
1.first_line
);
3025 | K_fork
':' IDENTIFIER K_join
3026 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
3027 tmp
->set_file
(@
1.text
);
3028 tmp
->set_lineno
(@
1.first_line
);
3033 | K_disable heirarchy_identifier
';'
3034 { PDisable
*tmp
= new PDisable
(*$2);
3035 tmp
->set_file
(@
1.text
);
3036 tmp
->set_lineno
(@
1.first_line
);
3040 | K_TRIGGER heirarchy_identifier
';'
3041 { PTrigger
*tmp
= new PTrigger
(*$2);
3042 tmp
->set_file
(@
2.text
);
3043 tmp
->set_lineno
(@
2.first_line
);
3047 | K_forever statement
3048 { PForever
*tmp
= new PForever
($2);
3049 tmp
->set_file
(@
1.text
);
3050 tmp
->set_lineno
(@
1.first_line
);
3053 | K_fork statement_list K_join
3054 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
, *$2);
3055 tmp
->set_file
(@
1.text
);
3056 tmp
->set_lineno
(@
1.first_line
);
3060 | K_repeat
'(' expression
')' statement
3061 { PRepeat
*tmp
= new PRepeat
($3, $5);
3062 tmp
->set_file
(@
1.text
);
3063 tmp
->set_lineno
(@
1.first_line
);
3066 | K_case
'(' expression
')' case_items K_endcase
3067 { PCase
*tmp
= new PCase
(NetCase
::EQ
, $3, $5);
3068 tmp
->set_file
(@
1.text
);
3069 tmp
->set_lineno
(@
1.first_line
);
3072 | K_casex
'(' expression
')' case_items K_endcase
3073 { PCase
*tmp
= new PCase
(NetCase
::EQX
, $3, $5);
3074 tmp
->set_file
(@
1.text
);
3075 tmp
->set_lineno
(@
1.first_line
);
3078 | K_casez
'(' expression
')' case_items K_endcase
3079 { PCase
*tmp
= new PCase
(NetCase
::EQZ
, $3, $5);
3080 tmp
->set_file
(@
1.text
);
3081 tmp
->set_lineno
(@
1.first_line
);
3084 | K_case
'(' expression
')' error K_endcase
3086 | K_casex
'(' expression
')' error K_endcase
3088 | K_casez
'(' expression
')' error K_endcase
3090 | K_if
'(' expression
')' statement_or_null %prec less_than_K_else
3091 { PCondit
*tmp
= new PCondit
($3, $5, 0);
3092 tmp
->set_file
(@
1.text
);
3093 tmp
->set_lineno
(@
1.first_line
);
3096 | K_if
'(' expression
')' statement_or_null K_else statement_or_null
3097 { PCondit
*tmp
= new PCondit
($3, $5, $7);
3098 tmp
->set_file
(@
1.text
);
3099 tmp
->set_lineno
(@
1.first_line
);
3102 | K_if
'(' error ')' statement_or_null %prec less_than_K_else
3103 { yyerror(@
1, "error: Malformed conditional expression.");
3106 | K_if
'(' error ')' statement_or_null K_else statement_or_null
3107 { yyerror(@
1, "error: Malformed conditional expression.");
3110 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3111 lpvalue
'=' expression
')' statement
3112 { PForStatement
*tmp
= new PForStatement
($3, $5, $7, $9, $11, $13);
3113 tmp
->set_file
(@
1.text
);
3114 tmp
->set_lineno
(@
1.first_line
);
3117 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3120 yyerror(@
9, "error: Error in for loop step assignment.");
3122 | K_for
'(' lpvalue
'=' expression
';' error ';'
3123 lpvalue
'=' expression
')' statement
3125 yyerror(@
7, "error: Error in for loop condition expression.");
3127 | K_for
'(' error ')' statement
3129 yyerror(@
3, "error: Incomprehensible for loop.");
3131 | K_while
'(' expression
')' statement
3132 { PWhile
*tmp
= new PWhile
($3, $5);
3135 | K_while
'(' error ')' statement
3137 yyerror(@
3, "error: Error in while loop condition.");
3139 | delay1 statement_or_null
3140 { PExpr
*del
= (*$1)[0];
3141 assert
($1->count
() == 1);
3142 PDelayStatement
*tmp
= new PDelayStatement
(del
, $2);
3143 tmp
->set_file
(@
1.text
);
3144 tmp
->set_lineno
(@
1.first_line
);
3147 | event_control statement_or_null
3148 { PEventStatement
*tmp
= $1;
3150 yyerror(@
1, "error: Invalid event control.");
3153 tmp
->set_statement
($2);
3157 |
'@' '*' statement_or_null
3158 { PEventStatement
*tmp
= new PEventStatement
;
3159 tmp
->set_file
(@
1.text
);
3160 tmp
->set_lineno
(@
1.first_line
);
3161 tmp
->set_statement
($3);
3164 |
'@' '(' '*' ')' statement_or_null
3165 { PEventStatement
*tmp
= new PEventStatement
;
3166 tmp
->set_file
(@
1.text
);
3167 tmp
->set_lineno
(@
1.first_line
);
3168 tmp
->set_statement
($5);
3171 | lpvalue
'=' expression
';'
3172 { PAssign
*tmp
= new PAssign
($1,$3);
3173 tmp
->set_file
(@
1.text
);
3174 tmp
->set_lineno
(@
1.first_line
);
3177 |
error '=' expression
';'
3178 { yyerror(@
1, "Syntax in assignment statement l-value.");
3182 | lpvalue K_LE expression
';'
3183 { PAssignNB
*tmp
= new PAssignNB
($1,$3);
3184 tmp
->set_file
(@
1.text
);
3185 tmp
->set_lineno
(@
1.first_line
);
3188 |
error K_LE expression
';'
3189 { yyerror(@
1, "Syntax in assignment statement l-value.");
3193 | lpvalue
'=' delay1 expression
';'
3194 { assert
($3->count
() == 1);
3195 PExpr
*del
= (*$3)[0];
3196 PAssign
*tmp
= new PAssign
($1,del
,$4);
3197 tmp
->set_file
(@
1.text
);
3198 tmp
->set_lineno
(@
1.first_line
);
3201 | lpvalue K_LE delay1 expression
';'
3202 { assert
($3->count
() == 1);
3203 PExpr
*del
= (*$3)[0];
3204 PAssignNB
*tmp
= new PAssignNB
($1,del
,$4);
3205 tmp
->set_file
(@
1.text
);
3206 tmp
->set_lineno
(@
1.first_line
);
3209 | lpvalue
'=' event_control expression
';'
3210 { PAssign
*tmp
= new PAssign
($1,$3,$4);
3211 tmp
->set_file
(@
1.text
);
3212 tmp
->set_lineno
(@
1.first_line
);
3215 | lpvalue
'=' K_repeat
'(' expression
')' event_control expression
';'
3216 { PAssign
*tmp
= new PAssign
($1,$7,$8);
3217 tmp
->set_file
(@
1.text
);
3218 tmp
->set_lineno
(@
1.first_line
);
3219 yyerror(@
3, "sorry: repeat event control not supported.");
3223 | lpvalue K_LE event_control expression
';'
3224 { yyerror(@
1, "sorry: Event controls not supported here.");
3225 PAssignNB
*tmp
= new PAssignNB
($1,$4);
3226 tmp
->set_file
(@
1.text
);
3227 tmp
->set_lineno
(@
1.first_line
);
3230 | lpvalue K_LE K_repeat
'(' expression
')' event_control expression
';'
3231 { yyerror(@
1, "sorry: Event controls not supported here.");
3233 PAssignNB
*tmp
= new PAssignNB
($1,$8);
3234 tmp
->set_file
(@
1.text
);
3235 tmp
->set_lineno
(@
1.first_line
);
3238 | K_wait
'(' expression
')' statement_or_null
3239 { PEventStatement
*tmp
;
3240 PEEvent
*etmp
= new PEEvent
(PEEvent
::POSITIVE
, $3);
3241 tmp
= new PEventStatement
(etmp
);
3242 tmp
->set_file
(@
1.text
);
3243 tmp
->set_lineno
(@
1.first_line
);
3244 tmp
->set_statement
($5);
3247 | SYSTEM_IDENTIFIER
'(' expression_list_with_nuls
')' ';'
3248 { PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), *$3);
3249 tmp
->set_file
(@
1.text
);
3250 tmp
->set_lineno
(@
1.first_line
);
3255 | SYSTEM_IDENTIFIER
';'
3256 { svector
<PExpr
*>pt
(0);
3257 PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), pt
);
3258 tmp
->set_file
(@
1.text
);
3259 tmp
->set_lineno
(@
1.first_line
);
3263 | heirarchy_identifier
'(' expression_list_proper
')' ';'
3264 { PCallTask
*tmp
= new PCallTask
(*$1, *$3);
3265 tmp
->set_file
(@
1.text
);
3266 tmp
->set_lineno
(@
1.first_line
);
3272 /* NOTE: The standard doesn't really support an empty argument list
3273 between parentheses, but it seems natural, and people commonly
3274 want it. So accept it explicitly. */
3276 | heirarchy_identifier
'(' ')' ';'
3277 { svector
<PExpr
*>pt
(0);
3278 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3279 tmp
->set_file
(@
1.text
);
3280 tmp
->set_lineno
(@
1.first_line
);
3284 | heirarchy_identifier
';'
3285 { svector
<PExpr
*>pt
(0);
3286 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3287 tmp
->set_file
(@
1.text
);
3288 tmp
->set_lineno
(@
1.first_line
);
3293 { yyerror(@
1, "error: malformed statement");
3300 : statement_list statement
3301 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(*$1, $2);
3306 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(1);
3317 /* Task items are, other than the statement, task port items and
3318 other block items. */
3320 : block_item_decl
{ $$
= new svector
<PWire
*>(0); }
3321 | task_port_item
{ $$
= $1; }
3326 : K_input signed_opt range_opt list_of_identifiers
';'
3327 { svector
<PWire
*>*tmp
3328 = pform_make_task_ports
(NetNet
::PINPUT
,
3331 @
1.text
, @
1.first_line
);
3334 | K_output signed_opt range_opt list_of_identifiers
';'
3335 { svector
<PWire
*>*tmp
3336 = pform_make_task_ports
(NetNet
::POUTPUT
,
3339 @
1.text
, @
1.first_line
);
3342 | K_inout signed_opt range_opt list_of_identifiers
';'
3343 { svector
<PWire
*>*tmp
3344 = pform_make_task_ports
(NetNet
::PINOUT
,
3347 @
1.text
, @
1.first_line
);
3351 /* When the port is an integer, infer a signed vector of the integer
3352 shape. Generate a range to make it work. */
3354 | K_input K_integer list_of_identifiers
';'
3355 { svector
<PExpr
*>*range_stub
3356 = new svector
<PExpr
*>(2);
3358 re
= new PENumber
(new verinum
(integer_width
-1,
3360 (*range_stub
)[0] = re
;
3361 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3362 (*range_stub
)[1] = re
;
3364 = pform_make_task_ports
(NetNet
::PINPUT
,
3367 @
1.text
, @
1.first_line
);
3370 | K_output K_integer list_of_identifiers
';'
3371 { svector
<PExpr
*>*range_stub
3372 = new svector
<PExpr
*>(2);
3374 re
= new PENumber
(new verinum
(integer_width
-1,
3376 (*range_stub
)[0] = re
;
3377 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3378 (*range_stub
)[1] = re
;
3380 = pform_make_task_ports
(NetNet
::POUTPUT
,
3383 @
1.text
, @
1.first_line
);
3386 | K_inout K_integer list_of_identifiers
';'
3387 { svector
<PExpr
*>*range_stub
3388 = new svector
<PExpr
*>(2);
3390 re
= new PENumber
(new verinum
(integer_width
-1,
3392 (*range_stub
)[0] = re
;
3393 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3394 (*range_stub
)[1] = re
;
3396 = pform_make_task_ports
(NetNet
::PINOUT
,
3399 @
1.text
, @
1.first_line
);
3403 /* Ports can be real. */
3405 | K_input K_real list_of_identifiers
';'
3406 { svector
<PWire
*>*tmp
3407 = pform_make_task_ports
(NetNet
::PINPUT
,
3410 @
1.text
, @
1.first_line
);
3413 | K_output K_real list_of_identifiers
';'
3414 { svector
<PWire
*>*tmp
3415 = pform_make_task_ports
(NetNet
::POUTPUT
,
3418 @
1.text
, @
1.first_line
);
3421 | K_inout K_real list_of_identifiers
';'
3422 { svector
<PWire
*>*tmp
3423 = pform_make_task_ports
(NetNet
::PINOUT
,
3426 @
1.text
, @
1.first_line
);
3432 : task_item_list task_item
3433 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3451 : K_input signed_opt range_opt IDENTIFIER
3452 { svector
<PWire
*>*tmp
3453 = pform_make_task_ports
(NetNet
::PINPUT
,
3455 $3, list_from_identifier
($4),
3456 @
1.text
, @
1.first_line
);
3460 | K_output signed_opt range_opt IDENTIFIER
3461 { svector
<PWire
*>*tmp
3462 = pform_make_task_ports
(NetNet
::POUTPUT
,
3464 $3, list_from_identifier
($4),
3465 @
1.text
, @
1.first_line
);
3468 | K_inout signed_opt range_opt IDENTIFIER
3469 { svector
<PWire
*>*tmp
3470 = pform_make_task_ports
(NetNet
::PINOUT
,
3472 $3, list_from_identifier
($4),
3473 @
1.text
, @
1.first_line
);
3477 | K_input K_integer IDENTIFIER
3478 { svector
<PExpr
*>*range_stub
3479 = new svector
<PExpr
*>(2);
3481 re
= new PENumber
(new verinum
(integer_width
-1,
3483 (*range_stub
)[0] = re
;
3484 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3485 (*range_stub
)[1] = re
;
3487 = pform_make_task_ports
(NetNet
::PINPUT
,
3490 list_from_identifier
($3),
3491 @
1.text
, @
1.first_line
);
3494 | K_output K_integer IDENTIFIER
3495 { svector
<PExpr
*>*range_stub
3496 = new svector
<PExpr
*>(2);
3498 re
= new PENumber
(new verinum
(integer_width
-1,
3500 (*range_stub
)[0] = re
;
3501 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3502 (*range_stub
)[1] = re
;
3504 = pform_make_task_ports
(NetNet
::POUTPUT
,
3507 list_from_identifier
($3),
3508 @
1.text
, @
1.first_line
);
3511 | K_inout K_integer IDENTIFIER
3512 { svector
<PExpr
*>*range_stub
3513 = new svector
<PExpr
*>(2);
3515 re
= new PENumber
(new verinum
(integer_width
-1,
3517 (*range_stub
)[0] = re
;
3518 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3519 (*range_stub
)[1] = re
;
3521 = pform_make_task_ports
(NetNet
::PINOUT
,
3524 list_from_identifier
($3),
3525 @
1.text
, @
1.first_line
);
3529 /* Ports can be real. */
3531 | K_input K_real IDENTIFIER
3532 { svector
<PWire
*>*tmp
3533 = pform_make_task_ports
(NetNet
::PINPUT
,
3535 0, list_from_identifier
($3),
3536 @
1.text
, @
1.first_line
);
3539 | K_output K_real IDENTIFIER
3540 { svector
<PWire
*>*tmp
3541 = pform_make_task_ports
(NetNet
::POUTPUT
,
3543 0, list_from_identifier
($3),
3544 @
1.text
, @
1.first_line
);
3547 | K_inout K_real IDENTIFIER
3548 { svector
<PWire
*>*tmp
3549 = pform_make_task_ports
(NetNet
::PINOUT
,
3551 0, list_from_identifier
($3),
3552 @
1.text
, @
1.first_line
);
3558 : task_port_decl_list
',' task_port_decl
3559 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$3);
3569 : K_table
{ lex_start_table
(); }
3571 K_endtable
{ lex_end_table
(); $$
= $3; }
3575 : udp_comb_entry_list
3576 | udp_sequ_entry_list
3580 : udp_input_list
':' udp_output_sym
';'
3581 { char*tmp
= new
char[strlen
($1)+3];
3583 char*tp
= tmp
+strlen
(tmp
);
3594 { list
<string>*tmp
= new list
<string>;
3599 | udp_comb_entry_list udp_comb_entry
3600 { list
<string>*tmp
= $1;
3609 { list
<string>*tmp
= new list
<string>;
3614 | udp_sequ_entry_list udp_sequ_entry
3615 { list
<string>*tmp
= $1;
3623 : udp_input_list
':' udp_input_sym
':' udp_output_sym
';'
3624 { char*tmp
= new
char[strlen
($1)+5];
3626 char*tp
= tmp
+strlen
(tmp
);
3637 : K_initial IDENTIFIER
'=' number
';'
3638 { PExpr
*etmp
= new PENumber
($4);
3639 PEIdent
*itmp
= new PEIdent
(lex_strings.make
($2));
3640 PAssign
*atmp
= new PAssign
(itmp
, etmp
);
3641 atmp
->set_file
(@
2.text
);
3642 atmp
->set_lineno
(@
2.first_line
);
3649 : udp_initial
{ $$
= $1; }
3655 { char*tmp
= new
char[2];
3660 | udp_input_list udp_input_sym
3661 { char*tmp
= new
char[strlen
($1)+2];
3663 char*tp
= tmp
+strlen
(tmp
);
3704 /* Port declarations create wires for the inputs and the output. The
3705 makes for these ports are scoped within the UDP, so there is no
3706 heirarchy involved. */
3708 : K_input list_of_identifiers
';'
3709 { $$
= pform_make_udp_input_ports
($2); }
3710 | K_output IDENTIFIER
';'
3711 { pform_name_t pname
;
3712 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3713 PWire
*pp
= new PWire
(pname
, NetNet
::IMPLICIT
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3714 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3719 | K_reg IDENTIFIER
';'
3720 { pform_name_t pname
;
3721 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3722 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::PIMPLICIT
, IVL_VT_LOGIC
);
3723 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3728 | K_reg K_output IDENTIFIER
';'
3729 { pform_name_t pname
;
3730 pname.push_back
(name_component_t
(lex_strings.make
($3)));
3731 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3732 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3742 | udp_port_decls udp_port_decl
3743 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3752 { list
<string>*tmp
= new list
<string>;
3757 | udp_port_list
',' IDENTIFIER
3758 { list
<string>*tmp
= $1;
3765 udp_reg_opt: K_reg
{ $$
= true
; } |
{ $$
= false
; };
3767 udp_initial_expr_opt
3768 : '=' expression
{ $$
= $2; }
3772 udp_input_declaration_list
3773 : K_input IDENTIFIER
3774 { list
<perm_string
>*tmp
= new list
<perm_string
>;
3775 tmp
->push_back
(lex_strings.make
($2));
3779 | udp_input_declaration_list
',' K_input IDENTIFIER
3780 { list
<perm_string
>*tmp
= $1;
3781 tmp
->push_back
(lex_strings.make
($4));
3788 /* This is the syntax for primitives that uses the IEEE1364-1995
3789 format. The ports are simply names in the port list, and the
3790 declarations are in the body. */
3792 : K_primitive IDENTIFIER
'(' udp_port_list
')' ';'
3798 { perm_string tmp2
= lex_strings.make
($2);
3799 pform_make_udp
(tmp2
, $4, $7, $9, $8,
3800 @
2.text
, @
2.first_line
);
3804 /* This is the syntax for IEEE1364-2001 format definitions. The port
3805 names and declarations are all in the parameter list. */
3807 | K_primitive IDENTIFIER
3808 '(' K_output udp_reg_opt IDENTIFIER udp_initial_expr_opt
','
3809 udp_input_declaration_list
')' ';'
3813 { perm_string tmp2
= lex_strings.make
($2);
3814 perm_string tmp6
= lex_strings.make
($6);
3815 pform_make_udp
(tmp2
, $5, tmp6
, $7, $9, $12,
3816 @
2.text
, @
2.first_line
);