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 real_variable
195 %type
<perm_strings
> register_variable_list net_variable_list real_variable_list list_of_identifiers
197 %type
<net_decl_assign
> net_decl_assign net_decl_assigns
199 %type
<mport
> port port_opt port_reference port_reference_list
200 %type
<mport
> port_declaration
201 %type
<mports
> list_of_ports module_port_list_opt list_of_port_declarations
203 %type
<wires
> task_item task_item_list task_item_list_opt
204 %type
<wires
> task_port_item task_port_decl task_port_decl_list
205 %type
<wires
> function_item function_item_list
207 %type
<named_pexpr
> port_name parameter_value_byname
208 %type
<named_pexprs
> port_name_list parameter_value_byname_list
210 %type
<named_pexpr
> attribute
211 %type
<named_pexprs
> attribute_list attribute_list_opt
213 %type
<citem
> case_item
214 %type
<citems
> case_items
216 %type
<gate
> gate_instance
217 %type
<gates
> gate_instance_list
219 %type
<pform_name
> heirarchy_identifier
220 %type
<expr
> expression expr_primary
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 | attribute_list_opt K_time register_variable_list
';'
373 { pform_set_reg_time
($3);
376 /* real declarations are fairly simple as there is no range of
377 signed flag in the declaration. Create the real as a NetNet::REG
378 with real value. Note that real and realtime are interchangable
381 | attribute_list_opt K_real real_variable_list
';'
383 | attribute_list_opt K_realtime real_variable_list
';'
386 | K_parameter parameter_assign_decl
';'
387 | K_localparam localparam_assign_decl
';'
389 /* Recover from errors that happen within variable lists. Use the
390 trailing semi-colon to resync the parser. */
392 | attribute_list_opt K_reg
error ';'
393 { yyerror(@
2, "error: syntax error in reg variable list.");
397 | attribute_list_opt K_integer
error ';'
398 { yyerror(@
2, "error: syntax error in integer variable list.");
402 | attribute_list_opt K_time
error ';'
403 { yyerror(@
2, "error: syntax error in time variable list.");
406 | attribute_list_opt K_real
error ';'
407 { yyerror(@
2, "error: syntax error in real variable list.");
410 | attribute_list_opt K_realtime
error ';'
411 { yyerror(@
1, "error: syntax error in realtime variable list.");
414 | K_parameter
error ';'
415 { yyerror(@
1, "error: syntax error in parameter list.");
418 | K_localparam
error ';'
419 { yyerror(@
1, "error: syntax error localparam list.");
426 | block_item_decls block_item_decl
435 : expression_list_proper
':' statement_or_null
436 { PCase
::Item
*tmp
= new PCase
::Item
;
442 | K_default
':' statement_or_null
443 { PCase
::Item
*tmp
= new PCase
::Item
;
447 | K_default statement_or_null
448 { PCase
::Item
*tmp
= new PCase
::Item
;
452 |
error ':' statement_or_null
453 { yyerror(@
1, "error: Incomprehensible case expression.");
459 : case_items case_item
460 { svector
<PCase
::Item
*>*tmp
;
461 tmp
= new svector
<PCase
::Item
*>(*$1, $2);
466 { svector
<PCase
::Item
*>*tmp
= new svector
<PCase
::Item
*>(1);
484 : heirarchy_identifier
'=' expression
486 if
(!pform_expression_is_constant
(tmp
)) {
487 yyerror(@
3, "error: parameter value "
488 "must be constant.");
492 pform_set_defparam
(*$1, $3);
499 | range defparam_assign
500 { yyerror(@
1, "error: defparam may not include a range.");
503 | defparam_assign_list
',' defparam_assign
507 : '#' delay_value_simple
508 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
512 |
'#' '(' delay_value
')'
513 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
520 : '#' delay_value_simple
521 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
525 |
'#' '(' delay_value
')'
526 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
530 |
'#' '(' delay_value
',' delay_value
')'
531 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
536 |
'#' '(' delay_value
',' delay_value
',' delay_value
')'
537 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(3);
546 : delay3
{ $$
= $1; }
552 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
556 | delay_value_list
',' delay_value
557 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
568 | expression
':' expression
':' expression
569 { $$
= pform_select_mtm_expr
($1, $3, $5); }
577 yyerror(@
1, "internal error: delay.");
580 $$
= new PENumber
(tmp
);
581 $$
->set_file
(@
1.text
);
582 $$
->set_lineno
(@
1.first_line
);
588 yyerror(@
1, "internal error: delay.");
591 $$
= new PEFNumber
(tmp
);
592 $$
->set_file
(@
1.text
);
593 $$
->set_lineno
(@
1.first_line
);
597 { PEIdent
*tmp
= new PEIdent
(lex_strings.make
($1));
598 tmp
->set_file
(@
1.text
);
599 tmp
->set_lineno
(@
1.first_line
);
608 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')'
609 { perm_string tmp3
= lex_strings.make
($3);
610 pform_set_type_attrib
(tmp3
, $5, $7);
617 : '(' dr_strength0
',' dr_strength1
')'
621 |
'(' dr_strength1
',' dr_strength0
')'
625 |
'(' dr_strength0
',' K_highz1
')'
627 $$.str1
= PGate
::HIGHZ
;
629 |
'(' dr_strength1
',' K_highz0
')'
630 { $$.str0
= PGate
::HIGHZ
;
633 |
'(' K_highz1
',' dr_strength0
')'
635 $$.str1
= PGate
::HIGHZ
;
637 |
'(' K_highz0
',' dr_strength1
')'
638 { $$.str0
= PGate
::HIGHZ
;
644 : drive_strength
{ $$
= $1; }
645 |
{ $$.str0
= PGate
::STRONG
; $$.str1
= PGate
::STRONG
; }
649 : K_supply0
{ $$.str0
= PGate
::SUPPLY
; }
650 | K_strong0
{ $$.str0
= PGate
::STRONG
; }
651 | K_pull0
{ $$.str0
= PGate
::PULL
; }
652 | K_weak0
{ $$.str0
= PGate
::WEAK
; }
656 : K_supply1
{ $$.str1
= PGate
::SUPPLY
; }
657 | K_strong1
{ $$.str1
= PGate
::STRONG
; }
658 | K_pull1
{ $$.str1
= PGate
::PULL
; }
659 | K_weak1
{ $$.str1
= PGate
::WEAK
; }
663 : '@' heirarchy_identifier
664 { PEIdent
*tmpi
= new PEIdent
(*$2);
665 PEEvent
*tmpe
= new PEEvent
(PEEvent
::ANYEDGE
, tmpi
);
666 PEventStatement
*tmps
= new PEventStatement
(tmpe
);
667 tmps
->set_file
(@
1.text
);
668 tmps
->set_lineno
(@
1.first_line
);
672 |
'@' '(' event_expression_list
')'
673 { PEventStatement
*tmp
= new PEventStatement
(*$3);
674 tmp
->set_file
(@
1.text
);
675 tmp
->set_lineno
(@
1.first_line
);
680 { yyerror(@
1, "error: Malformed event control expression.");
685 event_expression_list
688 | event_expression_list K_or event_expression
689 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
694 | event_expression_list
',' event_expression
695 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
703 : K_posedge expression
704 { PEEvent
*tmp
= new PEEvent
(PEEvent
::POSEDGE
, $2);
705 tmp
->set_file
(@
1.text
);
706 tmp
->set_lineno
(@
1.first_line
);
707 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
711 | K_negedge expression
712 { PEEvent
*tmp
= new PEEvent
(PEEvent
::NEGEDGE
, $2);
713 tmp
->set_file
(@
1.text
);
714 tmp
->set_lineno
(@
1.first_line
);
715 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
720 { PEEvent
*tmp
= new PEEvent
(PEEvent
::ANYEDGE
, $1);
721 tmp
->set_file
(@
1.text
);
722 tmp
->set_lineno
(@
1.first_line
);
723 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
732 |
'+' expr_primary %prec UNARY_PREC
734 |
'-' expr_primary %prec UNARY_PREC
735 { PEUnary
*tmp
= new PEUnary
('-', $2);
736 tmp
->set_file
(@
2.text
);
737 tmp
->set_lineno
(@
2.first_line
);
740 |
'~' expr_primary %prec UNARY_PREC
741 { PEUnary
*tmp
= new PEUnary
('~', $2);
742 tmp
->set_file
(@
2.text
);
743 tmp
->set_lineno
(@
2.first_line
);
746 |
'&' expr_primary %prec UNARY_PREC
747 { PEUnary
*tmp
= new PEUnary
('&', $2);
748 tmp
->set_file
(@
2.text
);
749 tmp
->set_lineno
(@
2.first_line
);
752 |
'!' expr_primary %prec UNARY_PREC
753 { PEUnary
*tmp
= new PEUnary
('!', $2);
754 tmp
->set_file
(@
2.text
);
755 tmp
->set_lineno
(@
2.first_line
);
758 |
'|' expr_primary %prec UNARY_PREC
759 { PEUnary
*tmp
= new PEUnary
('|', $2);
760 tmp
->set_file
(@
2.text
);
761 tmp
->set_lineno
(@
2.first_line
);
764 |
'^' expr_primary %prec UNARY_PREC
765 { PEUnary
*tmp
= new PEUnary
('^', $2);
766 tmp
->set_file
(@
2.text
);
767 tmp
->set_lineno
(@
2.first_line
);
770 | K_NAND expr_primary %prec UNARY_PREC
771 { PEUnary
*tmp
= new PEUnary
('A', $2);
772 tmp
->set_file
(@
2.text
);
773 tmp
->set_lineno
(@
2.first_line
);
776 | K_NOR expr_primary %prec UNARY_PREC
777 { PEUnary
*tmp
= new PEUnary
('N', $2);
778 tmp
->set_file
(@
2.text
);
779 tmp
->set_lineno
(@
2.first_line
);
782 | K_NXOR expr_primary %prec UNARY_PREC
783 { PEUnary
*tmp
= new PEUnary
('X', $2);
784 tmp
->set_file
(@
2.text
);
785 tmp
->set_lineno
(@
2.first_line
);
788 |
'!' error %prec UNARY_PREC
789 { yyerror(@
1, "error: Operand of unary ! "
790 "is not a primary expression.");
793 |
'^' error %prec UNARY_PREC
794 { yyerror(@
1, "error: Operand of reduction ^ "
795 "is not a primary expression.");
798 | expression
'^' expression
799 { PEBinary
*tmp
= new PEBinary
('^', $1, $3);
800 tmp
->set_file
(@
2.text
);
801 tmp
->set_lineno
(@
2.first_line
);
804 | expression K_POW expression
805 { PEBinary
*tmp
= new PEBinary
('p', $1, $3);
806 tmp
->set_file
(@
2.text
);
807 tmp
->set_lineno
(@
2.first_line
);
810 | expression
'*' expression
811 { PEBinary
*tmp
= new PEBinary
('*', $1, $3);
812 tmp
->set_file
(@
2.text
);
813 tmp
->set_lineno
(@
2.first_line
);
816 | expression
'/' expression
817 { PEBinary
*tmp
= new PEBinary
('/', $1, $3);
818 tmp
->set_file
(@
2.text
);
819 tmp
->set_lineno
(@
2.first_line
);
822 | expression
'%' expression
823 { PEBinary
*tmp
= new PEBinary
('%', $1, $3);
824 tmp
->set_file
(@
2.text
);
825 tmp
->set_lineno
(@
2.first_line
);
828 | expression
'+' expression
829 { PEBinary
*tmp
= new PEBinary
('+', $1, $3);
830 tmp
->set_file
(@
2.text
);
831 tmp
->set_lineno
(@
2.first_line
);
834 | expression
'-' expression
835 { PEBinary
*tmp
= new PEBinary
('-', $1, $3);
836 tmp
->set_file
(@
2.text
);
837 tmp
->set_lineno
(@
2.first_line
);
840 | expression
'&' expression
841 { PEBinary
*tmp
= new PEBinary
('&', $1, $3);
842 tmp
->set_file
(@
2.text
);
843 tmp
->set_lineno
(@
2.first_line
);
846 | expression
'|' expression
847 { PEBinary
*tmp
= new PEBinary
('|', $1, $3);
848 tmp
->set_file
(@
2.text
);
849 tmp
->set_lineno
(@
2.first_line
);
852 | expression K_NAND expression
853 { PEBinary
*tmp
= new PEBinary
('A', $1, $3);
854 tmp
->set_file
(@
2.text
);
855 tmp
->set_lineno
(@
2.first_line
);
858 | expression K_NOR expression
859 { PEBinary
*tmp
= new PEBinary
('O', $1, $3);
860 tmp
->set_file
(@
2.text
);
861 tmp
->set_lineno
(@
2.first_line
);
864 | expression K_NXOR expression
865 { PEBinary
*tmp
= new PEBinary
('X', $1, $3);
866 tmp
->set_file
(@
2.text
);
867 tmp
->set_lineno
(@
2.first_line
);
870 | expression
'<' expression
871 { PEBinary
*tmp
= new PEBComp
('<', $1, $3);
872 tmp
->set_file
(@
2.text
);
873 tmp
->set_lineno
(@
2.first_line
);
876 | expression
'>' expression
877 { PEBinary
*tmp
= new PEBComp
('>', $1, $3);
878 tmp
->set_file
(@
2.text
);
879 tmp
->set_lineno
(@
2.first_line
);
882 | expression K_LS expression
883 { PEBinary
*tmp
= new PEBShift
('l', $1, $3);
884 tmp
->set_file
(@
2.text
);
885 tmp
->set_lineno
(@
2.first_line
);
888 | expression K_RS expression
889 { PEBinary
*tmp
= new PEBShift
('r', $1, $3);
890 tmp
->set_file
(@
2.text
);
891 tmp
->set_lineno
(@
2.first_line
);
894 | expression K_RSS expression
895 { PEBinary
*tmp
= new PEBShift
('R', $1, $3);
896 tmp
->set_file
(@
2.text
);
897 tmp
->set_lineno
(@
2.first_line
);
900 | expression K_EQ expression
901 { PEBinary
*tmp
= new PEBComp
('e', $1, $3);
902 tmp
->set_file
(@
2.text
);
903 tmp
->set_lineno
(@
2.first_line
);
906 | expression K_CEQ expression
907 { PEBinary
*tmp
= new PEBComp
('E', $1, $3);
908 tmp
->set_file
(@
2.text
);
909 tmp
->set_lineno
(@
2.first_line
);
912 | expression K_LE expression
913 { PEBinary
*tmp
= new PEBComp
('L', $1, $3);
914 tmp
->set_file
(@
2.text
);
915 tmp
->set_lineno
(@
2.first_line
);
918 | expression K_GE expression
919 { PEBinary
*tmp
= new PEBComp
('G', $1, $3);
920 tmp
->set_file
(@
2.text
);
921 tmp
->set_lineno
(@
2.first_line
);
924 | expression K_NE expression
925 { PEBinary
*tmp
= new PEBComp
('n', $1, $3);
926 tmp
->set_file
(@
2.text
);
927 tmp
->set_lineno
(@
2.first_line
);
930 | expression K_CNE expression
931 { PEBinary
*tmp
= new PEBComp
('N', $1, $3);
932 tmp
->set_file
(@
2.text
);
933 tmp
->set_lineno
(@
2.first_line
);
936 | expression K_LOR expression
937 { PEBinary
*tmp
= new PEBinary
('o', $1, $3);
938 tmp
->set_file
(@
2.text
);
939 tmp
->set_lineno
(@
2.first_line
);
942 | expression K_LAND expression
943 { PEBinary
*tmp
= new PEBinary
('a', $1, $3);
944 tmp
->set_file
(@
2.text
);
945 tmp
->set_lineno
(@
2.first_line
);
948 | expression
'?' expression
':' expression
949 { PETernary
*tmp
= new PETernary
($1, $3, $5);
950 tmp
->set_file
(@
2.text
);
951 tmp
->set_lineno
(@
2.first_line
);
957 /* Many contexts take a comma separated list of expressions. Null
958 expressions can happen anywhere in the list, so there are two
959 extra rules in expression_list_with_nuls for parsing and
960 installing those nulls.
962 The expression_list_proper rules do not allow null items in the
963 expression list, so can be used where nul expressions are not allowed. */
965 expression_list_with_nuls
966 : expression_list_with_nuls
',' expression
967 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
972 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
977 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
982 | expression_list_with_nuls
','
983 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, 0);
989 expression_list_proper
990 : expression_list_proper
',' expression
991 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
996 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1005 PENumber
*tmp
= new PENumber
($1);
1006 tmp
->set_file
(@
1.text
);
1007 tmp
->set_lineno
(@
1.first_line
);
1011 { PEFNumber
*tmp
= new PEFNumber
($1);
1012 tmp
->set_file
(@
1.text
);
1013 tmp
->set_lineno
(@
1.first_line
);
1017 { PEString
*tmp
= new PEString
($1);
1018 tmp
->set_file
(@
1.text
);
1019 tmp
->set_lineno
(@
1.first_line
);
1023 { perm_string tn
= lex_strings.make
($1);
1024 PECallFunction
*tmp
= new PECallFunction
(tn
);
1025 tmp
->set_file
(@
1.text
);
1026 tmp
->set_lineno
(@
1.first_line
);
1031 /* The heirarchy_identifier rule matches simple identifiers as well as
1032 indexed arrays and part selects */
1034 | heirarchy_identifier
1035 { PEIdent
*tmp
= new PEIdent
(*$1);
1036 tmp
->set_file
(@
1.text
);
1037 tmp
->set_lineno
(@
1.first_line
);
1042 /* An identifer followed by an expression list in parentheses is a
1043 function call. If a system identifier, then a system function
1046 | heirarchy_identifier
'(' expression_list_proper
')'
1047 { PECallFunction
*tmp
= new PECallFunction
(*$1, *$3);
1048 tmp
->set_file
(@
1.text
);
1049 tmp
->set_lineno
(@
1.first_line
);
1053 | SYSTEM_IDENTIFIER
'(' expression_list_proper
')'
1054 { perm_string tn
= lex_strings.make
($1);
1055 PECallFunction
*tmp
= new PECallFunction
(tn
, *$3);
1056 tmp
->set_file
(@
1.text
);
1057 tmp
->set_lineno
(@
1.first_line
);
1061 /* Parenthesized expressions are primaries. */
1063 |
'(' expression
')'
1066 /* Various kinds of concatenation expressions. */
1068 |
'{' expression_list_proper
'}'
1069 { PEConcat
*tmp
= new PEConcat
(*$2);
1070 tmp
->set_file
(@
1.text
);
1071 tmp
->set_lineno
(@
1.first_line
);
1075 |
'{' expression
'{' expression_list_proper
'}' '}'
1077 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1078 tmp
->set_file
(@
1.text
);
1079 tmp
->set_lineno
(@
1.first_line
);
1083 |
'{' expression
'{' expression_list_proper
'}' error '}'
1085 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1086 tmp
->set_file
(@
1.text
);
1087 tmp
->set_lineno
(@
1.first_line
);
1090 yyerror(@
5, "error: Syntax error between internal '}' "
1091 "and closing '}' of repeat concatenation.");
1096 /* A function_item is either a block item (i.e. a reg or integer
1097 declaration) or an input declaration. There are no output or
1100 : K_input signed_opt range_opt list_of_identifiers
';'
1101 { svector
<PWire
*>*tmp
1102 = pform_make_task_ports
(NetNet
::PINPUT
,
1105 @
1.text
, @
1.first_line
);
1108 | K_output signed_opt range_opt list_of_identifiers
';'
1109 { svector
<PWire
*>*tmp
1110 = pform_make_task_ports
(NetNet
::PINPUT
,
1113 @
1.text
, @
1.first_line
);
1115 yyerror(@
1, "Functions may not have output ports.");
1117 | K_inout signed_opt range_opt list_of_identifiers
';'
1118 { svector
<PWire
*>*tmp
1119 = pform_make_task_ports
(NetNet
::PINPUT
,
1122 @
1.text
, @
1.first_line
);
1124 yyerror(@
1, "Functions may not have inout ports.");
1127 /* When the port is an integer, infer a signed vector of the integer
1128 shape. Generate a range to make it work. */
1130 | K_input K_integer list_of_identifiers
';'
1131 { svector
<PExpr
*>*range_stub
1132 = new svector
<PExpr
*>(2);
1134 re
= new PENumber
(new verinum
(integer_width
-1,
1136 (*range_stub
)[0] = re
;
1137 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
1138 (*range_stub
)[1] = re
;
1140 = pform_make_task_ports
(NetNet
::PINPUT
,
1143 @
1.text
, @
1.first_line
);
1147 /* Ports can be real. */
1149 | K_input K_real list_of_identifiers
';'
1150 { svector
<PWire
*>*tmp
1151 = pform_make_task_ports
(NetNet
::PINPUT
,
1154 @
1.text
, @
1.first_line
);
1162 /* A function_item_list only lists the input/output/inout
1163 declarations. The integer and reg declarations are handled in
1164 place, so are not listed. The list builder needs to account for
1165 the possibility that the various parts may be NULL. */
1169 | function_item_list function_item
1171 svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
1183 /* A gate_instance is a module instantiation or a built in part
1184 type. In any case, the gate has a set of connections to ports. */
1186 : IDENTIFIER
'(' expression_list_with_nuls
')'
1187 { lgate
*tmp
= new lgate
;
1190 tmp
->file
= @
1.text
;
1191 tmp
->lineno
= @
1.first_line
;
1196 | IDENTIFIER range
'(' expression_list_with_nuls
')'
1197 { lgate
*tmp
= new lgate
;
1198 svector
<PExpr
*>*rng
= $2;
1201 tmp
->range
[0] = (*rng
)[0];
1202 tmp
->range
[1] = (*rng
)[1];
1203 tmp
->file
= @
1.text
;
1204 tmp
->lineno
= @
1.first_line
;
1209 |
'(' expression_list_with_nuls
')'
1210 { lgate
*tmp
= new lgate
;
1213 tmp
->file
= @
1.text
;
1214 tmp
->lineno
= @
1.first_line
;
1218 /* Degenerate modules can have no ports. */
1221 { lgate
*tmp
= new lgate
;
1222 svector
<PExpr
*>*rng
= $2;
1225 tmp
->parms_by_name
= 0;
1226 tmp
->range
[0] = (*rng
)[0];
1227 tmp
->range
[1] = (*rng
)[1];
1228 tmp
->file
= @
1.text
;
1229 tmp
->lineno
= @
1.first_line
;
1235 /* Modules can also take ports by port-name expressions. */
1237 | IDENTIFIER
'(' port_name_list
')'
1238 { lgate
*tmp
= new lgate
;
1241 tmp
->parms_by_name
= $3;
1242 tmp
->file
= @
1.text
;
1243 tmp
->lineno
= @
1.first_line
;
1248 | IDENTIFIER range
'(' port_name_list
')'
1249 { lgate
*tmp
= new lgate
;
1250 svector
<PExpr
*>*rng
= $2;
1253 tmp
->parms_by_name
= $4;
1254 tmp
->range
[0] = (*rng
)[0];
1255 tmp
->range
[1] = (*rng
)[1];
1256 tmp
->file
= @
1.text
;
1257 tmp
->lineno
= @
1.first_line
;
1265 : gate_instance_list
',' gate_instance
1266 { svector
<lgate
>*tmp1
= $1;
1268 svector
<lgate
>*out
= new svector
<lgate
> (*tmp1
, *tmp2
);
1274 { svector
<lgate
>*tmp
= new svector
<lgate
>(1);
1282 : K_and
{ $$
= PGBuiltin
::AND
; }
1283 | K_nand
{ $$
= PGBuiltin
::NAND
; }
1284 | K_or
{ $$
= PGBuiltin
::OR
; }
1285 | K_nor
{ $$
= PGBuiltin
::NOR
; }
1286 | K_xor
{ $$
= PGBuiltin
::XOR
; }
1287 | K_xnor
{ $$
= PGBuiltin
::XNOR
; }
1288 | K_buf
{ $$
= PGBuiltin
::BUF
; }
1289 | K_bufif0
{ $$
= PGBuiltin
::BUFIF0
; }
1290 | K_bufif1
{ $$
= PGBuiltin
::BUFIF1
; }
1291 | K_not
{ $$
= PGBuiltin
::NOT
; }
1292 | K_notif0
{ $$
= PGBuiltin
::NOTIF0
; }
1293 | K_notif1
{ $$
= PGBuiltin
::NOTIF1
; }
1294 | K_nmos
{ $$
= PGBuiltin
::NMOS
; }
1295 | K_rnmos
{ $$
= PGBuiltin
::RNMOS
; }
1296 | K_pmos
{ $$
= PGBuiltin
::PMOS
; }
1297 | K_rpmos
{ $$
= PGBuiltin
::RPMOS
; }
1298 | K_cmos
{ $$
= PGBuiltin
::CMOS
; }
1299 | K_rcmos
{ $$
= PGBuiltin
::RCMOS
; }
1300 | K_tran
{ $$
= PGBuiltin
::TRAN
; }
1301 | K_rtran
{ $$
= PGBuiltin
::RTRAN
; }
1302 | K_tranif0
{ $$
= PGBuiltin
::TRANIF0
; }
1303 | K_tranif1
{ $$
= PGBuiltin
::TRANIF1
; }
1304 | K_rtranif0
{ $$
= PGBuiltin
::RTRANIF0
; }
1305 | K_rtranif1
{ $$
= PGBuiltin
::RTRANIF1
; }
1309 /* A general identifier is a hierarchical name, with the right most
1310 name the base of the identifier. This rule builds up a
1311 hierarchical name from the left to the right, forming a list of
1314 heirarchy_identifier
1316 { $$
= new pform_name_t
;
1317 $$
->push_back
(name_component_t
(lex_strings.make
($1)));
1320 | heirarchy_identifier
'.' IDENTIFIER
1321 { pform_name_t
* tmp
= $1;
1322 tmp
->push_back
(name_component_t
(lex_strings.make
($3)));
1326 | heirarchy_identifier
'[' expression
']'
1327 { pform_name_t
* tmp
= $1;
1328 name_component_t
&tail
= tmp
->back
();
1329 index_component_t itmp
;
1330 itmp.sel
= index_component_t
::SEL_BIT
;
1332 tail.index.push_back
(itmp
);
1335 | heirarchy_identifier
'[' expression
':' expression
']'
1336 { pform_name_t
* tmp
= $1;
1337 name_component_t
&tail
= tmp
->back
();
1338 index_component_t itmp
;
1339 itmp.sel
= index_component_t
::SEL_PART
;
1342 tail.index.push_back
(itmp
);
1345 | heirarchy_identifier
'[' expression K_PO_POS 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_IDX_UP
;
1352 tail.index.push_back
(itmp
);
1355 | heirarchy_identifier
'[' expression K_PO_NEG 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_DO
;
1362 tail.index.push_back
(itmp
);
1367 /* This is a list of identifiers. The result is a list of strings,
1368 each one of the identifiers in the list. These are simple,
1369 non-hierarchical names separated by ',' characters. */
1372 { $$
= list_from_identifier
($1); }
1373 | list_of_identifiers
',' IDENTIFIER
1374 { $$
= list_from_identifier
($1, $3); }
1378 /* The list_of_ports and list_of_port_declarations rules are the
1379 port list formats for module ports. The list_of_ports_opt rule is
1380 only used by the module start rule.
1382 The first, the list_of_ports, is the 1364-1995 format, a list of
1383 port names, including .name() syntax.
1385 The list_of_port_declarations the 1364-2001 format, an in-line
1386 declaration of the ports.
1388 In both cases, the list_of_ports and list_of_port_declarations
1389 returns an array of Module::port_t* items that include the name
1390 of the port internally and externally. The actual creation of the
1391 nets/variables is done in the declaration, whether internal to
1392 the port list or in amongst the module items. */
1396 { svector
<Module
::port_t
*>*tmp
1397 = new svector
<Module
::port_t
*>(1);
1401 | list_of_ports
',' port_opt
1402 { svector
<Module
::port_t
*>*tmp
1403 = new svector
<Module
::port_t
*>(*$1, $3);
1409 list_of_port_declarations
1411 { svector
<Module
::port_t
*>*tmp
1412 = new svector
<Module
::port_t
*>(1);
1415 * Uncommenting this makes lopd always fully specified.
1416 * Some wanted an implicit net to not be fully defined.
1418 * pform_set_net_range($1[0].name);
1422 | list_of_port_declarations
',' port_declaration
1423 { svector
<Module
::port_t
*>*tmp
1424 = new svector
<Module
::port_t
*>(*$1, $3);
1429 * pform_set_net_range($3[0].name);
1433 | list_of_port_declarations
',' IDENTIFIER
1434 { Module
::port_t
*ptmp
;
1435 ptmp
= pform_module_port_reference
($3, @
3.text
,
1437 svector
<Module
::port_t
*>*tmp
1438 = new svector
<Module
::port_t
*>(*$1, ptmp
);
1440 /* Get the port declaration details, the port type
1441 and what not, from context data stored by the
1442 last port_declaration rule. */
1443 pform_module_define_port
(@
3, $3,
1444 port_declaration_context.port_type
,
1445 port_declaration_context.port_net_type
,
1446 port_declaration_context.sign_flag
,
1447 port_declaration_context.range
, 0);
1452 * pform_set_net_range($3);
1459 : attribute_list_opt
1460 K_input net_type_opt signed_opt range_opt IDENTIFIER
1461 { Module
::port_t
*ptmp
;
1462 ptmp
= pform_module_port_reference
($6, @
2.text
,
1464 pform_module_define_port
(@
2, $6, NetNet
::PINPUT
,
1466 port_declaration_context.port_type
= NetNet
::PINPUT
;
1467 port_declaration_context.port_net_type
= $3;
1468 port_declaration_context.sign_flag
= $4;
1469 port_declaration_context.range
= $5;
1474 | attribute_list_opt
1475 K_inout net_type_opt signed_opt range_opt IDENTIFIER
1476 { Module
::port_t
*ptmp
;
1477 ptmp
= pform_module_port_reference
($6, @
2.text
,
1479 pform_module_define_port
(@
2, $6, NetNet
::PINOUT
,
1481 port_declaration_context.port_type
= NetNet
::PINOUT
;
1482 port_declaration_context.port_net_type
= $3;
1483 port_declaration_context.sign_flag
= $4;
1484 port_declaration_context.range
= $5;
1489 | attribute_list_opt
1490 K_output net_type_opt signed_opt range_opt IDENTIFIER
1491 { Module
::port_t
*ptmp
;
1492 ptmp
= pform_module_port_reference
($6, @
2.text
,
1494 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1496 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1497 port_declaration_context.port_net_type
= $3;
1498 port_declaration_context.sign_flag
= $4;
1499 port_declaration_context.range
= $5;
1504 | attribute_list_opt
1505 K_output var_type signed_opt range_opt IDENTIFIER
1506 { Module
::port_t
*ptmp
;
1507 ptmp
= pform_module_port_reference
($6, @
2.text
,
1509 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1511 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1512 port_declaration_context.port_net_type
= $3;
1513 port_declaration_context.sign_flag
= $4;
1514 port_declaration_context.range
= $5;
1519 | attribute_list_opt
1520 K_output var_type signed_opt range_opt IDENTIFIER
'=' expression
1521 { Module
::port_t
*ptmp
;
1522 ptmp
= pform_module_port_reference
($6, @
2.text
,
1524 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1526 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1527 port_declaration_context.port_net_type
= $3;
1528 port_declaration_context.sign_flag
= $4;
1529 port_declaration_context.range
= $5;
1531 if
(! pform_expression_is_constant
($8))
1532 yyerror(@
8, "error: register declaration assignment"
1533 " value must be a constant expression.");
1534 pform_make_reginit
(@
6, $6, $8);
1545 : net_type
{ $$
= $1; }
1546 |
{ $$
= NetNet
::IMPLICIT
; }
1549 signed_opt
: K_signed
{ $$
= true
; } |
{$$
= false
; } ;
1551 /* An lpvalue is the expression that can go on the left side of a
1552 procedural assignment. This rule handles only procedural
1553 assignments. It is more limited then the general expr_primary
1554 rule to reflect the rules for assignment l-values. */
1556 : heirarchy_identifier
1557 { PEIdent
*tmp
= new PEIdent
(*$1);
1558 tmp
->set_file
(@
1.text
);
1559 tmp
->set_lineno
(@
1.first_line
);
1563 |
'{' expression_list_proper
'}'
1564 { PEConcat
*tmp
= new PEConcat
(*$2);
1565 tmp
->set_file
(@
1.text
);
1566 tmp
->set_lineno
(@
1.first_line
);
1573 /* Continuous assignments have a list of individual assignments. */
1576 : lpvalue
'=' expression
1577 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
1585 : cont_assign_list
',' cont_assign
1586 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, *$3);
1596 /* This is the global structure of a module. A module in a start
1597 section, with optional ports, then an optional list of module
1598 items, and finally an end marker. */
1600 module
: attribute_list_opt module_start IDENTIFIER
1601 { pform_startmodule
($3, @
2.text
, @
2.first_line
, $1); }
1602 module_parameter_port_list_opt
1603 module_port_list_opt
';'
1604 { pform_module_set_ports
($6); }
1605 module_item_list_opt
1607 { pform_endmodule
($3);
1613 module_start
: K_module | K_macromodule
;
1615 module_port_list_opt
1616 : '(' list_of_ports
')' { $$
= $2; }
1617 |
'(' list_of_port_declarations
')' { $$
= $2; }
1621 /* Module declarations include optional ANSII style module parameter
1622 ports. These are simply advance ways to declare parameters, so
1623 that the port declarations may use them. */
1624 module_parameter_port_list_opt
1626 |
'#' '(' module_parameter_port_list
')'
1629 module_parameter_port_list
1630 : K_parameter parameter_assign
1631 | module_parameter_port_list
',' parameter_assign
1632 | module_parameter_port_list
',' K_parameter parameter_assign
1637 /* This rule detects net declarations that possibly include a
1638 primitive type, an optional vector range and signed flag. This
1639 also includes an optional delay set. The values are then applied
1640 to a list of names. If the primitive type is not specified, then
1641 resort to the default type LOGIC. */
1643 : attribute_list_opt net_type
1644 primitive_type_opt signed_opt range_opt
1646 net_variable_list
';'
1648 { ivl_variable_type_t dtype
= $3;
1649 if
(dtype
== IVL_VT_NO_TYPE
)
1650 dtype
= IVL_VT_LOGIC
;
1651 pform_makewire
(@
2, $5, $4, $7, $2,
1652 NetNet
::NOT_A_PORT
, dtype
, $1);
1654 yyerror(@
6, "sorry: net delays not supported.");
1660 /* Very similar to the rule above, but this takes a list of
1661 net_decl_assigns, which are <name> = <expr> assignment
1664 | attribute_list_opt net_type
1665 primitive_type_opt signed_opt range_opt
1666 delay3_opt net_decl_assigns
';'
1668 { ivl_variable_type_t dtype
= $3;
1669 if
(dtype
== IVL_VT_NO_TYPE
)
1670 dtype
= IVL_VT_LOGIC
;
1671 pform_makewire
(@
2, $5, $4, $6,
1672 str_strength
, $7, $2, dtype
);
1674 yyerror(@
2, "sorry: Attributes not supported "
1675 "on net declaration assignments.");
1680 /* This form doesn't have the range, but does have strengths. This
1681 gives strength to the assignment drivers. */
1683 | attribute_list_opt net_type
1684 primitive_type_opt signed_opt
1685 drive_strength net_decl_assigns
';'
1687 { ivl_variable_type_t dtype
= $3;
1688 if
(dtype
== IVL_VT_NO_TYPE
)
1689 dtype
= IVL_VT_LOGIC
;
1690 pform_makewire
(@
2, 0, $4, 0, $5, $6, $2, dtype
);
1692 yyerror(@
2, "sorry: Attributes not supported "
1693 "on net declaration assignments.");
1698 | K_trireg charge_strength_opt range_opt delay3_opt list_of_identifiers
';'
1699 { yyerror(@
1, "sorry: trireg nets not supported.");
1704 | port_type signed_opt range_opt delay3_opt list_of_identifiers
';'
1705 { pform_set_port_type
(@
1, $5, $3, $2, $1);
1708 /* The next two rules handle Verilog 2001 statements of the form:
1709 input wire signed [h:l] <list>;
1710 This creates the wire and sets the port type all at once. */
1712 | port_type net_type signed_opt range_opt list_of_identifiers
';'
1713 { pform_makewire
(@
1, $4, $3, $5, $2, $1, IVL_VT_NO_TYPE
, 0,
1717 | K_output var_type signed_opt range_opt list_of_identifiers
';'
1718 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::POUTPUT
,
1719 IVL_VT_NO_TYPE
, 0, SR_BOTH
);
1722 /* var_type declaration (reg variables) cannot be input or output,
1723 because the port declaration implies an external driver, which
1724 cannot be attached to a reg. These rules catch that error early. */
1726 | K_input var_type signed_opt range_opt list_of_identifiers
';'
1727 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINPUT
,
1729 yyerror(@
2, "error: reg variables cannot be inputs.");
1732 | K_inout var_type signed_opt range_opt list_of_identifiers
';'
1733 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINOUT
,
1735 yyerror(@
2, "error: reg variables cannot be inouts.");
1738 | port_type signed_opt range_opt delay3_opt
error ';'
1739 { yyerror(@
1, "error: Invalid variable list"
1740 " in port declaration.");
1746 /* block_item_decl rule is shared with task blocks and named
1753 | K_defparam defparam_assign_list
';'
1754 | K_event list_of_identifiers
';'
1755 { pform_make_events
($2, @
1.text
, @
1.first_line
);
1758 /* Most gate types have an optional drive strength and optional
1759 three-value delay. These rules handle the different cases. */
1761 | attribute_list_opt gatetype gate_instance_list
';'
1762 { pform_makegates
($2, str_strength
, 0, $3, $1);
1765 | attribute_list_opt gatetype delay3 gate_instance_list
';'
1766 { pform_makegates
($2, str_strength
, $3, $4, $1);
1769 | attribute_list_opt gatetype drive_strength gate_instance_list
';'
1770 { pform_makegates
($2, $3, 0, $4, $1);
1773 | attribute_list_opt gatetype drive_strength delay3 gate_instance_list
';'
1774 { pform_makegates
($2, $3, $4, $5, $1);
1777 /* Pullup and pulldown devices cannot have delays, and their
1778 strengths are limited. */
1780 | K_pullup gate_instance_list
';'
1781 { pform_makegates
(PGBuiltin
::PULLUP
, pull_strength
, 0,
1784 | K_pulldown gate_instance_list
';'
1785 { pform_makegates
(PGBuiltin
::PULLDOWN
, pull_strength
,
1789 | K_pullup
'(' dr_strength1
')' gate_instance_list
';'
1790 { pform_makegates
(PGBuiltin
::PULLUP
, $3, 0, $5, 0);
1793 | K_pulldown
'(' dr_strength0
')' gate_instance_list
';'
1794 { pform_makegates
(PGBuiltin
::PULLDOWN
, $3, 0, $5, 0);
1797 /* This rule handles instantiations of modules and user defined
1798 primitives. These devices to not have delay lists or strengths,
1799 but then can have parameter lists. */
1801 | attribute_list_opt
1802 IDENTIFIER parameter_value_opt gate_instance_list
';'
1803 { perm_string tmp1
= lex_strings.make
($2);
1804 pform_make_modgates
(tmp1
, $3, $4);
1809 | attribute_list_opt
1810 IDENTIFIER parameter_value_opt
error ';'
1811 { yyerror(@
2, "error: Invalid module instantiation");
1815 /* Continuous assignment can have an optional drive strength, then
1816 an optional delay3 that applies to all the assignments in the
1817 cont_assign_list. */
1819 | K_assign drive_strength_opt delay3_opt cont_assign_list
';'
1820 { pform_make_pgassign_list
($4, $3, $2, @
1.text
, @
1.first_line
); }
1822 /* Always and initial items are behavioral processes. */
1824 | attribute_list_opt K_always statement
1825 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_ALWAYS
,
1827 tmp
->set_file
(@
2.text
);
1828 tmp
->set_lineno
(@
2.first_line
);
1830 | attribute_list_opt K_initial statement
1831 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_INITIAL
,
1833 tmp
->set_file
(@
2.text
);
1834 tmp
->set_lineno
(@
2.first_line
);
1837 /* The task declaration rule matches the task declaration
1838 header, then pushes the function scope. This causes the
1839 definitions in the task_body to take on the scope of the task
1840 instead of the module. Note that these runs accept for the task
1841 body statement_or_null, although the standard does not allow null
1842 statements in the task body. But we continue to accept it as an
1845 | K_task IDENTIFIER
';'
1846 { pform_push_scope
($2); }
1850 { PTask
*tmp
= new PTask
;
1851 perm_string tmp2
= lex_strings.make
($2);
1852 tmp
->set_file
(@
1.text
);
1853 tmp
->set_lineno
(@
1.first_line
);
1855 tmp
->set_statement
($6);
1856 pform_set_task
(tmp2
, tmp
);
1862 { pform_push_scope
($2); }
1863 '(' task_port_decl_list
')' ';'
1867 { PTask
*tmp
= new PTask
;
1868 perm_string tmp2
= lex_strings.make
($2);
1869 tmp
->set_file
(@
1.text
);
1870 tmp
->set_lineno
(@
1.first_line
);
1872 tmp
->set_statement
($9);
1873 pform_set_task
(tmp2
, tmp
);
1878 /* The function declaration rule matches the function declaration
1879 header, then pushes the function scope. This causes the
1880 definitions in the func_body to take on the scope of the function
1881 instead of the module. */
1883 | K_function function_range_or_type_opt IDENTIFIER
';'
1884 { pform_push_scope
($3); }
1885 function_item_list statement
1887 { perm_string name
= lex_strings.make
($3);
1888 PFunction
*tmp
= new PFunction
(name
);
1889 tmp
->set_file
(@
1.text
);
1890 tmp
->set_lineno
(@
1.first_line
);
1892 tmp
->set_statement
($7);
1893 tmp
->set_return
($2);
1894 pform_set_function
(name
, tmp
);
1899 /* A generate region can contain further module items. Actually, it
1900 is supposed to be limited to certain kinds of module items, but
1901 the semantic tests will check that for us. */
1903 | K_generate module_item_list_opt K_endgenerate
1905 | K_genvar list_of_identifiers
';'
1906 { pform_genvars
($2); }
1908 | K_for
'(' IDENTIFIER
'=' expression
';'
1910 IDENTIFIER
'=' expression
')'
1911 { pform_start_generate_for
(@
1, $3, $5, $7, $9, $11); }
1913 { pform_endgenerate
(); }
1918 { pform_start_generate_else
(@
1); }
1920 { pform_endgenerate
(); }
1923 generate_block_opt %prec less_than_K_else
1924 { pform_endgenerate
(); }
1926 /* specify blocks are parsed but ignored. */
1928 | K_specify K_endspecify
1929 { /* empty lists are legal syntax. */ }
1931 | K_specify specify_item_list K_endspecify
1935 | K_specify
error K_endspecify
1936 { yyerror(@
1, "error: syntax error in specify block");
1940 /* These rules match various errors that the user can type into
1941 module items. These rules try to catch them at a point where a
1942 reasonable error message can be produced. */
1944 | K_module
error ';'
1945 { yyerror(@
2, "error: missing endmodule or attempt to "
1947 pform_error_nested_modules
();
1952 { yyerror(@
2, "error: invalid module item.");
1956 | K_assign
error '=' expression
';'
1957 { yyerror(@
1, "error: syntax error in left side "
1958 "of continuous assignment.");
1962 | K_assign
error ';'
1963 { yyerror(@
1, "error: syntax error in "
1964 "continuous assignment");
1968 | K_function
error K_endfunction
1969 { yyerror(@
1, "error: I give up on this "
1970 "function definition.");
1974 /* These rules are for the Icarus Verilog specific $attribute
1975 extensions. Then catch the parameters of the $attribute keyword. */
1977 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')' ';'
1978 { perm_string tmp3
= lex_strings.make
($3);
1979 perm_string tmp5
= lex_strings.make
($5);
1980 pform_set_attrib
(tmp3
, tmp5
, $7);
1984 | KK_attribute
'(' error ')' ';'
1985 { yyerror(@
1, "error: Malformed $attribute parameter list."); }
1988 generate_if
: K_if
'(' expression
')' { pform_start_generate_if
(@
1, $3); }
1991 : module_item_list module_item
1995 module_item_list_opt
2000 /* A generate block is the thing within a generate scheme. It may be
2001 a single module item, an anonymous block of module items, or a
2002 named module item. In all cases, the meat is in the module items
2003 inside, and the processing is done by the module_item rules. We
2004 only need to take note here of the scope name, if any. */
2008 | K_begin module_item_list_opt K_end
2009 | K_begin
':' IDENTIFIER module_item_list_opt K_end
2010 { pform_generate_block_name
($3); }
2013 generate_block_opt
: generate_block |
';' ;
2016 /* A net declaration assignment allows the programmer to combine the
2017 net declaration and the continuous assignment into a single
2020 Note that the continuous assignment statement is generated as a
2021 side effect, and all I pass up is the name of the l-value. */
2024 : IDENTIFIER
'=' expression
2025 { net_decl_assign_t
*tmp
= new net_decl_assign_t
;
2034 : net_decl_assigns
',' net_decl_assign
2035 { net_decl_assign_t
*tmp
= $1;
2036 $3->next
= tmp
->next
;
2046 : K_logic
{ $$
= IVL_VT_LOGIC
; }
2047 | K_bool
{ $$
= IVL_VT_BOOL
; }
2048 | K_real
{ $$
= IVL_VT_REAL
; }
2051 primitive_type_opt
: primitive_type
{ $$
= $1; } |
{ $$
= IVL_VT_NO_TYPE
; } ;
2054 : K_wire
{ $$
= NetNet
::WIRE
; }
2055 | K_tri
{ $$
= NetNet
::TRI
; }
2056 | K_tri1
{ $$
= NetNet
::TRI1
; }
2057 | K_supply0
{ $$
= NetNet
::SUPPLY0
; }
2058 | K_wand
{ $$
= NetNet
::WAND
; }
2059 | K_triand
{ $$
= NetNet
::TRIAND
; }
2060 | K_tri0
{ $$
= NetNet
::TRI0
; }
2061 | K_supply1
{ $$
= NetNet
::SUPPLY1
; }
2062 | K_wor
{ $$
= NetNet
::WOR
; }
2063 | K_trior
{ $$
= NetNet
::TRIOR
; }
2064 | K_wone
{ $$
= NetNet
::WONE
; }
2068 : K_reg
{ $$
= NetNet
::REG
; }
2071 /* In this rule we have matched the "parameter" keyword. The rule
2072 generates a type (optional) and a list of assignments. */
2074 parameter_assign_decl
2075 : parameter_assign_list
2076 | range
{ active_range
= $1; active_signed
= false
; }
2077 parameter_assign_list
2079 active_signed
= false
;
2081 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2082 parameter_assign_list
2084 active_signed
= false
;
2086 | K_integer
{ active_range
= 0; active_signed
= true
; }
2087 parameter_assign_list
2089 active_signed
= false
;
2093 parameter_assign_list
2095 | parameter_assign_list
',' parameter_assign
2099 : IDENTIFIER
'=' expression
2101 if
(!pform_expression_is_constant
(tmp
)) {
2102 yyerror(@
3, "error: parameter value "
2103 "must be a constant expression.");
2107 pform_set_parameter
(lex_strings.make
($1),
2115 /* Localparam assignments and assignment lists are broken into
2116 separate BNF so that I can call slightly different parameter
2117 handling code. They parse the same as parameters, they just
2118 behave differently when someone tries to override them. */
2121 : IDENTIFIER
'=' expression
2123 if
(!pform_expression_is_constant
(tmp
)) {
2124 yyerror(@
3, "error: parameter value "
2125 "must be constant.");
2129 pform_set_localparam
(lex_strings.make
($1),
2137 localparam_assign_decl
2138 : localparam_assign_list
2139 | range
{ active_range
= $1; active_signed
= false
; }
2140 localparam_assign_list
2142 active_signed
= false
;
2144 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2145 localparam_assign_list
2147 active_signed
= false
;
2151 localparam_assign_list
2153 | localparam_assign_list
',' localparam_assign
2158 /* The parameters of a module instance can be overridden by writing
2159 a list of expressions in a syntax much like a delay list. (The
2160 difference being the list can have any length.) The pform that
2161 attaches the expression list to the module checks that the
2162 expressions are constant.
2164 Although the BNF in IEEE1364-1995 implies that parameter value
2165 lists must be in parentheses, in practice most compilers will
2166 accept simple expressions outside of parentheses if there is only
2167 one value, so I'll accept simple numbers here.
2169 The parameter value by name syntax is OVI enhancement BTF-B06 as
2170 approved by WG1364 on 6/28/1998. */
2173 : '#' '(' expression_list_with_nuls
')'
2174 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2179 |
'#' '(' parameter_value_byname_list
')'
2180 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2187 PENumber
*tmp
= new PENumber
($2);
2188 tmp
->set_file
(@
1.text
);
2189 tmp
->set_lineno
(@
1.first_line
);
2191 struct parmvalue_t
*lst
= new
struct parmvalue_t
;
2192 lst
->by_order
= new svector
<PExpr
*>(1);
2193 (*lst
->by_order
)[0] = tmp
;
2198 { yyerror(@
1, "error: syntax error in parameter value "
2199 "assignment list.");
2206 parameter_value_byname
2207 : '.' IDENTIFIER
'(' expression
')'
2208 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2209 tmp
->name
= lex_strings.make
($2);
2214 |
'.' IDENTIFIER
'(' ')'
2215 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2216 tmp
->name
= lex_strings.make
($2);
2223 parameter_value_byname_list
2224 : parameter_value_byname
2225 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2229 | parameter_value_byname_list
',' parameter_value_byname
2230 { svector
<named_pexpr_t
*>*tmp
=
2231 new svector
<named_pexpr_t
*>(*$1,$3);
2238 /* The port (of a module) is a fairly complex item. Each port is
2239 handled as a Module::port_t object. A simple port reference has a
2240 name and a PExpr object, but more complex constructs are possible
2241 where the name can be attached to a list of PWire objects.
2243 The port_reference returns a Module::port_t, and so does the
2244 port_reference_list. The port_reference_list may have built up a
2245 list of PWires in the port_t object, but it is still a single
2246 Module::port_t object.
2248 The port rule below takes the built up Module::port_t object and
2249 tweaks its name as needed. */
2255 /* This syntax attaches an external name to the port reference so
2256 that the caller can bind by name to non-trivial port
2257 references. The port_t object gets its PWire from the
2258 port_reference, but its name from the IDENTIFIER. */
2260 |
'.' IDENTIFIER
'(' port_reference
')'
2261 { Module
::port_t
*tmp
= $4;
2262 tmp
->name
= lex_strings.make
($2);
2267 /* A port can also be a concatenation of port references. In this
2268 case the port does not have a name available to the outside, only
2269 positional parameter passing is possible here. */
2271 |
'{' port_reference_list
'}'
2272 { Module
::port_t
*tmp
= $2;
2273 tmp
->name
= perm_string
();
2277 /* This attaches a name to a port reference concatenation list so
2278 that parameter passing be name is possible. */
2280 |
'.' IDENTIFIER
'(' '{' port_reference_list
'}' ')'
2281 { Module
::port_t
*tmp
= $5;
2282 tmp
->name
= lex_strings.make
($2);
2294 /* A port reference is an internal (to the module) name of the port,
2295 possibly with a part of bit select to attach it to specific bits
2296 of a signal fully declared inside the module.
2298 The parser creates a PEIdent for every port reference, even if the
2299 signal is bound to different ports. The elaboration figures out
2300 the mess that this creates. The port_reference (and the
2301 port_reference_list below) puts the port reference PEIdent into the
2302 port_t object to pass it up to the module declaration code. */
2307 { Module
::port_t
*ptmp
;
2308 ptmp
= pform_module_port_reference
($1, @
1.text
, @
1.first_line
);
2313 | IDENTIFIER
'[' expression
':' expression
']'
2314 { if
(!pform_expression_is_constant
($3)) {
2315 yyerror(@
3, "error: msb expression of "
2316 "port part select must be constant.");
2318 if
(!pform_expression_is_constant
($5)) {
2319 yyerror(@
5, "error: lsb expression of "
2320 "port part select must be constant.");
2322 index_component_t itmp
;
2323 itmp.sel
= index_component_t
::SEL_PART
;
2327 name_component_t ntmp
(lex_strings.make
($1));
2328 ntmp.index.push_back
(itmp
);
2331 pname.push_back
(ntmp
);
2333 PEIdent
*wtmp
= new PEIdent
(pname
);
2334 wtmp
->set_file
(@
1.text
);
2335 wtmp
->set_lineno
(@
1.first_line
);
2337 Module
::port_t
*ptmp
= new Module
::port_t
;
2338 ptmp
->name
= perm_string
();
2339 ptmp
->expr
= svector
<PEIdent
*>(1);
2340 ptmp
->expr
[0] = wtmp
;
2346 | IDENTIFIER
'[' expression
']'
2347 { if
(!pform_expression_is_constant
($3)) {
2348 yyerror(@
3, "error: port bit select "
2349 "must be constant.");
2351 index_component_t itmp
;
2352 itmp.sel
= index_component_t
::SEL_BIT
;
2356 name_component_t ntmp
(lex_strings.make
($1));
2357 ntmp.index.push_back
(itmp
);
2360 pname.push_back
(ntmp
);
2362 PEIdent
*tmp
= new PEIdent
(pname
);
2363 tmp
->set_file
(@
1.text
);
2364 tmp
->set_lineno
(@
1.first_line
);
2366 Module
::port_t
*ptmp
= new Module
::port_t
;
2367 ptmp
->name
= perm_string
();
2368 ptmp
->expr
= svector
<PEIdent
*>(1);
2369 ptmp
->expr
[0] = tmp
;
2374 | IDENTIFIER
'[' error ']'
2375 { yyerror(@
1, "error: invalid port bit select");
2376 Module
::port_t
*ptmp
= new Module
::port_t
;
2377 PEIdent
*wtmp
= new PEIdent
(lex_strings.make
($1));
2378 wtmp
->set_file
(@
1.text
);
2379 wtmp
->set_lineno
(@
1.first_line
);
2380 ptmp
->name
= lex_strings.make
($1);
2381 ptmp
->expr
= svector
<PEIdent
*>(1);
2382 ptmp
->expr
[0] = wtmp
;
2392 | port_reference_list
',' port_reference
2393 { Module
::port_t
*tmp
= $1;
2394 tmp
->expr
= svector
<PEIdent
*>(tmp
->expr
, $3->expr
);
2400 /* The port_name rule is used with a module is being *instantiated*,
2401 and not when it is being declared. See the port rule if you are
2402 looking for the ports of a module declaration. */
2405 : '.' IDENTIFIER
'(' expression
')'
2406 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2407 tmp
->name
= lex_strings.make
($2);
2412 |
'.' IDENTIFIER
'(' error ')'
2413 { yyerror(@
4, "error: invalid port connection expression.");
2414 named_pexpr_t
*tmp
= new named_pexpr_t
;
2415 tmp
->name
= lex_strings.make
($2);
2420 |
'.' IDENTIFIER
'(' ')'
2421 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2422 tmp
->name
= lex_strings.make
($2);
2430 : port_name_list
',' port_name
2431 { svector
<named_pexpr_t
*>*tmp
;
2432 tmp
= new svector
<named_pexpr_t
*>(*$1, $3);
2437 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2444 : K_input
{ $$
= NetNet
::PINPUT
; }
2445 | K_output
{ $$
= NetNet
::POUTPUT
; }
2446 | K_inout
{ $$
= NetNet
::PINOUT
; }
2450 : '[' expression
':' expression
']'
2451 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*> (2);
2452 if
(!pform_expression_is_constant
($2))
2453 yyerror(@
2, "error: msb of range must be constant.");
2457 if
(!pform_expression_is_constant
($4))
2458 yyerror(@
4, "error: lsb of range must be constant.");
2471 /* This is used to express the return type of a function. */
2472 function_range_or_type_opt
2473 : range
{ $$.range
= $1; $$.type
= PTF_REG
; }
2474 | K_signed range
{ $$.range
= $2; $$.type
= PTF_REG_S
; }
2475 | K_integer
{ $$.range
= 0; $$.type
= PTF_INTEGER
; }
2476 | K_real
{ $$.range
= 0; $$.type
= PTF_REAL
; }
2477 | K_realtime
{ $$.range
= 0; $$.type
= PTF_REALTIME
; }
2478 | K_time
{ $$.range
= 0; $$.type
= PTF_TIME
; }
2479 |
{ $$.range
= 0; $$.type
= PTF_REG
; }
2482 /* The register_variable rule is matched only when I am parsing
2483 variables in a "reg" definition. I therefore know that I am
2484 creating registers and I do not need to let the containing rule
2485 handle it. The register variable list simply packs them together
2486 so that bit ranges can be assigned. */
2489 { pform_makewire
(@
1, $1, NetNet
::REG
,
2494 | IDENTIFIER
'=' expression
2495 { pform_makewire
(@
1, $1, NetNet
::REG
,
2498 if
(! pform_expression_is_constant
($3))
2499 yyerror(@
3, "error: register declaration assignment"
2500 " value must be a constant expression.");
2501 pform_make_reginit
(@
1, $1, $3);
2504 | IDENTIFIER
'[' expression
':' expression
']'
2505 { pform_makewire
(@
1, $1, NetNet
::REG
,
2508 if
(! pform_expression_is_constant
($3))
2509 yyerror(@
3, "error: msb of register range must be constant.");
2510 if
(! pform_expression_is_constant
($5))
2511 yyerror(@
3, "error: lsb of register range must be constant.");
2512 pform_set_reg_idx
($1, $3, $5);
2517 register_variable_list
2519 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2520 tmp
->push_back
(lex_strings.make
($1));
2524 | register_variable_list
',' register_variable
2525 { list
<perm_string
>*tmp
= $1;
2526 tmp
->push_back
(lex_strings.make
($3));
2534 { pform_makewire
(@
1, $1, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2537 | IDENTIFIER
'=' expression
2538 { pform_makewire
(@
1, $1, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2539 pform_make_reginit
(@
1, $1, $3);
2546 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2547 tmp
->push_back
(lex_strings.make
($1));
2551 | real_variable_list
',' real_variable
2552 { list
<perm_string
>*tmp
= $1;
2553 tmp
->push_back
(lex_strings.make
($3));
2561 { pform_makewire
(@
1, $1, NetNet
::IMPLICIT
,
2566 | IDENTIFIER
'[' expression
':' expression
']'
2567 { pform_makewire
(@
1, $1, NetNet
::IMPLICIT
,
2570 if
(! pform_expression_is_constant
($3))
2571 yyerror(@
3, "error: msb of net range must be constant.");
2572 if
(! pform_expression_is_constant
($5))
2573 yyerror(@
3, "error: lsb of net range must be constant.");
2574 pform_set_reg_idx
($1, $3, $5);
2580 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2581 tmp
->push_back
(lex_strings.make
($1));
2585 | net_variable_list
',' net_variable
2586 { list
<perm_string
>*tmp
= $1;
2587 tmp
->push_back
(lex_strings.make
($3));
2594 : K_specparam specparam_list
';'
2595 | specify_simple_path_decl
';'
2596 { pform_module_specify_path
($1);
2598 | specify_edge_path_decl
';'
2599 { pform_module_specify_path
($1);
2601 | K_if
'(' expression
')' specify_simple_path_decl
';'
2602 { PSpecPath
*tmp
= $5;
2604 tmp
->conditional
= true
;
2605 tmp
->condition
= $3;
2607 pform_module_specify_path
(tmp
);
2609 | K_if
'(' expression
')' specify_edge_path_decl
';'
2610 { PSpecPath
*tmp
= $5;
2612 tmp
->conditional
= true
;
2613 tmp
->condition
= $3;
2615 pform_module_specify_path
(tmp
);
2617 | K_ifnone specify_simple_path_decl
';'
2618 { PSpecPath
*tmp
= $2;
2620 tmp
->conditional
= true
;
2623 pform_module_specify_path
(tmp
);
2625 | K_Shold
'(' spec_reference_event
',' spec_reference_event
2626 ',' delay_value spec_notifier_opt
')' ';'
2629 | K_Speriod
'(' spec_reference_event
',' delay_value
2630 spec_notifier_opt
')' ';'
2633 | K_Srecovery
'(' spec_reference_event
',' spec_reference_event
2634 ',' delay_value spec_notifier_opt
')' ';'
2637 | K_Ssetup
'(' spec_reference_event
',' spec_reference_event
2638 ',' delay_value spec_notifier_opt
')' ';'
2641 | K_Ssetuphold
'(' spec_reference_event
',' spec_reference_event
2642 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2646 | K_Srecrem
'(' spec_reference_event
',' spec_reference_event
2647 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2651 | K_Swidth
'(' spec_reference_event
',' delay_value
',' expression
2652 spec_notifier_opt
')' ';'
2656 | K_Swidth
'(' spec_reference_event
',' delay_value
')' ';'
2663 | specify_item_list specify_item
2666 specify_edge_path_decl
2667 : specify_edge_path
'=' '(' delay_value_list
')'
2668 { $$
= pform_assign_path_delay
($1, $4); }
2669 | specify_edge_path
'=' delay_value_simple
2670 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2672 $$
= pform_assign_path_delay
($1, tmp
);
2676 edge_operator
: K_posedge
{ $$
= true
; } | K_negedge
{ $$
= false
; } ;
2679 : '(' specify_path_identifiers spec_polarity
2680 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2681 { int edge_flag
= 0;
2682 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, false
, $6, $8); }
2683 |
'(' edge_operator specify_path_identifiers spec_polarity
2684 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2685 { int edge_flag
= $2?
1 : -1;
2686 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, false
, $7, $9);}
2687 |
'(' specify_path_identifiers spec_polarity
2688 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2689 { int edge_flag
= 0;
2690 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, true
, $6, $8); }
2691 |
'(' edge_operator specify_path_identifiers spec_polarity
2692 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2693 { int edge_flag
= $2?
1 : -1;
2694 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, true
, $7, $9); }
2703 specify_simple_path_decl
2704 : specify_simple_path
'=' '(' delay_value_list
')'
2705 { $$
= pform_assign_path_delay
($1, $4); }
2706 | specify_simple_path
'=' delay_value_simple
2707 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2709 $$
= pform_assign_path_delay
($1, tmp
);
2711 | specify_simple_path
'=' '(' error ')'
2712 { yyerror(@
2, "Syntax error in delay value list.");
2719 : '(' specify_path_identifiers spec_polarity
2720 K_EG specify_path_identifiers
')'
2721 { $$
= pform_make_specify_path
(@
1, $2, $3, false
, $5); }
2722 |
'(' specify_path_identifiers spec_polarity
2723 K_SG specify_path_identifiers
')'
2724 { $$
= pform_make_specify_path
(@
1, $2, $3, true
, $5); }
2726 { yyerror(@
2, "Invalid simple path");
2731 specify_path_identifiers
2733 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2734 tmp
->push_back
(lex_strings.make
($1));
2738 | IDENTIFIER
'[' expr_primary
']'
2739 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2740 tmp
->push_back
(lex_strings.make
($1));
2744 | specify_path_identifiers
',' IDENTIFIER
2745 { list
<perm_string
>*tmp
= $1;
2746 tmp
->push_back
(lex_strings.make
($3));
2750 | specify_path_identifiers
',' IDENTIFIER
'[' expr_primary
']'
2751 { list
<perm_string
>*tmp
= $1;
2752 tmp
->push_back
(lex_strings.make
($3));
2759 : IDENTIFIER
'=' expression
2761 pform_set_specparam
(lex_strings.make
($1), tmp
);
2764 | IDENTIFIER
'=' expression
':' expression
':' expression
2766 switch
(min_typ_max_flag
) {
2783 pform_set_specparam
(lex_strings.make
($1), tmp
);
2786 | PATHPULSE_IDENTIFIER
'=' expression
2790 | PATHPULSE_IDENTIFIER
'=' '(' expression
',' expression
')'
2799 | specparam_list
',' specparam
2808 spec_reference_event
2809 : K_posedge expression
2811 | K_negedge expression
2813 | K_posedge expr_primary K_TAND expression
2817 | K_negedge expr_primary K_TAND expression
2821 | K_edge
'[' edge_descriptor_list
']' expr_primary K_TAND expression
2825 | expr_primary K_TAND expression
2833 /* The edge_descriptor is detected by the lexor as the various
2834 2-letter edge sequences that are supported here. For now, we
2835 don't care what they are, because we do not yet support specify
2837 edge_descriptor_list
2838 : edge_descriptor_list
',' K_edge_descriptor
2851 |
',' heirarchy_identifier
2855 | spec_notifier
',' heirarchy_identifier
2864 /* assign and deassign statements are procedural code to do
2865 structural assignments, and to turn that structural assignment
2866 off. This stronger then any other assign, but weaker then the
2867 force assignments. */
2869 : K_assign lpvalue
'=' expression
';'
2870 { PCAssign
*tmp
= new PCAssign
($2, $4);
2871 tmp
->set_file
(@
1.text
);
2872 tmp
->set_lineno
(@
1.first_line
);
2876 | K_deassign lpvalue
';'
2877 { PDeassign
*tmp
= new PDeassign
($2);
2878 tmp
->set_file
(@
1.text
);
2879 tmp
->set_lineno
(@
1.first_line
);
2884 /* Force and release statements are similar to assignments,
2885 syntactically, but they will be elaborated differently. */
2887 | K_force lpvalue
'=' expression
';'
2888 { PForce
*tmp
= new PForce
($2, $4);
2889 tmp
->set_file
(@
1.text
);
2890 tmp
->set_lineno
(@
1.first_line
);
2893 | K_release lpvalue
';'
2894 { PRelease
*tmp
= new PRelease
($2);
2895 tmp
->set_file
(@
1.text
);
2896 tmp
->set_lineno
(@
1.first_line
);
2900 /* begin-end blocks come in a variety of forms, including named and
2901 anonymous. The named blocks can also carry their own reg
2902 variables, which are placed in the scope created by the block
2903 name. These are handled by pushing the scope name then matching
2904 the declarations. The scope is popped at the end of the block. */
2906 | K_begin statement_list K_end
2907 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
, *$2);
2908 tmp
->set_file
(@
1.text
);
2909 tmp
->set_lineno
(@
1.first_line
);
2913 | K_begin
':' IDENTIFIER
2914 { pform_push_scope
($3); }
2915 block_item_decls_opt
2916 statement_list K_end
2917 { pform_pop_scope
();
2918 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
2919 PBlock
::BL_SEQ
, *$6);
2920 tmp
->set_file
(@
1.text
);
2921 tmp
->set_lineno
(@
1.first_line
);
2927 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2928 tmp
->set_file
(@
1.text
);
2929 tmp
->set_lineno
(@
1.first_line
);
2932 | K_begin
':' IDENTIFIER K_end
2933 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2934 tmp
->set_file
(@
1.text
);
2935 tmp
->set_lineno
(@
1.first_line
);
2938 | K_begin
error K_end
2941 /* fork-join blocks are very similar to begin-end blocks. In fact,
2942 from the parser's perspective there is no real difference. All we
2943 need to do is remember that this is a parallel block so that the
2944 code generator can do the right thing. */
2946 | K_fork
':' IDENTIFIER
2947 { pform_push_scope
($3); }
2948 block_item_decls_opt
2949 statement_list K_join
2950 { pform_pop_scope
();
2951 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
2952 PBlock
::BL_PAR
, *$6);
2953 tmp
->set_file
(@
1.text
);
2954 tmp
->set_lineno
(@
1.first_line
);
2960 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
2961 tmp
->set_file
(@
1.text
);
2962 tmp
->set_lineno
(@
1.first_line
);
2965 | K_fork
':' IDENTIFIER K_join
2966 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
2967 tmp
->set_file
(@
1.text
);
2968 tmp
->set_lineno
(@
1.first_line
);
2973 | K_disable heirarchy_identifier
';'
2974 { PDisable
*tmp
= new PDisable
(*$2);
2975 tmp
->set_file
(@
1.text
);
2976 tmp
->set_lineno
(@
1.first_line
);
2980 | K_TRIGGER heirarchy_identifier
';'
2981 { PTrigger
*tmp
= new PTrigger
(*$2);
2982 tmp
->set_file
(@
2.text
);
2983 tmp
->set_lineno
(@
2.first_line
);
2987 | K_forever statement
2988 { PForever
*tmp
= new PForever
($2);
2989 tmp
->set_file
(@
1.text
);
2990 tmp
->set_lineno
(@
1.first_line
);
2993 | K_fork statement_list K_join
2994 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
, *$2);
2995 tmp
->set_file
(@
1.text
);
2996 tmp
->set_lineno
(@
1.first_line
);
3000 | K_repeat
'(' expression
')' statement
3001 { PRepeat
*tmp
= new PRepeat
($3, $5);
3002 tmp
->set_file
(@
1.text
);
3003 tmp
->set_lineno
(@
1.first_line
);
3006 | K_case
'(' expression
')' case_items K_endcase
3007 { PCase
*tmp
= new PCase
(NetCase
::EQ
, $3, $5);
3008 tmp
->set_file
(@
1.text
);
3009 tmp
->set_lineno
(@
1.first_line
);
3012 | K_casex
'(' expression
')' case_items K_endcase
3013 { PCase
*tmp
= new PCase
(NetCase
::EQX
, $3, $5);
3014 tmp
->set_file
(@
1.text
);
3015 tmp
->set_lineno
(@
1.first_line
);
3018 | K_casez
'(' expression
')' case_items K_endcase
3019 { PCase
*tmp
= new PCase
(NetCase
::EQZ
, $3, $5);
3020 tmp
->set_file
(@
1.text
);
3021 tmp
->set_lineno
(@
1.first_line
);
3024 | K_case
'(' expression
')' error K_endcase
3026 | K_casex
'(' expression
')' error K_endcase
3028 | K_casez
'(' expression
')' error K_endcase
3030 | K_if
'(' expression
')' statement_or_null %prec less_than_K_else
3031 { PCondit
*tmp
= new PCondit
($3, $5, 0);
3032 tmp
->set_file
(@
1.text
);
3033 tmp
->set_lineno
(@
1.first_line
);
3036 | K_if
'(' expression
')' statement_or_null K_else statement_or_null
3037 { PCondit
*tmp
= new PCondit
($3, $5, $7);
3038 tmp
->set_file
(@
1.text
);
3039 tmp
->set_lineno
(@
1.first_line
);
3042 | K_if
'(' error ')' statement_or_null %prec less_than_K_else
3043 { yyerror(@
1, "error: Malformed conditional expression.");
3046 | K_if
'(' error ')' statement_or_null K_else statement_or_null
3047 { yyerror(@
1, "error: Malformed conditional expression.");
3050 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3051 lpvalue
'=' expression
')' statement
3052 { PForStatement
*tmp
= new PForStatement
($3, $5, $7, $9, $11, $13);
3053 tmp
->set_file
(@
1.text
);
3054 tmp
->set_lineno
(@
1.first_line
);
3057 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3060 yyerror(@
9, "error: Error in for loop step assignment.");
3062 | K_for
'(' lpvalue
'=' expression
';' error ';'
3063 lpvalue
'=' expression
')' statement
3065 yyerror(@
7, "error: Error in for loop condition expression.");
3067 | K_for
'(' error ')' statement
3069 yyerror(@
3, "error: Incomprehensible for loop.");
3071 | K_while
'(' expression
')' statement
3072 { PWhile
*tmp
= new PWhile
($3, $5);
3075 | K_while
'(' error ')' statement
3077 yyerror(@
3, "error: Error in while loop condition.");
3079 | delay1 statement_or_null
3080 { PExpr
*del
= (*$1)[0];
3081 assert
($1->count
() == 1);
3082 PDelayStatement
*tmp
= new PDelayStatement
(del
, $2);
3083 tmp
->set_file
(@
1.text
);
3084 tmp
->set_lineno
(@
1.first_line
);
3087 | event_control statement_or_null
3088 { PEventStatement
*tmp
= $1;
3090 yyerror(@
1, "error: Invalid event control.");
3093 tmp
->set_statement
($2);
3097 |
'@' '*' statement_or_null
3098 { PEventStatement
*tmp
= new PEventStatement
;
3099 tmp
->set_file
(@
1.text
);
3100 tmp
->set_lineno
(@
1.first_line
);
3101 tmp
->set_statement
($3);
3104 |
'@' '(' '*' ')' statement_or_null
3105 { PEventStatement
*tmp
= new PEventStatement
;
3106 tmp
->set_file
(@
1.text
);
3107 tmp
->set_lineno
(@
1.first_line
);
3108 tmp
->set_statement
($5);
3111 | lpvalue
'=' expression
';'
3112 { PAssign
*tmp
= new PAssign
($1,$3);
3113 tmp
->set_file
(@
1.text
);
3114 tmp
->set_lineno
(@
1.first_line
);
3117 |
error '=' expression
';'
3118 { yyerror(@
1, "Syntax in assignment statement l-value.");
3122 | lpvalue K_LE expression
';'
3123 { PAssignNB
*tmp
= new PAssignNB
($1,$3);
3124 tmp
->set_file
(@
1.text
);
3125 tmp
->set_lineno
(@
1.first_line
);
3128 |
error K_LE expression
';'
3129 { yyerror(@
1, "Syntax in assignment statement l-value.");
3133 | lpvalue
'=' delay1 expression
';'
3134 { assert
($3->count
() == 1);
3135 PExpr
*del
= (*$3)[0];
3136 PAssign
*tmp
= new PAssign
($1,del
,$4);
3137 tmp
->set_file
(@
1.text
);
3138 tmp
->set_lineno
(@
1.first_line
);
3141 | lpvalue K_LE delay1 expression
';'
3142 { assert
($3->count
() == 1);
3143 PExpr
*del
= (*$3)[0];
3144 PAssignNB
*tmp
= new PAssignNB
($1,del
,$4);
3145 tmp
->set_file
(@
1.text
);
3146 tmp
->set_lineno
(@
1.first_line
);
3149 | lpvalue
'=' event_control expression
';'
3150 { PAssign
*tmp
= new PAssign
($1,$3,$4);
3151 tmp
->set_file
(@
1.text
);
3152 tmp
->set_lineno
(@
1.first_line
);
3155 | lpvalue
'=' K_repeat
'(' expression
')' event_control expression
';'
3156 { PAssign
*tmp
= new PAssign
($1,$7,$8);
3157 tmp
->set_file
(@
1.text
);
3158 tmp
->set_lineno
(@
1.first_line
);
3159 yyerror(@
3, "sorry: repeat event control not supported.");
3163 | lpvalue K_LE event_control expression
';'
3164 { yyerror(@
1, "sorry: Event controls not supported here.");
3165 PAssignNB
*tmp
= new PAssignNB
($1,$4);
3166 tmp
->set_file
(@
1.text
);
3167 tmp
->set_lineno
(@
1.first_line
);
3170 | lpvalue K_LE K_repeat
'(' expression
')' event_control expression
';'
3171 { yyerror(@
1, "sorry: Event controls not supported here.");
3173 PAssignNB
*tmp
= new PAssignNB
($1,$8);
3174 tmp
->set_file
(@
1.text
);
3175 tmp
->set_lineno
(@
1.first_line
);
3178 | K_wait
'(' expression
')' statement_or_null
3179 { PEventStatement
*tmp
;
3180 PEEvent
*etmp
= new PEEvent
(PEEvent
::POSITIVE
, $3);
3181 tmp
= new PEventStatement
(etmp
);
3182 tmp
->set_file
(@
1.text
);
3183 tmp
->set_lineno
(@
1.first_line
);
3184 tmp
->set_statement
($5);
3187 | SYSTEM_IDENTIFIER
'(' expression_list_with_nuls
')' ';'
3188 { PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), *$3);
3189 tmp
->set_file
(@
1.text
);
3190 tmp
->set_lineno
(@
1.first_line
);
3195 | SYSTEM_IDENTIFIER
';'
3196 { svector
<PExpr
*>pt
(0);
3197 PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), pt
);
3198 tmp
->set_file
(@
1.text
);
3199 tmp
->set_lineno
(@
1.first_line
);
3203 | heirarchy_identifier
'(' expression_list_proper
')' ';'
3204 { PCallTask
*tmp
= new PCallTask
(*$1, *$3);
3205 tmp
->set_file
(@
1.text
);
3206 tmp
->set_lineno
(@
1.first_line
);
3212 /* NOTE: The standard doesn't really support an empty argument list
3213 between parentheses, but it seems natural, and people commonly
3214 want it. So accept it explicitly. */
3216 | heirarchy_identifier
'(' ')' ';'
3217 { svector
<PExpr
*>pt
(0);
3218 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3219 tmp
->set_file
(@
1.text
);
3220 tmp
->set_lineno
(@
1.first_line
);
3224 | heirarchy_identifier
';'
3225 { svector
<PExpr
*>pt
(0);
3226 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3227 tmp
->set_file
(@
1.text
);
3228 tmp
->set_lineno
(@
1.first_line
);
3233 { yyerror(@
1, "error: malformed statement");
3240 : statement_list statement
3241 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(*$1, $2);
3246 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(1);
3257 /* Task items are, other than the statement, task port items and
3258 other block items. */
3260 : block_item_decl
{ $$
= new svector
<PWire
*>(0); }
3261 | task_port_item
{ $$
= $1; }
3266 : K_input signed_opt range_opt list_of_identifiers
';'
3267 { svector
<PWire
*>*tmp
3268 = pform_make_task_ports
(NetNet
::PINPUT
,
3271 @
1.text
, @
1.first_line
);
3274 | K_output signed_opt range_opt list_of_identifiers
';'
3275 { svector
<PWire
*>*tmp
3276 = pform_make_task_ports
(NetNet
::POUTPUT
,
3279 @
1.text
, @
1.first_line
);
3282 | K_inout signed_opt range_opt list_of_identifiers
';'
3283 { svector
<PWire
*>*tmp
3284 = pform_make_task_ports
(NetNet
::PINOUT
,
3287 @
1.text
, @
1.first_line
);
3291 /* When the port is an integer, infer a signed vector of the integer
3292 shape. Generate a range to make it work. */
3294 | K_input K_integer list_of_identifiers
';'
3295 { svector
<PExpr
*>*range_stub
3296 = new svector
<PExpr
*>(2);
3298 re
= new PENumber
(new verinum
(integer_width
-1,
3300 (*range_stub
)[0] = re
;
3301 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3302 (*range_stub
)[1] = re
;
3304 = pform_make_task_ports
(NetNet
::PINPUT
,
3307 @
1.text
, @
1.first_line
);
3310 | K_output K_integer list_of_identifiers
';'
3311 { svector
<PExpr
*>*range_stub
3312 = new svector
<PExpr
*>(2);
3314 re
= new PENumber
(new verinum
(integer_width
-1,
3316 (*range_stub
)[0] = re
;
3317 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3318 (*range_stub
)[1] = re
;
3320 = pform_make_task_ports
(NetNet
::POUTPUT
,
3323 @
1.text
, @
1.first_line
);
3326 | K_inout K_integer list_of_identifiers
';'
3327 { svector
<PExpr
*>*range_stub
3328 = new svector
<PExpr
*>(2);
3330 re
= new PENumber
(new verinum
(integer_width
-1,
3332 (*range_stub
)[0] = re
;
3333 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3334 (*range_stub
)[1] = re
;
3336 = pform_make_task_ports
(NetNet
::PINOUT
,
3339 @
1.text
, @
1.first_line
);
3343 /* Ports can be real. */
3345 | K_input K_real list_of_identifiers
';'
3346 { svector
<PWire
*>*tmp
3347 = pform_make_task_ports
(NetNet
::PINPUT
,
3350 @
1.text
, @
1.first_line
);
3353 | K_output K_real list_of_identifiers
';'
3354 { svector
<PWire
*>*tmp
3355 = pform_make_task_ports
(NetNet
::POUTPUT
,
3358 @
1.text
, @
1.first_line
);
3361 | K_inout K_real list_of_identifiers
';'
3362 { svector
<PWire
*>*tmp
3363 = pform_make_task_ports
(NetNet
::PINOUT
,
3366 @
1.text
, @
1.first_line
);
3372 : task_item_list task_item
3373 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3391 : K_input signed_opt range_opt IDENTIFIER
3392 { svector
<PWire
*>*tmp
3393 = pform_make_task_ports
(NetNet
::PINPUT
,
3395 $3, list_from_identifier
($4),
3396 @
1.text
, @
1.first_line
);
3400 | K_output signed_opt range_opt IDENTIFIER
3401 { svector
<PWire
*>*tmp
3402 = pform_make_task_ports
(NetNet
::POUTPUT
,
3404 $3, list_from_identifier
($4),
3405 @
1.text
, @
1.first_line
);
3408 | K_inout signed_opt range_opt IDENTIFIER
3409 { svector
<PWire
*>*tmp
3410 = pform_make_task_ports
(NetNet
::PINOUT
,
3412 $3, list_from_identifier
($4),
3413 @
1.text
, @
1.first_line
);
3417 | K_input K_integer IDENTIFIER
3418 { svector
<PExpr
*>*range_stub
3419 = new svector
<PExpr
*>(2);
3421 re
= new PENumber
(new verinum
(integer_width
-1,
3423 (*range_stub
)[0] = re
;
3424 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3425 (*range_stub
)[1] = re
;
3427 = pform_make_task_ports
(NetNet
::PINPUT
,
3430 list_from_identifier
($3),
3431 @
1.text
, @
1.first_line
);
3434 | K_output K_integer IDENTIFIER
3435 { svector
<PExpr
*>*range_stub
3436 = new svector
<PExpr
*>(2);
3438 re
= new PENumber
(new verinum
(integer_width
-1,
3440 (*range_stub
)[0] = re
;
3441 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3442 (*range_stub
)[1] = re
;
3444 = pform_make_task_ports
(NetNet
::POUTPUT
,
3447 list_from_identifier
($3),
3448 @
1.text
, @
1.first_line
);
3451 | K_inout K_integer IDENTIFIER
3452 { svector
<PExpr
*>*range_stub
3453 = new svector
<PExpr
*>(2);
3455 re
= new PENumber
(new verinum
(integer_width
-1,
3457 (*range_stub
)[0] = re
;
3458 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3459 (*range_stub
)[1] = re
;
3461 = pform_make_task_ports
(NetNet
::PINOUT
,
3464 list_from_identifier
($3),
3465 @
1.text
, @
1.first_line
);
3469 /* Ports can be real. */
3471 | K_input K_real IDENTIFIER
3472 { svector
<PWire
*>*tmp
3473 = pform_make_task_ports
(NetNet
::PINPUT
,
3475 0, list_from_identifier
($3),
3476 @
1.text
, @
1.first_line
);
3479 | K_output K_real IDENTIFIER
3480 { svector
<PWire
*>*tmp
3481 = pform_make_task_ports
(NetNet
::POUTPUT
,
3483 0, list_from_identifier
($3),
3484 @
1.text
, @
1.first_line
);
3487 | K_inout K_real IDENTIFIER
3488 { svector
<PWire
*>*tmp
3489 = pform_make_task_ports
(NetNet
::PINOUT
,
3491 0, list_from_identifier
($3),
3492 @
1.text
, @
1.first_line
);
3498 : task_port_decl_list
',' task_port_decl
3499 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$3);
3509 : K_table
{ lex_start_table
(); }
3511 K_endtable
{ lex_end_table
(); $$
= $3; }
3515 : udp_comb_entry_list
3516 | udp_sequ_entry_list
3520 : udp_input_list
':' udp_output_sym
';'
3521 { char*tmp
= new
char[strlen
($1)+3];
3523 char*tp
= tmp
+strlen
(tmp
);
3534 { list
<string>*tmp
= new list
<string>;
3539 | udp_comb_entry_list udp_comb_entry
3540 { list
<string>*tmp
= $1;
3549 { list
<string>*tmp
= new list
<string>;
3554 | udp_sequ_entry_list udp_sequ_entry
3555 { list
<string>*tmp
= $1;
3563 : udp_input_list
':' udp_input_sym
':' udp_output_sym
';'
3564 { char*tmp
= new
char[strlen
($1)+5];
3566 char*tp
= tmp
+strlen
(tmp
);
3577 : K_initial IDENTIFIER
'=' number
';'
3578 { PExpr
*etmp
= new PENumber
($4);
3579 PEIdent
*itmp
= new PEIdent
(lex_strings.make
($2));
3580 PAssign
*atmp
= new PAssign
(itmp
, etmp
);
3581 atmp
->set_file
(@
2.text
);
3582 atmp
->set_lineno
(@
2.first_line
);
3589 : udp_initial
{ $$
= $1; }
3595 { char*tmp
= new
char[2];
3600 | udp_input_list udp_input_sym
3601 { char*tmp
= new
char[strlen
($1)+2];
3603 char*tp
= tmp
+strlen
(tmp
);
3644 /* Port declarations create wires for the inputs and the output. The
3645 makes for these ports are scoped within the UDP, so there is no
3646 heirarchy involved. */
3648 : K_input list_of_identifiers
';'
3649 { $$
= pform_make_udp_input_ports
($2); }
3650 | K_output IDENTIFIER
';'
3651 { pform_name_t pname
;
3652 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3653 PWire
*pp
= new PWire
(pname
, NetNet
::IMPLICIT
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3654 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3659 | K_reg IDENTIFIER
';'
3660 { pform_name_t pname
;
3661 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3662 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::PIMPLICIT
, IVL_VT_LOGIC
);
3663 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3668 | K_reg K_output IDENTIFIER
';'
3669 { pform_name_t pname
;
3670 pname.push_back
(name_component_t
(lex_strings.make
($3)));
3671 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3672 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3682 | udp_port_decls udp_port_decl
3683 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3692 { list
<string>*tmp
= new list
<string>;
3697 | udp_port_list
',' IDENTIFIER
3698 { list
<string>*tmp
= $1;
3705 udp_reg_opt: K_reg
{ $$
= true
; } |
{ $$
= false
; };
3707 udp_initial_expr_opt
3708 : '=' expression
{ $$
= $2; }
3712 udp_input_declaration_list
3713 : K_input IDENTIFIER
3714 { list
<perm_string
>*tmp
= new list
<perm_string
>;
3715 tmp
->push_back
(lex_strings.make
($2));
3719 | udp_input_declaration_list
',' K_input IDENTIFIER
3720 { list
<perm_string
>*tmp
= $1;
3721 tmp
->push_back
(lex_strings.make
($4));
3728 /* This is the syntax for primitives that uses the IEEE1364-1995
3729 format. The ports are simply names in the port list, and the
3730 declarations are in the body. */
3732 : K_primitive IDENTIFIER
'(' udp_port_list
')' ';'
3738 { perm_string tmp2
= lex_strings.make
($2);
3739 pform_make_udp
(tmp2
, $4, $7, $9, $8,
3740 @
2.text
, @
2.first_line
);
3744 /* This is the syntax for IEEE1364-2001 format definitions. The port
3745 names and declarations are all in the parameter list. */
3747 | K_primitive IDENTIFIER
3748 '(' K_output udp_reg_opt IDENTIFIER udp_initial_expr_opt
','
3749 udp_input_declaration_list
')' ';'
3753 { perm_string tmp2
= lex_strings.make
($2);
3754 perm_string tmp6
= lex_strings.make
($6);
3755 pform_make_udp
(tmp2
, $5, tmp6
, $7, $9, $12,
3756 @
2.text
, @
2.first_line
);