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
;
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
182 %type
<number
> number
183 %type
<flag
> signed_opt udp_reg_opt edge_operator
184 %type
<drive
> drive_strength drive_strength_opt dr_strength0 dr_strength1
185 %type
<letter
> udp_input_sym udp_output_sym
186 %type
<text
> udp_input_list udp_sequ_entry udp_comb_entry
187 %type
<perm_strings
> udp_input_declaration_list
188 %type
<strings
> udp_entry_list udp_comb_entry_list udp_sequ_entry_list
189 %type
<strings
> udp_body udp_port_list
190 %type
<wires
> udp_port_decl udp_port_decls
191 %type
<statement
> udp_initial udp_init_opt
192 %type
<expr
> udp_initial_expr_opt
194 %type
<text
> register_variable net_variable
195 %type
<perm_strings
> register_variable_list net_variable_list list_of_identifiers
197 %type
<net_decl_assign
> net_decl_assign net_decl_assigns
199 %type
<mport
> port port_opt port_reference port_reference_list
200 %type
<mport
> port_declaration
201 %type
<mports
> list_of_ports module_port_list_opt list_of_port_declarations
203 %type
<wires
> task_item task_item_list task_item_list_opt
204 %type
<wires
> task_port_item task_port_decl task_port_decl_list
205 %type
<wires
> function_item function_item_list
207 %type
<named_pexpr
> port_name parameter_value_byname
208 %type
<named_pexprs
> port_name_list parameter_value_byname_list
210 %type
<named_pexpr
> attribute
211 %type
<named_pexprs
> attribute_list attribute_list_opt
213 %type
<citem
> case_item
214 %type
<citems
> case_items
216 %type
<gate
> gate_instance
217 %type
<gates
> gate_instance_list
219 %type
<pform_name
> heirarchy_identifier
220 %type
<expr
> expression expr_primary
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
252 %left
'^' K_NXOR K_NOR
254 %left K_EQ K_NE K_CEQ K_CNE
255 %left K_GE K_LE
'<' '>'
256 %left K_LS K_RS K_RSS
262 /* to resolve dangling else ambiguity. */
263 %nonassoc less_than_K_else
268 /* A degenerate source file can be completely empty. */
269 main
: source_file |
;
273 | source_file description
276 number
: BASED_NUMBER
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. */
288 : K_PSTAR attribute_list K_STARP
{ $$
= $2; }
289 | K_PSTAR K_STARP
{ $$
= 0; }
294 : attribute_list
',' attribute
295 { svector
<named_pexpr_t
*>*tmp
=
296 new svector
<named_pexpr_t
*>(*$1,$3);
301 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
310 { named_pexpr_t
*tmp
= new named_pexpr_t
;
311 tmp
->name
= lex_strings.make
($1);
316 | IDENTIFIER
'=' expression
318 if
(!pform_expression_is_constant
(tmp
)) {
319 yyerror(@
3, "error: attribute value "
320 "expression must be constant.");
324 named_pexpr_t
*tmp2
= new named_pexpr_t
;
325 tmp2
->name
= lex_strings.make
($1);
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. */
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
);
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
);
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);
372 | K_time register_variable_list
';'
373 { pform_set_reg_time
($2);
376 /* real declarations are fairly simple as there is no range of
377 signed flag in the declaration. Create the real as a NetNet::REG
378 with real value. Note that real and realtime are interchangable
381 | K_real list_of_identifiers
';'
382 { pform_makewire
(@
1, 0, true
, $2,
388 | K_realtime list_of_identifiers
';'
389 { pform_makewire
(@
1, 0, true
, $2,
396 | K_parameter parameter_assign_decl
';'
397 | K_localparam localparam_assign_decl
';'
399 /* Recover from errors that happen within variable lists. Use the
400 trailing semi-colon to resync the parser. */
402 | attribute_list_opt K_reg
error ';'
403 { yyerror(@
2, "error: syntax error in reg variable list.");
407 | attribute_list_opt K_integer
error ';'
408 { yyerror(@
2, "error: syntax error in integer variable list.");
413 { yyerror(@
1, "error: syntax error in time variable list.");
417 { yyerror(@
1, "error: syntax error in real variable list.");
420 | K_realtime
error ';'
421 { yyerror(@
1, "error: syntax error in realtime variable list.");
424 | K_parameter
error ';'
425 { yyerror(@
1, "error: syntax error in parameter list.");
428 | K_localparam
error ';'
429 { yyerror(@
1, "error: syntax error localparam list.");
436 | block_item_decls block_item_decl
445 : expression_list_proper
':' statement_or_null
446 { PCase
::Item
*tmp
= new PCase
::Item
;
452 | K_default
':' statement_or_null
453 { PCase
::Item
*tmp
= new PCase
::Item
;
457 | K_default statement_or_null
458 { PCase
::Item
*tmp
= new PCase
::Item
;
462 |
error ':' statement_or_null
463 { yyerror(@
1, "error: Incomprehensible case expression.");
469 : case_items case_item
470 { svector
<PCase
::Item
*>*tmp
;
471 tmp
= new svector
<PCase
::Item
*>(*$1, $2);
476 { svector
<PCase
::Item
*>*tmp
= new svector
<PCase
::Item
*>(1);
494 : heirarchy_identifier
'=' expression
496 if
(!pform_expression_is_constant
(tmp
)) {
497 yyerror(@
3, "error: parameter value "
498 "must be constant.");
502 pform_set_defparam
(*$1, $3);
509 | range defparam_assign
510 { yyerror(@
1, "error: defparam may not include a range.");
513 | defparam_assign_list
',' defparam_assign
517 : '#' delay_value_simple
518 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
522 |
'#' '(' delay_value
')'
523 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
530 : '#' delay_value_simple
531 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
535 |
'#' '(' delay_value
')'
536 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
540 |
'#' '(' delay_value
',' delay_value
')'
541 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
546 |
'#' '(' delay_value
',' delay_value
',' delay_value
')'
547 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(3);
556 : delay3
{ $$
= $1; }
562 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
566 | delay_value_list
',' delay_value
567 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
578 | expression
':' expression
':' expression
579 { $$
= pform_select_mtm_expr
($1, $3, $5); }
587 yyerror(@
1, "internal error: delay.");
590 $$
= new PENumber
(tmp
);
591 $$
->set_file
(@
1.text
);
592 $$
->set_lineno
(@
1.first_line
);
598 yyerror(@
1, "internal error: delay.");
601 $$
= new PEFNumber
(tmp
);
602 $$
->set_file
(@
1.text
);
603 $$
->set_lineno
(@
1.first_line
);
607 { PEIdent
*tmp
= new PEIdent
(lex_strings.make
($1));
608 tmp
->set_file
(@
1.text
);
609 tmp
->set_lineno
(@
1.first_line
);
618 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')'
619 { perm_string tmp3
= lex_strings.make
($3);
620 pform_set_type_attrib
(tmp3
, $5, $7);
627 : '(' dr_strength0
',' dr_strength1
')'
631 |
'(' dr_strength1
',' dr_strength0
')'
635 |
'(' dr_strength0
',' K_highz1
')'
637 $$.str1
= PGate
::HIGHZ
;
639 |
'(' dr_strength1
',' K_highz0
')'
640 { $$.str0
= PGate
::HIGHZ
;
643 |
'(' K_highz1
',' dr_strength0
')'
645 $$.str1
= PGate
::HIGHZ
;
647 |
'(' K_highz0
',' dr_strength1
')'
648 { $$.str0
= PGate
::HIGHZ
;
654 : drive_strength
{ $$
= $1; }
655 |
{ $$.str0
= PGate
::STRONG
; $$.str1
= PGate
::STRONG
; }
659 : K_supply0
{ $$.str0
= PGate
::SUPPLY
; }
660 | K_strong0
{ $$.str0
= PGate
::STRONG
; }
661 | K_pull0
{ $$.str0
= PGate
::PULL
; }
662 | K_weak0
{ $$.str0
= PGate
::WEAK
; }
666 : K_supply1
{ $$.str1
= PGate
::SUPPLY
; }
667 | K_strong1
{ $$.str1
= PGate
::STRONG
; }
668 | K_pull1
{ $$.str1
= PGate
::PULL
; }
669 | K_weak1
{ $$.str1
= PGate
::WEAK
; }
673 : '@' heirarchy_identifier
674 { PEIdent
*tmpi
= new PEIdent
(*$2);
675 PEEvent
*tmpe
= new PEEvent
(PEEvent
::ANYEDGE
, tmpi
);
676 PEventStatement
*tmps
= new PEventStatement
(tmpe
);
677 tmps
->set_file
(@
1.text
);
678 tmps
->set_lineno
(@
1.first_line
);
682 |
'@' '(' event_expression_list
')'
683 { PEventStatement
*tmp
= new PEventStatement
(*$3);
684 tmp
->set_file
(@
1.text
);
685 tmp
->set_lineno
(@
1.first_line
);
690 { yyerror(@
1, "error: Malformed event control expression.");
695 event_expression_list
698 | event_expression_list K_or event_expression
699 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
704 | event_expression_list
',' event_expression
705 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
713 : K_posedge expression
714 { PEEvent
*tmp
= new PEEvent
(PEEvent
::POSEDGE
, $2);
715 tmp
->set_file
(@
1.text
);
716 tmp
->set_lineno
(@
1.first_line
);
717 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
721 | K_negedge expression
722 { PEEvent
*tmp
= new PEEvent
(PEEvent
::NEGEDGE
, $2);
723 tmp
->set_file
(@
1.text
);
724 tmp
->set_lineno
(@
1.first_line
);
725 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
730 { PEEvent
*tmp
= new PEEvent
(PEEvent
::ANYEDGE
, $1);
731 tmp
->set_file
(@
1.text
);
732 tmp
->set_lineno
(@
1.first_line
);
733 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
742 |
'+' expr_primary %prec UNARY_PREC
744 |
'-' expr_primary %prec UNARY_PREC
745 { PEUnary
*tmp
= new PEUnary
('-', $2);
746 tmp
->set_file
(@
2.text
);
747 tmp
->set_lineno
(@
2.first_line
);
750 |
'~' expr_primary %prec UNARY_PREC
751 { PEUnary
*tmp
= new PEUnary
('~', $2);
752 tmp
->set_file
(@
2.text
);
753 tmp
->set_lineno
(@
2.first_line
);
756 |
'&' expr_primary %prec UNARY_PREC
757 { PEUnary
*tmp
= new PEUnary
('&', $2);
758 tmp
->set_file
(@
2.text
);
759 tmp
->set_lineno
(@
2.first_line
);
762 |
'!' expr_primary %prec UNARY_PREC
763 { PEUnary
*tmp
= new PEUnary
('!', $2);
764 tmp
->set_file
(@
2.text
);
765 tmp
->set_lineno
(@
2.first_line
);
768 |
'|' expr_primary %prec UNARY_PREC
769 { PEUnary
*tmp
= new PEUnary
('|', $2);
770 tmp
->set_file
(@
2.text
);
771 tmp
->set_lineno
(@
2.first_line
);
774 |
'^' expr_primary %prec UNARY_PREC
775 { PEUnary
*tmp
= new PEUnary
('^', $2);
776 tmp
->set_file
(@
2.text
);
777 tmp
->set_lineno
(@
2.first_line
);
780 | K_NAND expr_primary %prec UNARY_PREC
781 { PEUnary
*tmp
= new PEUnary
('A', $2);
782 tmp
->set_file
(@
2.text
);
783 tmp
->set_lineno
(@
2.first_line
);
786 | K_NOR expr_primary %prec UNARY_PREC
787 { PEUnary
*tmp
= new PEUnary
('N', $2);
788 tmp
->set_file
(@
2.text
);
789 tmp
->set_lineno
(@
2.first_line
);
792 | K_NXOR expr_primary %prec UNARY_PREC
793 { PEUnary
*tmp
= new PEUnary
('X', $2);
794 tmp
->set_file
(@
2.text
);
795 tmp
->set_lineno
(@
2.first_line
);
798 |
'!' error %prec UNARY_PREC
799 { yyerror(@
1, "error: Operand of unary ! "
800 "is not a primary expression.");
803 |
'^' error %prec UNARY_PREC
804 { yyerror(@
1, "error: Operand of reduction ^ "
805 "is not a primary expression.");
808 | expression
'^' expression
809 { PEBinary
*tmp
= new PEBinary
('^', $1, $3);
810 tmp
->set_file
(@
2.text
);
811 tmp
->set_lineno
(@
2.first_line
);
814 | expression K_POW expression
815 { PEBinary
*tmp
= new PEBinary
('p', $1, $3);
816 tmp
->set_file
(@
2.text
);
817 tmp
->set_lineno
(@
2.first_line
);
820 | expression
'*' expression
821 { PEBinary
*tmp
= new PEBinary
('*', $1, $3);
822 tmp
->set_file
(@
2.text
);
823 tmp
->set_lineno
(@
2.first_line
);
826 | expression
'/' expression
827 { PEBinary
*tmp
= new PEBinary
('/', $1, $3);
828 tmp
->set_file
(@
2.text
);
829 tmp
->set_lineno
(@
2.first_line
);
832 | expression
'%' expression
833 { PEBinary
*tmp
= new PEBinary
('%', $1, $3);
834 tmp
->set_file
(@
2.text
);
835 tmp
->set_lineno
(@
2.first_line
);
838 | expression
'+' expression
839 { PEBinary
*tmp
= new PEBinary
('+', $1, $3);
840 tmp
->set_file
(@
2.text
);
841 tmp
->set_lineno
(@
2.first_line
);
844 | expression
'-' expression
845 { PEBinary
*tmp
= new PEBinary
('-', $1, $3);
846 tmp
->set_file
(@
2.text
);
847 tmp
->set_lineno
(@
2.first_line
);
850 | expression
'&' expression
851 { PEBinary
*tmp
= new PEBinary
('&', $1, $3);
852 tmp
->set_file
(@
2.text
);
853 tmp
->set_lineno
(@
2.first_line
);
856 | expression
'|' expression
857 { PEBinary
*tmp
= new PEBinary
('|', $1, $3);
858 tmp
->set_file
(@
2.text
);
859 tmp
->set_lineno
(@
2.first_line
);
862 | expression K_NAND expression
863 { PEBinary
*tmp
= new PEBinary
('A', $1, $3);
864 tmp
->set_file
(@
2.text
);
865 tmp
->set_lineno
(@
2.first_line
);
868 | expression K_NOR expression
869 { PEBinary
*tmp
= new PEBinary
('O', $1, $3);
870 tmp
->set_file
(@
2.text
);
871 tmp
->set_lineno
(@
2.first_line
);
874 | expression K_NXOR expression
875 { PEBinary
*tmp
= new PEBinary
('X', $1, $3);
876 tmp
->set_file
(@
2.text
);
877 tmp
->set_lineno
(@
2.first_line
);
880 | expression
'<' expression
881 { PEBinary
*tmp
= new PEBComp
('<', $1, $3);
882 tmp
->set_file
(@
2.text
);
883 tmp
->set_lineno
(@
2.first_line
);
886 | expression
'>' expression
887 { PEBinary
*tmp
= new PEBComp
('>', $1, $3);
888 tmp
->set_file
(@
2.text
);
889 tmp
->set_lineno
(@
2.first_line
);
892 | expression K_LS expression
893 { PEBinary
*tmp
= new PEBShift
('l', $1, $3);
894 tmp
->set_file
(@
2.text
);
895 tmp
->set_lineno
(@
2.first_line
);
898 | expression K_RS expression
899 { PEBinary
*tmp
= new PEBShift
('r', $1, $3);
900 tmp
->set_file
(@
2.text
);
901 tmp
->set_lineno
(@
2.first_line
);
904 | expression K_RSS expression
905 { PEBinary
*tmp
= new PEBShift
('R', $1, $3);
906 tmp
->set_file
(@
2.text
);
907 tmp
->set_lineno
(@
2.first_line
);
910 | expression K_EQ expression
911 { PEBinary
*tmp
= new PEBComp
('e', $1, $3);
912 tmp
->set_file
(@
2.text
);
913 tmp
->set_lineno
(@
2.first_line
);
916 | expression K_CEQ expression
917 { PEBinary
*tmp
= new PEBComp
('E', $1, $3);
918 tmp
->set_file
(@
2.text
);
919 tmp
->set_lineno
(@
2.first_line
);
922 | expression K_LE expression
923 { PEBinary
*tmp
= new PEBComp
('L', $1, $3);
924 tmp
->set_file
(@
2.text
);
925 tmp
->set_lineno
(@
2.first_line
);
928 | expression K_GE expression
929 { PEBinary
*tmp
= new PEBComp
('G', $1, $3);
930 tmp
->set_file
(@
2.text
);
931 tmp
->set_lineno
(@
2.first_line
);
934 | expression K_NE expression
935 { PEBinary
*tmp
= new PEBComp
('n', $1, $3);
936 tmp
->set_file
(@
2.text
);
937 tmp
->set_lineno
(@
2.first_line
);
940 | expression K_CNE expression
941 { PEBinary
*tmp
= new PEBComp
('N', $1, $3);
942 tmp
->set_file
(@
2.text
);
943 tmp
->set_lineno
(@
2.first_line
);
946 | expression K_LOR expression
947 { PEBinary
*tmp
= new PEBinary
('o', $1, $3);
948 tmp
->set_file
(@
2.text
);
949 tmp
->set_lineno
(@
2.first_line
);
952 | expression K_LAND expression
953 { PEBinary
*tmp
= new PEBinary
('a', $1, $3);
954 tmp
->set_file
(@
2.text
);
955 tmp
->set_lineno
(@
2.first_line
);
958 | expression
'?' expression
':' expression
959 { PETernary
*tmp
= new PETernary
($1, $3, $5);
960 tmp
->set_file
(@
2.text
);
961 tmp
->set_lineno
(@
2.first_line
);
967 /* Many contexts take a comma separated list of expressions. Null
968 expressions can happen anywhere in the list, so there are two
969 extra rules in expression_list_with_nuls for parsing and
970 installing those nulls.
972 The expression_list_proper rules do not allow null items in the
973 expression list, so can be used where nul expressions are not allowed. */
975 expression_list_with_nuls
976 : expression_list_with_nuls
',' expression
977 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
982 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
987 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
992 | expression_list_with_nuls
','
993 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, 0);
999 expression_list_proper
1000 : expression_list_proper
',' expression
1001 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
1006 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1015 PENumber
*tmp
= new PENumber
($1);
1016 tmp
->set_file
(@
1.text
);
1017 tmp
->set_lineno
(@
1.first_line
);
1021 { PEFNumber
*tmp
= new PEFNumber
($1);
1022 tmp
->set_file
(@
1.text
);
1023 tmp
->set_lineno
(@
1.first_line
);
1027 { PEString
*tmp
= new PEString
($1);
1028 tmp
->set_file
(@
1.text
);
1029 tmp
->set_lineno
(@
1.first_line
);
1033 { perm_string tn
= lex_strings.make
($1);
1034 PECallFunction
*tmp
= new PECallFunction
(tn
);
1035 tmp
->set_file
(@
1.text
);
1036 tmp
->set_lineno
(@
1.first_line
);
1041 /* The heirarchy_identifier rule matches simple identifiers as well as
1042 indexed arrays and part selects */
1044 | heirarchy_identifier
1045 { PEIdent
*tmp
= new PEIdent
(*$1);
1046 tmp
->set_file
(@
1.text
);
1047 tmp
->set_lineno
(@
1.first_line
);
1052 /* An identifer followed by an expression list in parentheses is a
1053 function call. If a system identifier, then a system function
1056 | heirarchy_identifier
'(' expression_list_proper
')'
1057 { PECallFunction
*tmp
= new PECallFunction
(*$1, *$3);
1058 tmp
->set_file
(@
1.text
);
1059 tmp
->set_lineno
(@
1.first_line
);
1063 | SYSTEM_IDENTIFIER
'(' expression_list_proper
')'
1064 { perm_string tn
= lex_strings.make
($1);
1065 PECallFunction
*tmp
= new PECallFunction
(tn
, *$3);
1066 tmp
->set_file
(@
1.text
);
1067 tmp
->set_lineno
(@
1.first_line
);
1071 /* Parenthesized expressions are primaries. */
1073 |
'(' expression
')'
1076 /* Various kinds of concatenation expressions. */
1078 |
'{' expression_list_proper
'}'
1079 { PEConcat
*tmp
= new PEConcat
(*$2);
1080 tmp
->set_file
(@
1.text
);
1081 tmp
->set_lineno
(@
1.first_line
);
1085 |
'{' expression
'{' expression_list_proper
'}' '}'
1087 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1088 tmp
->set_file
(@
1.text
);
1089 tmp
->set_lineno
(@
1.first_line
);
1093 |
'{' expression
'{' expression_list_proper
'}' error '}'
1095 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1096 tmp
->set_file
(@
1.text
);
1097 tmp
->set_lineno
(@
1.first_line
);
1100 yyerror(@
5, "error: Syntax error between internal '}' "
1101 "and closing '}' of repeat concatenation.");
1106 /* A function_item is either a block item (i.e. a reg or integer
1107 declaration) or an input declaration. There are no output or
1110 : K_input signed_opt range_opt list_of_identifiers
';'
1111 { svector
<PWire
*>*tmp
1112 = pform_make_task_ports
(NetNet
::PINPUT
,
1115 @
1.text
, @
1.first_line
);
1118 | K_output signed_opt range_opt list_of_identifiers
';'
1119 { svector
<PWire
*>*tmp
1120 = pform_make_task_ports
(NetNet
::PINPUT
,
1123 @
1.text
, @
1.first_line
);
1125 yyerror(@
1, "Functions may not have output ports.");
1127 | K_inout signed_opt range_opt list_of_identifiers
';'
1128 { svector
<PWire
*>*tmp
1129 = pform_make_task_ports
(NetNet
::PINPUT
,
1132 @
1.text
, @
1.first_line
);
1134 yyerror(@
1, "Functions may not have inout ports.");
1137 /* When the port is an integer, infer a signed vector of the integer
1138 shape. Generate a range to make it work. */
1140 | K_input K_integer list_of_identifiers
';'
1141 { svector
<PExpr
*>*range_stub
1142 = new svector
<PExpr
*>(2);
1144 re
= new PENumber
(new verinum
(integer_width
-1,
1146 (*range_stub
)[0] = re
;
1147 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
1148 (*range_stub
)[1] = re
;
1150 = pform_make_task_ports
(NetNet
::PINPUT
,
1153 @
1.text
, @
1.first_line
);
1157 /* Ports can be real. */
1159 | K_input K_real list_of_identifiers
';'
1160 { svector
<PWire
*>*tmp
1161 = pform_make_task_ports
(NetNet
::PINPUT
,
1164 @
1.text
, @
1.first_line
);
1172 /* A function_item_list only lists the input/output/inout
1173 declarations. The integer and reg declarations are handled in
1174 place, so are not listed. The list builder needs to account for
1175 the possibility that the various parts may be NULL. */
1179 | function_item_list function_item
1181 svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
1193 /* A gate_instance is a module instantiation or a built in part
1194 type. In any case, the gate has a set of connections to ports. */
1196 : IDENTIFIER
'(' expression_list_with_nuls
')'
1197 { lgate
*tmp
= new lgate
;
1200 tmp
->file
= @
1.text
;
1201 tmp
->lineno
= @
1.first_line
;
1206 | IDENTIFIER range
'(' expression_list_with_nuls
')'
1207 { lgate
*tmp
= new lgate
;
1208 svector
<PExpr
*>*rng
= $2;
1211 tmp
->range
[0] = (*rng
)[0];
1212 tmp
->range
[1] = (*rng
)[1];
1213 tmp
->file
= @
1.text
;
1214 tmp
->lineno
= @
1.first_line
;
1219 |
'(' expression_list_with_nuls
')'
1220 { lgate
*tmp
= new lgate
;
1223 tmp
->file
= @
1.text
;
1224 tmp
->lineno
= @
1.first_line
;
1228 /* Degenerate modules can have no ports. */
1231 { lgate
*tmp
= new lgate
;
1232 svector
<PExpr
*>*rng
= $2;
1235 tmp
->parms_by_name
= 0;
1236 tmp
->range
[0] = (*rng
)[0];
1237 tmp
->range
[1] = (*rng
)[1];
1238 tmp
->file
= @
1.text
;
1239 tmp
->lineno
= @
1.first_line
;
1245 /* Modules can also take ports by port-name expressions. */
1247 | IDENTIFIER
'(' port_name_list
')'
1248 { lgate
*tmp
= new lgate
;
1251 tmp
->parms_by_name
= $3;
1252 tmp
->file
= @
1.text
;
1253 tmp
->lineno
= @
1.first_line
;
1258 | IDENTIFIER range
'(' port_name_list
')'
1259 { lgate
*tmp
= new lgate
;
1260 svector
<PExpr
*>*rng
= $2;
1263 tmp
->parms_by_name
= $4;
1264 tmp
->range
[0] = (*rng
)[0];
1265 tmp
->range
[1] = (*rng
)[1];
1266 tmp
->file
= @
1.text
;
1267 tmp
->lineno
= @
1.first_line
;
1275 : gate_instance_list
',' gate_instance
1276 { svector
<lgate
>*tmp1
= $1;
1278 svector
<lgate
>*out
= new svector
<lgate
> (*tmp1
, *tmp2
);
1284 { svector
<lgate
>*tmp
= new svector
<lgate
>(1);
1292 : K_and
{ $$
= PGBuiltin
::AND
; }
1293 | K_nand
{ $$
= PGBuiltin
::NAND
; }
1294 | K_or
{ $$
= PGBuiltin
::OR
; }
1295 | K_nor
{ $$
= PGBuiltin
::NOR
; }
1296 | K_xor
{ $$
= PGBuiltin
::XOR
; }
1297 | K_xnor
{ $$
= PGBuiltin
::XNOR
; }
1298 | K_buf
{ $$
= PGBuiltin
::BUF
; }
1299 | K_bufif0
{ $$
= PGBuiltin
::BUFIF0
; }
1300 | K_bufif1
{ $$
= PGBuiltin
::BUFIF1
; }
1301 | K_not
{ $$
= PGBuiltin
::NOT
; }
1302 | K_notif0
{ $$
= PGBuiltin
::NOTIF0
; }
1303 | K_notif1
{ $$
= PGBuiltin
::NOTIF1
; }
1304 | K_nmos
{ $$
= PGBuiltin
::NMOS
; }
1305 | K_rnmos
{ $$
= PGBuiltin
::RNMOS
; }
1306 | K_pmos
{ $$
= PGBuiltin
::PMOS
; }
1307 | K_rpmos
{ $$
= PGBuiltin
::RPMOS
; }
1308 | K_cmos
{ $$
= PGBuiltin
::CMOS
; }
1309 | K_rcmos
{ $$
= PGBuiltin
::RCMOS
; }
1310 | K_tran
{ $$
= PGBuiltin
::TRAN
; }
1311 | K_rtran
{ $$
= PGBuiltin
::RTRAN
; }
1312 | K_tranif0
{ $$
= PGBuiltin
::TRANIF0
; }
1313 | K_tranif1
{ $$
= PGBuiltin
::TRANIF1
; }
1314 | K_rtranif0
{ $$
= PGBuiltin
::RTRANIF0
; }
1315 | K_rtranif1
{ $$
= PGBuiltin
::RTRANIF1
; }
1319 /* A general identifier is a hierarchical name, with the right most
1320 name the base of the identifier. This rule builds up a
1321 hierarchical name from the left to the right, forming a list of
1324 heirarchy_identifier
1326 { $$
= new pform_name_t
;
1327 $$
->push_back
(name_component_t
(lex_strings.make
($1)));
1330 | heirarchy_identifier
'.' IDENTIFIER
1331 { pform_name_t
* tmp
= $1;
1332 tmp
->push_back
(name_component_t
(lex_strings.make
($3)));
1336 | heirarchy_identifier
'[' expression
']'
1337 { pform_name_t
* tmp
= $1;
1338 name_component_t
&tail
= tmp
->back
();
1339 index_component_t itmp
;
1340 itmp.sel
= index_component_t
::SEL_BIT
;
1342 tail.index.push_back
(itmp
);
1345 | heirarchy_identifier
'[' expression
':' expression
']'
1346 { pform_name_t
* tmp
= $1;
1347 name_component_t
&tail
= tmp
->back
();
1348 index_component_t itmp
;
1349 itmp.sel
= index_component_t
::SEL_PART
;
1352 tail.index.push_back
(itmp
);
1355 | heirarchy_identifier
'[' expression K_PO_POS expression
']'
1356 { pform_name_t
* tmp
= $1;
1357 name_component_t
&tail
= tmp
->back
();
1358 index_component_t itmp
;
1359 itmp.sel
= index_component_t
::SEL_IDX_UP
;
1362 tail.index.push_back
(itmp
);
1365 | heirarchy_identifier
'[' expression K_PO_NEG expression
']'
1366 { pform_name_t
* tmp
= $1;
1367 name_component_t
&tail
= tmp
->back
();
1368 index_component_t itmp
;
1369 itmp.sel
= index_component_t
::SEL_IDX_DO
;
1372 tail.index.push_back
(itmp
);
1377 /* This is a list of identifiers. The result is a list of strings,
1378 each one of the identifiers in the list. These are simple,
1379 non-hierarchical names separated by ',' characters. */
1382 { $$
= list_from_identifier
($1); }
1383 | list_of_identifiers
',' IDENTIFIER
1384 { $$
= list_from_identifier
($1, $3); }
1388 /* The list_of_ports and list_of_port_declarations rules are the
1389 port list formats for module ports. The list_of_ports_opt rule is
1390 only used by the module start rule.
1392 The first, the list_of_ports, is the 1364-1995 format, a list of
1393 port names, including .name() syntax.
1395 The list_of_port_declarations the 1364-2001 format, an in-line
1396 declaration of the ports.
1398 In both cases, the list_of_ports and list_of_port_declarations
1399 returns an array of Module::port_t* items that include the name
1400 of the port internally and externally. The actual creation of the
1401 nets/variables is done in the declaration, whether internal to
1402 the port list or in amongst the module items. */
1406 { svector
<Module
::port_t
*>*tmp
1407 = new svector
<Module
::port_t
*>(1);
1411 | list_of_ports
',' port_opt
1412 { svector
<Module
::port_t
*>*tmp
1413 = new svector
<Module
::port_t
*>(*$1, $3);
1419 list_of_port_declarations
1421 { svector
<Module
::port_t
*>*tmp
1422 = new svector
<Module
::port_t
*>(1);
1426 | list_of_port_declarations
',' port_declaration
1427 { svector
<Module
::port_t
*>*tmp
1428 = new svector
<Module
::port_t
*>(*$1, $3);
1432 | list_of_port_declarations
',' IDENTIFIER
1433 { Module
::port_t
*ptmp
;
1434 ptmp
= pform_module_port_reference
($3, @
3.text
,
1436 svector
<Module
::port_t
*>*tmp
1437 = new svector
<Module
::port_t
*>(*$1, ptmp
);
1439 /* Get the port declaration details, the port type
1440 and what not, from context data stored by the
1441 last port_declaration rule. */
1442 pform_module_define_port
(@
3, $3,
1443 port_declaration_context.port_type
,
1444 port_declaration_context.port_net_type
,
1445 port_declaration_context.sign_flag
,
1446 port_declaration_context.range
, 0);
1453 : attribute_list_opt
1454 K_input net_type_opt signed_opt range_opt IDENTIFIER
1455 { Module
::port_t
*ptmp
;
1456 ptmp
= pform_module_port_reference
($6, @
2.text
,
1458 pform_module_define_port
(@
2, $6, NetNet
::PINPUT
,
1460 port_declaration_context.port_type
= NetNet
::PINPUT
;
1461 port_declaration_context.port_net_type
= $3;
1462 port_declaration_context.sign_flag
= $4;
1463 port_declaration_context.range
= $5;
1468 | attribute_list_opt
1469 K_inout net_type_opt signed_opt range_opt IDENTIFIER
1470 { Module
::port_t
*ptmp
;
1471 ptmp
= pform_module_port_reference
($6, @
2.text
,
1473 pform_module_define_port
(@
2, $6, NetNet
::PINOUT
,
1475 port_declaration_context.port_type
= NetNet
::PINOUT
;
1476 port_declaration_context.port_net_type
= $3;
1477 port_declaration_context.sign_flag
= $4;
1478 port_declaration_context.range
= $5;
1483 | attribute_list_opt
1484 K_output net_type_opt signed_opt range_opt IDENTIFIER
1485 { Module
::port_t
*ptmp
;
1486 ptmp
= pform_module_port_reference
($6, @
2.text
,
1488 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1490 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1491 port_declaration_context.port_net_type
= $3;
1492 port_declaration_context.sign_flag
= $4;
1493 port_declaration_context.range
= $5;
1498 | attribute_list_opt
1499 K_output var_type signed_opt range_opt IDENTIFIER
1500 { Module
::port_t
*ptmp
;
1501 ptmp
= pform_module_port_reference
($6, @
2.text
,
1503 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1505 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1506 port_declaration_context.port_net_type
= $3;
1507 port_declaration_context.sign_flag
= $4;
1508 port_declaration_context.range
= $5;
1513 | attribute_list_opt
1514 K_output var_type signed_opt range_opt IDENTIFIER
'=' expression
1515 { Module
::port_t
*ptmp
;
1516 ptmp
= pform_module_port_reference
($6, @
2.text
,
1518 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1520 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1521 port_declaration_context.port_net_type
= $3;
1522 port_declaration_context.sign_flag
= $4;
1523 port_declaration_context.range
= $5;
1525 if
(! pform_expression_is_constant
($8))
1526 yyerror(@
8, "error: register declaration assignment"
1527 " value must be a constant expression.");
1528 pform_make_reginit
(@
6, $6, $8);
1539 : net_type
{ $$
= $1; }
1540 |
{ $$
= NetNet
::IMPLICIT
; }
1543 signed_opt
: K_signed
{ $$
= true
; } |
{$$
= false
; } ;
1545 /* An lpvalue is the expression that can go on the left side of a
1546 procedural assignment. This rule handles only procedural
1547 assignments. It is more limited then the general expr_primary
1548 rule to reflect the rules for assignment l-values. */
1550 : heirarchy_identifier
1551 { PEIdent
*tmp
= new PEIdent
(*$1);
1552 tmp
->set_file
(@
1.text
);
1553 tmp
->set_lineno
(@
1.first_line
);
1557 |
'{' expression_list_proper
'}'
1558 { PEConcat
*tmp
= new PEConcat
(*$2);
1559 tmp
->set_file
(@
1.text
);
1560 tmp
->set_lineno
(@
1.first_line
);
1567 /* Continuous assignments have a list of individual assignments. */
1570 : lpvalue
'=' expression
1571 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
1579 : cont_assign_list
',' cont_assign
1580 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, *$3);
1590 /* This is the global structure of a module. A module in a start
1591 section, with optional ports, then an optional list of module
1592 items, and finally an end marker. */
1594 module
: attribute_list_opt module_start IDENTIFIER
1595 { pform_startmodule
($3, @
2.text
, @
2.first_line
, $1); }
1596 module_parameter_port_list_opt
1597 module_port_list_opt
';'
1598 { pform_module_set_ports
($6); }
1599 module_item_list_opt
1601 { pform_endmodule
($3);
1607 module_start
: K_module | K_macromodule
;
1609 module_port_list_opt
1610 : '(' list_of_ports
')' { $$
= $2; }
1611 |
'(' list_of_port_declarations
')' { $$
= $2; }
1615 /* Module declarations include optional ANSII style module parameter
1616 ports. These are simply advance ways to declare parameters, so
1617 that the port declarations may use them. */
1618 module_parameter_port_list_opt
1620 |
'#' '(' module_parameter_port_list
')'
1623 module_parameter_port_list
1624 : K_parameter parameter_assign
1625 | module_parameter_port_list
',' parameter_assign
1626 | module_parameter_port_list
',' K_parameter parameter_assign
1631 /* This rule detects net declarations that possibly include a
1632 primitive type, an optional vector range and signed flag. This
1633 also includes an optional delay set. The values are then applied
1634 to a list of names. If the primitive type is not specified, then
1635 resort to the default type LOGIC. */
1637 : attribute_list_opt net_type
1638 primitive_type_opt signed_opt range_opt
1640 net_variable_list
';'
1642 { ivl_variable_type_t dtype
= $3;
1643 if
(dtype
== IVL_VT_NO_TYPE
)
1644 dtype
= IVL_VT_LOGIC
;
1645 pform_makewire
(@
2, $5, $4, $7, $2,
1646 NetNet
::NOT_A_PORT
, dtype
, $1);
1648 yyerror(@
6, "sorry: net delays not supported.");
1654 /* Very similar to the rule above, but this takes a list of
1655 net_decl_assigns, which are <name> = <expr> assignment
1658 | attribute_list_opt net_type
1659 primitive_type_opt signed_opt range_opt
1660 delay3_opt net_decl_assigns
';'
1662 { ivl_variable_type_t dtype
= $3;
1663 if
(dtype
== IVL_VT_NO_TYPE
)
1664 dtype
= IVL_VT_LOGIC
;
1665 pform_makewire
(@
2, $5, $4, $6,
1666 str_strength
, $7, $2, dtype
);
1668 yyerror(@
2, "sorry: Attributes not supported "
1669 "on net declaration assignments.");
1674 /* This form doesn't have the range, but does have strengths. This
1675 gives strength to the assignment drivers. */
1677 | attribute_list_opt net_type
1678 primitive_type_opt signed_opt
1679 drive_strength net_decl_assigns
';'
1681 { ivl_variable_type_t dtype
= $3;
1682 if
(dtype
== IVL_VT_NO_TYPE
)
1683 dtype
= IVL_VT_LOGIC
;
1684 pform_makewire
(@
2, 0, $4, 0, $5, $6, $2, dtype
);
1686 yyerror(@
2, "sorry: Attributes not supported "
1687 "on net declaration assignments.");
1692 | K_trireg charge_strength_opt range_opt delay3_opt list_of_identifiers
';'
1693 { yyerror(@
1, "sorry: trireg nets not supported.");
1698 | port_type signed_opt range_opt delay3_opt list_of_identifiers
';'
1699 { pform_set_port_type
(@
1, $5, $3, $2, $1);
1702 /* The next two rules handle Verilog 2001 statements of the form:
1703 input wire signed [h:l] <list>;
1704 This creates the wire and sets the port type all at once. */
1706 | port_type net_type signed_opt range_opt list_of_identifiers
';'
1707 { pform_makewire
(@
1, $4, $3, $5, $2, $1, IVL_VT_NO_TYPE
, 0);
1710 | K_output var_type signed_opt range_opt list_of_identifiers
';'
1711 { pform_makewire
(@
1, $4, $3, $5, $2,
1716 /* var_type declaration (reg variables) cannot be input or output,
1717 because the port declaration implies an external driver, which
1718 cannot be attached to a reg. These rules catch that error early. */
1720 | K_input var_type signed_opt range_opt list_of_identifiers
';'
1721 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINPUT
,
1723 yyerror(@
2, "error: reg variables cannot be inputs.");
1726 | K_inout var_type signed_opt range_opt list_of_identifiers
';'
1727 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINOUT
,
1729 yyerror(@
2, "error: reg variables cannot be inouts.");
1732 | port_type signed_opt range_opt delay3_opt
error ';'
1733 { yyerror(@
1, "error: Invalid variable list"
1734 " in port declaration.");
1740 /* block_item_decl rule is shared with task blocks and named
1747 | K_defparam defparam_assign_list
';'
1748 | K_event list_of_identifiers
';'
1749 { pform_make_events
($2, @
1.text
, @
1.first_line
);
1752 /* Most gate types have an optional drive strength and optional
1753 three-value delay. These rules handle the different cases. */
1755 | attribute_list_opt gatetype gate_instance_list
';'
1756 { pform_makegates
($2, str_strength
, 0, $3, $1);
1759 | attribute_list_opt gatetype delay3 gate_instance_list
';'
1760 { pform_makegates
($2, str_strength
, $3, $4, $1);
1763 | attribute_list_opt gatetype drive_strength gate_instance_list
';'
1764 { pform_makegates
($2, $3, 0, $4, $1);
1767 | attribute_list_opt gatetype drive_strength delay3 gate_instance_list
';'
1768 { pform_makegates
($2, $3, $4, $5, $1);
1771 /* Pullup and pulldown devices cannot have delays, and their
1772 strengths are limited. */
1774 | K_pullup gate_instance_list
';'
1775 { pform_makegates
(PGBuiltin
::PULLUP
, pull_strength
, 0,
1778 | K_pulldown gate_instance_list
';'
1779 { pform_makegates
(PGBuiltin
::PULLDOWN
, pull_strength
,
1783 | K_pullup
'(' dr_strength1
')' gate_instance_list
';'
1784 { pform_makegates
(PGBuiltin
::PULLUP
, $3, 0, $5, 0);
1787 | K_pulldown
'(' dr_strength0
')' gate_instance_list
';'
1788 { pform_makegates
(PGBuiltin
::PULLDOWN
, $3, 0, $5, 0);
1791 /* This rule handles instantiations of modules and user defined
1792 primitives. These devices to not have delay lists or strengths,
1793 but then can have parameter lists. */
1795 | attribute_list_opt
1796 IDENTIFIER parameter_value_opt gate_instance_list
';'
1797 { perm_string tmp1
= lex_strings.make
($2);
1798 pform_make_modgates
(tmp1
, $3, $4);
1803 | attribute_list_opt
1804 IDENTIFIER parameter_value_opt
error ';'
1805 { yyerror(@
2, "error: Invalid module instantiation");
1809 /* Continuous assignment can have an optional drive strength, then
1810 an optional delay3 that applies to all the assignments in the
1811 cont_assign_list. */
1813 | K_assign drive_strength_opt delay3_opt cont_assign_list
';'
1814 { pform_make_pgassign_list
($4, $3, $2, @
1.text
, @
1.first_line
); }
1816 /* Always and initial items are behavioral processes. */
1818 | attribute_list_opt K_always statement
1819 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_ALWAYS
,
1821 tmp
->set_file
(@
2.text
);
1822 tmp
->set_lineno
(@
2.first_line
);
1824 | attribute_list_opt K_initial statement
1825 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_INITIAL
,
1827 tmp
->set_file
(@
2.text
);
1828 tmp
->set_lineno
(@
2.first_line
);
1831 /* The task declaration rule matches the task declaration
1832 header, then pushes the function scope. This causes the
1833 definitions in the task_body to take on the scope of the task
1834 instead of the module. Note that these runs accept for the task
1835 body statement_or_null, although the standard does not allow null
1836 statements in the task body. But we continue to accept it as an
1839 | K_task IDENTIFIER
';'
1840 { pform_push_scope
($2); }
1844 { PTask
*tmp
= new PTask
;
1845 perm_string tmp2
= lex_strings.make
($2);
1846 tmp
->set_file
(@
1.text
);
1847 tmp
->set_lineno
(@
1.first_line
);
1849 tmp
->set_statement
($6);
1850 pform_set_task
(tmp2
, tmp
);
1856 { pform_push_scope
($2); }
1857 '(' task_port_decl_list
')' ';'
1861 { PTask
*tmp
= new PTask
;
1862 perm_string tmp2
= lex_strings.make
($2);
1863 tmp
->set_file
(@
1.text
);
1864 tmp
->set_lineno
(@
1.first_line
);
1866 tmp
->set_statement
($9);
1867 pform_set_task
(tmp2
, tmp
);
1872 /* The function declaration rule matches the function declaration
1873 header, then pushes the function scope. This causes the
1874 definitions in the func_body to take on the scope of the function
1875 instead of the module. */
1877 | K_function function_range_or_type_opt IDENTIFIER
';'
1878 { pform_push_scope
($3); }
1879 function_item_list statement
1881 { perm_string name
= lex_strings.make
($3);
1882 PFunction
*tmp
= new PFunction
(name
);
1883 tmp
->set_file
(@
1.text
);
1884 tmp
->set_lineno
(@
1.first_line
);
1886 tmp
->set_statement
($7);
1887 tmp
->set_return
($2);
1888 pform_set_function
(name
, tmp
);
1893 /* A generate region can contain further module items. Actually, it
1894 is supposed to be limited to certain kinds of module items, but
1895 the semantic tests will check that for us. */
1897 | K_generate module_item_list_opt K_endgenerate
1899 | K_genvar list_of_identifiers
';'
1900 { pform_genvars
($2); }
1902 | K_for
'(' IDENTIFIER
'=' expression
';'
1904 IDENTIFIER
'=' expression
')'
1905 { pform_start_generate_for
(@
1, $3, $5, $7, $9, $11); }
1907 { pform_endgenerate
(); }
1912 { pform_start_generate_else
(@
1); }
1914 { pform_endgenerate
(); }
1917 generate_block_opt %prec less_than_K_else
1918 { pform_endgenerate
(); }
1920 /* specify blocks are parsed but ignored. */
1922 | K_specify K_endspecify
1923 { /* empty lists are legal syntax. */ }
1925 | K_specify specify_item_list K_endspecify
1929 | K_specify
error K_endspecify
1930 { yyerror(@
1, "error: syntax error in specify block");
1934 /* These rules match various errors that the user can type into
1935 module items. These rules try to catch them at a point where a
1936 reasonable error message can be produced. */
1939 { yyerror(@
2, "error: invalid module item.");
1943 | K_assign
error '=' expression
';'
1944 { yyerror(@
1, "error: syntax error in left side "
1945 "of continuous assignment.");
1949 | K_assign
error ';'
1950 { yyerror(@
1, "error: syntax error in "
1951 "continuous assignment");
1955 | K_function
error K_endfunction
1956 { yyerror(@
1, "error: I give up on this "
1957 "function definition.");
1961 /* These rules are for the Icarus Verilog specific $attribute
1962 extensions. Then catch the parameters of the $attribute keyword. */
1964 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')' ';'
1965 { perm_string tmp3
= lex_strings.make
($3);
1966 perm_string tmp5
= lex_strings.make
($5);
1967 pform_set_attrib
(tmp3
, tmp5
, $7);
1971 | KK_attribute
'(' error ')' ';'
1972 { yyerror(@
1, "error: Malformed $attribute parameter list."); }
1975 generate_if
: K_if
'(' expression
')' { pform_start_generate_if
(@
1, $3); }
1978 : module_item_list module_item
1982 module_item_list_opt
1987 /* A generate block is the thing within a generate scheme. It may be
1988 a single module item, an anonymous block of module items, or a
1989 named module item. In all cases, the meat is in the module items
1990 inside, and the processing is done by the module_item rules. We
1991 only need to take note here of the scope name, if any. */
1995 | K_begin module_item_list_opt K_end
1996 | K_begin
':' IDENTIFIER module_item_list_opt K_end
1997 { pform_generate_block_name
($3); }
2000 generate_block_opt
: generate_block |
';' ;
2003 /* A net declaration assignment allows the programmer to combine the
2004 net declaration and the continuous assignment into a single
2007 Note that the continuous assignment statement is generated as a
2008 side effect, and all I pass up is the name of the l-value. */
2011 : IDENTIFIER
'=' expression
2012 { net_decl_assign_t
*tmp
= new net_decl_assign_t
;
2021 : net_decl_assigns
',' net_decl_assign
2022 { net_decl_assign_t
*tmp
= $1;
2023 $3->next
= tmp
->next
;
2033 : K_logic
{ $$
= IVL_VT_LOGIC
; }
2034 | K_bool
{ $$
= IVL_VT_BOOL
; }
2035 | K_real
{ $$
= IVL_VT_REAL
; }
2038 primitive_type_opt
: primitive_type
{ $$
= $1; } |
{ $$
= IVL_VT_NO_TYPE
; } ;
2041 : K_wire
{ $$
= NetNet
::WIRE
; }
2042 | K_tri
{ $$
= NetNet
::TRI
; }
2043 | K_tri1
{ $$
= NetNet
::TRI1
; }
2044 | K_supply0
{ $$
= NetNet
::SUPPLY0
; }
2045 | K_wand
{ $$
= NetNet
::WAND
; }
2046 | K_triand
{ $$
= NetNet
::TRIAND
; }
2047 | K_tri0
{ $$
= NetNet
::TRI0
; }
2048 | K_supply1
{ $$
= NetNet
::SUPPLY1
; }
2049 | K_wor
{ $$
= NetNet
::WOR
; }
2050 | K_trior
{ $$
= NetNet
::TRIOR
; }
2051 | K_wone
{ $$
= NetNet
::WONE
; }
2055 : K_reg
{ $$
= NetNet
::REG
; }
2058 /* In this rule we have matched the "parameter" keyword. The rule
2059 generates a type (optional) and a list of assignments. */
2061 parameter_assign_decl
2062 : parameter_assign_list
2063 | range
{ active_range
= $1; active_signed
= false
; }
2064 parameter_assign_list
2066 active_signed
= false
;
2068 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2069 parameter_assign_list
2071 active_signed
= false
;
2073 | K_integer
{ active_range
= 0; active_signed
= true
; }
2074 parameter_assign_list
2076 active_signed
= false
;
2080 parameter_assign_list
2082 | parameter_assign_list
',' parameter_assign
2086 : IDENTIFIER
'=' expression
2088 if
(!pform_expression_is_constant
(tmp
)) {
2089 yyerror(@
3, "error: parameter value "
2090 "must be a constant expression.");
2094 pform_set_parameter
(lex_strings.make
($1),
2102 /* Localparam assignments and assignment lists are broken into
2103 separate BNF so that I can call slightly different parameter
2104 handling code. They parse the same as parameters, they just
2105 behave differently when someone tries to override them. */
2108 : IDENTIFIER
'=' expression
2110 if
(!pform_expression_is_constant
(tmp
)) {
2111 yyerror(@
3, "error: parameter value "
2112 "must be constant.");
2116 pform_set_localparam
(lex_strings.make
($1),
2124 localparam_assign_decl
2125 : localparam_assign_list
2126 | range
{ active_range
= $1; active_signed
= false
; }
2127 localparam_assign_list
2129 active_signed
= false
;
2131 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2132 localparam_assign_list
2134 active_signed
= false
;
2138 localparam_assign_list
2140 | localparam_assign_list
',' localparam_assign
2145 /* The parameters of a module instance can be overridden by writing
2146 a list of expressions in a syntax much like a delay list. (The
2147 difference being the list can have any length.) The pform that
2148 attaches the expression list to the module checks that the
2149 expressions are constant.
2151 Although the BNF in IEEE1364-1995 implies that parameter value
2152 lists must be in parentheses, in practice most compilers will
2153 accept simple expressions outside of parentheses if there is only
2154 one value, so I'll accept simple numbers here.
2156 The parameter value by name syntax is OVI enhancement BTF-B06 as
2157 approved by WG1364 on 6/28/1998. */
2160 : '#' '(' expression_list_with_nuls
')'
2161 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2166 |
'#' '(' parameter_value_byname_list
')'
2167 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2174 PENumber
*tmp
= new PENumber
($2);
2175 tmp
->set_file
(@
1.text
);
2176 tmp
->set_lineno
(@
1.first_line
);
2178 struct parmvalue_t
*lst
= new
struct parmvalue_t
;
2179 lst
->by_order
= new svector
<PExpr
*>(1);
2180 (*lst
->by_order
)[0] = tmp
;
2185 { yyerror(@
1, "error: syntax error in parameter value "
2186 "assignment list.");
2193 parameter_value_byname
2194 : '.' IDENTIFIER
'(' expression
')'
2195 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2196 tmp
->name
= lex_strings.make
($2);
2201 |
'.' IDENTIFIER
'(' ')'
2202 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2203 tmp
->name
= lex_strings.make
($2);
2210 parameter_value_byname_list
2211 : parameter_value_byname
2212 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2216 | parameter_value_byname_list
',' parameter_value_byname
2217 { svector
<named_pexpr_t
*>*tmp
=
2218 new svector
<named_pexpr_t
*>(*$1,$3);
2225 /* The port (of a module) is a fairly complex item. Each port is
2226 handled as a Module::port_t object. A simple port reference has a
2227 name and a PExpr object, but more complex constructs are possible
2228 where the name can be attached to a list of PWire objects.
2230 The port_reference returns a Module::port_t, and so does the
2231 port_reference_list. The port_reference_list may have built up a
2232 list of PWires in the port_t object, but it is still a single
2233 Module::port_t object.
2235 The port rule below takes the built up Module::port_t object and
2236 tweaks its name as needed. */
2242 /* This syntax attaches an external name to the port reference so
2243 that the caller can bind by name to non-trivial port
2244 references. The port_t object gets its PWire from the
2245 port_reference, but its name from the IDENTIFIER. */
2247 |
'.' IDENTIFIER
'(' port_reference
')'
2248 { Module
::port_t
*tmp
= $4;
2249 tmp
->name
= lex_strings.make
($2);
2254 /* A port can also be a concatenation of port references. In this
2255 case the port does not have a name available to the outside, only
2256 positional parameter passing is possible here. */
2258 |
'{' port_reference_list
'}'
2259 { Module
::port_t
*tmp
= $2;
2260 tmp
->name
= perm_string
();
2264 /* This attaches a name to a port reference concatenation list so
2265 that parameter passing be name is possible. */
2267 |
'.' IDENTIFIER
'(' '{' port_reference_list
'}' ')'
2268 { Module
::port_t
*tmp
= $5;
2269 tmp
->name
= lex_strings.make
($2);
2281 /* A port reference is an internal (to the module) name of the port,
2282 possibly with a part of bit select to attach it to specific bits
2283 of a signal fully declared inside the module.
2285 The parser creates a PEIdent for every port reference, even if the
2286 signal is bound to different ports. The elaboration figures out
2287 the mess that this creates. The port_reference (and the
2288 port_reference_list below) puts the port reference PEIdent into the
2289 port_t object to pass it up to the module declaration code. */
2294 { Module
::port_t
*ptmp
;
2295 ptmp
= pform_module_port_reference
($1, @
1.text
, @
1.first_line
);
2300 | IDENTIFIER
'[' expression
':' expression
']'
2301 { if
(!pform_expression_is_constant
($3)) {
2302 yyerror(@
3, "error: msb expression of "
2303 "port part select must be constant.");
2305 if
(!pform_expression_is_constant
($5)) {
2306 yyerror(@
5, "error: lsb expression of "
2307 "port part select must be constant.");
2309 index_component_t itmp
;
2310 itmp.sel
= index_component_t
::SEL_PART
;
2314 name_component_t ntmp
(lex_strings.make
($1));
2315 ntmp.index.push_back
(itmp
);
2318 pname.push_back
(ntmp
);
2320 PEIdent
*wtmp
= new PEIdent
(pname
);
2321 wtmp
->set_file
(@
1.text
);
2322 wtmp
->set_lineno
(@
1.first_line
);
2324 Module
::port_t
*ptmp
= new Module
::port_t
;
2325 ptmp
->name
= perm_string
();
2326 ptmp
->expr
= svector
<PEIdent
*>(1);
2327 ptmp
->expr
[0] = wtmp
;
2333 | IDENTIFIER
'[' expression
']'
2334 { if
(!pform_expression_is_constant
($3)) {
2335 yyerror(@
3, "error: port bit select "
2336 "must be constant.");
2338 index_component_t itmp
;
2339 itmp.sel
= index_component_t
::SEL_BIT
;
2343 name_component_t ntmp
(lex_strings.make
($1));
2344 ntmp.index.push_back
(itmp
);
2347 pname.push_back
(ntmp
);
2349 PEIdent
*tmp
= new PEIdent
(pname
);
2350 tmp
->set_file
(@
1.text
);
2351 tmp
->set_lineno
(@
1.first_line
);
2353 Module
::port_t
*ptmp
= new Module
::port_t
;
2354 ptmp
->name
= perm_string
();
2355 ptmp
->expr
= svector
<PEIdent
*>(1);
2356 ptmp
->expr
[0] = tmp
;
2361 | IDENTIFIER
'[' error ']'
2362 { yyerror(@
1, "error: invalid port bit select");
2363 Module
::port_t
*ptmp
= new Module
::port_t
;
2364 PEIdent
*wtmp
= new PEIdent
(lex_strings.make
($1));
2365 wtmp
->set_file
(@
1.text
);
2366 wtmp
->set_lineno
(@
1.first_line
);
2367 ptmp
->name
= lex_strings.make
($1);
2368 ptmp
->expr
= svector
<PEIdent
*>(1);
2369 ptmp
->expr
[0] = wtmp
;
2379 | port_reference_list
',' port_reference
2380 { Module
::port_t
*tmp
= $1;
2381 tmp
->expr
= svector
<PEIdent
*>(tmp
->expr
, $3->expr
);
2387 /* The port_name rule is used with a module is being *instantiated*,
2388 and not when it is being declared. See the port rule if you are
2389 looking for the ports of a module declaration. */
2392 : '.' IDENTIFIER
'(' expression
')'
2393 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2394 tmp
->name
= lex_strings.make
($2);
2399 |
'.' IDENTIFIER
'(' error ')'
2400 { yyerror(@
4, "error: invalid port connection expression.");
2401 named_pexpr_t
*tmp
= new named_pexpr_t
;
2402 tmp
->name
= lex_strings.make
($2);
2407 |
'.' IDENTIFIER
'(' ')'
2408 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2409 tmp
->name
= lex_strings.make
($2);
2417 : port_name_list
',' port_name
2418 { svector
<named_pexpr_t
*>*tmp
;
2419 tmp
= new svector
<named_pexpr_t
*>(*$1, $3);
2424 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2431 : K_input
{ $$
= NetNet
::PINPUT
; }
2432 | K_output
{ $$
= NetNet
::POUTPUT
; }
2433 | K_inout
{ $$
= NetNet
::PINOUT
; }
2437 : '[' expression
':' expression
']'
2438 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*> (2);
2439 if
(!pform_expression_is_constant
($2))
2440 yyerror(@
2, "error: msb of range must be constant.");
2444 if
(!pform_expression_is_constant
($4))
2445 yyerror(@
4, "error: lsb of range must be constant.");
2458 /* This is used to express the return type of a function. */
2459 function_range_or_type_opt
2460 : range
{ $$.range
= $1; $$.type
= PTF_REG
; }
2461 | K_signed range
{ $$.range
= $2; $$.type
= PTF_REG_S
; }
2462 | K_integer
{ $$.range
= 0; $$.type
= PTF_INTEGER
; }
2463 | K_real
{ $$.range
= 0; $$.type
= PTF_REAL
; }
2464 | K_realtime
{ $$.range
= 0; $$.type
= PTF_REALTIME
; }
2465 | K_time
{ $$.range
= 0; $$.type
= PTF_TIME
; }
2466 |
{ $$.range
= 0; $$.type
= PTF_REG
; }
2469 /* The register_variable rule is matched only when I am parsing
2470 variables in a "reg" definition. I therefore know that I am
2471 creating registers and I do not need to let the containing rule
2472 handle it. The register variable list simply packs them together
2473 so that bit ranges can be assigned. */
2476 { pform_makewire
(@
1, $1, NetNet
::REG
,
2481 | IDENTIFIER
'=' expression
2482 { pform_makewire
(@
1, $1, NetNet
::REG
,
2485 if
(! pform_expression_is_constant
($3))
2486 yyerror(@
3, "error: register declaration assignment"
2487 " value must be a constant expression.");
2488 pform_make_reginit
(@
1, $1, $3);
2491 | IDENTIFIER
'[' expression
':' expression
']'
2492 { pform_makewire
(@
1, $1, NetNet
::REG
,
2495 if
(! pform_expression_is_constant
($3))
2496 yyerror(@
3, "error: msb of register range must be constant.");
2497 if
(! pform_expression_is_constant
($5))
2498 yyerror(@
3, "error: lsb of register range must be constant.");
2499 pform_set_reg_idx
($1, $3, $5);
2504 register_variable_list
2506 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2507 tmp
->push_back
(lex_strings.make
($1));
2511 | register_variable_list
',' register_variable
2512 { list
<perm_string
>*tmp
= $1;
2513 tmp
->push_back
(lex_strings.make
($3));
2521 { pform_makewire
(@
1, $1, NetNet
::IMPLICIT
,
2526 | IDENTIFIER
'[' expression
':' expression
']'
2527 { pform_makewire
(@
1, $1, NetNet
::IMPLICIT
,
2530 if
(! pform_expression_is_constant
($3))
2531 yyerror(@
3, "error: msb of net range must be constant.");
2532 if
(! pform_expression_is_constant
($5))
2533 yyerror(@
3, "error: lsb of net range must be constant.");
2534 pform_set_reg_idx
($1, $3, $5);
2540 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2541 tmp
->push_back
(lex_strings.make
($1));
2545 | net_variable_list
',' net_variable
2546 { list
<perm_string
>*tmp
= $1;
2547 tmp
->push_back
(lex_strings.make
($3));
2554 : K_specparam specparam_list
';'
2555 | specify_simple_path_decl
';'
2556 { pform_module_specify_path
($1);
2558 | specify_edge_path_decl
';'
2559 { pform_module_specify_path
($1);
2561 | K_if
'(' expression
')' specify_simple_path_decl
';'
2562 { PSpecPath
*tmp
= $5;
2564 tmp
->conditional
= true
;
2565 tmp
->condition
= $3;
2567 pform_module_specify_path
(tmp
);
2569 | K_if
'(' expression
')' specify_edge_path_decl
';'
2570 { PSpecPath
*tmp
= $5;
2572 tmp
->conditional
= true
;
2573 tmp
->condition
= $3;
2575 pform_module_specify_path
(tmp
);
2577 | K_ifnone specify_simple_path_decl
';'
2578 { PSpecPath
*tmp
= $2;
2580 tmp
->conditional
= true
;
2583 pform_module_specify_path
(tmp
);
2585 | K_Shold
'(' spec_reference_event
',' spec_reference_event
2586 ',' delay_value spec_notifier_opt
')' ';'
2589 | K_Speriod
'(' spec_reference_event
',' delay_value
2590 spec_notifier_opt
')' ';'
2593 | K_Srecovery
'(' spec_reference_event
',' spec_reference_event
2594 ',' delay_value spec_notifier_opt
')' ';'
2597 | K_Ssetup
'(' spec_reference_event
',' spec_reference_event
2598 ',' delay_value spec_notifier_opt
')' ';'
2601 | K_Ssetuphold
'(' spec_reference_event
',' spec_reference_event
2602 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2606 | K_Srecrem
'(' spec_reference_event
',' spec_reference_event
2607 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2611 | K_Swidth
'(' spec_reference_event
',' delay_value
',' expression
2612 spec_notifier_opt
')' ';'
2616 | K_Swidth
'(' spec_reference_event
',' delay_value
')' ';'
2623 | specify_item_list specify_item
2626 specify_edge_path_decl
2627 : specify_edge_path
'=' '(' delay_value_list
')'
2628 { $$
= pform_assign_path_delay
($1, $4); }
2629 | specify_edge_path
'=' delay_value_simple
2630 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2632 $$
= pform_assign_path_delay
($1, tmp
);
2636 edge_operator
: K_posedge
{ $$
= true
; } | K_negedge
{ $$
= false
; } ;
2639 : '(' specify_path_identifiers spec_polarity
2640 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2641 { int edge_flag
= 0;
2642 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, false
, $6, $8); }
2643 |
'(' edge_operator specify_path_identifiers spec_polarity
2644 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2645 { int edge_flag
= $2?
1 : -1;
2646 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, false
, $7, $9);}
2647 |
'(' specify_path_identifiers spec_polarity
2648 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2649 { int edge_flag
= 0;
2650 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, true
, $6, $8); }
2651 |
'(' edge_operator specify_path_identifiers spec_polarity
2652 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2653 { int edge_flag
= $2?
1 : -1;
2654 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, true
, $7, $9); }
2663 specify_simple_path_decl
2664 : specify_simple_path
'=' '(' delay_value_list
')'
2665 { $$
= pform_assign_path_delay
($1, $4); }
2666 | specify_simple_path
'=' delay_value_simple
2667 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2669 $$
= pform_assign_path_delay
($1, tmp
);
2671 | specify_simple_path
'=' '(' error ')'
2672 { yyerror(@
2, "Syntax error in delay value list.");
2679 : '(' specify_path_identifiers spec_polarity
2680 K_EG specify_path_identifiers
')'
2681 { $$
= pform_make_specify_path
(@
1, $2, $3, false
, $5); }
2682 |
'(' specify_path_identifiers spec_polarity
2683 K_SG specify_path_identifiers
')'
2684 { $$
= pform_make_specify_path
(@
1, $2, $3, true
, $5); }
2686 { yyerror(@
2, "Invalid simple path");
2691 specify_path_identifiers
2693 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2694 tmp
->push_back
(lex_strings.make
($1));
2698 | IDENTIFIER
'[' expr_primary
']'
2699 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2700 tmp
->push_back
(lex_strings.make
($1));
2704 | specify_path_identifiers
',' IDENTIFIER
2705 { list
<perm_string
>*tmp
= $1;
2706 tmp
->push_back
(lex_strings.make
($3));
2710 | specify_path_identifiers
',' IDENTIFIER
'[' expr_primary
']'
2711 { list
<perm_string
>*tmp
= $1;
2712 tmp
->push_back
(lex_strings.make
($3));
2719 : IDENTIFIER
'=' expression
2721 pform_set_specparam
(lex_strings.make
($1), tmp
);
2724 | IDENTIFIER
'=' expression
':' expression
':' expression
2726 switch
(min_typ_max_flag
) {
2743 pform_set_specparam
(lex_strings.make
($1), tmp
);
2746 | PATHPULSE_IDENTIFIER
'=' expression
2750 | PATHPULSE_IDENTIFIER
'=' '(' expression
',' expression
')'
2759 | specparam_list
',' specparam
2768 spec_reference_event
2769 : K_posedge expression
2771 | K_negedge expression
2773 | K_posedge expr_primary K_TAND expression
2777 | K_negedge expr_primary K_TAND expression
2781 | K_edge
'[' edge_descriptor_list
']' expr_primary K_TAND expression
2785 | expr_primary K_TAND expression
2793 /* The edge_descriptor is detected by the lexor as the various
2794 2-letter edge sequences that are supported here. For now, we
2795 don't care what they are, because we do not yet support specify
2797 edge_descriptor_list
2798 : edge_descriptor_list
',' K_edge_descriptor
2811 |
',' heirarchy_identifier
2815 | spec_notifier
',' heirarchy_identifier
2824 /* assign and deassign statements are procedural code to do
2825 structural assignments, and to turn that structural assignment
2826 off. This stronger then any other assign, but weaker then the
2827 force assignments. */
2829 : K_assign lpvalue
'=' expression
';'
2830 { PCAssign
*tmp
= new PCAssign
($2, $4);
2831 tmp
->set_file
(@
1.text
);
2832 tmp
->set_lineno
(@
1.first_line
);
2836 | K_deassign lpvalue
';'
2837 { PDeassign
*tmp
= new PDeassign
($2);
2838 tmp
->set_file
(@
1.text
);
2839 tmp
->set_lineno
(@
1.first_line
);
2844 /* Force and release statements are similar to assignments,
2845 syntactically, but they will be elaborated differently. */
2847 | K_force lpvalue
'=' expression
';'
2848 { PForce
*tmp
= new PForce
($2, $4);
2849 tmp
->set_file
(@
1.text
);
2850 tmp
->set_lineno
(@
1.first_line
);
2853 | K_release lpvalue
';'
2854 { PRelease
*tmp
= new PRelease
($2);
2855 tmp
->set_file
(@
1.text
);
2856 tmp
->set_lineno
(@
1.first_line
);
2860 /* begin-end blocks come in a variety of forms, including named and
2861 anonymous. The named blocks can also carry their own reg
2862 variables, which are placed in the scope created by the block
2863 name. These are handled by pushing the scope name then matching
2864 the declarations. The scope is popped at the end of the block. */
2866 | K_begin statement_list K_end
2867 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
, *$2);
2868 tmp
->set_file
(@
1.text
);
2869 tmp
->set_lineno
(@
1.first_line
);
2873 | K_begin
':' IDENTIFIER
2874 { pform_push_scope
($3); }
2875 block_item_decls_opt
2876 statement_list K_end
2877 { pform_pop_scope
();
2878 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
2879 PBlock
::BL_SEQ
, *$6);
2880 tmp
->set_file
(@
1.text
);
2881 tmp
->set_lineno
(@
1.first_line
);
2887 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2888 tmp
->set_file
(@
1.text
);
2889 tmp
->set_lineno
(@
1.first_line
);
2892 | K_begin
':' IDENTIFIER K_end
2893 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2894 tmp
->set_file
(@
1.text
);
2895 tmp
->set_lineno
(@
1.first_line
);
2898 | K_begin
error K_end
2901 /* fork-join blocks are very similar to begin-end blocks. In fact,
2902 from the parser's perspective there is no real difference. All we
2903 need to do is remember that this is a parallel block so that the
2904 code generator can do the right thing. */
2906 | K_fork
':' IDENTIFIER
2907 { pform_push_scope
($3); }
2908 block_item_decls_opt
2909 statement_list K_join
2910 { pform_pop_scope
();
2911 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
2912 PBlock
::BL_PAR
, *$6);
2913 tmp
->set_file
(@
1.text
);
2914 tmp
->set_lineno
(@
1.first_line
);
2920 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
2921 tmp
->set_file
(@
1.text
);
2922 tmp
->set_lineno
(@
1.first_line
);
2925 | K_fork
':' IDENTIFIER K_join
2926 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
2927 tmp
->set_file
(@
1.text
);
2928 tmp
->set_lineno
(@
1.first_line
);
2933 | K_disable heirarchy_identifier
';'
2934 { PDisable
*tmp
= new PDisable
(*$2);
2935 tmp
->set_file
(@
1.text
);
2936 tmp
->set_lineno
(@
1.first_line
);
2940 | K_TRIGGER heirarchy_identifier
';'
2941 { PTrigger
*tmp
= new PTrigger
(*$2);
2942 tmp
->set_file
(@
2.text
);
2943 tmp
->set_lineno
(@
2.first_line
);
2947 | K_forever statement
2948 { PForever
*tmp
= new PForever
($2);
2949 tmp
->set_file
(@
1.text
);
2950 tmp
->set_lineno
(@
1.first_line
);
2953 | K_fork statement_list K_join
2954 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
, *$2);
2955 tmp
->set_file
(@
1.text
);
2956 tmp
->set_lineno
(@
1.first_line
);
2960 | K_repeat
'(' expression
')' statement
2961 { PRepeat
*tmp
= new PRepeat
($3, $5);
2962 tmp
->set_file
(@
1.text
);
2963 tmp
->set_lineno
(@
1.first_line
);
2966 | K_case
'(' expression
')' case_items K_endcase
2967 { PCase
*tmp
= new PCase
(NetCase
::EQ
, $3, $5);
2968 tmp
->set_file
(@
1.text
);
2969 tmp
->set_lineno
(@
1.first_line
);
2972 | K_casex
'(' expression
')' case_items K_endcase
2973 { PCase
*tmp
= new PCase
(NetCase
::EQX
, $3, $5);
2974 tmp
->set_file
(@
1.text
);
2975 tmp
->set_lineno
(@
1.first_line
);
2978 | K_casez
'(' expression
')' case_items K_endcase
2979 { PCase
*tmp
= new PCase
(NetCase
::EQZ
, $3, $5);
2980 tmp
->set_file
(@
1.text
);
2981 tmp
->set_lineno
(@
1.first_line
);
2984 | K_case
'(' expression
')' error K_endcase
2986 | K_casex
'(' expression
')' error K_endcase
2988 | K_casez
'(' expression
')' error K_endcase
2990 | K_if
'(' expression
')' statement_or_null %prec less_than_K_else
2991 { PCondit
*tmp
= new PCondit
($3, $5, 0);
2992 tmp
->set_file
(@
1.text
);
2993 tmp
->set_lineno
(@
1.first_line
);
2996 | K_if
'(' expression
')' statement_or_null K_else statement_or_null
2997 { PCondit
*tmp
= new PCondit
($3, $5, $7);
2998 tmp
->set_file
(@
1.text
);
2999 tmp
->set_lineno
(@
1.first_line
);
3002 | K_if
'(' error ')' statement_or_null %prec less_than_K_else
3003 { yyerror(@
1, "error: Malformed conditional expression.");
3006 | K_if
'(' error ')' statement_or_null K_else statement_or_null
3007 { yyerror(@
1, "error: Malformed conditional expression.");
3010 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3011 lpvalue
'=' expression
')' statement
3012 { PForStatement
*tmp
= new PForStatement
($3, $5, $7, $9, $11, $13);
3013 tmp
->set_file
(@
1.text
);
3014 tmp
->set_lineno
(@
1.first_line
);
3017 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3020 yyerror(@
9, "error: Error in for loop step assignment.");
3022 | K_for
'(' lpvalue
'=' expression
';' error ';'
3023 lpvalue
'=' expression
')' statement
3025 yyerror(@
7, "error: Error in for loop condition expression.");
3027 | K_for
'(' error ')' statement
3029 yyerror(@
3, "error: Incomprehensible for loop.");
3031 | K_while
'(' expression
')' statement
3032 { PWhile
*tmp
= new PWhile
($3, $5);
3035 | K_while
'(' error ')' statement
3037 yyerror(@
3, "error: Error in while loop condition.");
3039 | delay1 statement_or_null
3040 { PExpr
*del
= (*$1)[0];
3041 assert
($1->count
() == 1);
3042 PDelayStatement
*tmp
= new PDelayStatement
(del
, $2);
3043 tmp
->set_file
(@
1.text
);
3044 tmp
->set_lineno
(@
1.first_line
);
3047 | event_control statement_or_null
3048 { PEventStatement
*tmp
= $1;
3050 yyerror(@
1, "error: Invalid event control.");
3053 tmp
->set_statement
($2);
3057 |
'@' '*' statement_or_null
3058 { PEventStatement
*tmp
= new PEventStatement
;
3059 tmp
->set_file
(@
1.text
);
3060 tmp
->set_lineno
(@
1.first_line
);
3061 tmp
->set_statement
($3);
3064 |
'@' '(' '*' ')' statement_or_null
3065 { PEventStatement
*tmp
= new PEventStatement
;
3066 tmp
->set_file
(@
1.text
);
3067 tmp
->set_lineno
(@
1.first_line
);
3068 tmp
->set_statement
($5);
3071 | lpvalue
'=' expression
';'
3072 { PAssign
*tmp
= new PAssign
($1,$3);
3073 tmp
->set_file
(@
1.text
);
3074 tmp
->set_lineno
(@
1.first_line
);
3077 |
error '=' expression
';'
3078 { yyerror(@
1, "Syntax in assignment statement l-value.");
3082 | lpvalue K_LE expression
';'
3083 { PAssignNB
*tmp
= new PAssignNB
($1,$3);
3084 tmp
->set_file
(@
1.text
);
3085 tmp
->set_lineno
(@
1.first_line
);
3088 |
error K_LE expression
';'
3089 { yyerror(@
1, "Syntax in assignment statement l-value.");
3093 | lpvalue
'=' delay1 expression
';'
3094 { assert
($3->count
() == 1);
3095 PExpr
*del
= (*$3)[0];
3096 PAssign
*tmp
= new PAssign
($1,del
,$4);
3097 tmp
->set_file
(@
1.text
);
3098 tmp
->set_lineno
(@
1.first_line
);
3101 | lpvalue K_LE delay1 expression
';'
3102 { assert
($3->count
() == 1);
3103 PExpr
*del
= (*$3)[0];
3104 PAssignNB
*tmp
= new PAssignNB
($1,del
,$4);
3105 tmp
->set_file
(@
1.text
);
3106 tmp
->set_lineno
(@
1.first_line
);
3109 | lpvalue
'=' event_control expression
';'
3110 { PAssign
*tmp
= new PAssign
($1,$3,$4);
3111 tmp
->set_file
(@
1.text
);
3112 tmp
->set_lineno
(@
1.first_line
);
3115 | lpvalue
'=' K_repeat
'(' expression
')' event_control expression
';'
3116 { PAssign
*tmp
= new PAssign
($1,$7,$8);
3117 tmp
->set_file
(@
1.text
);
3118 tmp
->set_lineno
(@
1.first_line
);
3119 yyerror(@
3, "sorry: repeat event control not supported.");
3123 | lpvalue K_LE event_control expression
';'
3124 { yyerror(@
1, "sorry: Event controls not supported here.");
3125 PAssignNB
*tmp
= new PAssignNB
($1,$4);
3126 tmp
->set_file
(@
1.text
);
3127 tmp
->set_lineno
(@
1.first_line
);
3130 | lpvalue K_LE K_repeat
'(' expression
')' event_control expression
';'
3131 { yyerror(@
1, "sorry: Event controls not supported here.");
3133 PAssignNB
*tmp
= new PAssignNB
($1,$8);
3134 tmp
->set_file
(@
1.text
);
3135 tmp
->set_lineno
(@
1.first_line
);
3138 | K_wait
'(' expression
')' statement_or_null
3139 { PEventStatement
*tmp
;
3140 PEEvent
*etmp
= new PEEvent
(PEEvent
::POSITIVE
, $3);
3141 tmp
= new PEventStatement
(etmp
);
3142 tmp
->set_file
(@
1.text
);
3143 tmp
->set_lineno
(@
1.first_line
);
3144 tmp
->set_statement
($5);
3147 | SYSTEM_IDENTIFIER
'(' expression_list_with_nuls
')' ';'
3148 { PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), *$3);
3149 tmp
->set_file
(@
1.text
);
3150 tmp
->set_lineno
(@
1.first_line
);
3155 | SYSTEM_IDENTIFIER
';'
3156 { svector
<PExpr
*>pt
(0);
3157 PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), pt
);
3158 tmp
->set_file
(@
1.text
);
3159 tmp
->set_lineno
(@
1.first_line
);
3163 | heirarchy_identifier
'(' expression_list_proper
')' ';'
3164 { PCallTask
*tmp
= new PCallTask
(*$1, *$3);
3165 tmp
->set_file
(@
1.text
);
3166 tmp
->set_lineno
(@
1.first_line
);
3172 /* NOTE: The standard doesn't really support an empty argument list
3173 between parentheses, but it seems natural, and people commonly
3174 want it. So accept it explicitly. */
3176 | heirarchy_identifier
'(' ')' ';'
3177 { svector
<PExpr
*>pt
(0);
3178 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3179 tmp
->set_file
(@
1.text
);
3180 tmp
->set_lineno
(@
1.first_line
);
3184 | heirarchy_identifier
';'
3185 { svector
<PExpr
*>pt
(0);
3186 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3187 tmp
->set_file
(@
1.text
);
3188 tmp
->set_lineno
(@
1.first_line
);
3193 { yyerror(@
1, "error: malformed statement");
3200 : statement_list statement
3201 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(*$1, $2);
3206 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(1);
3217 /* Task items are, other than the statement, task port items and
3218 other block items. */
3220 : block_item_decl
{ $$
= new svector
<PWire
*>(0); }
3221 | task_port_item
{ $$
= $1; }
3226 : K_input signed_opt range_opt list_of_identifiers
';'
3227 { svector
<PWire
*>*tmp
3228 = pform_make_task_ports
(NetNet
::PINPUT
,
3231 @
1.text
, @
1.first_line
);
3234 | K_output signed_opt range_opt list_of_identifiers
';'
3235 { svector
<PWire
*>*tmp
3236 = pform_make_task_ports
(NetNet
::POUTPUT
,
3239 @
1.text
, @
1.first_line
);
3242 | K_inout signed_opt range_opt list_of_identifiers
';'
3243 { svector
<PWire
*>*tmp
3244 = pform_make_task_ports
(NetNet
::PINOUT
,
3247 @
1.text
, @
1.first_line
);
3251 /* When the port is an integer, infer a signed vector of the integer
3252 shape. Generate a range to make it work. */
3254 | K_input K_integer list_of_identifiers
';'
3255 { svector
<PExpr
*>*range_stub
3256 = new svector
<PExpr
*>(2);
3258 re
= new PENumber
(new verinum
(integer_width
-1,
3260 (*range_stub
)[0] = re
;
3261 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3262 (*range_stub
)[1] = re
;
3264 = pform_make_task_ports
(NetNet
::PINPUT
,
3267 @
1.text
, @
1.first_line
);
3270 | K_output K_integer list_of_identifiers
';'
3271 { svector
<PExpr
*>*range_stub
3272 = new svector
<PExpr
*>(2);
3274 re
= new PENumber
(new verinum
(integer_width
-1,
3276 (*range_stub
)[0] = re
;
3277 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3278 (*range_stub
)[1] = re
;
3280 = pform_make_task_ports
(NetNet
::POUTPUT
,
3283 @
1.text
, @
1.first_line
);
3286 | K_inout K_integer list_of_identifiers
';'
3287 { svector
<PExpr
*>*range_stub
3288 = new svector
<PExpr
*>(2);
3290 re
= new PENumber
(new verinum
(integer_width
-1,
3292 (*range_stub
)[0] = re
;
3293 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3294 (*range_stub
)[1] = re
;
3296 = pform_make_task_ports
(NetNet
::PINOUT
,
3299 @
1.text
, @
1.first_line
);
3303 /* Ports can be real. */
3305 | K_input K_real list_of_identifiers
';'
3306 { svector
<PWire
*>*tmp
3307 = pform_make_task_ports
(NetNet
::PINPUT
,
3310 @
1.text
, @
1.first_line
);
3313 | K_output K_real list_of_identifiers
';'
3314 { svector
<PWire
*>*tmp
3315 = pform_make_task_ports
(NetNet
::POUTPUT
,
3318 @
1.text
, @
1.first_line
);
3321 | K_inout K_real list_of_identifiers
';'
3322 { svector
<PWire
*>*tmp
3323 = pform_make_task_ports
(NetNet
::PINOUT
,
3326 @
1.text
, @
1.first_line
);
3332 : task_item_list task_item
3333 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3351 : K_input signed_opt range_opt IDENTIFIER
3352 { svector
<PWire
*>*tmp
3353 = pform_make_task_ports
(NetNet
::PINPUT
,
3355 $3, list_from_identifier
($4),
3356 @
1.text
, @
1.first_line
);
3360 | K_output signed_opt range_opt IDENTIFIER
3361 { svector
<PWire
*>*tmp
3362 = pform_make_task_ports
(NetNet
::POUTPUT
,
3364 $3, list_from_identifier
($4),
3365 @
1.text
, @
1.first_line
);
3368 | K_inout signed_opt range_opt IDENTIFIER
3369 { svector
<PWire
*>*tmp
3370 = pform_make_task_ports
(NetNet
::PINOUT
,
3372 $3, list_from_identifier
($4),
3373 @
1.text
, @
1.first_line
);
3377 | K_input K_integer IDENTIFIER
3378 { svector
<PExpr
*>*range_stub
3379 = new svector
<PExpr
*>(2);
3381 re
= new PENumber
(new verinum
(integer_width
-1,
3383 (*range_stub
)[0] = re
;
3384 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3385 (*range_stub
)[1] = re
;
3387 = pform_make_task_ports
(NetNet
::PINPUT
,
3390 list_from_identifier
($3),
3391 @
1.text
, @
1.first_line
);
3394 | K_output K_integer IDENTIFIER
3395 { svector
<PExpr
*>*range_stub
3396 = new svector
<PExpr
*>(2);
3398 re
= new PENumber
(new verinum
(integer_width
-1,
3400 (*range_stub
)[0] = re
;
3401 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3402 (*range_stub
)[1] = re
;
3404 = pform_make_task_ports
(NetNet
::POUTPUT
,
3407 list_from_identifier
($3),
3408 @
1.text
, @
1.first_line
);
3411 | K_inout K_integer IDENTIFIER
3412 { svector
<PExpr
*>*range_stub
3413 = new svector
<PExpr
*>(2);
3415 re
= new PENumber
(new verinum
(integer_width
-1,
3417 (*range_stub
)[0] = re
;
3418 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3419 (*range_stub
)[1] = re
;
3421 = pform_make_task_ports
(NetNet
::PINOUT
,
3424 list_from_identifier
($3),
3425 @
1.text
, @
1.first_line
);
3429 /* Ports can be real. */
3431 | K_input K_real IDENTIFIER
3432 { svector
<PWire
*>*tmp
3433 = pform_make_task_ports
(NetNet
::PINPUT
,
3435 0, list_from_identifier
($3),
3436 @
1.text
, @
1.first_line
);
3439 | K_output K_real IDENTIFIER
3440 { svector
<PWire
*>*tmp
3441 = pform_make_task_ports
(NetNet
::POUTPUT
,
3443 0, list_from_identifier
($3),
3444 @
1.text
, @
1.first_line
);
3447 | K_inout K_real IDENTIFIER
3448 { svector
<PWire
*>*tmp
3449 = pform_make_task_ports
(NetNet
::PINOUT
,
3451 0, list_from_identifier
($3),
3452 @
1.text
, @
1.first_line
);
3458 : task_port_decl_list
',' task_port_decl
3459 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$3);
3469 : K_table
{ lex_start_table
(); }
3471 K_endtable
{ lex_end_table
(); $$
= $3; }
3475 : udp_comb_entry_list
3476 | udp_sequ_entry_list
3480 : udp_input_list
':' udp_output_sym
';'
3481 { char*tmp
= new
char[strlen
($1)+3];
3483 char*tp
= tmp
+strlen
(tmp
);
3494 { list
<string>*tmp
= new list
<string>;
3499 | udp_comb_entry_list udp_comb_entry
3500 { list
<string>*tmp
= $1;
3509 { list
<string>*tmp
= new list
<string>;
3514 | udp_sequ_entry_list udp_sequ_entry
3515 { list
<string>*tmp
= $1;
3523 : udp_input_list
':' udp_input_sym
':' udp_output_sym
';'
3524 { char*tmp
= new
char[strlen
($1)+5];
3526 char*tp
= tmp
+strlen
(tmp
);
3537 : K_initial IDENTIFIER
'=' number
';'
3538 { PExpr
*etmp
= new PENumber
($4);
3539 PEIdent
*itmp
= new PEIdent
(lex_strings.make
($2));
3540 PAssign
*atmp
= new PAssign
(itmp
, etmp
);
3541 atmp
->set_file
(@
2.text
);
3542 atmp
->set_lineno
(@
2.first_line
);
3549 : udp_initial
{ $$
= $1; }
3555 { char*tmp
= new
char[2];
3560 | udp_input_list udp_input_sym
3561 { char*tmp
= new
char[strlen
($1)+2];
3563 char*tp
= tmp
+strlen
(tmp
);
3604 /* Port declarations create wires for the inputs and the output. The
3605 makes for these ports are scoped within the UDP, so there is no
3606 heirarchy involved. */
3608 : K_input list_of_identifiers
';'
3609 { $$
= pform_make_udp_input_ports
($2); }
3610 | K_output IDENTIFIER
';'
3611 { pform_name_t pname
;
3612 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3613 PWire
*pp
= new PWire
(pname
, NetNet
::IMPLICIT
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3614 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3619 | K_reg IDENTIFIER
';'
3620 { pform_name_t pname
;
3621 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3622 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::PIMPLICIT
, IVL_VT_LOGIC
);
3623 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3628 | K_reg K_output IDENTIFIER
';'
3629 { pform_name_t pname
;
3630 pname.push_back
(name_component_t
(lex_strings.make
($3)));
3631 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3632 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3642 | udp_port_decls udp_port_decl
3643 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3652 { list
<string>*tmp
= new list
<string>;
3657 | udp_port_list
',' IDENTIFIER
3658 { list
<string>*tmp
= $1;
3665 udp_reg_opt: K_reg
{ $$
= true
; } |
{ $$
= false
; };
3667 udp_initial_expr_opt
3668 : '=' expression
{ $$
= $2; }
3672 udp_input_declaration_list
3673 : K_input IDENTIFIER
3674 { list
<perm_string
>*tmp
= new list
<perm_string
>;
3675 tmp
->push_back
(lex_strings.make
($2));
3679 | udp_input_declaration_list
',' K_input IDENTIFIER
3680 { list
<perm_string
>*tmp
= $1;
3681 tmp
->push_back
(lex_strings.make
($4));
3688 /* This is the syntax for primitives that uses the IEEE1364-1995
3689 format. The ports are simply names in the port list, and the
3690 declarations are in the body. */
3692 : K_primitive IDENTIFIER
'(' udp_port_list
')' ';'
3698 { perm_string tmp2
= lex_strings.make
($2);
3699 pform_make_udp
(tmp2
, $4, $7, $9, $8,
3700 @
2.text
, @
2.first_line
);
3704 /* This is the syntax for IEEE1364-2001 format definitions. The port
3705 names and declarations are all in the parameter list. */
3707 | K_primitive IDENTIFIER
3708 '(' K_output udp_reg_opt IDENTIFIER udp_initial_expr_opt
','
3709 udp_input_declaration_list
')' ';'
3713 { perm_string tmp2
= lex_strings.make
($2);
3714 perm_string tmp6
= lex_strings.make
($6);
3715 pform_make_udp
(tmp2
, $5, tmp6
, $7, $9, $12,
3716 @
2.text
, @
2.first_line
);