4 * Copyright (c) 1998-2008 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
24 # include "parse_misc.h"
25 # include "compiler.h"
27 # include "Statement.h"
35 extern
void lex_start_table
();
36 extern
void lex_end_table
();
38 static svector
<PExpr
*>* active_range
= 0;
39 static bool active_signed
= false
;
41 /* Port declaration lists use this structure for context. */
43 NetNet
::Type port_net_type
;
44 NetNet
::PortType port_type
;
45 ivl_variable_type_t var_type
;
47 svector
<PExpr
*>* range
;
48 } port_declaration_context
= {NetNet
::NONE
, NetNet
::NOT_A_PORT
,
49 IVL_VT_NO_TYPE
, false
, 0};
51 /* The task and function rules need to briefly hold the pointer to the
52 task/function that is currently in progress. */
53 static PTask
* current_task
= 0;
54 static PFunction
* current_function
= 0;
55 static stack
<PBlock
*> current_block_stack
;
57 /* Later version of bison (including 1.35) will not compile in stack
58 extension if the output is compiled with C++ and either the YYSTYPE
59 or YYLTYPE are provided by the source code. However, I can get the
60 old behavior back by defining these symbols. */
61 # define YYSTYPE_IS_TRIVIAL 1
62 # define YYLTYPE_IS_TRIVIAL 1
64 /* Recent version of bison expect that the user supply a
65 YYLLOC_DEFAULT macro that makes up a yylloc value from existing
66 values. I need to supply an explicit version to account for the
67 text field, that otherwise won't be copied. */
68 # define YYLLOC_DEFAULT(Current, Rhs, N) do { \
69 (Current
).first_line
= (Rhs
)[1].first_line
; \
70 (Current
).first_column
= (Rhs
)[1].first_column
; \
71 (Current
).last_line
= (Rhs
)[N
].last_line
; \
72 (Current
).last_column
= (Rhs
)[N
].last_column
; \
73 (Current
).text
= (Rhs
)[1].text
; } while
(0)
76 * These are some common strength pairs that are used as defaults when
77 * the user is not otherwise specific.
79 const static struct str_pair_t pull_strength
= { PGate
::PULL
, PGate
::PULL
};
80 const static struct str_pair_t str_strength
= { PGate
::STRONG
, PGate
::STRONG
};
82 static list
<perm_string
>* list_from_identifier
(char*id
)
84 list
<perm_string
>*tmp
= new list
<perm_string
>;
85 tmp
->push_back
(lex_strings.make
(id
));
90 static list
<perm_string
>* list_from_identifier
(list
<perm_string
>*tmp
, char*id
)
92 tmp
->push_back
(lex_strings.make
(id
));
97 static inline
void FILE_NAME
(LineInfo
*tmp
, const struct vlltype
&where
)
99 tmp
->set_lineno
(where.first_line
);
100 tmp
->set_file
(filename_strings.make
(where.text
));
103 static svector
<PExpr
*>* copy_range
(svector
<PExpr
*>* orig
)
105 svector
<PExpr
*>*copy
= 0;
108 copy
= new svector
<PExpr
*>(2);
109 (*copy
)[0] = (*orig
)[0];
110 (*copy
)[1] = (*orig
)[1];
117 * This is a shorthand for making a PECallFunction that takes a single
118 * arg. This is used by some of the code that detects built-ins.
120 static PECallFunction
*make_call_function
(perm_string tn
, PExpr
*arg
)
122 svector
<PExpr
*> parms
(1);
124 PECallFunction
*tmp
= new PECallFunction
(tn
, parms
);
128 static PECallFunction
*make_call_function
(perm_string tn
, PExpr
*arg1
, PExpr
*arg2
)
130 svector
<PExpr
*> parms
(2);
133 PECallFunction
*tmp
= new PECallFunction
(tn
, parms
);
144 /* text items are C strings allocated by the lexor using
145 strdup. They can be put into lists with the texts type. */
147 list
<perm_string
>*perm_strings
;
148 pform_name_t
*pform_name
;
152 list
<string>*strings
;
154 struct str_pair_t drive
;
157 svector
<PCase
::Item
*>*citems
;
160 svector
<lgate
>*gates
;
162 Module
::port_t
*mport
;
163 svector
<Module
::port_t
*>*mports
;
165 named_pexpr_t
*named_pexpr
;
166 svector
<named_pexpr_t
*>*named_pexprs
;
167 struct parmvalue_t
*parmvalue
;
170 svector
<PExpr
*>*exprs
;
172 svector
<PEEvent
*>*event_expr
;
174 NetNet
::Type nettype
;
175 PGBuiltin
::Type gatetype
;
176 NetNet
::PortType porttype
;
177 ivl_variable_type_t datatype
;
180 svector
<PWire
*>*wires
;
182 PEventStatement
*event_statement
;
184 svector
<Statement
*>*statement_list
;
186 PTaskFuncArg function_type
;
188 net_decl_assign_t
*net_decl_assign
;
195 list
<index_component_t
> *dimensions
;
198 %token
<text
> IDENTIFIER SYSTEM_IDENTIFIER STRING
199 %token
<text
> PATHPULSE_IDENTIFIER
200 %token
<number
> BASED_NUMBER DEC_NUMBER
201 %token
<realtime
> REALTIME
202 %token K_LE K_GE K_EG K_EQ K_NE K_CEQ K_CNE K_LS K_RS K_RSS K_SG
203 %token K_PO_POS K_PO_NEG K_POW
204 %token K_PSTAR K_STARP
205 %token K_LOR K_LAND K_NAND K_NOR K_NXOR K_TRIGGER
206 %token K_abs K_acos K_acosh K_asin K_asinh K_atan K_atanh K_atan2
207 %token K_always K_and K_assign K_begin K_bool K_buf K_bufif0 K_bufif1 K_case
208 %token K_casex K_casez K_ceil K_cmos K_cos K_cosh
209 %token K_deassign K_default K_defparam K_disable
210 %token K_edge K_edge_descriptor
211 %token K_else K_end K_endcase K_endfunction K_endgenerate K_endmodule
212 %token K_endprimitive K_endspecify K_endtable K_endtask K_event K_exp K_floor
213 %token K_for K_force K_forever K_fork K_function K_generate K_genvar
214 %token K_highz0 K_highz1 K_hypot K_if K_ifnone
215 %token K_initial K_inout K_input K_integer K_join K_large K_ln K_localparam
216 %token K_log K_logic K_macromodule K_max
217 %token K_medium K_min K_module K_nand K_negedge K_nmos K_nor K_not K_notif0
218 %token K_notif1 K_or K_output K_parameter K_pmos K_posedge K_pow K_primitive
219 %token K_pull0 K_pull1 K_pulldown K_pullup K_rcmos K_real K_realtime
220 %token K_reg K_release K_repeat
221 %token K_rnmos K_rpmos K_rtran K_rtranif0 K_rtranif1 K_scalared
222 %token K_signed K_sin K_sinh K_small K_specify
223 %token K_specparam K_sqrt K_strong0 K_strong1 K_supply0 K_supply1 K_table
224 %token K_tan K_tanh K_task
225 %token K_time K_tran K_tranif0 K_tranif1 K_tri K_tri0 K_tri1 K_triand
226 %token K_trior K_trireg K_vectored K_wait K_wand K_weak0 K_weak1
227 %token K_while K_wire
228 %token K_wone K_wor K_xnor K_xor
229 %token K_Shold K_Speriod K_Srecovery K_Srecrem K_Ssetup K_Swidth K_Ssetuphold
233 %type
<number
> number
234 %type
<flag
> signed_opt udp_reg_opt edge_operator
235 %type
<drive
> drive_strength drive_strength_opt dr_strength0 dr_strength1
236 %type
<letter
> udp_input_sym udp_output_sym
237 %type
<text
> udp_input_list udp_sequ_entry udp_comb_entry
238 %type
<perm_strings
> udp_input_declaration_list
239 %type
<strings
> udp_entry_list udp_comb_entry_list udp_sequ_entry_list
240 %type
<strings
> udp_body
241 %type
<perm_strings
> udp_port_list
242 %type
<wires
> udp_port_decl udp_port_decls
243 %type
<statement
> udp_initial udp_init_opt
244 %type
<expr
> udp_initial_expr_opt
246 %type
<text
> register_variable net_variable real_variable
247 %type
<perm_strings
> register_variable_list net_variable_list real_variable_list list_of_identifiers
249 %type
<net_decl_assign
> net_decl_assign net_decl_assigns
251 %type
<mport
> port port_opt port_reference port_reference_list
252 %type
<mport
> port_declaration
253 %type
<mports
> list_of_ports module_port_list_opt list_of_port_declarations
255 %type
<wires
> task_item task_item_list task_item_list_opt
256 %type
<wires
> task_port_item task_port_decl task_port_decl_list
257 %type
<wires
> function_item function_item_list
259 %type
<named_pexpr
> port_name parameter_value_byname
260 %type
<named_pexprs
> port_name_list parameter_value_byname_list
262 %type
<named_pexpr
> attribute
263 %type
<named_pexprs
> attribute_list attribute_list_opt
265 %type
<citem
> case_item
266 %type
<citems
> case_items
268 %type
<gate
> gate_instance
269 %type
<gates
> gate_instance_list
271 %type
<pform_name
> hierarchy_identifier
272 %type
<expr
> expression expr_primary expr_mintypmax
274 %type
<expr
> delay_value delay_value_simple
275 %type
<exprs
> delay1 delay3 delay3_opt delay_value_list
276 %type
<exprs
> expression_list_with_nuls expression_list_proper
277 %type
<exprs
> cont_assign cont_assign_list
279 %type
<exprs
> range range_opt
280 %type
<dimensions
> dimensions_opt dimensions
281 %type
<nettype
> net_type var_type net_type_opt
282 %type
<gatetype
> gatetype
283 %type
<porttype
> port_type
284 %type
<datatype
> primitive_type primitive_type_opt
285 %type
<parmvalue
> parameter_value_opt
287 %type
<function_type
> function_range_or_type_opt
288 %type
<event_expr
> event_expression_list
289 %type
<event_expr
> event_expression
290 %type
<event_statement
> event_control
291 %type
<statement
> statement statement_or_null
292 %type
<statement_list
> statement_list
294 %type
<letter
> spec_polarity
295 %type
<perm_strings
> specify_path_identifiers
297 %type
<specpath
> specify_simple_path specify_simple_path_decl
298 %type
<specpath
> specify_edge_path specify_edge_path_decl
305 %left
'^' K_NXOR K_NOR
307 %left K_EQ K_NE K_CEQ K_CNE
308 %left K_GE K_LE
'<' '>'
309 %left K_LS K_RS K_RSS
315 /* to resolve dangling else ambiguity. */
316 %nonassoc less_than_K_else
321 /* A degenerate source file can be completely empty. */
322 main
: source_file |
;
326 | source_file description
329 number
: BASED_NUMBER
330 { $$
= $1; based_size
= 0;}
332 { $$
= $1; based_size
= 0;}
333 | DEC_NUMBER BASED_NUMBER
334 { $$
= pform_verinum_with_size
($1,$2, @
2.text
, @
2.first_line
);
338 /* Verilog-2001 supports attribute lists, which can be attached to a
339 variety of different objects. The syntax inside the (* *) is a
340 comma separated list of names or names with assigned values. */
342 : K_PSTAR attribute_list K_STARP
{ $$
= $2; }
343 | K_PSTAR K_STARP
{ $$
= 0; }
348 : attribute_list
',' attribute
349 { svector
<named_pexpr_t
*>*tmp
=
350 new svector
<named_pexpr_t
*>(*$1,$3);
355 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
364 { named_pexpr_t
*tmp
= new named_pexpr_t
;
365 tmp
->name
= lex_strings.make
($1);
370 | IDENTIFIER
'=' expression
372 if
(!pform_expression_is_constant
(tmp
)) {
373 yyerror(@
3, "error: attribute value "
374 "expression must be constant.");
378 named_pexpr_t
*tmp2
= new named_pexpr_t
;
379 tmp2
->name
= lex_strings.make
($1);
387 /* The block_item_decl is used in function definitions, task
388 definitions, module definitions and named blocks. Wherever a new
389 scope is entered, the source may declare new registers and
390 integers. This rule matches those declarations. The containing
391 rule has presumably set up the scope. */
394 : attribute_list_opt K_reg
395 primitive_type_opt signed_opt range
396 register_variable_list
';'
397 { ivl_variable_type_t dtype
= $3;
398 if
(dtype
== IVL_VT_NO_TYPE
)
399 dtype
= IVL_VT_LOGIC
;
400 pform_set_net_range
($6, $5, $4, dtype
);
404 /* This differs from the above pattern only in the absence of the
405 range. This is the rule for a scalar. */
407 | attribute_list_opt K_reg
408 primitive_type_opt signed_opt
409 register_variable_list
';'
410 { ivl_variable_type_t dtype
= $3;
411 if
(dtype
== IVL_VT_NO_TYPE
)
412 dtype
= IVL_VT_LOGIC
;
413 pform_set_net_range
($5, 0, $4, dtype
);
417 /* Integer declarations are simpler in that they do not have all the
418 trappings of a general variable declaration. All of that is
419 implicit in the "integer" of the declaratin. */
421 | attribute_list_opt K_integer register_variable_list
';'
422 { pform_set_reg_integer
($3);
426 | attribute_list_opt K_time register_variable_list
';'
427 { pform_set_reg_time
($3);
430 /* real declarations are fairly simple as there is no range of
431 signed flag in the declaration. Create the real as a NetNet::REG
432 with real value. Note that real and realtime are interchangable
435 | attribute_list_opt K_real real_variable_list
';'
437 | attribute_list_opt K_realtime real_variable_list
';'
440 | K_parameter parameter_assign_decl
';'
441 | K_localparam localparam_assign_decl
';'
443 /* Recover from errors that happen within variable lists. Use the
444 trailing semi-colon to resync the parser. */
446 | attribute_list_opt K_reg
error ';'
447 { yyerror(@
2, "error: syntax error in reg variable list.");
451 | attribute_list_opt K_integer
error ';'
452 { yyerror(@
2, "error: syntax error in integer variable list.");
456 | attribute_list_opt K_time
error ';'
457 { yyerror(@
2, "error: syntax error in time variable list.");
460 | attribute_list_opt K_real
error ';'
461 { yyerror(@
2, "error: syntax error in real variable list.");
464 | attribute_list_opt K_realtime
error ';'
465 { yyerror(@
2, "error: syntax error in realtime variable list.");
468 | K_parameter
error ';'
469 { yyerror(@
1, "error: syntax error in parameter list.");
472 | K_localparam
error ';'
473 { yyerror(@
1, "error: syntax error localparam list.");
480 | block_item_decls block_item_decl
489 : expression_list_proper
':' statement_or_null
490 { PCase
::Item
*tmp
= new PCase
::Item
;
496 | K_default
':' statement_or_null
497 { PCase
::Item
*tmp
= new PCase
::Item
;
501 | K_default statement_or_null
502 { PCase
::Item
*tmp
= new PCase
::Item
;
506 |
error ':' statement_or_null
507 { yyerror(@
2, "error: Incomprehensible case expression.");
513 : case_items case_item
514 { svector
<PCase
::Item
*>*tmp
;
515 tmp
= new svector
<PCase
::Item
*>(*$1, $2);
520 { svector
<PCase
::Item
*>*tmp
= new svector
<PCase
::Item
*>(1);
538 : hierarchy_identifier
'=' expression
540 if
(!pform_expression_is_constant
(tmp
)) {
541 yyerror(@
3, "error: parameter value "
542 "must be constant.");
546 pform_set_defparam
(*$1, $3);
553 | range defparam_assign
554 { yyerror(@
1, "error: defparam may not include a range.");
557 | defparam_assign_list
',' defparam_assign
561 : '#' delay_value_simple
562 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
566 |
'#' '(' delay_value
')'
567 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
574 : '#' delay_value_simple
575 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
579 |
'#' '(' delay_value
')'
580 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
584 |
'#' '(' delay_value
',' delay_value
')'
585 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
590 |
'#' '(' delay_value
',' delay_value
',' delay_value
')'
591 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(3);
600 : delay3
{ $$
= $1; }
606 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
610 | delay_value_list
',' delay_value
611 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
622 | expression
':' expression
':' expression
623 { $$
= pform_select_mtm_expr
($1, $3, $5); }
631 yyerror(@
1, "internal error: delay.");
634 $$
= new PENumber
(tmp
);
642 yyerror(@
1, "internal error: delay.");
645 $$
= new PEFNumber
(tmp
);
650 { PEIdent
*tmp
= new PEIdent
(lex_strings.make
($1));
660 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')'
661 { perm_string tmp3
= lex_strings.make
($3);
662 pform_set_type_attrib
(tmp3
, $5, $7);
669 : '(' dr_strength0
',' dr_strength1
')'
673 |
'(' dr_strength1
',' dr_strength0
')'
677 |
'(' dr_strength0
',' K_highz1
')'
679 $$.str1
= PGate
::HIGHZ
;
681 |
'(' dr_strength1
',' K_highz0
')'
682 { $$.str0
= PGate
::HIGHZ
;
685 |
'(' K_highz1
',' dr_strength0
')'
687 $$.str1
= PGate
::HIGHZ
;
689 |
'(' K_highz0
',' dr_strength1
')'
690 { $$.str0
= PGate
::HIGHZ
;
696 : drive_strength
{ $$
= $1; }
697 |
{ $$.str0
= PGate
::STRONG
; $$.str1
= PGate
::STRONG
; }
701 : K_supply0
{ $$.str0
= PGate
::SUPPLY
; }
702 | K_strong0
{ $$.str0
= PGate
::STRONG
; }
703 | K_pull0
{ $$.str0
= PGate
::PULL
; }
704 | K_weak0
{ $$.str0
= PGate
::WEAK
; }
708 : K_supply1
{ $$.str1
= PGate
::SUPPLY
; }
709 | K_strong1
{ $$.str1
= PGate
::STRONG
; }
710 | K_pull1
{ $$.str1
= PGate
::PULL
; }
711 | K_weak1
{ $$.str1
= PGate
::WEAK
; }
715 : '@' hierarchy_identifier
716 { PEIdent
*tmpi
= new PEIdent
(*$2);
717 PEEvent
*tmpe
= new PEEvent
(PEEvent
::ANYEDGE
, tmpi
);
718 PEventStatement
*tmps
= new PEventStatement
(tmpe
);
723 |
'@' '(' event_expression_list
')'
724 { PEventStatement
*tmp
= new PEventStatement
(*$3);
730 { yyerror(@
1, "error: Malformed event control expression.");
735 event_expression_list
738 | event_expression_list K_or event_expression
739 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
744 | event_expression_list
',' event_expression
745 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
753 : K_posedge expression
754 { PEEvent
*tmp
= new PEEvent
(PEEvent
::POSEDGE
, $2);
756 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
760 | K_negedge expression
761 { PEEvent
*tmp
= new PEEvent
(PEEvent
::NEGEDGE
, $2);
763 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
768 { PEEvent
*tmp
= new PEEvent
(PEEvent
::ANYEDGE
, $1);
770 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
779 |
'+' expr_primary %prec UNARY_PREC
781 |
'-' expr_primary %prec UNARY_PREC
782 { PEUnary
*tmp
= new PEUnary
('-', $2);
786 |
'~' expr_primary %prec UNARY_PREC
787 { PEUnary
*tmp
= new PEUnary
('~', $2);
791 |
'&' expr_primary %prec UNARY_PREC
792 { PEUnary
*tmp
= new PEUnary
('&', $2);
796 |
'!' expr_primary %prec UNARY_PREC
797 { PEUnary
*tmp
= new PEUnary
('!', $2);
801 |
'|' expr_primary %prec UNARY_PREC
802 { PEUnary
*tmp
= new PEUnary
('|', $2);
806 |
'^' expr_primary %prec UNARY_PREC
807 { PEUnary
*tmp
= new PEUnary
('^', $2);
811 | K_NAND expr_primary %prec UNARY_PREC
812 { PEUnary
*tmp
= new PEUnary
('A', $2);
816 | K_NOR expr_primary %prec UNARY_PREC
817 { PEUnary
*tmp
= new PEUnary
('N', $2);
821 | K_NXOR expr_primary %prec UNARY_PREC
822 { PEUnary
*tmp
= new PEUnary
('X', $2);
826 |
'!' error %prec UNARY_PREC
827 { yyerror(@
1, "error: Operand of unary ! "
828 "is not a primary expression.");
831 |
'^' error %prec UNARY_PREC
832 { yyerror(@
1, "error: Operand of reduction ^ "
833 "is not a primary expression.");
836 | expression
'^' expression
837 { PEBinary
*tmp
= new PEBinary
('^', $1, $3);
841 | expression K_POW expression
842 { PEBinary
*tmp
= new PEBinary
('p', $1, $3);
846 | expression
'*' expression
847 { PEBinary
*tmp
= new PEBinary
('*', $1, $3);
851 | expression
'/' expression
852 { PEBinary
*tmp
= new PEBinary
('/', $1, $3);
856 | expression
'%' expression
857 { PEBinary
*tmp
= new PEBinary
('%', $1, $3);
861 | expression
'+' expression
862 { PEBinary
*tmp
= new PEBinary
('+', $1, $3);
866 | expression
'-' expression
867 { PEBinary
*tmp
= new PEBinary
('-', $1, $3);
871 | expression
'&' expression
872 { PEBinary
*tmp
= new PEBinary
('&', $1, $3);
876 | expression
'|' expression
877 { PEBinary
*tmp
= new PEBinary
('|', $1, $3);
881 | expression K_NAND expression
882 { PEBinary
*tmp
= new PEBinary
('A', $1, $3);
886 | expression K_NOR expression
887 { PEBinary
*tmp
= new PEBinary
('O', $1, $3);
891 | expression K_NXOR expression
892 { PEBinary
*tmp
= new PEBinary
('X', $1, $3);
896 | expression
'<' expression
897 { PEBinary
*tmp
= new PEBComp
('<', $1, $3);
901 | expression
'>' expression
902 { PEBinary
*tmp
= new PEBComp
('>', $1, $3);
906 | expression K_LS expression
907 { PEBinary
*tmp
= new PEBShift
('l', $1, $3);
911 | expression K_RS expression
912 { PEBinary
*tmp
= new PEBShift
('r', $1, $3);
916 | expression K_RSS expression
917 { PEBinary
*tmp
= new PEBShift
('R', $1, $3);
921 | expression K_EQ expression
922 { PEBinary
*tmp
= new PEBComp
('e', $1, $3);
926 | expression K_CEQ expression
927 { PEBinary
*tmp
= new PEBComp
('E', $1, $3);
931 | expression K_LE expression
932 { PEBinary
*tmp
= new PEBComp
('L', $1, $3);
936 | expression K_GE expression
937 { PEBinary
*tmp
= new PEBComp
('G', $1, $3);
941 | expression K_NE expression
942 { PEBinary
*tmp
= new PEBComp
('n', $1, $3);
946 | expression K_CNE expression
947 { PEBinary
*tmp
= new PEBComp
('N', $1, $3);
951 | expression K_LOR expression
952 { PEBinary
*tmp
= new PEBinary
('o', $1, $3);
956 | expression K_LAND expression
957 { PEBinary
*tmp
= new PEBinary
('a', $1, $3);
961 | expression
'?' expression
':' expression
962 { PETernary
*tmp
= new PETernary
($1, $3, $5);
971 | expression
':' expression
':' expression
972 { switch
(min_typ_max_flag
) {
989 if
(min_typ_max_warn
> 0) {
990 cerr
<< $$
->get_fileline
() << ": warning: choosing ";
991 switch
(min_typ_max_flag
) {
1002 cerr
<< " expression." << endl
;
1003 min_typ_max_warn
-= 1;
1009 /* Many contexts take a comma separated list of expressions. Null
1010 expressions can happen anywhere in the list, so there are two
1011 extra rules in expression_list_with_nuls for parsing and
1012 installing those nulls.
1014 The expression_list_proper rules do not allow null items in the
1015 expression list, so can be used where nul expressions are not allowed. */
1017 expression_list_with_nuls
1018 : expression_list_with_nuls
',' expression
1019 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
1024 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1029 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1034 | expression_list_with_nuls
','
1035 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, 0);
1041 expression_list_proper
1042 : expression_list_proper
',' expression
1043 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
1048 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1057 PENumber
*tmp
= new PENumber
($1);
1062 { PEFNumber
*tmp
= new PEFNumber
($1);
1067 { PEString
*tmp
= new PEString
($1);
1072 { perm_string tn
= lex_strings.make
($1);
1073 PECallFunction
*tmp
= new PECallFunction
(tn
);
1079 /* The hierarchy_identifier rule matches simple identifiers as well as
1080 indexed arrays and part selects */
1082 | hierarchy_identifier
1083 { PEIdent
*tmp
= new PEIdent
(*$1);
1089 /* An identifier followed by an expression list in parentheses is a
1090 function call. If a system identifier, then a system function
1093 | hierarchy_identifier
'(' expression_list_proper
')'
1094 { PECallFunction
*tmp
= new PECallFunction
(*$1, *$3);
1099 | SYSTEM_IDENTIFIER
'(' expression_list_proper
')'
1100 { perm_string tn
= lex_strings.make
($1);
1101 PECallFunction
*tmp
= new PECallFunction
(tn
, *$3);
1107 /* Many of the VAMS built-in functions are available as builtin
1108 functions with $system_function equivilents. */
1110 | K_acos
'(' expression
')'
1111 { perm_string tn
= perm_string
::literal
("$acos");
1112 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1117 | K_acosh
'(' expression
')'
1118 { perm_string tn
= perm_string
::literal
("$acosh");
1119 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1124 | K_asin
'(' expression
')'
1125 { perm_string tn
= perm_string
::literal
("$asin");
1126 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1131 | K_asinh
'(' expression
')'
1132 { perm_string tn
= perm_string
::literal
("$asinh");
1133 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1138 | K_atan
'(' expression
')'
1139 { perm_string tn
= perm_string
::literal
("$atan");
1140 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1145 | K_atanh
'(' expression
')'
1146 { perm_string tn
= perm_string
::literal
("$atanh");
1147 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1152 | K_atan2
'(' expression
',' expression
')'
1153 { perm_string tn
= perm_string
::literal
("$atan2");
1154 PECallFunction
*tmp
= make_call_function
(tn
, $3, $5);
1159 | K_ceil
'(' expression
')'
1160 { perm_string tn
= perm_string
::literal
("$ceil");
1161 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1166 | K_cos
'(' expression
')'
1167 { perm_string tn
= perm_string
::literal
("$cos");
1168 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1173 | K_cosh
'(' expression
')'
1174 { perm_string tn
= perm_string
::literal
("$cosh");
1175 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1180 | K_exp
'(' expression
')'
1181 { perm_string tn
= perm_string
::literal
("$exp");
1182 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1187 | K_floor
'(' expression
')'
1188 { perm_string tn
= perm_string
::literal
("$floor");
1189 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1194 | K_hypot
'(' expression
',' expression
')'
1195 { perm_string tn
= perm_string
::literal
("$hypot");
1196 PECallFunction
*tmp
= make_call_function
(tn
, $3, $5);
1201 | K_ln
'(' expression
')'
1202 { perm_string tn
= perm_string
::literal
("$ln");
1203 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1208 | K_log
'(' expression
')'
1209 { perm_string tn
= perm_string
::literal
("$log10");
1210 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1215 | K_pow
'(' expression
',' expression
')'
1216 { perm_string tn
= perm_string
::literal
("$pow");
1217 PECallFunction
*tmp
= make_call_function
(tn
, $3, $5);
1222 | K_sin
'(' expression
')'
1223 { perm_string tn
= perm_string
::literal
("$sin");
1224 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1229 | K_sinh
'(' expression
')'
1230 { perm_string tn
= perm_string
::literal
("$sinh");
1231 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1236 | K_sqrt
'(' expression
')'
1237 { perm_string tn
= perm_string
::literal
("$sqrt");
1238 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1243 | K_tan
'(' expression
')'
1244 { perm_string tn
= perm_string
::literal
("$tan");
1245 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1250 | K_tanh
'(' expression
')'
1251 { perm_string tn
= perm_string
::literal
("$tanh");
1252 PECallFunction
*tmp
= make_call_function
(tn
, $3);
1257 /* These mathematical functions are conveniently expressed as unary
1258 and binary expressions. They behave much like unary/binary
1259 operators, even though they are parsed as functions. */
1261 | K_abs
'(' expression
')'
1262 { PEUnary
*tmp
= new PEUnary
('m', $3);
1267 | K_max
'(' expression
',' expression
')'
1268 { PEBinary
*tmp
= new PEBinary
('M', $3, $5);
1273 | K_min
'(' expression
',' expression
')'
1274 { PEBinary
*tmp
= new PEBinary
('m', $3, $5);
1279 /* Parenthesized expressions are primaries. */
1281 |
'(' expr_mintypmax
')'
1284 /* Various kinds of concatenation expressions. */
1286 |
'{' expression_list_proper
'}'
1287 { PEConcat
*tmp
= new PEConcat
(*$2);
1292 |
'{' expression
'{' expression_list_proper
'}' '}'
1294 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1299 |
'{' expression
'{' expression_list_proper
'}' error '}'
1301 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1305 yyerror(@
5, "error: Syntax error between internal '}' "
1306 "and closing '}' of repeat concatenation.");
1311 /* A function_item_list borrows the task_port_item run to match
1312 declarations of ports. We check later to make sure there are no
1313 output or inout ports actually used. */
1317 | function_item_list function_item
1319 svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
1338 /* A gate_instance is a module instantiation or a built in part
1339 type. In any case, the gate has a set of connections to ports. */
1341 : IDENTIFIER
'(' expression_list_with_nuls
')'
1342 { lgate
*tmp
= new lgate
;
1345 tmp
->file
= @
1.text
;
1346 tmp
->lineno
= @
1.first_line
;
1351 | IDENTIFIER range
'(' expression_list_with_nuls
')'
1352 { lgate
*tmp
= new lgate
;
1353 svector
<PExpr
*>*rng
= $2;
1356 tmp
->range
[0] = (*rng
)[0];
1357 tmp
->range
[1] = (*rng
)[1];
1358 tmp
->file
= @
1.text
;
1359 tmp
->lineno
= @
1.first_line
;
1364 |
'(' expression_list_with_nuls
')'
1365 { lgate
*tmp
= new lgate
;
1368 tmp
->file
= @
1.text
;
1369 tmp
->lineno
= @
1.first_line
;
1373 /* Degenerate modules can have no ports. */
1376 { lgate
*tmp
= new lgate
;
1377 svector
<PExpr
*>*rng
= $2;
1380 tmp
->parms_by_name
= 0;
1381 tmp
->range
[0] = (*rng
)[0];
1382 tmp
->range
[1] = (*rng
)[1];
1383 tmp
->file
= @
1.text
;
1384 tmp
->lineno
= @
1.first_line
;
1390 /* Modules can also take ports by port-name expressions. */
1392 | IDENTIFIER
'(' port_name_list
')'
1393 { lgate
*tmp
= new lgate
;
1396 tmp
->parms_by_name
= $3;
1397 tmp
->file
= @
1.text
;
1398 tmp
->lineno
= @
1.first_line
;
1403 | IDENTIFIER range
'(' port_name_list
')'
1404 { lgate
*tmp
= new lgate
;
1405 svector
<PExpr
*>*rng
= $2;
1408 tmp
->parms_by_name
= $4;
1409 tmp
->range
[0] = (*rng
)[0];
1410 tmp
->range
[1] = (*rng
)[1];
1411 tmp
->file
= @
1.text
;
1412 tmp
->lineno
= @
1.first_line
;
1420 : gate_instance_list
',' gate_instance
1421 { svector
<lgate
>*tmp1
= $1;
1423 svector
<lgate
>*out
= new svector
<lgate
> (*tmp1
, *tmp2
);
1429 { svector
<lgate
>*tmp
= new svector
<lgate
>(1);
1437 : K_and
{ $$
= PGBuiltin
::AND
; }
1438 | K_nand
{ $$
= PGBuiltin
::NAND
; }
1439 | K_or
{ $$
= PGBuiltin
::OR
; }
1440 | K_nor
{ $$
= PGBuiltin
::NOR
; }
1441 | K_xor
{ $$
= PGBuiltin
::XOR
; }
1442 | K_xnor
{ $$
= PGBuiltin
::XNOR
; }
1443 | K_buf
{ $$
= PGBuiltin
::BUF
; }
1444 | K_bufif0
{ $$
= PGBuiltin
::BUFIF0
; }
1445 | K_bufif1
{ $$
= PGBuiltin
::BUFIF1
; }
1446 | K_not
{ $$
= PGBuiltin
::NOT
; }
1447 | K_notif0
{ $$
= PGBuiltin
::NOTIF0
; }
1448 | K_notif1
{ $$
= PGBuiltin
::NOTIF1
; }
1449 | K_nmos
{ $$
= PGBuiltin
::NMOS
; }
1450 | K_rnmos
{ $$
= PGBuiltin
::RNMOS
; }
1451 | K_pmos
{ $$
= PGBuiltin
::PMOS
; }
1452 | K_rpmos
{ $$
= PGBuiltin
::RPMOS
; }
1453 | K_cmos
{ $$
= PGBuiltin
::CMOS
; }
1454 | K_rcmos
{ $$
= PGBuiltin
::RCMOS
; }
1455 | K_tran
{ $$
= PGBuiltin
::TRAN
; }
1456 | K_rtran
{ $$
= PGBuiltin
::RTRAN
; }
1457 | K_tranif0
{ $$
= PGBuiltin
::TRANIF0
; }
1458 | K_tranif1
{ $$
= PGBuiltin
::TRANIF1
; }
1459 | K_rtranif0
{ $$
= PGBuiltin
::RTRANIF0
; }
1460 | K_rtranif1
{ $$
= PGBuiltin
::RTRANIF1
; }
1464 /* A general identifier is a hierarchical name, with the right most
1465 name the base of the identifier. This rule builds up a
1466 hierarchical name from the left to the right, forming a list of
1469 hierarchy_identifier
1471 { $$
= new pform_name_t
;
1472 $$
->push_back
(name_component_t
(lex_strings.make
($1)));
1475 | hierarchy_identifier
'.' IDENTIFIER
1476 { pform_name_t
* tmp
= $1;
1477 tmp
->push_back
(name_component_t
(lex_strings.make
($3)));
1481 | hierarchy_identifier
'[' expression
']'
1482 { pform_name_t
* tmp
= $1;
1483 name_component_t
&tail
= tmp
->back
();
1484 index_component_t itmp
;
1485 itmp.sel
= index_component_t
::SEL_BIT
;
1487 tail.index.push_back
(itmp
);
1490 | hierarchy_identifier
'[' expression
':' expression
']'
1491 { pform_name_t
* tmp
= $1;
1492 name_component_t
&tail
= tmp
->back
();
1493 index_component_t itmp
;
1494 itmp.sel
= index_component_t
::SEL_PART
;
1497 tail.index.push_back
(itmp
);
1500 | hierarchy_identifier
'[' expression K_PO_POS expression
']'
1501 { pform_name_t
* tmp
= $1;
1502 name_component_t
&tail
= tmp
->back
();
1503 index_component_t itmp
;
1504 itmp.sel
= index_component_t
::SEL_IDX_UP
;
1507 tail.index.push_back
(itmp
);
1510 | hierarchy_identifier
'[' expression K_PO_NEG expression
']'
1511 { pform_name_t
* tmp
= $1;
1512 name_component_t
&tail
= tmp
->back
();
1513 index_component_t itmp
;
1514 itmp.sel
= index_component_t
::SEL_IDX_DO
;
1517 tail.index.push_back
(itmp
);
1522 /* This is a list of identifiers. The result is a list of strings,
1523 each one of the identifiers in the list. These are simple,
1524 non-hierarchical names separated by ',' characters. */
1527 { $$
= list_from_identifier
($1); }
1528 | list_of_identifiers
',' IDENTIFIER
1529 { $$
= list_from_identifier
($1, $3); }
1533 /* The list_of_ports and list_of_port_declarations rules are the
1534 port list formats for module ports. The list_of_ports_opt rule is
1535 only used by the module start rule.
1537 The first, the list_of_ports, is the 1364-1995 format, a list of
1538 port names, including .name() syntax.
1540 The list_of_port_declarations the 1364-2001 format, an in-line
1541 declaration of the ports.
1543 In both cases, the list_of_ports and list_of_port_declarations
1544 returns an array of Module::port_t* items that include the name
1545 of the port internally and externally. The actual creation of the
1546 nets/variables is done in the declaration, whether internal to
1547 the port list or in amongst the module items. */
1551 { svector
<Module
::port_t
*>*tmp
1552 = new svector
<Module
::port_t
*>(1);
1556 | list_of_ports
',' port_opt
1557 { svector
<Module
::port_t
*>*tmp
1558 = new svector
<Module
::port_t
*>(*$1, $3);
1564 list_of_port_declarations
1566 { svector
<Module
::port_t
*>*tmp
1567 = new svector
<Module
::port_t
*>(1);
1571 | list_of_port_declarations
',' port_declaration
1572 { svector
<Module
::port_t
*>*tmp
1573 = new svector
<Module
::port_t
*>(*$1, $3);
1577 | list_of_port_declarations
',' IDENTIFIER
1578 { Module
::port_t
*ptmp
;
1579 perm_string name
= lex_strings.make
($3);
1580 ptmp
= pform_module_port_reference
(name
, @
3.text
,
1582 svector
<Module
::port_t
*>*tmp
1583 = new svector
<Module
::port_t
*>(*$1, ptmp
);
1585 /* Get the port declaration details, the port type
1586 and what not, from context data stored by the
1587 last port_declaration rule. */
1588 pform_module_define_port
(@
3, name
,
1589 port_declaration_context.port_type
,
1590 port_declaration_context.port_net_type
,
1591 port_declaration_context.sign_flag
,
1592 port_declaration_context.range
, 0);
1597 | list_of_port_declarations
','
1599 yyerror(@
2, "error: NULL port declarations are not "
1602 | list_of_port_declarations
';'
1604 yyerror(@
2, "error: ';' is an invalid port declaration "
1610 : attribute_list_opt
1611 K_input net_type_opt signed_opt range_opt IDENTIFIER
1612 { Module
::port_t
*ptmp
;
1613 perm_string name
= lex_strings.make
($6);
1614 ptmp
= pform_module_port_reference
(name
, @
2.text
,
1616 pform_module_define_port
(@
2, name
, NetNet
::PINPUT
,
1618 port_declaration_context.port_type
= NetNet
::PINPUT
;
1619 port_declaration_context.port_net_type
= $3;
1620 port_declaration_context.sign_flag
= $4;
1621 delete port_declaration_context.range
;
1622 port_declaration_context.range
= $5;
1627 | attribute_list_opt
1628 K_inout net_type_opt signed_opt range_opt IDENTIFIER
1629 { Module
::port_t
*ptmp
;
1630 perm_string name
= lex_strings.make
($6);
1631 ptmp
= pform_module_port_reference
(name
, @
2.text
,
1633 pform_module_define_port
(@
2, name
, NetNet
::PINOUT
,
1635 port_declaration_context.port_type
= NetNet
::PINOUT
;
1636 port_declaration_context.port_net_type
= $3;
1637 port_declaration_context.sign_flag
= $4;
1638 delete port_declaration_context.range
;
1639 port_declaration_context.range
= $5;
1644 | attribute_list_opt
1645 K_output net_type_opt signed_opt range_opt IDENTIFIER
1646 { Module
::port_t
*ptmp
;
1647 perm_string name
= lex_strings.make
($6);
1648 ptmp
= pform_module_port_reference
(name
, @
2.text
,
1650 pform_module_define_port
(@
2, name
, NetNet
::POUTPUT
,
1652 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1653 port_declaration_context.port_net_type
= $3;
1654 port_declaration_context.sign_flag
= $4;
1655 delete port_declaration_context.range
;
1656 port_declaration_context.range
= $5;
1661 | attribute_list_opt
1662 K_output var_type signed_opt range_opt IDENTIFIER
1663 { Module
::port_t
*ptmp
;
1664 perm_string name
= lex_strings.make
($6);
1665 ptmp
= pform_module_port_reference
(name
, @
2.text
,
1667 pform_module_define_port
(@
2, name
, NetNet
::POUTPUT
,
1669 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1670 port_declaration_context.port_net_type
= $3;
1671 port_declaration_context.sign_flag
= $4;
1672 delete port_declaration_context.range
;
1673 port_declaration_context.range
= $5;
1678 | attribute_list_opt
1679 K_output var_type signed_opt range_opt IDENTIFIER
'=' expression
1680 { Module
::port_t
*ptmp
;
1681 perm_string name
= lex_strings.make
($6);
1682 ptmp
= pform_module_port_reference
(name
, @
2.text
,
1684 pform_module_define_port
(@
2, name
, NetNet
::POUTPUT
,
1686 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1687 port_declaration_context.port_net_type
= $3;
1688 port_declaration_context.sign_flag
= $4;
1689 delete port_declaration_context.range
;
1690 port_declaration_context.range
= $5;
1692 if
(! pform_expression_is_constant
($8))
1693 yyerror(@
8, "error: register declaration assignment"
1694 " value must be a constant expression.");
1695 pform_make_reginit
(@
6, name
, $8);
1706 : net_type
{ $$
= $1; }
1707 |
{ $$
= NetNet
::IMPLICIT
; }
1710 signed_opt
: K_signed
{ $$
= true
; } |
{$$
= false
; } ;
1712 /* An lpvalue is the expression that can go on the left side of a
1713 procedural assignment. This rule handles only procedural
1714 assignments. It is more limited then the general expr_primary
1715 rule to reflect the rules for assignment l-values. */
1717 : hierarchy_identifier
1718 { PEIdent
*tmp
= new PEIdent
(*$1);
1723 |
'{' expression_list_proper
'}'
1724 { PEConcat
*tmp
= new PEConcat
(*$2);
1732 /* Continuous assignments have a list of individual assignments. */
1735 : lpvalue
'=' expression
1736 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
1744 : cont_assign_list
',' cont_assign
1745 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, *$3);
1755 /* This is the global structure of a module. A module in a start
1756 section, with optional ports, then an optional list of module
1757 items, and finally an end marker. */
1759 module
: attribute_list_opt module_start IDENTIFIER
1760 { pform_startmodule
($3, @
2.text
, @
2.first_line
, $1); }
1761 module_parameter_port_list_opt
1762 module_port_list_opt
';'
1763 { pform_module_set_ports
($6); }
1764 module_item_list_opt
1766 { pform_endmodule
($3);
1772 module_start
: K_module | K_macromodule
;
1774 module_port_list_opt
1775 : '(' list_of_ports
')' { $$
= $2; }
1776 |
'(' list_of_port_declarations
')' { $$
= $2; }
1780 /* Module declarations include optional ANSI style module parameter
1781 ports. These are simply advance ways to declare parameters, so
1782 that the port declarations may use them. */
1783 module_parameter_port_list_opt
1785 |
'#' '(' module_parameter_port_list
')'
1788 module_parameter_port_list
1789 : K_parameter parameter_assign
1790 | module_parameter_port_list
',' parameter_assign
1791 | module_parameter_port_list
',' K_parameter parameter_assign
1796 /* This rule detects net declarations that possibly include a
1797 primitive type, an optional vector range and signed flag. This
1798 also includes an optional delay set. The values are then applied
1799 to a list of names. If the primitive type is not specified, then
1800 resort to the default type LOGIC. */
1802 : attribute_list_opt net_type
1803 primitive_type_opt signed_opt range_opt
1805 net_variable_list
';'
1807 { ivl_variable_type_t dtype
= $3;
1808 if
(dtype
== IVL_VT_NO_TYPE
)
1809 dtype
= IVL_VT_LOGIC
;
1810 pform_makewire
(@
2, $5, $4, $7, $2,
1811 NetNet
::NOT_A_PORT
, dtype
, $1);
1813 yyerror(@
6, "sorry: net delays not supported.");
1819 /* Very similar to the rule above, but this takes a list of
1820 net_decl_assigns, which are <name> = <expr> assignment
1823 | attribute_list_opt net_type
1824 primitive_type_opt signed_opt range_opt
1825 delay3_opt net_decl_assigns
';'
1827 { ivl_variable_type_t dtype
= $3;
1828 if
(dtype
== IVL_VT_NO_TYPE
)
1829 dtype
= IVL_VT_LOGIC
;
1830 pform_makewire
(@
2, $5, $4, $6,
1831 str_strength
, $7, $2, dtype
);
1833 yyerror(@
2, "sorry: Attributes not supported "
1834 "on net declaration assignments.");
1839 /* This form doesn't have the range, but does have strengths. This
1840 gives strength to the assignment drivers. */
1842 | attribute_list_opt net_type
1843 primitive_type_opt signed_opt
1844 drive_strength net_decl_assigns
';'
1846 { ivl_variable_type_t dtype
= $3;
1847 if
(dtype
== IVL_VT_NO_TYPE
)
1848 dtype
= IVL_VT_LOGIC
;
1849 pform_makewire
(@
2, 0, $4, 0, $5, $6, $2, dtype
);
1851 yyerror(@
2, "sorry: Attributes not supported "
1852 "on net declaration assignments.");
1857 | K_trireg charge_strength_opt range_opt delay3_opt list_of_identifiers
';'
1858 { yyerror(@
1, "sorry: trireg nets not supported.");
1863 | port_type signed_opt range_opt delay3_opt list_of_identifiers
';'
1864 { pform_set_port_type
(@
1, $5, $3, $2, $1);
1867 /* The next two rules handle Verilog 2001 statements of the form:
1868 input wire signed [h:l] <list>;
1869 This creates the wire and sets the port type all at once. */
1871 | port_type net_type signed_opt range_opt list_of_identifiers
';'
1872 { pform_makewire
(@
1, $4, $3, $5, $2, $1, IVL_VT_NO_TYPE
, 0,
1876 | K_output var_type signed_opt range_opt list_of_identifiers
';'
1877 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::POUTPUT
,
1878 IVL_VT_NO_TYPE
, 0, SR_BOTH
);
1881 /* var_type declaration (reg variables) cannot be input or output,
1882 because the port declaration implies an external driver, which
1883 cannot be attached to a reg. These rules catch that error early. */
1885 | K_input var_type signed_opt range_opt list_of_identifiers
';'
1886 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINPUT
,
1888 yyerror(@
2, "error: reg variables cannot be inputs.");
1891 | K_inout var_type signed_opt range_opt list_of_identifiers
';'
1892 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINOUT
,
1894 yyerror(@
2, "error: reg variables cannot be inouts.");
1897 | port_type signed_opt range_opt delay3_opt
error ';'
1898 { yyerror(@
1, "error: Invalid variable list"
1899 " in port declaration.");
1905 /* block_item_decl rule is shared with task blocks and named
1912 | K_defparam defparam_assign_list
';'
1913 | K_event list_of_identifiers
';'
1914 { pform_make_events
($2, @
1.text
, @
1.first_line
);
1917 /* Most gate types have an optional drive strength and optional
1918 three-value delay. These rules handle the different cases. */
1920 | attribute_list_opt gatetype gate_instance_list
';'
1921 { pform_makegates
($2, str_strength
, 0, $3, $1);
1924 | attribute_list_opt gatetype delay3 gate_instance_list
';'
1925 { pform_makegates
($2, str_strength
, $3, $4, $1);
1928 | attribute_list_opt gatetype drive_strength gate_instance_list
';'
1929 { pform_makegates
($2, $3, 0, $4, $1);
1932 | attribute_list_opt gatetype drive_strength delay3 gate_instance_list
';'
1933 { pform_makegates
($2, $3, $4, $5, $1);
1936 /* Pullup and pulldown devices cannot have delays, and their
1937 strengths are limited. */
1939 | K_pullup gate_instance_list
';'
1940 { pform_makegates
(PGBuiltin
::PULLUP
, pull_strength
, 0,
1943 | K_pulldown gate_instance_list
';'
1944 { pform_makegates
(PGBuiltin
::PULLDOWN
, pull_strength
,
1948 | K_pullup
'(' dr_strength1
')' gate_instance_list
';'
1949 { pform_makegates
(PGBuiltin
::PULLUP
, $3, 0, $5, 0);
1952 | K_pulldown
'(' dr_strength0
')' gate_instance_list
';'
1953 { pform_makegates
(PGBuiltin
::PULLDOWN
, $3, 0, $5, 0);
1956 /* This rule handles instantiations of modules and user defined
1957 primitives. These devices to not have delay lists or strengths,
1958 but then can have parameter lists. */
1960 | attribute_list_opt
1961 IDENTIFIER parameter_value_opt gate_instance_list
';'
1962 { perm_string tmp1
= lex_strings.make
($2);
1963 pform_make_modgates
(tmp1
, $3, $4);
1968 | attribute_list_opt
1969 IDENTIFIER parameter_value_opt
error ';'
1970 { yyerror(@
2, "error: Invalid module instantiation");
1975 /* Continuous assignment can have an optional drive strength, then
1976 an optional delay3 that applies to all the assignments in the
1977 cont_assign_list. */
1979 | K_assign drive_strength_opt delay3_opt cont_assign_list
';'
1980 { pform_make_pgassign_list
($4, $3, $2, @
1.text
, @
1.first_line
); }
1982 /* Always and initial items are behavioral processes. */
1984 | attribute_list_opt K_always statement
1985 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_ALWAYS
,
1989 | attribute_list_opt K_initial statement
1990 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_INITIAL
,
1995 /* The task declaration rule matches the task declaration
1996 header, then pushes the function scope. This causes the
1997 definitions in the task_body to take on the scope of the task
1998 instead of the module. Note that these runs accept for the task
1999 body statement_or_null, although the standard does not allow null
2000 statements in the task body. But we continue to accept it as an
2003 | K_task IDENTIFIER
';'
2004 { assert
(current_task
== 0);
2005 current_task
= pform_push_task_scope
($2);
2006 FILE_NAME
(current_task
, @
1);
2011 { current_task
->set_ports
($5);
2012 current_task
->set_statement
($6);
2019 { assert
(current_task
== 0);
2020 current_task
= pform_push_task_scope
($2);
2021 FILE_NAME
(current_task
, @
1);
2023 '(' task_port_decl_list
')' ';'
2024 block_item_decls_opt
2027 { current_task
->set_ports
($5);
2028 current_task
->set_statement
($9);
2033 | K_task IDENTIFIER
error K_endtask
2040 /* The function declaration rule matches the function declaration
2041 header, then pushes the function scope. This causes the
2042 definitions in the func_body to take on the scope of the function
2043 instead of the module. */
2045 | K_function function_range_or_type_opt IDENTIFIER
';'
2046 { assert
(current_function
== 0);
2047 current_function
= pform_push_function_scope
($3);
2048 FILE_NAME
(current_function
, @
1);
2050 function_item_list statement
2052 { current_function
->set_ports
($6);
2053 current_function
->set_statement
($7);
2054 current_function
->set_return
($2);
2056 current_function
= 0;
2060 | K_function function_range_or_type_opt IDENTIFIER
2061 { assert
(current_function
== 0);
2062 current_function
= pform_push_function_scope
($3);
2063 FILE_NAME
(current_function
, @
1);
2065 '(' task_port_decl_list
')' ';'
2066 block_item_decls_opt
2069 { current_function
->set_ports
($6);
2070 current_function
->set_statement
($10);
2071 current_function
->set_return
($2);
2073 current_function
= 0;
2076 | K_function function_range_or_type_opt IDENTIFIER
error K_endfunction
2083 /* A generate region can contain further module items. Actually, it
2084 is supposed to be limited to certain kinds of module items, but
2085 the semantic tests will check that for us. */
2087 | K_generate module_item_list_opt K_endgenerate
2089 | K_genvar list_of_identifiers
';'
2090 { pform_genvars
(@
1, $2); }
2092 | K_for
'(' IDENTIFIER
'=' expression
';'
2094 IDENTIFIER
'=' expression
')'
2095 { pform_start_generate_for
(@
1, $3, $5, $7, $9, $11); }
2097 { pform_endgenerate
(); }
2102 { pform_start_generate_else
(@
1); }
2104 { pform_endgenerate
(); }
2107 generate_block_opt %prec less_than_K_else
2108 { pform_endgenerate
(); }
2110 | K_case
'(' expression
')'
2111 { pform_start_generate_case
(@
1, $3); }
2114 { pform_endgenerate
(); }
2116 /* specify blocks are parsed but ignored. */
2118 | K_specify K_endspecify
2119 { /* empty lists are legal syntax. */ }
2121 | K_specify specify_item_list K_endspecify
2125 | K_specify
error K_endspecify
2126 { yyerror(@
1, "error: syntax error in specify block");
2130 /* These rules match various errors that the user can type into
2131 module items. These rules try to catch them at a point where a
2132 reasonable error message can be produced. */
2134 | K_module
error ';'
2135 { yyerror(@
1, "error: missing endmodule or attempt to "
2137 pform_error_nested_modules
();
2142 { yyerror(@
2, "error: invalid module item.");
2146 | K_assign
error '=' expression
';'
2147 { yyerror(@
1, "error: syntax error in left side "
2148 "of continuous assignment.");
2152 | K_assign
error ';'
2153 { yyerror(@
1, "error: syntax error in "
2154 "continuous assignment");
2158 | K_function
error K_endfunction
2159 { yyerror(@
1, "error: I give up on this "
2160 "function definition.");
2164 /* These rules are for the Icarus Verilog specific $attribute
2165 extensions. Then catch the parameters of the $attribute keyword. */
2167 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')' ';'
2168 { perm_string tmp3
= lex_strings.make
($3);
2169 perm_string tmp5
= lex_strings.make
($5);
2170 pform_set_attrib
(tmp3
, tmp5
, $7);
2174 | KK_attribute
'(' error ')' ';'
2175 { yyerror(@
1, "error: Malformed $attribute parameter list."); }
2178 generate_if
: K_if
'(' expression
')' { pform_start_generate_if
(@
1, $3); }
2181 : generate_case_items generate_case_item
2182 | generate_case_item
2186 : expression
':' { pform_generate_case_item
(@
1, $1); } generate_block
2187 { pform_endgenerate
(); }
2188 | K_default
':' { pform_generate_case_item
(@
1, 0); } generate_block
2189 { pform_endgenerate
(); }
2193 : module_item_list module_item
2197 module_item_list_opt
2202 /* A generate block is the thing within a generate scheme. It may be
2203 a single module item, an anonymous block of module items, or a
2204 named module item. In all cases, the meat is in the module items
2205 inside, and the processing is done by the module_item rules. We
2206 only need to take note here of the scope name, if any. */
2210 | K_begin module_item_list_opt K_end
2211 | K_begin
':' IDENTIFIER module_item_list_opt K_end
2212 { pform_generate_block_name
($3); }
2215 generate_block_opt
: generate_block |
';' ;
2218 /* A net declaration assignment allows the programmer to combine the
2219 net declaration and the continuous assignment into a single
2222 Note that the continuous assignment statement is generated as a
2223 side effect, and all I pass up is the name of the l-value. */
2226 : IDENTIFIER
'=' expression
2227 { net_decl_assign_t
*tmp
= new net_decl_assign_t
;
2229 tmp
->name
= lex_strings.make
($1);
2237 : net_decl_assigns
',' net_decl_assign
2238 { net_decl_assign_t
*tmp
= $1;
2239 $3->next
= tmp
->next
;
2249 : K_logic
{ $$
= IVL_VT_LOGIC
; }
2250 | K_bool
{ $$
= IVL_VT_BOOL
; }
2251 | K_real
{ $$
= IVL_VT_REAL
; }
2254 primitive_type_opt
: primitive_type
{ $$
= $1; } |
{ $$
= IVL_VT_NO_TYPE
; } ;
2257 : K_wire
{ $$
= NetNet
::WIRE
; }
2258 | K_tri
{ $$
= NetNet
::TRI
; }
2259 | K_tri1
{ $$
= NetNet
::TRI1
; }
2260 | K_supply0
{ $$
= NetNet
::SUPPLY0
; }
2261 | K_wand
{ $$
= NetNet
::WAND
; }
2262 | K_triand
{ $$
= NetNet
::TRIAND
; }
2263 | K_tri0
{ $$
= NetNet
::TRI0
; }
2264 | K_supply1
{ $$
= NetNet
::SUPPLY1
; }
2265 | K_wor
{ $$
= NetNet
::WOR
; }
2266 | K_trior
{ $$
= NetNet
::TRIOR
; }
2267 | K_wone
{ $$
= NetNet
::WONE
; }
2271 : K_reg
{ $$
= NetNet
::REG
; }
2274 /* In this rule we have matched the "parameter" keyword. The rule
2275 generates a type (optional) and a list of assignments. */
2277 parameter_assign_decl
2278 : parameter_assign_list
2279 | range
{ active_range
= $1; active_signed
= false
; }
2280 parameter_assign_list
2282 active_signed
= false
;
2284 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2285 parameter_assign_list
2287 active_signed
= false
;
2289 | K_integer
{ active_range
= 0; active_signed
= true
; }
2290 parameter_assign_list
2292 active_signed
= false
;
2296 parameter_assign_list
2298 | parameter_assign_list
',' parameter_assign
2302 : IDENTIFIER
'=' expression
2304 if
(!pform_expression_is_constant
(tmp
)) {
2305 yyerror(@
3, "error: parameter value "
2306 "must be a constant expression.");
2310 pform_set_parameter
(lex_strings.make
($1),
2313 @
1.text
, @
1.first_line
);
2319 /* Localparam assignments and assignment lists are broken into
2320 separate BNF so that I can call slightly different parameter
2321 handling code. They parse the same as parameters, they just
2322 behave differently when someone tries to override them. */
2325 : IDENTIFIER
'=' expression
2327 if
(!pform_expression_is_constant
(tmp
)) {
2328 yyerror(@
3, "error: parameter value "
2329 "must be constant.");
2333 pform_set_localparam
(lex_strings.make
($1),
2336 @
1.text
, @
1.first_line
);
2342 localparam_assign_decl
2343 : localparam_assign_list
2344 | range
{ active_range
= $1; active_signed
= false
; }
2345 localparam_assign_list
2347 active_signed
= false
;
2349 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2350 localparam_assign_list
2352 active_signed
= false
;
2354 | K_integer
{ active_range
= 0; active_signed
= true
; }
2355 localparam_assign_list
2357 active_signed
= false
;
2361 localparam_assign_list
2363 | localparam_assign_list
',' localparam_assign
2368 /* The parameters of a module instance can be overridden by writing
2369 a list of expressions in a syntax much like a delay list. (The
2370 difference being the list can have any length.) The pform that
2371 attaches the expression list to the module checks that the
2372 expressions are constant.
2374 Although the BNF in IEEE1364-1995 implies that parameter value
2375 lists must be in parentheses, in practice most compilers will
2376 accept simple expressions outside of parentheses if there is only
2377 one value, so I'll accept simple numbers here.
2379 The parameter value by name syntax is OVI enhancement BTF-B06 as
2380 approved by WG1364 on 6/28/1998. */
2383 : '#' '(' expression_list_with_nuls
')'
2384 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2389 |
'#' '(' parameter_value_byname_list
')'
2390 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2397 PENumber
*tmp
= new PENumber
($2);
2400 struct parmvalue_t
*lst
= new
struct parmvalue_t
;
2401 lst
->by_order
= new svector
<PExpr
*>(1);
2402 (*lst
->by_order
)[0] = tmp
;
2408 { yyerror(@
1, "error: syntax error in parameter value "
2409 "assignment list.");
2416 parameter_value_byname
2417 : '.' IDENTIFIER
'(' expression
')'
2418 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2419 tmp
->name
= lex_strings.make
($2);
2424 |
'.' IDENTIFIER
'(' ')'
2425 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2426 tmp
->name
= lex_strings.make
($2);
2433 parameter_value_byname_list
2434 : parameter_value_byname
2435 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2439 | parameter_value_byname_list
',' parameter_value_byname
2440 { svector
<named_pexpr_t
*>*tmp
=
2441 new svector
<named_pexpr_t
*>(*$1,$3);
2448 /* The port (of a module) is a fairly complex item. Each port is
2449 handled as a Module::port_t object. A simple port reference has a
2450 name and a PExpr object, but more complex constructs are possible
2451 where the name can be attached to a list of PWire objects.
2453 The port_reference returns a Module::port_t, and so does the
2454 port_reference_list. The port_reference_list may have built up a
2455 list of PWires in the port_t object, but it is still a single
2456 Module::port_t object.
2458 The port rule below takes the built up Module::port_t object and
2459 tweaks its name as needed. */
2465 /* This syntax attaches an external name to the port reference so
2466 that the caller can bind by name to non-trivial port
2467 references. The port_t object gets its PWire from the
2468 port_reference, but its name from the IDENTIFIER. */
2470 |
'.' IDENTIFIER
'(' port_reference
')'
2471 { Module
::port_t
*tmp
= $4;
2472 tmp
->name
= lex_strings.make
($2);
2477 /* A port can also be a concatenation of port references. In this
2478 case the port does not have a name available to the outside, only
2479 positional parameter passing is possible here. */
2481 |
'{' port_reference_list
'}'
2482 { Module
::port_t
*tmp
= $2;
2483 tmp
->name
= perm_string
();
2487 /* This attaches a name to a port reference concatenation list so
2488 that parameter passing be name is possible. */
2490 |
'.' IDENTIFIER
'(' '{' port_reference_list
'}' ')'
2491 { Module
::port_t
*tmp
= $5;
2492 tmp
->name
= lex_strings.make
($2);
2504 /* A port reference is an internal (to the module) name of the port,
2505 possibly with a part of bit select to attach it to specific bits
2506 of a signal fully declared inside the module.
2508 The parser creates a PEIdent for every port reference, even if the
2509 signal is bound to different ports. The elaboration figures out
2510 the mess that this creates. The port_reference (and the
2511 port_reference_list below) puts the port reference PEIdent into the
2512 port_t object to pass it up to the module declaration code. */
2517 { Module
::port_t
*ptmp
;
2518 perm_string name
= lex_strings.make
($1);
2519 ptmp
= pform_module_port_reference
(name
, @
1.text
, @
1.first_line
);
2524 | IDENTIFIER
'[' expression
':' expression
']'
2525 { if
(!pform_expression_is_constant
($3)) {
2526 yyerror(@
3, "error: msb expression of "
2527 "port part select must be constant.");
2529 if
(!pform_expression_is_constant
($5)) {
2530 yyerror(@
5, "error: lsb expression of "
2531 "port part select must be constant.");
2533 index_component_t itmp
;
2534 itmp.sel
= index_component_t
::SEL_PART
;
2538 name_component_t ntmp
(lex_strings.make
($1));
2539 ntmp.index.push_back
(itmp
);
2542 pname.push_back
(ntmp
);
2544 PEIdent
*wtmp
= new PEIdent
(pname
);
2545 FILE_NAME
(wtmp
, @
1);
2547 Module
::port_t
*ptmp
= new Module
::port_t
;
2548 ptmp
->name
= perm_string
();
2549 ptmp
->expr
= svector
<PEIdent
*>(1);
2550 ptmp
->expr
[0] = wtmp
;
2556 | IDENTIFIER
'[' expression
']'
2557 { if
(!pform_expression_is_constant
($3)) {
2558 yyerror(@
3, "error: port bit select "
2559 "must be constant.");
2561 index_component_t itmp
;
2562 itmp.sel
= index_component_t
::SEL_BIT
;
2566 name_component_t ntmp
(lex_strings.make
($1));
2567 ntmp.index.push_back
(itmp
);
2570 pname.push_back
(ntmp
);
2572 PEIdent
*tmp
= new PEIdent
(pname
);
2575 Module
::port_t
*ptmp
= new Module
::port_t
;
2576 ptmp
->name
= perm_string
();
2577 ptmp
->expr
= svector
<PEIdent
*>(1);
2578 ptmp
->expr
[0] = tmp
;
2583 | IDENTIFIER
'[' error ']'
2584 { yyerror(@
1, "error: invalid port bit select");
2585 Module
::port_t
*ptmp
= new Module
::port_t
;
2586 PEIdent
*wtmp
= new PEIdent
(lex_strings.make
($1));
2587 FILE_NAME
(wtmp
, @
1);
2588 ptmp
->name
= lex_strings.make
($1);
2589 ptmp
->expr
= svector
<PEIdent
*>(1);
2590 ptmp
->expr
[0] = wtmp
;
2600 | port_reference_list
',' port_reference
2601 { Module
::port_t
*tmp
= $1;
2602 tmp
->expr
= svector
<PEIdent
*>(tmp
->expr
, $3->expr
);
2608 /* The port_name rule is used with a module is being *instantiated*,
2609 and not when it is being declared. See the port rule if you are
2610 looking for the ports of a module declaration. */
2613 : '.' IDENTIFIER
'(' expression
')'
2614 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2615 tmp
->name
= lex_strings.make
($2);
2620 |
'.' IDENTIFIER
'(' error ')'
2621 { yyerror(@
3, "error: invalid port connection expression.");
2622 named_pexpr_t
*tmp
= new named_pexpr_t
;
2623 tmp
->name
= lex_strings.make
($2);
2628 |
'.' IDENTIFIER
'(' ')'
2629 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2630 tmp
->name
= lex_strings.make
($2);
2638 : port_name_list
',' port_name
2639 { svector
<named_pexpr_t
*>*tmp
;
2640 tmp
= new svector
<named_pexpr_t
*>(*$1, $3);
2645 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2652 : K_input
{ $$
= NetNet
::PINPUT
; }
2653 | K_output
{ $$
= NetNet
::POUTPUT
; }
2654 | K_inout
{ $$
= NetNet
::PINOUT
; }
2658 : '[' expression
':' expression
']'
2659 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*> (2);
2660 if
(!pform_expression_is_constant
($2))
2661 yyerror(@
2, "error: msb of range must be constant.");
2665 if
(!pform_expression_is_constant
($4))
2666 yyerror(@
4, "error: lsb of range must be constant.");
2680 | dimensions
{ $$
= $1; }
2683 : '[' expression
':' expression
']'
2684 { list
<index_component_t
> *tmp
= new list
<index_component_t
>;
2685 index_component_t index
;
2686 if
(!pform_expression_is_constant
($2))
2687 yyerror(@
2, "error: left array address must be "
2690 if
(!pform_expression_is_constant
($4))
2691 yyerror(@
4, "error: right array address must be "
2694 tmp
->push_back
(index
);
2697 | dimensions
'[' expression
':' expression
']'
2698 { list
<index_component_t
> *tmp
= $1;
2699 index_component_t index
;
2700 if
(!pform_expression_is_constant
($3))
2701 yyerror(@
3, "error: left array address must be "
2704 if
(!pform_expression_is_constant
($5))
2705 yyerror(@
5, "error: right array address must be "
2708 tmp
->push_back
(index
);
2712 /* This is used to express the return type of a function. */
2713 function_range_or_type_opt
2714 : range
{ $$.range
= $1; $$.type
= PTF_REG
; }
2715 | K_signed range
{ $$.range
= $2; $$.type
= PTF_REG_S
; }
2716 | K_integer
{ $$.range
= 0; $$.type
= PTF_INTEGER
; }
2717 | K_real
{ $$.range
= 0; $$.type
= PTF_REAL
; }
2718 | K_realtime
{ $$.range
= 0; $$.type
= PTF_REALTIME
; }
2719 | K_time
{ $$.range
= 0; $$.type
= PTF_TIME
; }
2720 |
{ $$.range
= 0; $$.type
= PTF_REG
; }
2723 /* The register_variable rule is matched only when I am parsing
2724 variables in a "reg" definition. I therefore know that I am
2725 creating registers and I do not need to let the containing rule
2726 handle it. The register variable list simply packs them together
2727 so that bit ranges can be assigned. */
2729 : IDENTIFIER dimensions_opt
2730 { perm_string ident_name
= lex_strings.make
($1);
2731 pform_makewire
(@
1, ident_name
, NetNet
::REG
,
2732 NetNet
::NOT_A_PORT
, IVL_VT_NO_TYPE
, 0);
2734 index_component_t index
;
2735 if
($2->size
() > 1) {
2736 yyerror(@
2, "sorry: only 1 dimensional arrays "
2737 "are currently supported.");
2739 index
= $2->front
();
2740 pform_set_reg_idx
(ident_name
, index.msb
, index.lsb
);
2745 | IDENTIFIER
'=' expression
2746 { perm_string ident_name
= lex_strings.make
($1);
2747 pform_makewire
(@
1, ident_name
, NetNet
::REG
,
2748 NetNet
::NOT_A_PORT
, IVL_VT_NO_TYPE
, 0);
2749 if
(! pform_expression_is_constant
($3))
2750 yyerror(@
3, "error: register declaration assignment"
2751 " value must be a constant expression.");
2752 pform_make_reginit
(@
1, ident_name
, $3);
2757 register_variable_list
2759 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2760 tmp
->push_back
(lex_strings.make
($1));
2764 | register_variable_list
',' register_variable
2765 { list
<perm_string
>*tmp
= $1;
2766 tmp
->push_back
(lex_strings.make
($3));
2773 : IDENTIFIER dimensions_opt
2774 { perm_string name
= lex_strings.make
($1);
2775 pform_makewire
(@
1, name
, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2777 yyerror(@
2, "sorry: real variables do not currently support arrays.");
2782 | IDENTIFIER
'=' expression
2783 { perm_string name
= lex_strings.make
($1);
2784 pform_makewire
(@
1, name
, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2785 pform_make_reginit
(@
1, name
, $3);
2792 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2793 tmp
->push_back
(lex_strings.make
($1));
2797 | real_variable_list
',' real_variable
2798 { list
<perm_string
>*tmp
= $1;
2799 tmp
->push_back
(lex_strings.make
($3));
2806 : IDENTIFIER dimensions_opt
2807 { perm_string name
= lex_strings.make
($1);
2808 pform_makewire
(@
1, name
, NetNet
::IMPLICIT
,
2809 NetNet
::NOT_A_PORT
, IVL_VT_NO_TYPE
, 0);
2811 index_component_t index
;
2812 if
($2->size
() > 1) {
2813 yyerror(@
2, "sorry: only 1 dimensional arrays "
2814 "are currently supported.");
2816 index
= $2->front
();
2817 pform_set_reg_idx
(name
, index.msb
, index.lsb
);
2826 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2827 tmp
->push_back
(lex_strings.make
($1));
2831 | net_variable_list
',' net_variable
2832 { list
<perm_string
>*tmp
= $1;
2833 tmp
->push_back
(lex_strings.make
($3));
2840 : K_specparam specparam_list
';'
2841 | specify_simple_path_decl
';'
2842 { pform_module_specify_path
($1);
2844 | specify_edge_path_decl
';'
2845 { pform_module_specify_path
($1);
2847 | K_if
'(' expression
')' specify_simple_path_decl
';'
2848 { PSpecPath
*tmp
= $5;
2850 tmp
->conditional
= true
;
2851 tmp
->condition
= $3;
2853 pform_module_specify_path
(tmp
);
2855 | K_if
'(' expression
')' specify_edge_path_decl
';'
2856 { PSpecPath
*tmp
= $5;
2858 tmp
->conditional
= true
;
2859 tmp
->condition
= $3;
2861 pform_module_specify_path
(tmp
);
2863 | K_ifnone specify_simple_path_decl
';'
2864 { PSpecPath
*tmp
= $2;
2866 tmp
->conditional
= true
;
2869 pform_module_specify_path
(tmp
);
2871 | K_Shold
'(' spec_reference_event
',' spec_reference_event
2872 ',' delay_value spec_notifier_opt
')' ';'
2875 | K_Speriod
'(' spec_reference_event
',' delay_value
2876 spec_notifier_opt
')' ';'
2879 | K_Srecovery
'(' spec_reference_event
',' spec_reference_event
2880 ',' delay_value spec_notifier_opt
')' ';'
2883 | K_Ssetup
'(' spec_reference_event
',' spec_reference_event
2884 ',' delay_value spec_notifier_opt
')' ';'
2887 | K_Ssetuphold
'(' spec_reference_event
',' spec_reference_event
2888 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2892 | K_Srecrem
'(' spec_reference_event
',' spec_reference_event
2893 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2897 | K_Swidth
'(' spec_reference_event
',' delay_value
',' expression
2898 spec_notifier_opt
')' ';'
2902 | K_Swidth
'(' spec_reference_event
',' delay_value
')' ';'
2909 | specify_item_list specify_item
2912 specify_edge_path_decl
2913 : specify_edge_path
'=' '(' delay_value_list
')'
2914 { $$
= pform_assign_path_delay
($1, $4); }
2915 | specify_edge_path
'=' delay_value_simple
2916 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2918 $$
= pform_assign_path_delay
($1, tmp
);
2922 edge_operator
: K_posedge
{ $$
= true
; } | K_negedge
{ $$
= false
; } ;
2925 : '(' specify_path_identifiers spec_polarity
2926 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2927 { int edge_flag
= 0;
2928 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, false
, $6, $8); }
2929 |
'(' edge_operator specify_path_identifiers spec_polarity
2930 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2931 { int edge_flag
= $2?
1 : -1;
2932 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, false
, $7, $9);}
2933 |
'(' specify_path_identifiers spec_polarity
2934 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2935 { int edge_flag
= 0;
2936 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, true
, $6, $8); }
2937 |
'(' edge_operator specify_path_identifiers spec_polarity
2938 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2939 { int edge_flag
= $2?
1 : -1;
2940 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, true
, $7, $9); }
2949 specify_simple_path_decl
2950 : specify_simple_path
'=' '(' delay_value_list
')'
2951 { $$
= pform_assign_path_delay
($1, $4); }
2952 | specify_simple_path
'=' delay_value_simple
2953 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2955 $$
= pform_assign_path_delay
($1, tmp
);
2957 | specify_simple_path
'=' '(' error ')'
2958 { yyerror(@
3, "Syntax error in delay value list.");
2965 : '(' specify_path_identifiers spec_polarity
2966 K_EG specify_path_identifiers
')'
2967 { $$
= pform_make_specify_path
(@
1, $2, $3, false
, $5); }
2968 |
'(' specify_path_identifiers spec_polarity
2969 K_SG specify_path_identifiers
')'
2970 { $$
= pform_make_specify_path
(@
1, $2, $3, true
, $5); }
2972 { yyerror(@
1, "Invalid simple path");
2977 specify_path_identifiers
2979 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2980 tmp
->push_back
(lex_strings.make
($1));
2984 | IDENTIFIER
'[' expr_primary
']'
2985 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2986 tmp
->push_back
(lex_strings.make
($1));
2990 | specify_path_identifiers
',' IDENTIFIER
2991 { list
<perm_string
>*tmp
= $1;
2992 tmp
->push_back
(lex_strings.make
($3));
2996 | specify_path_identifiers
',' IDENTIFIER
'[' expr_primary
']'
2997 { list
<perm_string
>*tmp
= $1;
2998 tmp
->push_back
(lex_strings.make
($3));
3005 : IDENTIFIER
'=' expression
3007 pform_set_specparam
(lex_strings.make
($1), tmp
);
3010 | IDENTIFIER
'=' expression
':' expression
':' expression
3012 switch
(min_typ_max_flag
) {
3029 if
(min_typ_max_warn
> 0) {
3030 cerr
<< tmp
->get_fileline
() << ": warning: choosing ";
3031 switch
(min_typ_max_flag
) {
3042 cerr
<< " expression." << endl
;
3043 min_typ_max_warn
-= 1;
3045 pform_set_specparam
(lex_strings.make
($1), tmp
);
3048 | PATHPULSE_IDENTIFIER
'=' expression
3052 | PATHPULSE_IDENTIFIER
'=' '(' expression
',' expression
')'
3061 | specparam_list
',' specparam
3070 spec_reference_event
3071 : K_posedge expression
3073 | K_negedge expression
3075 | K_posedge expr_primary K_TAND expression
3079 | K_negedge expr_primary K_TAND expression
3083 | K_edge
'[' edge_descriptor_list
']' expr_primary
3085 | K_edge
'[' edge_descriptor_list
']' expr_primary K_TAND expression
3089 | expr_primary K_TAND expression
3097 /* The edge_descriptor is detected by the lexor as the various
3098 2-letter edge sequences that are supported here. For now, we
3099 don't care what they are, because we do not yet support specify
3101 edge_descriptor_list
3102 : edge_descriptor_list
',' K_edge_descriptor
3115 |
',' hierarchy_identifier
3119 | spec_notifier
',' hierarchy_identifier
3128 /* assign and deassign statements are procedural code to do
3129 structural assignments, and to turn that structural assignment
3130 off. This stronger then any other assign, but weaker then the
3131 force assignments. */
3133 : K_assign lpvalue
'=' expression
';'
3134 { PCAssign
*tmp
= new PCAssign
($2, $4);
3139 | K_deassign lpvalue
';'
3140 { PDeassign
*tmp
= new PDeassign
($2);
3146 /* Force and release statements are similar to assignments,
3147 syntactically, but they will be elaborated differently. */
3149 | K_force lpvalue
'=' expression
';'
3150 { PForce
*tmp
= new PForce
($2, $4);
3154 | K_release lpvalue
';'
3155 { PRelease
*tmp
= new PRelease
($2);
3160 /* begin-end blocks come in a variety of forms, including named and
3161 anonymous. The named blocks can also carry their own reg
3162 variables, which are placed in the scope created by the block
3163 name. These are handled by pushing the scope name then matching
3164 the declarations. The scope is popped at the end of the block. */
3166 | K_begin statement_list K_end
3167 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
3169 tmp
->set_statement
(*$2);
3173 | K_begin
':' IDENTIFIER
3174 { PBlock
*tmp
= pform_push_block_scope
($3, PBlock
::BL_SEQ
);
3176 current_block_stack.push
(tmp
);
3178 block_item_decls_opt
3179 statement_list K_end
3180 { pform_pop_scope
();
3181 assert
(! current_block_stack.empty
());
3182 PBlock
*tmp
= current_block_stack.top
();
3183 current_block_stack.pop
();
3184 tmp
->set_statement
(*$6);
3190 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
3194 | K_begin
':' IDENTIFIER K_end
3195 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
3200 | K_begin
error K_end
3203 /* fork-join blocks are very similar to begin-end blocks. In fact,
3204 from the parser's perspective there is no real difference. All we
3205 need to do is remember that this is a parallel block so that the
3206 code generator can do the right thing. */
3208 | K_fork
':' IDENTIFIER
3209 { PBlock
*tmp
= pform_push_block_scope
($3, PBlock
::BL_PAR
);
3211 current_block_stack.push
(tmp
);
3213 block_item_decls_opt
3214 statement_list K_join
3215 { pform_pop_scope
();
3216 assert
(! current_block_stack.empty
());
3217 PBlock
*tmp
= current_block_stack.top
();
3218 current_block_stack.pop
();
3219 tmp
->set_statement
(*$6);
3225 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
3229 | K_fork
':' IDENTIFIER K_join
3230 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
3236 | K_disable hierarchy_identifier
';'
3237 { PDisable
*tmp
= new PDisable
(*$2);
3242 | K_TRIGGER hierarchy_identifier
';'
3243 { PTrigger
*tmp
= new PTrigger
(*$2);
3248 | K_forever statement
3249 { PForever
*tmp
= new PForever
($2);
3253 | K_fork statement_list K_join
3254 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
3256 tmp
->set_statement
(*$2);
3260 | K_repeat
'(' expression
')' statement
3261 { PRepeat
*tmp
= new PRepeat
($3, $5);
3265 | K_case
'(' expression
')' case_items K_endcase
3266 { PCase
*tmp
= new PCase
(NetCase
::EQ
, $3, $5);
3270 | K_casex
'(' expression
')' case_items K_endcase
3271 { PCase
*tmp
= new PCase
(NetCase
::EQX
, $3, $5);
3275 | K_casez
'(' expression
')' case_items K_endcase
3276 { PCase
*tmp
= new PCase
(NetCase
::EQZ
, $3, $5);
3280 | K_case
'(' expression
')' error K_endcase
3282 | K_casex
'(' expression
')' error K_endcase
3284 | K_casez
'(' expression
')' error K_endcase
3286 | K_if
'(' expression
')' statement_or_null %prec less_than_K_else
3287 { PCondit
*tmp
= new PCondit
($3, $5, 0);
3291 | K_if
'(' expression
')' statement_or_null K_else statement_or_null
3292 { PCondit
*tmp
= new PCondit
($3, $5, $7);
3296 | K_if
'(' error ')' statement_or_null %prec less_than_K_else
3297 { yyerror(@
1, "error: Malformed conditional expression.");
3300 | K_if
'(' error ')' statement_or_null K_else statement_or_null
3301 { yyerror(@
1, "error: Malformed conditional expression.");
3304 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3305 lpvalue
'=' expression
')' statement
3306 { PForStatement
*tmp
= new PForStatement
($3, $5, $7, $9, $11, $13);
3310 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3313 yyerror(@
1, "error: Error in for loop step assignment.");
3315 | K_for
'(' lpvalue
'=' expression
';' error ';'
3316 lpvalue
'=' expression
')' statement
3318 yyerror(@
1, "error: Error in for loop condition expression.");
3320 | K_for
'(' error ')' statement
3322 yyerror(@
1, "error: Incomprehensible for loop.");
3324 | K_while
'(' expression
')' statement
3325 { PWhile
*tmp
= new PWhile
($3, $5);
3329 | K_while
'(' error ')' statement
3331 yyerror(@
1, "error: Error in while loop condition.");
3333 | delay1 statement_or_null
3334 { PExpr
*del
= (*$1)[0];
3335 assert
($1->count
() == 1);
3336 PDelayStatement
*tmp
= new PDelayStatement
(del
, $2);
3340 | event_control statement_or_null
3341 { PEventStatement
*tmp
= $1;
3343 yyerror(@
1, "error: Invalid event control.");
3346 tmp
->set_statement
($2);
3350 |
'@' '*' statement_or_null
3351 { PEventStatement
*tmp
= new PEventStatement
;
3353 tmp
->set_statement
($3);
3356 |
'@' '(' '*' ')' statement_or_null
3357 { PEventStatement
*tmp
= new PEventStatement
;
3359 tmp
->set_statement
($5);
3362 | lpvalue
'=' expression
';'
3363 { PAssign
*tmp
= new PAssign
($1,$3);
3367 |
error '=' expression
';'
3368 { yyerror(@
2, "Syntax in assignment statement l-value.");
3372 | lpvalue K_LE expression
';'
3373 { PAssignNB
*tmp
= new PAssignNB
($1,$3);
3377 |
error K_LE expression
';'
3378 { yyerror(@
2, "Syntax in assignment statement l-value.");
3382 | lpvalue
'=' delay1 expression
';'
3383 { assert
($3->count
() == 1);
3384 PExpr
*del
= (*$3)[0];
3385 PAssign
*tmp
= new PAssign
($1,del
,$4);
3389 | lpvalue K_LE delay1 expression
';'
3390 { assert
($3->count
() == 1);
3391 PExpr
*del
= (*$3)[0];
3392 PAssignNB
*tmp
= new PAssignNB
($1,del
,$4);
3396 | lpvalue
'=' event_control expression
';'
3397 { PAssign
*tmp
= new PAssign
($1,$3,$4);
3401 | lpvalue
'=' K_repeat
'(' expression
')' event_control expression
';'
3402 { PAssign
*tmp
= new PAssign
($1,$7,$8);
3404 tmp
->set_lineno
(@
1.first_line
);
3405 yyerror(@
3, "sorry: repeat event control not supported.");
3409 | lpvalue K_LE event_control expression
';'
3410 { yyerror(@
1, "sorry: Event controls not supported here.");
3411 PAssignNB
*tmp
= new PAssignNB
($1,$4);
3415 | lpvalue K_LE K_repeat
'(' expression
')' event_control expression
';'
3416 { yyerror(@
1, "sorry: Event controls not supported here.");
3418 PAssignNB
*tmp
= new PAssignNB
($1,$8);
3422 | K_wait
'(' expression
')' statement_or_null
3423 { PEventStatement
*tmp
;
3424 PEEvent
*etmp
= new PEEvent
(PEEvent
::POSITIVE
, $3);
3425 tmp
= new PEventStatement
(etmp
);
3427 tmp
->set_statement
($5);
3430 | SYSTEM_IDENTIFIER
'(' expression_list_with_nuls
')' ';'
3431 { PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), *$3);
3437 | SYSTEM_IDENTIFIER
';'
3438 { svector
<PExpr
*>pt
(0);
3439 PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), pt
);
3444 | hierarchy_identifier
'(' expression_list_proper
')' ';'
3445 { PCallTask
*tmp
= new PCallTask
(*$1, *$3);
3452 /* NOTE: The standard doesn't really support an empty argument list
3453 between parentheses, but it seems natural, and people commonly
3454 want it. So accept it explicitly. */
3456 | hierarchy_identifier
'(' ')' ';'
3457 { svector
<PExpr
*>pt
(0);
3458 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3463 | hierarchy_identifier
';'
3464 { svector
<PExpr
*>pt
(0);
3465 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3471 { yyerror(@
2, "error: malformed statement");
3478 : statement_list statement
3479 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(*$1, $2);
3484 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(1);
3495 /* Task items are, other than the statement, task port items and
3496 other block items. */
3498 : block_item_decl
{ $$
= new svector
<PWire
*>(0); }
3499 | task_port_item
{ $$
= $1; }
3504 : K_input signed_opt range_opt list_of_identifiers
';'
3505 { svector
<PWire
*>*tmp
3506 = pform_make_task_ports
(NetNet
::PINPUT
,
3509 @
1.text
, @
1.first_line
);
3512 | K_output signed_opt range_opt list_of_identifiers
';'
3513 { svector
<PWire
*>*tmp
3514 = pform_make_task_ports
(NetNet
::POUTPUT
,
3517 @
1.text
, @
1.first_line
);
3520 | K_inout signed_opt range_opt list_of_identifiers
';'
3521 { svector
<PWire
*>*tmp
3522 = pform_make_task_ports
(NetNet
::PINOUT
,
3525 @
1.text
, @
1.first_line
);
3529 /* When the port is an integer, infer a signed vector of the integer
3530 shape. Generate a range to make it work. */
3532 | K_input K_integer list_of_identifiers
';'
3533 { svector
<PExpr
*>*range_stub
3534 = new svector
<PExpr
*>(2);
3536 re
= new PENumber
(new verinum
(integer_width
-1,
3538 (*range_stub
)[0] = re
;
3539 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3540 (*range_stub
)[1] = re
;
3542 = pform_make_task_ports
(NetNet
::PINPUT
,
3545 @
1.text
, @
1.first_line
);
3548 | K_output K_integer list_of_identifiers
';'
3549 { svector
<PExpr
*>*range_stub
3550 = new svector
<PExpr
*>(2);
3552 re
= new PENumber
(new verinum
(integer_width
-1,
3554 (*range_stub
)[0] = re
;
3555 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3556 (*range_stub
)[1] = re
;
3558 = pform_make_task_ports
(NetNet
::POUTPUT
,
3561 @
1.text
, @
1.first_line
);
3564 | K_inout K_integer list_of_identifiers
';'
3565 { svector
<PExpr
*>*range_stub
3566 = new svector
<PExpr
*>(2);
3568 re
= new PENumber
(new verinum
(integer_width
-1,
3570 (*range_stub
)[0] = re
;
3571 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3572 (*range_stub
)[1] = re
;
3574 = pform_make_task_ports
(NetNet
::PINOUT
,
3577 @
1.text
, @
1.first_line
);
3581 /* Ports can be real. */
3583 | K_input K_real list_of_identifiers
';'
3584 { svector
<PWire
*>*tmp
3585 = pform_make_task_ports
(NetNet
::PINPUT
,
3588 @
1.text
, @
1.first_line
);
3591 | K_output K_real list_of_identifiers
';'
3592 { svector
<PWire
*>*tmp
3593 = pform_make_task_ports
(NetNet
::POUTPUT
,
3596 @
1.text
, @
1.first_line
);
3599 | K_inout K_real list_of_identifiers
';'
3600 { svector
<PWire
*>*tmp
3601 = pform_make_task_ports
(NetNet
::PINOUT
,
3604 @
1.text
, @
1.first_line
);
3610 : task_item_list task_item
3611 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3629 : K_input signed_opt range_opt IDENTIFIER
3630 { port_declaration_context.port_type
= NetNet
::PINPUT
;
3631 port_declaration_context.var_type
= IVL_VT_LOGIC
;
3632 port_declaration_context.sign_flag
= $2;
3633 delete port_declaration_context.range
;
3634 port_declaration_context.range
= copy_range
($3);
3636 = pform_make_task_ports
(NetNet
::PINPUT
,
3638 $3, list_from_identifier
($4),
3639 @
1.text
, @
1.first_line
);
3643 | K_output signed_opt range_opt IDENTIFIER
3644 { port_declaration_context.port_type
= NetNet
::POUTPUT
;
3645 port_declaration_context.var_type
= IVL_VT_LOGIC
;
3646 port_declaration_context.sign_flag
= $2;
3647 delete port_declaration_context.range
;
3648 port_declaration_context.range
= copy_range
($3);
3650 = pform_make_task_ports
(NetNet
::POUTPUT
,
3652 $3, list_from_identifier
($4),
3653 @
1.text
, @
1.first_line
);
3656 | K_inout signed_opt range_opt IDENTIFIER
3657 { port_declaration_context.port_type
= NetNet
::PINOUT
;
3658 port_declaration_context.var_type
= IVL_VT_LOGIC
;
3659 port_declaration_context.sign_flag
= $2;
3660 delete port_declaration_context.range
;
3661 port_declaration_context.range
= copy_range
($3);
3663 = pform_make_task_ports
(NetNet
::PINOUT
,
3665 $3, list_from_identifier
($4),
3666 @
1.text
, @
1.first_line
);
3670 | K_input K_integer IDENTIFIER
3671 { svector
<PExpr
*>*range_stub
3672 = new svector
<PExpr
*>(2);
3674 re
= new PENumber
(new verinum
(integer_width
-1,
3676 (*range_stub
)[0] = re
;
3677 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3678 (*range_stub
)[1] = re
;
3679 port_declaration_context.port_type
= NetNet
::PINPUT
;
3680 port_declaration_context.var_type
= IVL_VT_LOGIC
;
3681 port_declaration_context.sign_flag
= true
;
3682 delete port_declaration_context.range
;
3683 port_declaration_context.range
= copy_range
(range_stub
);
3685 = pform_make_task_ports
(NetNet
::PINPUT
,
3688 list_from_identifier
($3),
3689 @
1.text
, @
1.first_line
);
3692 | K_output K_integer IDENTIFIER
3693 { svector
<PExpr
*>*range_stub
3694 = new svector
<PExpr
*>(2);
3696 re
= new PENumber
(new verinum
(integer_width
-1,
3698 (*range_stub
)[0] = re
;
3699 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3700 (*range_stub
)[1] = re
;
3701 port_declaration_context.port_type
= NetNet
::POUTPUT
;
3702 port_declaration_context.var_type
= IVL_VT_LOGIC
;
3703 port_declaration_context.sign_flag
= true
;
3704 delete port_declaration_context.range
;
3705 port_declaration_context.range
= copy_range
(range_stub
);
3707 = pform_make_task_ports
(NetNet
::POUTPUT
,
3710 list_from_identifier
($3),
3711 @
1.text
, @
1.first_line
);
3714 | K_inout K_integer IDENTIFIER
3715 { svector
<PExpr
*>*range_stub
3716 = new svector
<PExpr
*>(2);
3718 re
= new PENumber
(new verinum
(integer_width
-1,
3720 (*range_stub
)[0] = re
;
3721 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3722 (*range_stub
)[1] = re
;
3723 port_declaration_context.port_type
= NetNet
::PINOUT
;
3724 port_declaration_context.var_type
= IVL_VT_LOGIC
;
3725 port_declaration_context.sign_flag
= true
;
3726 delete port_declaration_context.range
;
3727 port_declaration_context.range
= copy_range
(range_stub
);
3729 = pform_make_task_ports
(NetNet
::PINOUT
,
3732 list_from_identifier
($3),
3733 @
1.text
, @
1.first_line
);
3737 /* Ports can be real. */
3739 | K_input K_real IDENTIFIER
3740 { port_declaration_context.port_type
= NetNet
::PINPUT
;
3741 port_declaration_context.var_type
= IVL_VT_REAL
;
3742 port_declaration_context.sign_flag
= false
;
3743 delete port_declaration_context.range
;
3744 port_declaration_context.range
= 0;
3746 = pform_make_task_ports
(NetNet
::PINPUT
,
3748 0, list_from_identifier
($3),
3749 @
1.text
, @
1.first_line
);
3752 | K_output K_real IDENTIFIER
3753 { port_declaration_context.port_type
= NetNet
::POUTPUT
;
3754 port_declaration_context.var_type
= IVL_VT_REAL
;
3755 port_declaration_context.sign_flag
= false
;
3756 delete port_declaration_context.range
;
3757 port_declaration_context.range
= 0;
3759 = pform_make_task_ports
(NetNet
::POUTPUT
,
3761 0, list_from_identifier
($3),
3762 @
1.text
, @
1.first_line
);
3765 | K_inout K_real IDENTIFIER
3766 { port_declaration_context.port_type
= NetNet
::PINOUT
;
3767 port_declaration_context.var_type
= IVL_VT_REAL
;
3768 port_declaration_context.sign_flag
= false
;
3769 delete port_declaration_context.range
;
3770 port_declaration_context.range
= 0;
3772 = pform_make_task_ports
(NetNet
::PINOUT
,
3774 0, list_from_identifier
($3),
3775 @
1.text
, @
1.first_line
);
3781 : task_port_decl_list
',' task_port_decl
3782 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$3);
3789 | task_port_decl_list
',' IDENTIFIER
3790 { svector
<PWire
*>*new_decl
3791 = pform_make_task_ports
(
3792 port_declaration_context.port_type
,
3793 port_declaration_context.var_type
,
3794 port_declaration_context.sign_flag
,
3795 copy_range
(port_declaration_context.range
),
3796 list_from_identifier
($3),
3797 @
3.text
, @
3.first_line
);
3798 svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *new_decl
);
3803 | task_port_decl_list
','
3805 yyerror(@
2, "error: NULL port declarations are not "
3808 | task_port_decl_list
';'
3810 yyerror(@
2, "error: ';' is an invalid port declaration "
3817 : K_table
{ lex_start_table
(); }
3819 K_endtable
{ lex_end_table
(); $$
= $3; }
3823 : udp_comb_entry_list
3824 | udp_sequ_entry_list
3828 : udp_input_list
':' udp_output_sym
';'
3829 { char*tmp
= new
char[strlen
($1)+3];
3831 char*tp
= tmp
+strlen
(tmp
);
3842 { list
<string>*tmp
= new list
<string>;
3847 | udp_comb_entry_list udp_comb_entry
3848 { list
<string>*tmp
= $1;
3857 { list
<string>*tmp
= new list
<string>;
3862 | udp_sequ_entry_list udp_sequ_entry
3863 { list
<string>*tmp
= $1;
3871 : udp_input_list
':' udp_input_sym
':' udp_output_sym
';'
3872 { char*tmp
= new
char[strlen
($1)+5];
3874 char*tp
= tmp
+strlen
(tmp
);
3885 : K_initial IDENTIFIER
'=' number
';'
3886 { PExpr
*etmp
= new PENumber
($4);
3887 PEIdent
*itmp
= new PEIdent
(lex_strings.make
($2));
3888 PAssign
*atmp
= new PAssign
(itmp
, etmp
);
3889 FILE_NAME
(atmp
, @
2);
3896 : udp_initial
{ $$
= $1; }
3902 { char*tmp
= new
char[2];
3907 | udp_input_list udp_input_sym
3908 { char*tmp
= new
char[strlen
($1)+2];
3910 char*tp
= tmp
+strlen
(tmp
);
3951 /* Port declarations create wires for the inputs and the output. The
3952 makes for these ports are scoped within the UDP, so there is no
3953 hierarchy involved. */
3955 : K_input list_of_identifiers
';'
3956 { $$
= pform_make_udp_input_ports
($2); }
3957 | K_output IDENTIFIER
';'
3958 { perm_string pname
= lex_strings.make
($2);
3959 PWire
*pp
= new PWire
(pname
, NetNet
::IMPLICIT
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3960 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3965 | K_reg IDENTIFIER
';'
3966 { perm_string pname
= lex_strings.make
($2);
3967 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::PIMPLICIT
, IVL_VT_LOGIC
);
3968 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3973 | K_reg K_output IDENTIFIER
';'
3974 { perm_string pname
= lex_strings.make
($3);
3975 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3976 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3986 | udp_port_decls udp_port_decl
3987 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3996 { list
<perm_string
>*tmp
= new list
<perm_string
>;
3997 tmp
->push_back
(lex_strings.make
($1));
4001 | udp_port_list
',' IDENTIFIER
4002 { list
<perm_string
>*tmp
= $1;
4003 tmp
->push_back
(lex_strings.make
($3));
4009 udp_reg_opt: K_reg
{ $$
= true
; } |
{ $$
= false
; };
4011 udp_initial_expr_opt
4012 : '=' expression
{ $$
= $2; }
4016 udp_input_declaration_list
4017 : K_input IDENTIFIER
4018 { list
<perm_string
>*tmp
= new list
<perm_string
>;
4019 tmp
->push_back
(lex_strings.make
($2));
4023 | udp_input_declaration_list
',' K_input IDENTIFIER
4024 { list
<perm_string
>*tmp
= $1;
4025 tmp
->push_back
(lex_strings.make
($4));
4032 /* This is the syntax for primitives that uses the IEEE1364-1995
4033 format. The ports are simply names in the port list, and the
4034 declarations are in the body. */
4036 : K_primitive IDENTIFIER
'(' udp_port_list
')' ';'
4042 { perm_string tmp2
= lex_strings.make
($2);
4043 pform_make_udp
(tmp2
, $4, $7, $9, $8,
4044 @
2.text
, @
2.first_line
);
4048 /* This is the syntax for IEEE1364-2001 format definitions. The port
4049 names and declarations are all in the parameter list. */
4051 | K_primitive IDENTIFIER
4052 '(' K_output udp_reg_opt IDENTIFIER udp_initial_expr_opt
','
4053 udp_input_declaration_list
')' ';'
4057 { perm_string tmp2
= lex_strings.make
($2);
4058 perm_string tmp6
= lex_strings.make
($6);
4059 pform_make_udp
(tmp2
, $5, tmp6
, $7, $9, $12,
4060 @
2.text
, @
2.first_line
);