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 expr_mintypmax
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
);
959 | expression
':' expression
':' expression
960 { switch
(min_typ_max_flag
) {
981 /* Many contexts take a comma separated list of expressions. Null
982 expressions can happen anywhere in the list, so there are two
983 extra rules in expression_list_with_nuls for parsing and
984 installing those nulls.
986 The expression_list_proper rules do not allow null items in the
987 expression list, so can be used where nul expressions are not allowed. */
989 expression_list_with_nuls
990 : expression_list_with_nuls
',' expression
991 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
996 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1001 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1006 | expression_list_with_nuls
','
1007 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, 0);
1013 expression_list_proper
1014 : expression_list_proper
',' expression
1015 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
1020 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1029 PENumber
*tmp
= new PENumber
($1);
1030 tmp
->set_file
(@
1.text
);
1031 tmp
->set_lineno
(@
1.first_line
);
1035 { PEFNumber
*tmp
= new PEFNumber
($1);
1036 tmp
->set_file
(@
1.text
);
1037 tmp
->set_lineno
(@
1.first_line
);
1041 { PEString
*tmp
= new PEString
($1);
1042 tmp
->set_file
(@
1.text
);
1043 tmp
->set_lineno
(@
1.first_line
);
1047 { perm_string tn
= lex_strings.make
($1);
1048 PECallFunction
*tmp
= new PECallFunction
(tn
);
1049 tmp
->set_file
(@
1.text
);
1050 tmp
->set_lineno
(@
1.first_line
);
1055 /* The heirarchy_identifier rule matches simple identifiers as well as
1056 indexed arrays and part selects */
1058 | heirarchy_identifier
1059 { PEIdent
*tmp
= new PEIdent
(*$1);
1060 tmp
->set_file
(@
1.text
);
1061 tmp
->set_lineno
(@
1.first_line
);
1066 /* An identifer followed by an expression list in parentheses is a
1067 function call. If a system identifier, then a system function
1070 | heirarchy_identifier
'(' expression_list_proper
')'
1071 { PECallFunction
*tmp
= new PECallFunction
(*$1, *$3);
1072 tmp
->set_file
(@
1.text
);
1073 tmp
->set_lineno
(@
1.first_line
);
1077 | SYSTEM_IDENTIFIER
'(' expression_list_proper
')'
1078 { perm_string tn
= lex_strings.make
($1);
1079 PECallFunction
*tmp
= new PECallFunction
(tn
, *$3);
1080 tmp
->set_file
(@
1.text
);
1081 tmp
->set_lineno
(@
1.first_line
);
1085 /* Parenthesized expressions are primaries. */
1087 |
'(' expr_mintypmax
')'
1090 /* Various kinds of concatenation expressions. */
1092 |
'{' expression_list_proper
'}'
1093 { PEConcat
*tmp
= new PEConcat
(*$2);
1094 tmp
->set_file
(@
1.text
);
1095 tmp
->set_lineno
(@
1.first_line
);
1099 |
'{' expression
'{' expression_list_proper
'}' '}'
1101 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1102 tmp
->set_file
(@
1.text
);
1103 tmp
->set_lineno
(@
1.first_line
);
1107 |
'{' expression
'{' expression_list_proper
'}' error '}'
1109 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1110 tmp
->set_file
(@
1.text
);
1111 tmp
->set_lineno
(@
1.first_line
);
1114 yyerror(@
5, "error: Syntax error between internal '}' "
1115 "and closing '}' of repeat concatenation.");
1120 /* A function_item is either a block item (i.e. a reg or integer
1121 declaration) or an input declaration. There are no output or
1124 : K_input signed_opt range_opt list_of_identifiers
';'
1125 { svector
<PWire
*>*tmp
1126 = pform_make_task_ports
(NetNet
::PINPUT
,
1129 @
1.text
, @
1.first_line
);
1132 | K_output signed_opt range_opt list_of_identifiers
';'
1133 { svector
<PWire
*>*tmp
1134 = pform_make_task_ports
(NetNet
::PINPUT
,
1137 @
1.text
, @
1.first_line
);
1139 yyerror(@
1, "Functions may not have output ports.");
1141 | K_inout signed_opt range_opt list_of_identifiers
';'
1142 { svector
<PWire
*>*tmp
1143 = pform_make_task_ports
(NetNet
::PINPUT
,
1146 @
1.text
, @
1.first_line
);
1148 yyerror(@
1, "Functions may not have inout ports.");
1151 /* When the port is an integer, infer a signed vector of the integer
1152 shape. Generate a range to make it work. */
1154 | K_input K_integer list_of_identifiers
';'
1155 { svector
<PExpr
*>*range_stub
1156 = new svector
<PExpr
*>(2);
1158 re
= new PENumber
(new verinum
(integer_width
-1,
1160 (*range_stub
)[0] = re
;
1161 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
1162 (*range_stub
)[1] = re
;
1164 = pform_make_task_ports
(NetNet
::PINPUT
,
1167 @
1.text
, @
1.first_line
);
1171 /* Ports can be real. */
1173 | K_input K_real list_of_identifiers
';'
1174 { svector
<PWire
*>*tmp
1175 = pform_make_task_ports
(NetNet
::PINPUT
,
1178 @
1.text
, @
1.first_line
);
1186 /* A function_item_list only lists the input/output/inout
1187 declarations. The integer and reg declarations are handled in
1188 place, so are not listed. The list builder needs to account for
1189 the possibility that the various parts may be NULL. */
1193 | function_item_list function_item
1195 svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
1207 /* A gate_instance is a module instantiation or a built in part
1208 type. In any case, the gate has a set of connections to ports. */
1210 : IDENTIFIER
'(' expression_list_with_nuls
')'
1211 { lgate
*tmp
= new lgate
;
1214 tmp
->file
= @
1.text
;
1215 tmp
->lineno
= @
1.first_line
;
1220 | IDENTIFIER range
'(' expression_list_with_nuls
')'
1221 { lgate
*tmp
= new lgate
;
1222 svector
<PExpr
*>*rng
= $2;
1225 tmp
->range
[0] = (*rng
)[0];
1226 tmp
->range
[1] = (*rng
)[1];
1227 tmp
->file
= @
1.text
;
1228 tmp
->lineno
= @
1.first_line
;
1233 |
'(' expression_list_with_nuls
')'
1234 { lgate
*tmp
= new lgate
;
1237 tmp
->file
= @
1.text
;
1238 tmp
->lineno
= @
1.first_line
;
1242 /* Degenerate modules can have no ports. */
1245 { lgate
*tmp
= new lgate
;
1246 svector
<PExpr
*>*rng
= $2;
1249 tmp
->parms_by_name
= 0;
1250 tmp
->range
[0] = (*rng
)[0];
1251 tmp
->range
[1] = (*rng
)[1];
1252 tmp
->file
= @
1.text
;
1253 tmp
->lineno
= @
1.first_line
;
1259 /* Modules can also take ports by port-name expressions. */
1261 | IDENTIFIER
'(' port_name_list
')'
1262 { lgate
*tmp
= new lgate
;
1265 tmp
->parms_by_name
= $3;
1266 tmp
->file
= @
1.text
;
1267 tmp
->lineno
= @
1.first_line
;
1272 | IDENTIFIER range
'(' port_name_list
')'
1273 { lgate
*tmp
= new lgate
;
1274 svector
<PExpr
*>*rng
= $2;
1277 tmp
->parms_by_name
= $4;
1278 tmp
->range
[0] = (*rng
)[0];
1279 tmp
->range
[1] = (*rng
)[1];
1280 tmp
->file
= @
1.text
;
1281 tmp
->lineno
= @
1.first_line
;
1289 : gate_instance_list
',' gate_instance
1290 { svector
<lgate
>*tmp1
= $1;
1292 svector
<lgate
>*out
= new svector
<lgate
> (*tmp1
, *tmp2
);
1298 { svector
<lgate
>*tmp
= new svector
<lgate
>(1);
1306 : K_and
{ $$
= PGBuiltin
::AND
; }
1307 | K_nand
{ $$
= PGBuiltin
::NAND
; }
1308 | K_or
{ $$
= PGBuiltin
::OR
; }
1309 | K_nor
{ $$
= PGBuiltin
::NOR
; }
1310 | K_xor
{ $$
= PGBuiltin
::XOR
; }
1311 | K_xnor
{ $$
= PGBuiltin
::XNOR
; }
1312 | K_buf
{ $$
= PGBuiltin
::BUF
; }
1313 | K_bufif0
{ $$
= PGBuiltin
::BUFIF0
; }
1314 | K_bufif1
{ $$
= PGBuiltin
::BUFIF1
; }
1315 | K_not
{ $$
= PGBuiltin
::NOT
; }
1316 | K_notif0
{ $$
= PGBuiltin
::NOTIF0
; }
1317 | K_notif1
{ $$
= PGBuiltin
::NOTIF1
; }
1318 | K_nmos
{ $$
= PGBuiltin
::NMOS
; }
1319 | K_rnmos
{ $$
= PGBuiltin
::RNMOS
; }
1320 | K_pmos
{ $$
= PGBuiltin
::PMOS
; }
1321 | K_rpmos
{ $$
= PGBuiltin
::RPMOS
; }
1322 | K_cmos
{ $$
= PGBuiltin
::CMOS
; }
1323 | K_rcmos
{ $$
= PGBuiltin
::RCMOS
; }
1324 | K_tran
{ $$
= PGBuiltin
::TRAN
; }
1325 | K_rtran
{ $$
= PGBuiltin
::RTRAN
; }
1326 | K_tranif0
{ $$
= PGBuiltin
::TRANIF0
; }
1327 | K_tranif1
{ $$
= PGBuiltin
::TRANIF1
; }
1328 | K_rtranif0
{ $$
= PGBuiltin
::RTRANIF0
; }
1329 | K_rtranif1
{ $$
= PGBuiltin
::RTRANIF1
; }
1333 /* A general identifier is a hierarchical name, with the right most
1334 name the base of the identifier. This rule builds up a
1335 hierarchical name from the left to the right, forming a list of
1338 heirarchy_identifier
1340 { $$
= new pform_name_t
;
1341 $$
->push_back
(name_component_t
(lex_strings.make
($1)));
1344 | heirarchy_identifier
'.' IDENTIFIER
1345 { pform_name_t
* tmp
= $1;
1346 tmp
->push_back
(name_component_t
(lex_strings.make
($3)));
1350 | heirarchy_identifier
'[' expression
']'
1351 { pform_name_t
* tmp
= $1;
1352 name_component_t
&tail
= tmp
->back
();
1353 index_component_t itmp
;
1354 itmp.sel
= index_component_t
::SEL_BIT
;
1356 tail.index.push_back
(itmp
);
1359 | heirarchy_identifier
'[' expression
':' expression
']'
1360 { pform_name_t
* tmp
= $1;
1361 name_component_t
&tail
= tmp
->back
();
1362 index_component_t itmp
;
1363 itmp.sel
= index_component_t
::SEL_PART
;
1366 tail.index.push_back
(itmp
);
1369 | heirarchy_identifier
'[' expression K_PO_POS expression
']'
1370 { pform_name_t
* tmp
= $1;
1371 name_component_t
&tail
= tmp
->back
();
1372 index_component_t itmp
;
1373 itmp.sel
= index_component_t
::SEL_IDX_UP
;
1376 tail.index.push_back
(itmp
);
1379 | heirarchy_identifier
'[' expression K_PO_NEG expression
']'
1380 { pform_name_t
* tmp
= $1;
1381 name_component_t
&tail
= tmp
->back
();
1382 index_component_t itmp
;
1383 itmp.sel
= index_component_t
::SEL_IDX_DO
;
1386 tail.index.push_back
(itmp
);
1391 /* This is a list of identifiers. The result is a list of strings,
1392 each one of the identifiers in the list. These are simple,
1393 non-hierarchical names separated by ',' characters. */
1396 { $$
= list_from_identifier
($1); }
1397 | list_of_identifiers
',' IDENTIFIER
1398 { $$
= list_from_identifier
($1, $3); }
1402 /* The list_of_ports and list_of_port_declarations rules are the
1403 port list formats for module ports. The list_of_ports_opt rule is
1404 only used by the module start rule.
1406 The first, the list_of_ports, is the 1364-1995 format, a list of
1407 port names, including .name() syntax.
1409 The list_of_port_declarations the 1364-2001 format, an in-line
1410 declaration of the ports.
1412 In both cases, the list_of_ports and list_of_port_declarations
1413 returns an array of Module::port_t* items that include the name
1414 of the port internally and externally. The actual creation of the
1415 nets/variables is done in the declaration, whether internal to
1416 the port list or in amongst the module items. */
1420 { svector
<Module
::port_t
*>*tmp
1421 = new svector
<Module
::port_t
*>(1);
1425 | list_of_ports
',' port_opt
1426 { svector
<Module
::port_t
*>*tmp
1427 = new svector
<Module
::port_t
*>(*$1, $3);
1433 list_of_port_declarations
1435 { svector
<Module
::port_t
*>*tmp
1436 = new svector
<Module
::port_t
*>(1);
1439 * Uncommenting this makes lopd always fully specified.
1440 * Some wanted an implicit net to not be fully defined.
1442 * pform_set_net_range($1[0].name);
1446 | list_of_port_declarations
',' port_declaration
1447 { svector
<Module
::port_t
*>*tmp
1448 = new svector
<Module
::port_t
*>(*$1, $3);
1453 * pform_set_net_range($3[0].name);
1457 | list_of_port_declarations
',' IDENTIFIER
1458 { Module
::port_t
*ptmp
;
1459 ptmp
= pform_module_port_reference
($3, @
3.text
,
1461 svector
<Module
::port_t
*>*tmp
1462 = new svector
<Module
::port_t
*>(*$1, ptmp
);
1464 /* Get the port declaration details, the port type
1465 and what not, from context data stored by the
1466 last port_declaration rule. */
1467 pform_module_define_port
(@
3, $3,
1468 port_declaration_context.port_type
,
1469 port_declaration_context.port_net_type
,
1470 port_declaration_context.sign_flag
,
1471 port_declaration_context.range
, 0);
1476 * pform_set_net_range($3);
1483 : attribute_list_opt
1484 K_input net_type_opt signed_opt range_opt IDENTIFIER
1485 { Module
::port_t
*ptmp
;
1486 ptmp
= pform_module_port_reference
($6, @
2.text
,
1488 pform_module_define_port
(@
2, $6, NetNet
::PINPUT
,
1490 port_declaration_context.port_type
= NetNet
::PINPUT
;
1491 port_declaration_context.port_net_type
= $3;
1492 port_declaration_context.sign_flag
= $4;
1493 port_declaration_context.range
= $5;
1498 | attribute_list_opt
1499 K_inout net_type_opt signed_opt range_opt IDENTIFIER
1500 { Module
::port_t
*ptmp
;
1501 ptmp
= pform_module_port_reference
($6, @
2.text
,
1503 pform_module_define_port
(@
2, $6, NetNet
::PINOUT
,
1505 port_declaration_context.port_type
= NetNet
::PINOUT
;
1506 port_declaration_context.port_net_type
= $3;
1507 port_declaration_context.sign_flag
= $4;
1508 port_declaration_context.range
= $5;
1513 | attribute_list_opt
1514 K_output net_type_opt signed_opt range_opt IDENTIFIER
1515 { Module
::port_t
*ptmp
;
1516 ptmp
= pform_module_port_reference
($6, @
2.text
,
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;
1528 | attribute_list_opt
1529 K_output var_type signed_opt range_opt IDENTIFIER
1530 { Module
::port_t
*ptmp
;
1531 ptmp
= pform_module_port_reference
($6, @
2.text
,
1533 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1535 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1536 port_declaration_context.port_net_type
= $3;
1537 port_declaration_context.sign_flag
= $4;
1538 port_declaration_context.range
= $5;
1543 | attribute_list_opt
1544 K_output var_type signed_opt range_opt IDENTIFIER
'=' expression
1545 { Module
::port_t
*ptmp
;
1546 ptmp
= pform_module_port_reference
($6, @
2.text
,
1548 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1550 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1551 port_declaration_context.port_net_type
= $3;
1552 port_declaration_context.sign_flag
= $4;
1553 port_declaration_context.range
= $5;
1555 if
(! pform_expression_is_constant
($8))
1556 yyerror(@
8, "error: register declaration assignment"
1557 " value must be a constant expression.");
1558 pform_make_reginit
(@
6, $6, $8);
1569 : net_type
{ $$
= $1; }
1570 |
{ $$
= NetNet
::IMPLICIT
; }
1573 signed_opt
: K_signed
{ $$
= true
; } |
{$$
= false
; } ;
1575 /* An lpvalue is the expression that can go on the left side of a
1576 procedural assignment. This rule handles only procedural
1577 assignments. It is more limited then the general expr_primary
1578 rule to reflect the rules for assignment l-values. */
1580 : heirarchy_identifier
1581 { PEIdent
*tmp
= new PEIdent
(*$1);
1582 tmp
->set_file
(@
1.text
);
1583 tmp
->set_lineno
(@
1.first_line
);
1587 |
'{' expression_list_proper
'}'
1588 { PEConcat
*tmp
= new PEConcat
(*$2);
1589 tmp
->set_file
(@
1.text
);
1590 tmp
->set_lineno
(@
1.first_line
);
1597 /* Continuous assignments have a list of individual assignments. */
1600 : lpvalue
'=' expression
1601 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
1609 : cont_assign_list
',' cont_assign
1610 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, *$3);
1620 /* This is the global structure of a module. A module in a start
1621 section, with optional ports, then an optional list of module
1622 items, and finally an end marker. */
1624 module
: attribute_list_opt module_start IDENTIFIER
1625 { pform_startmodule
($3, @
2.text
, @
2.first_line
, $1); }
1626 module_parameter_port_list_opt
1627 module_port_list_opt
';'
1628 { pform_module_set_ports
($6); }
1629 module_item_list_opt
1631 { pform_endmodule
($3);
1637 module_start
: K_module | K_macromodule
;
1639 module_port_list_opt
1640 : '(' list_of_ports
')' { $$
= $2; }
1641 |
'(' list_of_port_declarations
')' { $$
= $2; }
1645 /* Module declarations include optional ANSII style module parameter
1646 ports. These are simply advance ways to declare parameters, so
1647 that the port declarations may use them. */
1648 module_parameter_port_list_opt
1650 |
'#' '(' module_parameter_port_list
')'
1653 module_parameter_port_list
1654 : K_parameter parameter_assign
1655 | module_parameter_port_list
',' parameter_assign
1656 | module_parameter_port_list
',' K_parameter parameter_assign
1661 /* This rule detects net declarations that possibly include a
1662 primitive type, an optional vector range and signed flag. This
1663 also includes an optional delay set. The values are then applied
1664 to a list of names. If the primitive type is not specified, then
1665 resort to the default type LOGIC. */
1667 : attribute_list_opt net_type
1668 primitive_type_opt signed_opt range_opt
1670 net_variable_list
';'
1672 { ivl_variable_type_t dtype
= $3;
1673 if
(dtype
== IVL_VT_NO_TYPE
)
1674 dtype
= IVL_VT_LOGIC
;
1675 pform_makewire
(@
2, $5, $4, $7, $2,
1676 NetNet
::NOT_A_PORT
, dtype
, $1);
1678 yyerror(@
6, "sorry: net delays not supported.");
1684 /* Very similar to the rule above, but this takes a list of
1685 net_decl_assigns, which are <name> = <expr> assignment
1688 | attribute_list_opt net_type
1689 primitive_type_opt signed_opt range_opt
1690 delay3_opt net_decl_assigns
';'
1692 { ivl_variable_type_t dtype
= $3;
1693 if
(dtype
== IVL_VT_NO_TYPE
)
1694 dtype
= IVL_VT_LOGIC
;
1695 pform_makewire
(@
2, $5, $4, $6,
1696 str_strength
, $7, $2, dtype
);
1698 yyerror(@
2, "sorry: Attributes not supported "
1699 "on net declaration assignments.");
1704 /* This form doesn't have the range, but does have strengths. This
1705 gives strength to the assignment drivers. */
1707 | attribute_list_opt net_type
1708 primitive_type_opt signed_opt
1709 drive_strength net_decl_assigns
';'
1711 { ivl_variable_type_t dtype
= $3;
1712 if
(dtype
== IVL_VT_NO_TYPE
)
1713 dtype
= IVL_VT_LOGIC
;
1714 pform_makewire
(@
2, 0, $4, 0, $5, $6, $2, dtype
);
1716 yyerror(@
2, "sorry: Attributes not supported "
1717 "on net declaration assignments.");
1722 | K_trireg charge_strength_opt range_opt delay3_opt list_of_identifiers
';'
1723 { yyerror(@
1, "sorry: trireg nets not supported.");
1728 | port_type signed_opt range_opt delay3_opt list_of_identifiers
';'
1729 { pform_set_port_type
(@
1, $5, $3, $2, $1);
1732 /* The next two rules handle Verilog 2001 statements of the form:
1733 input wire signed [h:l] <list>;
1734 This creates the wire and sets the port type all at once. */
1736 | port_type net_type signed_opt range_opt list_of_identifiers
';'
1737 { pform_makewire
(@
1, $4, $3, $5, $2, $1, IVL_VT_NO_TYPE
, 0,
1741 | K_output var_type signed_opt range_opt list_of_identifiers
';'
1742 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::POUTPUT
,
1743 IVL_VT_NO_TYPE
, 0, SR_BOTH
);
1746 /* var_type declaration (reg variables) cannot be input or output,
1747 because the port declaration implies an external driver, which
1748 cannot be attached to a reg. These rules catch that error early. */
1750 | K_input var_type signed_opt range_opt list_of_identifiers
';'
1751 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINPUT
,
1753 yyerror(@
2, "error: reg variables cannot be inputs.");
1756 | K_inout var_type signed_opt range_opt list_of_identifiers
';'
1757 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINOUT
,
1759 yyerror(@
2, "error: reg variables cannot be inouts.");
1762 | port_type signed_opt range_opt delay3_opt
error ';'
1763 { yyerror(@
1, "error: Invalid variable list"
1764 " in port declaration.");
1770 /* block_item_decl rule is shared with task blocks and named
1777 | K_defparam defparam_assign_list
';'
1778 | K_event list_of_identifiers
';'
1779 { pform_make_events
($2, @
1.text
, @
1.first_line
);
1782 /* Most gate types have an optional drive strength and optional
1783 three-value delay. These rules handle the different cases. */
1785 | attribute_list_opt gatetype gate_instance_list
';'
1786 { pform_makegates
($2, str_strength
, 0, $3, $1);
1789 | attribute_list_opt gatetype delay3 gate_instance_list
';'
1790 { pform_makegates
($2, str_strength
, $3, $4, $1);
1793 | attribute_list_opt gatetype drive_strength gate_instance_list
';'
1794 { pform_makegates
($2, $3, 0, $4, $1);
1797 | attribute_list_opt gatetype drive_strength delay3 gate_instance_list
';'
1798 { pform_makegates
($2, $3, $4, $5, $1);
1801 /* Pullup and pulldown devices cannot have delays, and their
1802 strengths are limited. */
1804 | K_pullup gate_instance_list
';'
1805 { pform_makegates
(PGBuiltin
::PULLUP
, pull_strength
, 0,
1808 | K_pulldown gate_instance_list
';'
1809 { pform_makegates
(PGBuiltin
::PULLDOWN
, pull_strength
,
1813 | K_pullup
'(' dr_strength1
')' gate_instance_list
';'
1814 { pform_makegates
(PGBuiltin
::PULLUP
, $3, 0, $5, 0);
1817 | K_pulldown
'(' dr_strength0
')' gate_instance_list
';'
1818 { pform_makegates
(PGBuiltin
::PULLDOWN
, $3, 0, $5, 0);
1821 /* This rule handles instantiations of modules and user defined
1822 primitives. These devices to not have delay lists or strengths,
1823 but then can have parameter lists. */
1825 | attribute_list_opt
1826 IDENTIFIER parameter_value_opt gate_instance_list
';'
1827 { perm_string tmp1
= lex_strings.make
($2);
1828 pform_make_modgates
(tmp1
, $3, $4);
1833 | attribute_list_opt
1834 IDENTIFIER parameter_value_opt
error ';'
1835 { yyerror(@
2, "error: Invalid module instantiation");
1839 /* Continuous assignment can have an optional drive strength, then
1840 an optional delay3 that applies to all the assignments in the
1841 cont_assign_list. */
1843 | K_assign drive_strength_opt delay3_opt cont_assign_list
';'
1844 { pform_make_pgassign_list
($4, $3, $2, @
1.text
, @
1.first_line
); }
1846 /* Always and initial items are behavioral processes. */
1848 | attribute_list_opt K_always statement
1849 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_ALWAYS
,
1851 tmp
->set_file
(@
2.text
);
1852 tmp
->set_lineno
(@
2.first_line
);
1854 | attribute_list_opt K_initial statement
1855 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_INITIAL
,
1857 tmp
->set_file
(@
2.text
);
1858 tmp
->set_lineno
(@
2.first_line
);
1861 /* The task declaration rule matches the task declaration
1862 header, then pushes the function scope. This causes the
1863 definitions in the task_body to take on the scope of the task
1864 instead of the module. Note that these runs accept for the task
1865 body statement_or_null, although the standard does not allow null
1866 statements in the task body. But we continue to accept it as an
1869 | K_task IDENTIFIER
';'
1870 { pform_push_scope
($2); }
1874 { PTask
*tmp
= new PTask
;
1875 perm_string tmp2
= lex_strings.make
($2);
1876 tmp
->set_file
(@
1.text
);
1877 tmp
->set_lineno
(@
1.first_line
);
1879 tmp
->set_statement
($6);
1880 pform_set_task
(tmp2
, tmp
);
1886 { pform_push_scope
($2); }
1887 '(' task_port_decl_list
')' ';'
1891 { PTask
*tmp
= new PTask
;
1892 perm_string tmp2
= lex_strings.make
($2);
1893 tmp
->set_file
(@
1.text
);
1894 tmp
->set_lineno
(@
1.first_line
);
1896 tmp
->set_statement
($9);
1897 pform_set_task
(tmp2
, tmp
);
1902 /* The function declaration rule matches the function declaration
1903 header, then pushes the function scope. This causes the
1904 definitions in the func_body to take on the scope of the function
1905 instead of the module. */
1907 | K_function function_range_or_type_opt IDENTIFIER
';'
1908 { pform_push_scope
($3); }
1909 function_item_list statement
1911 { perm_string name
= lex_strings.make
($3);
1912 PFunction
*tmp
= new PFunction
(name
);
1913 tmp
->set_file
(@
1.text
);
1914 tmp
->set_lineno
(@
1.first_line
);
1916 tmp
->set_statement
($7);
1917 tmp
->set_return
($2);
1918 pform_set_function
(name
, tmp
);
1923 /* A generate region can contain further module items. Actually, it
1924 is supposed to be limited to certain kinds of module items, but
1925 the semantic tests will check that for us. */
1927 | K_generate module_item_list_opt K_endgenerate
1929 | K_genvar list_of_identifiers
';'
1930 { pform_genvars
($2); }
1932 | K_for
'(' IDENTIFIER
'=' expression
';'
1934 IDENTIFIER
'=' expression
')'
1935 { pform_start_generate_for
(@
1, $3, $5, $7, $9, $11); }
1937 { pform_endgenerate
(); }
1942 { pform_start_generate_else
(@
1); }
1944 { pform_endgenerate
(); }
1947 generate_block_opt %prec less_than_K_else
1948 { pform_endgenerate
(); }
1950 /* specify blocks are parsed but ignored. */
1952 | K_specify K_endspecify
1953 { /* empty lists are legal syntax. */ }
1955 | K_specify specify_item_list K_endspecify
1959 | K_specify
error K_endspecify
1960 { yyerror(@
1, "error: syntax error in specify block");
1964 /* These rules match various errors that the user can type into
1965 module items. These rules try to catch them at a point where a
1966 reasonable error message can be produced. */
1968 | K_module
error ';'
1969 { yyerror(@
2, "error: missing endmodule or attempt to "
1971 pform_error_nested_modules
();
1976 { yyerror(@
2, "error: invalid module item.");
1980 | K_assign
error '=' expression
';'
1981 { yyerror(@
1, "error: syntax error in left side "
1982 "of continuous assignment.");
1986 | K_assign
error ';'
1987 { yyerror(@
1, "error: syntax error in "
1988 "continuous assignment");
1992 | K_function
error K_endfunction
1993 { yyerror(@
1, "error: I give up on this "
1994 "function definition.");
1998 /* These rules are for the Icarus Verilog specific $attribute
1999 extensions. Then catch the parameters of the $attribute keyword. */
2001 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')' ';'
2002 { perm_string tmp3
= lex_strings.make
($3);
2003 perm_string tmp5
= lex_strings.make
($5);
2004 pform_set_attrib
(tmp3
, tmp5
, $7);
2008 | KK_attribute
'(' error ')' ';'
2009 { yyerror(@
1, "error: Malformed $attribute parameter list."); }
2012 generate_if
: K_if
'(' expression
')' { pform_start_generate_if
(@
1, $3); }
2015 : module_item_list module_item
2019 module_item_list_opt
2024 /* A generate block is the thing within a generate scheme. It may be
2025 a single module item, an anonymous block of module items, or a
2026 named module item. In all cases, the meat is in the module items
2027 inside, and the processing is done by the module_item rules. We
2028 only need to take note here of the scope name, if any. */
2032 | K_begin module_item_list_opt K_end
2033 | K_begin
':' IDENTIFIER module_item_list_opt K_end
2034 { pform_generate_block_name
($3); }
2037 generate_block_opt
: generate_block |
';' ;
2040 /* A net declaration assignment allows the programmer to combine the
2041 net declaration and the continuous assignment into a single
2044 Note that the continuous assignment statement is generated as a
2045 side effect, and all I pass up is the name of the l-value. */
2048 : IDENTIFIER
'=' expression
2049 { net_decl_assign_t
*tmp
= new net_decl_assign_t
;
2058 : net_decl_assigns
',' net_decl_assign
2059 { net_decl_assign_t
*tmp
= $1;
2060 $3->next
= tmp
->next
;
2070 : K_logic
{ $$
= IVL_VT_LOGIC
; }
2071 | K_bool
{ $$
= IVL_VT_BOOL
; }
2072 | K_real
{ $$
= IVL_VT_REAL
; }
2075 primitive_type_opt
: primitive_type
{ $$
= $1; } |
{ $$
= IVL_VT_NO_TYPE
; } ;
2078 : K_wire
{ $$
= NetNet
::WIRE
; }
2079 | K_tri
{ $$
= NetNet
::TRI
; }
2080 | K_tri1
{ $$
= NetNet
::TRI1
; }
2081 | K_supply0
{ $$
= NetNet
::SUPPLY0
; }
2082 | K_wand
{ $$
= NetNet
::WAND
; }
2083 | K_triand
{ $$
= NetNet
::TRIAND
; }
2084 | K_tri0
{ $$
= NetNet
::TRI0
; }
2085 | K_supply1
{ $$
= NetNet
::SUPPLY1
; }
2086 | K_wor
{ $$
= NetNet
::WOR
; }
2087 | K_trior
{ $$
= NetNet
::TRIOR
; }
2088 | K_wone
{ $$
= NetNet
::WONE
; }
2092 : K_reg
{ $$
= NetNet
::REG
; }
2095 /* In this rule we have matched the "parameter" keyword. The rule
2096 generates a type (optional) and a list of assignments. */
2098 parameter_assign_decl
2099 : parameter_assign_list
2100 | range
{ active_range
= $1; active_signed
= false
; }
2101 parameter_assign_list
2103 active_signed
= false
;
2105 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2106 parameter_assign_list
2108 active_signed
= false
;
2110 | K_integer
{ active_range
= 0; active_signed
= true
; }
2111 parameter_assign_list
2113 active_signed
= false
;
2117 parameter_assign_list
2119 | parameter_assign_list
',' parameter_assign
2123 : IDENTIFIER
'=' expression
2125 if
(!pform_expression_is_constant
(tmp
)) {
2126 yyerror(@
3, "error: parameter value "
2127 "must be a constant expression.");
2131 pform_set_parameter
(lex_strings.make
($1),
2139 /* Localparam assignments and assignment lists are broken into
2140 separate BNF so that I can call slightly different parameter
2141 handling code. They parse the same as parameters, they just
2142 behave differently when someone tries to override them. */
2145 : IDENTIFIER
'=' expression
2147 if
(!pform_expression_is_constant
(tmp
)) {
2148 yyerror(@
3, "error: parameter value "
2149 "must be constant.");
2153 pform_set_localparam
(lex_strings.make
($1),
2161 localparam_assign_decl
2162 : localparam_assign_list
2163 | range
{ active_range
= $1; active_signed
= false
; }
2164 localparam_assign_list
2166 active_signed
= false
;
2168 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2169 localparam_assign_list
2171 active_signed
= false
;
2175 localparam_assign_list
2177 | localparam_assign_list
',' localparam_assign
2182 /* The parameters of a module instance can be overridden by writing
2183 a list of expressions in a syntax much like a delay list. (The
2184 difference being the list can have any length.) The pform that
2185 attaches the expression list to the module checks that the
2186 expressions are constant.
2188 Although the BNF in IEEE1364-1995 implies that parameter value
2189 lists must be in parentheses, in practice most compilers will
2190 accept simple expressions outside of parentheses if there is only
2191 one value, so I'll accept simple numbers here.
2193 The parameter value by name syntax is OVI enhancement BTF-B06 as
2194 approved by WG1364 on 6/28/1998. */
2197 : '#' '(' expression_list_with_nuls
')'
2198 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2203 |
'#' '(' parameter_value_byname_list
')'
2204 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2211 PENumber
*tmp
= new PENumber
($2);
2212 tmp
->set_file
(@
1.text
);
2213 tmp
->set_lineno
(@
1.first_line
);
2215 struct parmvalue_t
*lst
= new
struct parmvalue_t
;
2216 lst
->by_order
= new svector
<PExpr
*>(1);
2217 (*lst
->by_order
)[0] = tmp
;
2222 { yyerror(@
1, "error: syntax error in parameter value "
2223 "assignment list.");
2230 parameter_value_byname
2231 : '.' IDENTIFIER
'(' expression
')'
2232 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2233 tmp
->name
= lex_strings.make
($2);
2238 |
'.' IDENTIFIER
'(' ')'
2239 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2240 tmp
->name
= lex_strings.make
($2);
2247 parameter_value_byname_list
2248 : parameter_value_byname
2249 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2253 | parameter_value_byname_list
',' parameter_value_byname
2254 { svector
<named_pexpr_t
*>*tmp
=
2255 new svector
<named_pexpr_t
*>(*$1,$3);
2262 /* The port (of a module) is a fairly complex item. Each port is
2263 handled as a Module::port_t object. A simple port reference has a
2264 name and a PExpr object, but more complex constructs are possible
2265 where the name can be attached to a list of PWire objects.
2267 The port_reference returns a Module::port_t, and so does the
2268 port_reference_list. The port_reference_list may have built up a
2269 list of PWires in the port_t object, but it is still a single
2270 Module::port_t object.
2272 The port rule below takes the built up Module::port_t object and
2273 tweaks its name as needed. */
2279 /* This syntax attaches an external name to the port reference so
2280 that the caller can bind by name to non-trivial port
2281 references. The port_t object gets its PWire from the
2282 port_reference, but its name from the IDENTIFIER. */
2284 |
'.' IDENTIFIER
'(' port_reference
')'
2285 { Module
::port_t
*tmp
= $4;
2286 tmp
->name
= lex_strings.make
($2);
2291 /* A port can also be a concatenation of port references. In this
2292 case the port does not have a name available to the outside, only
2293 positional parameter passing is possible here. */
2295 |
'{' port_reference_list
'}'
2296 { Module
::port_t
*tmp
= $2;
2297 tmp
->name
= perm_string
();
2301 /* This attaches a name to a port reference concatenation list so
2302 that parameter passing be name is possible. */
2304 |
'.' IDENTIFIER
'(' '{' port_reference_list
'}' ')'
2305 { Module
::port_t
*tmp
= $5;
2306 tmp
->name
= lex_strings.make
($2);
2318 /* A port reference is an internal (to the module) name of the port,
2319 possibly with a part of bit select to attach it to specific bits
2320 of a signal fully declared inside the module.
2322 The parser creates a PEIdent for every port reference, even if the
2323 signal is bound to different ports. The elaboration figures out
2324 the mess that this creates. The port_reference (and the
2325 port_reference_list below) puts the port reference PEIdent into the
2326 port_t object to pass it up to the module declaration code. */
2331 { Module
::port_t
*ptmp
;
2332 ptmp
= pform_module_port_reference
($1, @
1.text
, @
1.first_line
);
2337 | IDENTIFIER
'[' expression
':' expression
']'
2338 { if
(!pform_expression_is_constant
($3)) {
2339 yyerror(@
3, "error: msb expression of "
2340 "port part select must be constant.");
2342 if
(!pform_expression_is_constant
($5)) {
2343 yyerror(@
5, "error: lsb expression of "
2344 "port part select must be constant.");
2346 index_component_t itmp
;
2347 itmp.sel
= index_component_t
::SEL_PART
;
2351 name_component_t ntmp
(lex_strings.make
($1));
2352 ntmp.index.push_back
(itmp
);
2355 pname.push_back
(ntmp
);
2357 PEIdent
*wtmp
= new PEIdent
(pname
);
2358 wtmp
->set_file
(@
1.text
);
2359 wtmp
->set_lineno
(@
1.first_line
);
2361 Module
::port_t
*ptmp
= new Module
::port_t
;
2362 ptmp
->name
= perm_string
();
2363 ptmp
->expr
= svector
<PEIdent
*>(1);
2364 ptmp
->expr
[0] = wtmp
;
2370 | IDENTIFIER
'[' expression
']'
2371 { if
(!pform_expression_is_constant
($3)) {
2372 yyerror(@
3, "error: port bit select "
2373 "must be constant.");
2375 index_component_t itmp
;
2376 itmp.sel
= index_component_t
::SEL_BIT
;
2380 name_component_t ntmp
(lex_strings.make
($1));
2381 ntmp.index.push_back
(itmp
);
2384 pname.push_back
(ntmp
);
2386 PEIdent
*tmp
= new PEIdent
(pname
);
2387 tmp
->set_file
(@
1.text
);
2388 tmp
->set_lineno
(@
1.first_line
);
2390 Module
::port_t
*ptmp
= new Module
::port_t
;
2391 ptmp
->name
= perm_string
();
2392 ptmp
->expr
= svector
<PEIdent
*>(1);
2393 ptmp
->expr
[0] = tmp
;
2398 | IDENTIFIER
'[' error ']'
2399 { yyerror(@
1, "error: invalid port bit select");
2400 Module
::port_t
*ptmp
= new Module
::port_t
;
2401 PEIdent
*wtmp
= new PEIdent
(lex_strings.make
($1));
2402 wtmp
->set_file
(@
1.text
);
2403 wtmp
->set_lineno
(@
1.first_line
);
2404 ptmp
->name
= lex_strings.make
($1);
2405 ptmp
->expr
= svector
<PEIdent
*>(1);
2406 ptmp
->expr
[0] = wtmp
;
2416 | port_reference_list
',' port_reference
2417 { Module
::port_t
*tmp
= $1;
2418 tmp
->expr
= svector
<PEIdent
*>(tmp
->expr
, $3->expr
);
2424 /* The port_name rule is used with a module is being *instantiated*,
2425 and not when it is being declared. See the port rule if you are
2426 looking for the ports of a module declaration. */
2429 : '.' IDENTIFIER
'(' expression
')'
2430 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2431 tmp
->name
= lex_strings.make
($2);
2436 |
'.' IDENTIFIER
'(' error ')'
2437 { yyerror(@
4, "error: invalid port connection expression.");
2438 named_pexpr_t
*tmp
= new named_pexpr_t
;
2439 tmp
->name
= lex_strings.make
($2);
2444 |
'.' IDENTIFIER
'(' ')'
2445 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2446 tmp
->name
= lex_strings.make
($2);
2454 : port_name_list
',' port_name
2455 { svector
<named_pexpr_t
*>*tmp
;
2456 tmp
= new svector
<named_pexpr_t
*>(*$1, $3);
2461 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2468 : K_input
{ $$
= NetNet
::PINPUT
; }
2469 | K_output
{ $$
= NetNet
::POUTPUT
; }
2470 | K_inout
{ $$
= NetNet
::PINOUT
; }
2474 : '[' expression
':' expression
']'
2475 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*> (2);
2476 if
(!pform_expression_is_constant
($2))
2477 yyerror(@
2, "error: msb of range must be constant.");
2481 if
(!pform_expression_is_constant
($4))
2482 yyerror(@
4, "error: lsb of range must be constant.");
2495 /* This is used to express the return type of a function. */
2496 function_range_or_type_opt
2497 : range
{ $$.range
= $1; $$.type
= PTF_REG
; }
2498 | K_signed range
{ $$.range
= $2; $$.type
= PTF_REG_S
; }
2499 | K_integer
{ $$.range
= 0; $$.type
= PTF_INTEGER
; }
2500 | K_real
{ $$.range
= 0; $$.type
= PTF_REAL
; }
2501 | K_realtime
{ $$.range
= 0; $$.type
= PTF_REALTIME
; }
2502 | K_time
{ $$.range
= 0; $$.type
= PTF_TIME
; }
2503 |
{ $$.range
= 0; $$.type
= PTF_REG
; }
2506 /* The register_variable rule is matched only when I am parsing
2507 variables in a "reg" definition. I therefore know that I am
2508 creating registers and I do not need to let the containing rule
2509 handle it. The register variable list simply packs them together
2510 so that bit ranges can be assigned. */
2513 { pform_makewire
(@
1, $1, NetNet
::REG
,
2518 | IDENTIFIER
'=' expression
2519 { pform_makewire
(@
1, $1, NetNet
::REG
,
2522 if
(! pform_expression_is_constant
($3))
2523 yyerror(@
3, "error: register declaration assignment"
2524 " value must be a constant expression.");
2525 pform_make_reginit
(@
1, $1, $3);
2528 | IDENTIFIER
'[' expression
':' expression
']'
2529 { pform_makewire
(@
1, $1, NetNet
::REG
,
2532 if
(! pform_expression_is_constant
($3))
2533 yyerror(@
3, "error: msb of register range must be constant.");
2534 if
(! pform_expression_is_constant
($5))
2535 yyerror(@
3, "error: lsb of register range must be constant.");
2536 pform_set_reg_idx
($1, $3, $5);
2541 register_variable_list
2543 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2544 tmp
->push_back
(lex_strings.make
($1));
2548 | register_variable_list
',' register_variable
2549 { list
<perm_string
>*tmp
= $1;
2550 tmp
->push_back
(lex_strings.make
($3));
2558 { pform_makewire
(@
1, $1, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2561 | IDENTIFIER
'=' expression
2562 { pform_makewire
(@
1, $1, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2563 pform_make_reginit
(@
1, $1, $3);
2570 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2571 tmp
->push_back
(lex_strings.make
($1));
2575 | real_variable_list
',' real_variable
2576 { list
<perm_string
>*tmp
= $1;
2577 tmp
->push_back
(lex_strings.make
($3));
2585 { pform_makewire
(@
1, $1, NetNet
::IMPLICIT
,
2590 | IDENTIFIER
'[' expression
':' expression
']'
2591 { pform_makewire
(@
1, $1, NetNet
::IMPLICIT
,
2594 if
(! pform_expression_is_constant
($3))
2595 yyerror(@
3, "error: msb of net range must be constant.");
2596 if
(! pform_expression_is_constant
($5))
2597 yyerror(@
3, "error: lsb of net range must be constant.");
2598 pform_set_reg_idx
($1, $3, $5);
2604 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2605 tmp
->push_back
(lex_strings.make
($1));
2609 | net_variable_list
',' net_variable
2610 { list
<perm_string
>*tmp
= $1;
2611 tmp
->push_back
(lex_strings.make
($3));
2618 : K_specparam specparam_list
';'
2619 | specify_simple_path_decl
';'
2620 { pform_module_specify_path
($1);
2622 | specify_edge_path_decl
';'
2623 { pform_module_specify_path
($1);
2625 | K_if
'(' expression
')' specify_simple_path_decl
';'
2626 { PSpecPath
*tmp
= $5;
2628 tmp
->conditional
= true
;
2629 tmp
->condition
= $3;
2631 pform_module_specify_path
(tmp
);
2633 | K_if
'(' expression
')' specify_edge_path_decl
';'
2634 { PSpecPath
*tmp
= $5;
2636 tmp
->conditional
= true
;
2637 tmp
->condition
= $3;
2639 pform_module_specify_path
(tmp
);
2641 | K_ifnone specify_simple_path_decl
';'
2642 { PSpecPath
*tmp
= $2;
2644 tmp
->conditional
= true
;
2647 pform_module_specify_path
(tmp
);
2649 | K_Shold
'(' spec_reference_event
',' spec_reference_event
2650 ',' delay_value spec_notifier_opt
')' ';'
2653 | K_Speriod
'(' spec_reference_event
',' delay_value
2654 spec_notifier_opt
')' ';'
2657 | K_Srecovery
'(' spec_reference_event
',' spec_reference_event
2658 ',' delay_value spec_notifier_opt
')' ';'
2661 | K_Ssetup
'(' spec_reference_event
',' spec_reference_event
2662 ',' delay_value spec_notifier_opt
')' ';'
2665 | K_Ssetuphold
'(' spec_reference_event
',' spec_reference_event
2666 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2670 | K_Srecrem
'(' spec_reference_event
',' spec_reference_event
2671 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2675 | K_Swidth
'(' spec_reference_event
',' delay_value
',' expression
2676 spec_notifier_opt
')' ';'
2680 | K_Swidth
'(' spec_reference_event
',' delay_value
')' ';'
2687 | specify_item_list specify_item
2690 specify_edge_path_decl
2691 : specify_edge_path
'=' '(' delay_value_list
')'
2692 { $$
= pform_assign_path_delay
($1, $4); }
2693 | specify_edge_path
'=' delay_value_simple
2694 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2696 $$
= pform_assign_path_delay
($1, tmp
);
2700 edge_operator
: K_posedge
{ $$
= true
; } | K_negedge
{ $$
= false
; } ;
2703 : '(' specify_path_identifiers spec_polarity
2704 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2705 { int edge_flag
= 0;
2706 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, false
, $6, $8); }
2707 |
'(' edge_operator specify_path_identifiers spec_polarity
2708 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2709 { int edge_flag
= $2?
1 : -1;
2710 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, false
, $7, $9);}
2711 |
'(' specify_path_identifiers spec_polarity
2712 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2713 { int edge_flag
= 0;
2714 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, true
, $6, $8); }
2715 |
'(' edge_operator specify_path_identifiers spec_polarity
2716 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2717 { int edge_flag
= $2?
1 : -1;
2718 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, true
, $7, $9); }
2727 specify_simple_path_decl
2728 : specify_simple_path
'=' '(' delay_value_list
')'
2729 { $$
= pform_assign_path_delay
($1, $4); }
2730 | specify_simple_path
'=' delay_value_simple
2731 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2733 $$
= pform_assign_path_delay
($1, tmp
);
2735 | specify_simple_path
'=' '(' error ')'
2736 { yyerror(@
2, "Syntax error in delay value list.");
2743 : '(' specify_path_identifiers spec_polarity
2744 K_EG specify_path_identifiers
')'
2745 { $$
= pform_make_specify_path
(@
1, $2, $3, false
, $5); }
2746 |
'(' specify_path_identifiers spec_polarity
2747 K_SG specify_path_identifiers
')'
2748 { $$
= pform_make_specify_path
(@
1, $2, $3, true
, $5); }
2750 { yyerror(@
2, "Invalid simple path");
2755 specify_path_identifiers
2757 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2758 tmp
->push_back
(lex_strings.make
($1));
2762 | IDENTIFIER
'[' expr_primary
']'
2763 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2764 tmp
->push_back
(lex_strings.make
($1));
2768 | specify_path_identifiers
',' IDENTIFIER
2769 { list
<perm_string
>*tmp
= $1;
2770 tmp
->push_back
(lex_strings.make
($3));
2774 | specify_path_identifiers
',' IDENTIFIER
'[' expr_primary
']'
2775 { list
<perm_string
>*tmp
= $1;
2776 tmp
->push_back
(lex_strings.make
($3));
2783 : IDENTIFIER
'=' expression
2785 pform_set_specparam
(lex_strings.make
($1), tmp
);
2788 | IDENTIFIER
'=' expression
':' expression
':' expression
2790 switch
(min_typ_max_flag
) {
2807 pform_set_specparam
(lex_strings.make
($1), tmp
);
2810 | PATHPULSE_IDENTIFIER
'=' expression
2814 | PATHPULSE_IDENTIFIER
'=' '(' expression
',' expression
')'
2823 | specparam_list
',' specparam
2832 spec_reference_event
2833 : K_posedge expression
2835 | K_negedge expression
2837 | K_posedge expr_primary K_TAND expression
2841 | K_negedge expr_primary K_TAND expression
2845 | K_edge
'[' edge_descriptor_list
']' expr_primary K_TAND expression
2849 | expr_primary K_TAND expression
2857 /* The edge_descriptor is detected by the lexor as the various
2858 2-letter edge sequences that are supported here. For now, we
2859 don't care what they are, because we do not yet support specify
2861 edge_descriptor_list
2862 : edge_descriptor_list
',' K_edge_descriptor
2875 |
',' heirarchy_identifier
2879 | spec_notifier
',' heirarchy_identifier
2888 /* assign and deassign statements are procedural code to do
2889 structural assignments, and to turn that structural assignment
2890 off. This stronger then any other assign, but weaker then the
2891 force assignments. */
2893 : K_assign lpvalue
'=' expression
';'
2894 { PCAssign
*tmp
= new PCAssign
($2, $4);
2895 tmp
->set_file
(@
1.text
);
2896 tmp
->set_lineno
(@
1.first_line
);
2900 | K_deassign lpvalue
';'
2901 { PDeassign
*tmp
= new PDeassign
($2);
2902 tmp
->set_file
(@
1.text
);
2903 tmp
->set_lineno
(@
1.first_line
);
2908 /* Force and release statements are similar to assignments,
2909 syntactically, but they will be elaborated differently. */
2911 | K_force lpvalue
'=' expression
';'
2912 { PForce
*tmp
= new PForce
($2, $4);
2913 tmp
->set_file
(@
1.text
);
2914 tmp
->set_lineno
(@
1.first_line
);
2917 | K_release lpvalue
';'
2918 { PRelease
*tmp
= new PRelease
($2);
2919 tmp
->set_file
(@
1.text
);
2920 tmp
->set_lineno
(@
1.first_line
);
2924 /* begin-end blocks come in a variety of forms, including named and
2925 anonymous. The named blocks can also carry their own reg
2926 variables, which are placed in the scope created by the block
2927 name. These are handled by pushing the scope name then matching
2928 the declarations. The scope is popped at the end of the block. */
2930 | K_begin statement_list K_end
2931 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
, *$2);
2932 tmp
->set_file
(@
1.text
);
2933 tmp
->set_lineno
(@
1.first_line
);
2937 | K_begin
':' IDENTIFIER
2938 { pform_push_scope
($3); }
2939 block_item_decls_opt
2940 statement_list K_end
2941 { pform_pop_scope
();
2942 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
2943 PBlock
::BL_SEQ
, *$6);
2944 tmp
->set_file
(@
1.text
);
2945 tmp
->set_lineno
(@
1.first_line
);
2951 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2952 tmp
->set_file
(@
1.text
);
2953 tmp
->set_lineno
(@
1.first_line
);
2956 | K_begin
':' IDENTIFIER K_end
2957 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2958 tmp
->set_file
(@
1.text
);
2959 tmp
->set_lineno
(@
1.first_line
);
2962 | K_begin
error K_end
2965 /* fork-join blocks are very similar to begin-end blocks. In fact,
2966 from the parser's perspective there is no real difference. All we
2967 need to do is remember that this is a parallel block so that the
2968 code generator can do the right thing. */
2970 | K_fork
':' IDENTIFIER
2971 { pform_push_scope
($3); }
2972 block_item_decls_opt
2973 statement_list K_join
2974 { pform_pop_scope
();
2975 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
2976 PBlock
::BL_PAR
, *$6);
2977 tmp
->set_file
(@
1.text
);
2978 tmp
->set_lineno
(@
1.first_line
);
2984 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
2985 tmp
->set_file
(@
1.text
);
2986 tmp
->set_lineno
(@
1.first_line
);
2989 | K_fork
':' IDENTIFIER K_join
2990 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
2991 tmp
->set_file
(@
1.text
);
2992 tmp
->set_lineno
(@
1.first_line
);
2997 | K_disable heirarchy_identifier
';'
2998 { PDisable
*tmp
= new PDisable
(*$2);
2999 tmp
->set_file
(@
1.text
);
3000 tmp
->set_lineno
(@
1.first_line
);
3004 | K_TRIGGER heirarchy_identifier
';'
3005 { PTrigger
*tmp
= new PTrigger
(*$2);
3006 tmp
->set_file
(@
2.text
);
3007 tmp
->set_lineno
(@
2.first_line
);
3011 | K_forever statement
3012 { PForever
*tmp
= new PForever
($2);
3013 tmp
->set_file
(@
1.text
);
3014 tmp
->set_lineno
(@
1.first_line
);
3017 | K_fork statement_list K_join
3018 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
, *$2);
3019 tmp
->set_file
(@
1.text
);
3020 tmp
->set_lineno
(@
1.first_line
);
3024 | K_repeat
'(' expression
')' statement
3025 { PRepeat
*tmp
= new PRepeat
($3, $5);
3026 tmp
->set_file
(@
1.text
);
3027 tmp
->set_lineno
(@
1.first_line
);
3030 | K_case
'(' expression
')' case_items K_endcase
3031 { PCase
*tmp
= new PCase
(NetCase
::EQ
, $3, $5);
3032 tmp
->set_file
(@
1.text
);
3033 tmp
->set_lineno
(@
1.first_line
);
3036 | K_casex
'(' expression
')' case_items K_endcase
3037 { PCase
*tmp
= new PCase
(NetCase
::EQX
, $3, $5);
3038 tmp
->set_file
(@
1.text
);
3039 tmp
->set_lineno
(@
1.first_line
);
3042 | K_casez
'(' expression
')' case_items K_endcase
3043 { PCase
*tmp
= new PCase
(NetCase
::EQZ
, $3, $5);
3044 tmp
->set_file
(@
1.text
);
3045 tmp
->set_lineno
(@
1.first_line
);
3048 | K_case
'(' expression
')' error K_endcase
3050 | K_casex
'(' expression
')' error K_endcase
3052 | K_casez
'(' expression
')' error K_endcase
3054 | K_if
'(' expression
')' statement_or_null %prec less_than_K_else
3055 { PCondit
*tmp
= new PCondit
($3, $5, 0);
3056 tmp
->set_file
(@
1.text
);
3057 tmp
->set_lineno
(@
1.first_line
);
3060 | K_if
'(' expression
')' statement_or_null K_else statement_or_null
3061 { PCondit
*tmp
= new PCondit
($3, $5, $7);
3062 tmp
->set_file
(@
1.text
);
3063 tmp
->set_lineno
(@
1.first_line
);
3066 | K_if
'(' error ')' statement_or_null %prec less_than_K_else
3067 { yyerror(@
1, "error: Malformed conditional expression.");
3070 | K_if
'(' error ')' statement_or_null K_else statement_or_null
3071 { yyerror(@
1, "error: Malformed conditional expression.");
3074 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3075 lpvalue
'=' expression
')' statement
3076 { PForStatement
*tmp
= new PForStatement
($3, $5, $7, $9, $11, $13);
3077 tmp
->set_file
(@
1.text
);
3078 tmp
->set_lineno
(@
1.first_line
);
3081 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3084 yyerror(@
9, "error: Error in for loop step assignment.");
3086 | K_for
'(' lpvalue
'=' expression
';' error ';'
3087 lpvalue
'=' expression
')' statement
3089 yyerror(@
7, "error: Error in for loop condition expression.");
3091 | K_for
'(' error ')' statement
3093 yyerror(@
3, "error: Incomprehensible for loop.");
3095 | K_while
'(' expression
')' statement
3096 { PWhile
*tmp
= new PWhile
($3, $5);
3099 | K_while
'(' error ')' statement
3101 yyerror(@
3, "error: Error in while loop condition.");
3103 | delay1 statement_or_null
3104 { PExpr
*del
= (*$1)[0];
3105 assert
($1->count
() == 1);
3106 PDelayStatement
*tmp
= new PDelayStatement
(del
, $2);
3107 tmp
->set_file
(@
1.text
);
3108 tmp
->set_lineno
(@
1.first_line
);
3111 | event_control statement_or_null
3112 { PEventStatement
*tmp
= $1;
3114 yyerror(@
1, "error: Invalid event control.");
3117 tmp
->set_statement
($2);
3121 |
'@' '*' statement_or_null
3122 { PEventStatement
*tmp
= new PEventStatement
;
3123 tmp
->set_file
(@
1.text
);
3124 tmp
->set_lineno
(@
1.first_line
);
3125 tmp
->set_statement
($3);
3128 |
'@' '(' '*' ')' statement_or_null
3129 { PEventStatement
*tmp
= new PEventStatement
;
3130 tmp
->set_file
(@
1.text
);
3131 tmp
->set_lineno
(@
1.first_line
);
3132 tmp
->set_statement
($5);
3135 | lpvalue
'=' expression
';'
3136 { PAssign
*tmp
= new PAssign
($1,$3);
3137 tmp
->set_file
(@
1.text
);
3138 tmp
->set_lineno
(@
1.first_line
);
3141 |
error '=' expression
';'
3142 { yyerror(@
1, "Syntax in assignment statement l-value.");
3146 | lpvalue K_LE expression
';'
3147 { PAssignNB
*tmp
= new PAssignNB
($1,$3);
3148 tmp
->set_file
(@
1.text
);
3149 tmp
->set_lineno
(@
1.first_line
);
3152 |
error K_LE expression
';'
3153 { yyerror(@
1, "Syntax in assignment statement l-value.");
3157 | lpvalue
'=' delay1 expression
';'
3158 { assert
($3->count
() == 1);
3159 PExpr
*del
= (*$3)[0];
3160 PAssign
*tmp
= new PAssign
($1,del
,$4);
3161 tmp
->set_file
(@
1.text
);
3162 tmp
->set_lineno
(@
1.first_line
);
3165 | lpvalue K_LE delay1 expression
';'
3166 { assert
($3->count
() == 1);
3167 PExpr
*del
= (*$3)[0];
3168 PAssignNB
*tmp
= new PAssignNB
($1,del
,$4);
3169 tmp
->set_file
(@
1.text
);
3170 tmp
->set_lineno
(@
1.first_line
);
3173 | lpvalue
'=' event_control expression
';'
3174 { PAssign
*tmp
= new PAssign
($1,$3,$4);
3175 tmp
->set_file
(@
1.text
);
3176 tmp
->set_lineno
(@
1.first_line
);
3179 | lpvalue
'=' K_repeat
'(' expression
')' event_control expression
';'
3180 { PAssign
*tmp
= new PAssign
($1,$7,$8);
3181 tmp
->set_file
(@
1.text
);
3182 tmp
->set_lineno
(@
1.first_line
);
3183 yyerror(@
3, "sorry: repeat event control not supported.");
3187 | lpvalue K_LE event_control expression
';'
3188 { yyerror(@
1, "sorry: Event controls not supported here.");
3189 PAssignNB
*tmp
= new PAssignNB
($1,$4);
3190 tmp
->set_file
(@
1.text
);
3191 tmp
->set_lineno
(@
1.first_line
);
3194 | lpvalue K_LE K_repeat
'(' expression
')' event_control expression
';'
3195 { yyerror(@
1, "sorry: Event controls not supported here.");
3197 PAssignNB
*tmp
= new PAssignNB
($1,$8);
3198 tmp
->set_file
(@
1.text
);
3199 tmp
->set_lineno
(@
1.first_line
);
3202 | K_wait
'(' expression
')' statement_or_null
3203 { PEventStatement
*tmp
;
3204 PEEvent
*etmp
= new PEEvent
(PEEvent
::POSITIVE
, $3);
3205 tmp
= new PEventStatement
(etmp
);
3206 tmp
->set_file
(@
1.text
);
3207 tmp
->set_lineno
(@
1.first_line
);
3208 tmp
->set_statement
($5);
3211 | SYSTEM_IDENTIFIER
'(' expression_list_with_nuls
')' ';'
3212 { PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), *$3);
3213 tmp
->set_file
(@
1.text
);
3214 tmp
->set_lineno
(@
1.first_line
);
3219 | SYSTEM_IDENTIFIER
';'
3220 { svector
<PExpr
*>pt
(0);
3221 PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), pt
);
3222 tmp
->set_file
(@
1.text
);
3223 tmp
->set_lineno
(@
1.first_line
);
3227 | heirarchy_identifier
'(' expression_list_proper
')' ';'
3228 { PCallTask
*tmp
= new PCallTask
(*$1, *$3);
3229 tmp
->set_file
(@
1.text
);
3230 tmp
->set_lineno
(@
1.first_line
);
3236 /* NOTE: The standard doesn't really support an empty argument list
3237 between parentheses, but it seems natural, and people commonly
3238 want it. So accept it explicitly. */
3240 | heirarchy_identifier
'(' ')' ';'
3241 { svector
<PExpr
*>pt
(0);
3242 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3243 tmp
->set_file
(@
1.text
);
3244 tmp
->set_lineno
(@
1.first_line
);
3248 | heirarchy_identifier
';'
3249 { svector
<PExpr
*>pt
(0);
3250 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3251 tmp
->set_file
(@
1.text
);
3252 tmp
->set_lineno
(@
1.first_line
);
3257 { yyerror(@
1, "error: malformed statement");
3264 : statement_list statement
3265 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(*$1, $2);
3270 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(1);
3281 /* Task items are, other than the statement, task port items and
3282 other block items. */
3284 : block_item_decl
{ $$
= new svector
<PWire
*>(0); }
3285 | task_port_item
{ $$
= $1; }
3290 : K_input signed_opt range_opt list_of_identifiers
';'
3291 { svector
<PWire
*>*tmp
3292 = pform_make_task_ports
(NetNet
::PINPUT
,
3295 @
1.text
, @
1.first_line
);
3298 | K_output signed_opt range_opt list_of_identifiers
';'
3299 { svector
<PWire
*>*tmp
3300 = pform_make_task_ports
(NetNet
::POUTPUT
,
3303 @
1.text
, @
1.first_line
);
3306 | K_inout signed_opt range_opt list_of_identifiers
';'
3307 { svector
<PWire
*>*tmp
3308 = pform_make_task_ports
(NetNet
::PINOUT
,
3311 @
1.text
, @
1.first_line
);
3315 /* When the port is an integer, infer a signed vector of the integer
3316 shape. Generate a range to make it work. */
3318 | K_input K_integer list_of_identifiers
';'
3319 { svector
<PExpr
*>*range_stub
3320 = new svector
<PExpr
*>(2);
3322 re
= new PENumber
(new verinum
(integer_width
-1,
3324 (*range_stub
)[0] = re
;
3325 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3326 (*range_stub
)[1] = re
;
3328 = pform_make_task_ports
(NetNet
::PINPUT
,
3331 @
1.text
, @
1.first_line
);
3334 | K_output K_integer list_of_identifiers
';'
3335 { svector
<PExpr
*>*range_stub
3336 = new svector
<PExpr
*>(2);
3338 re
= new PENumber
(new verinum
(integer_width
-1,
3340 (*range_stub
)[0] = re
;
3341 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3342 (*range_stub
)[1] = re
;
3344 = pform_make_task_ports
(NetNet
::POUTPUT
,
3347 @
1.text
, @
1.first_line
);
3350 | K_inout K_integer list_of_identifiers
';'
3351 { svector
<PExpr
*>*range_stub
3352 = new svector
<PExpr
*>(2);
3354 re
= new PENumber
(new verinum
(integer_width
-1,
3356 (*range_stub
)[0] = re
;
3357 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3358 (*range_stub
)[1] = re
;
3360 = pform_make_task_ports
(NetNet
::PINOUT
,
3363 @
1.text
, @
1.first_line
);
3367 /* Ports can be real. */
3369 | K_input K_real list_of_identifiers
';'
3370 { svector
<PWire
*>*tmp
3371 = pform_make_task_ports
(NetNet
::PINPUT
,
3374 @
1.text
, @
1.first_line
);
3377 | K_output K_real list_of_identifiers
';'
3378 { svector
<PWire
*>*tmp
3379 = pform_make_task_ports
(NetNet
::POUTPUT
,
3382 @
1.text
, @
1.first_line
);
3385 | K_inout K_real list_of_identifiers
';'
3386 { svector
<PWire
*>*tmp
3387 = pform_make_task_ports
(NetNet
::PINOUT
,
3390 @
1.text
, @
1.first_line
);
3396 : task_item_list task_item
3397 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3415 : K_input signed_opt range_opt IDENTIFIER
3416 { svector
<PWire
*>*tmp
3417 = pform_make_task_ports
(NetNet
::PINPUT
,
3419 $3, list_from_identifier
($4),
3420 @
1.text
, @
1.first_line
);
3424 | K_output signed_opt range_opt IDENTIFIER
3425 { svector
<PWire
*>*tmp
3426 = pform_make_task_ports
(NetNet
::POUTPUT
,
3428 $3, list_from_identifier
($4),
3429 @
1.text
, @
1.first_line
);
3432 | K_inout signed_opt range_opt IDENTIFIER
3433 { svector
<PWire
*>*tmp
3434 = pform_make_task_ports
(NetNet
::PINOUT
,
3436 $3, list_from_identifier
($4),
3437 @
1.text
, @
1.first_line
);
3441 | K_input K_integer IDENTIFIER
3442 { svector
<PExpr
*>*range_stub
3443 = new svector
<PExpr
*>(2);
3445 re
= new PENumber
(new verinum
(integer_width
-1,
3447 (*range_stub
)[0] = re
;
3448 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3449 (*range_stub
)[1] = re
;
3451 = pform_make_task_ports
(NetNet
::PINPUT
,
3454 list_from_identifier
($3),
3455 @
1.text
, @
1.first_line
);
3458 | K_output K_integer IDENTIFIER
3459 { svector
<PExpr
*>*range_stub
3460 = new svector
<PExpr
*>(2);
3462 re
= new PENumber
(new verinum
(integer_width
-1,
3464 (*range_stub
)[0] = re
;
3465 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3466 (*range_stub
)[1] = re
;
3468 = pform_make_task_ports
(NetNet
::POUTPUT
,
3471 list_from_identifier
($3),
3472 @
1.text
, @
1.first_line
);
3475 | K_inout K_integer IDENTIFIER
3476 { svector
<PExpr
*>*range_stub
3477 = new svector
<PExpr
*>(2);
3479 re
= new PENumber
(new verinum
(integer_width
-1,
3481 (*range_stub
)[0] = re
;
3482 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3483 (*range_stub
)[1] = re
;
3485 = pform_make_task_ports
(NetNet
::PINOUT
,
3488 list_from_identifier
($3),
3489 @
1.text
, @
1.first_line
);
3493 /* Ports can be real. */
3495 | K_input K_real IDENTIFIER
3496 { svector
<PWire
*>*tmp
3497 = pform_make_task_ports
(NetNet
::PINPUT
,
3499 0, list_from_identifier
($3),
3500 @
1.text
, @
1.first_line
);
3503 | K_output K_real IDENTIFIER
3504 { svector
<PWire
*>*tmp
3505 = pform_make_task_ports
(NetNet
::POUTPUT
,
3507 0, list_from_identifier
($3),
3508 @
1.text
, @
1.first_line
);
3511 | K_inout K_real IDENTIFIER
3512 { svector
<PWire
*>*tmp
3513 = pform_make_task_ports
(NetNet
::PINOUT
,
3515 0, list_from_identifier
($3),
3516 @
1.text
, @
1.first_line
);
3522 : task_port_decl_list
',' task_port_decl
3523 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$3);
3533 : K_table
{ lex_start_table
(); }
3535 K_endtable
{ lex_end_table
(); $$
= $3; }
3539 : udp_comb_entry_list
3540 | udp_sequ_entry_list
3544 : udp_input_list
':' udp_output_sym
';'
3545 { char*tmp
= new
char[strlen
($1)+3];
3547 char*tp
= tmp
+strlen
(tmp
);
3558 { list
<string>*tmp
= new list
<string>;
3563 | udp_comb_entry_list udp_comb_entry
3564 { list
<string>*tmp
= $1;
3573 { list
<string>*tmp
= new list
<string>;
3578 | udp_sequ_entry_list udp_sequ_entry
3579 { list
<string>*tmp
= $1;
3587 : udp_input_list
':' udp_input_sym
':' udp_output_sym
';'
3588 { char*tmp
= new
char[strlen
($1)+5];
3590 char*tp
= tmp
+strlen
(tmp
);
3601 : K_initial IDENTIFIER
'=' number
';'
3602 { PExpr
*etmp
= new PENumber
($4);
3603 PEIdent
*itmp
= new PEIdent
(lex_strings.make
($2));
3604 PAssign
*atmp
= new PAssign
(itmp
, etmp
);
3605 atmp
->set_file
(@
2.text
);
3606 atmp
->set_lineno
(@
2.first_line
);
3613 : udp_initial
{ $$
= $1; }
3619 { char*tmp
= new
char[2];
3624 | udp_input_list udp_input_sym
3625 { char*tmp
= new
char[strlen
($1)+2];
3627 char*tp
= tmp
+strlen
(tmp
);
3668 /* Port declarations create wires for the inputs and the output. The
3669 makes for these ports are scoped within the UDP, so there is no
3670 heirarchy involved. */
3672 : K_input list_of_identifiers
';'
3673 { $$
= pform_make_udp_input_ports
($2); }
3674 | K_output IDENTIFIER
';'
3675 { pform_name_t pname
;
3676 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3677 PWire
*pp
= new PWire
(pname
, NetNet
::IMPLICIT
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3678 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3683 | K_reg IDENTIFIER
';'
3684 { pform_name_t pname
;
3685 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3686 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::PIMPLICIT
, IVL_VT_LOGIC
);
3687 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3692 | K_reg K_output IDENTIFIER
';'
3693 { pform_name_t pname
;
3694 pname.push_back
(name_component_t
(lex_strings.make
($3)));
3695 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3696 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3706 | udp_port_decls udp_port_decl
3707 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3716 { list
<string>*tmp
= new list
<string>;
3721 | udp_port_list
',' IDENTIFIER
3722 { list
<string>*tmp
= $1;
3729 udp_reg_opt: K_reg
{ $$
= true
; } |
{ $$
= false
; };
3731 udp_initial_expr_opt
3732 : '=' expression
{ $$
= $2; }
3736 udp_input_declaration_list
3737 : K_input IDENTIFIER
3738 { list
<perm_string
>*tmp
= new list
<perm_string
>;
3739 tmp
->push_back
(lex_strings.make
($2));
3743 | udp_input_declaration_list
',' K_input IDENTIFIER
3744 { list
<perm_string
>*tmp
= $1;
3745 tmp
->push_back
(lex_strings.make
($4));
3752 /* This is the syntax for primitives that uses the IEEE1364-1995
3753 format. The ports are simply names in the port list, and the
3754 declarations are in the body. */
3756 : K_primitive IDENTIFIER
'(' udp_port_list
')' ';'
3762 { perm_string tmp2
= lex_strings.make
($2);
3763 pform_make_udp
(tmp2
, $4, $7, $9, $8,
3764 @
2.text
, @
2.first_line
);
3768 /* This is the syntax for IEEE1364-2001 format definitions. The port
3769 names and declarations are all in the parameter list. */
3771 | K_primitive IDENTIFIER
3772 '(' K_output udp_reg_opt IDENTIFIER udp_initial_expr_opt
','
3773 udp_input_declaration_list
')' ';'
3777 { perm_string tmp2
= lex_strings.make
($2);
3778 perm_string tmp6
= lex_strings.make
($6);
3779 pform_make_udp
(tmp2
, $5, tmp6
, $7, $9, $12,
3780 @
2.text
, @
2.first_line
);