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
277 { $$
= $1; based_size
= 0;}
279 { $$
= $1; based_size
= 0;}
280 | DEC_NUMBER BASED_NUMBER
281 { $$
= pform_verinum_with_size
($1,$2, @
2.text
, @
2.first_line
);
285 /* Verilog-2001 supports attribute lists, which can be attached to a
286 variety of different objects. The syntax inside the (* *) is a
287 comma separated list of names or names with assigned values. */
289 : K_PSTAR attribute_list K_STARP
{ $$
= $2; }
290 | K_PSTAR K_STARP
{ $$
= 0; }
295 : attribute_list
',' attribute
296 { svector
<named_pexpr_t
*>*tmp
=
297 new svector
<named_pexpr_t
*>(*$1,$3);
302 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
311 { named_pexpr_t
*tmp
= new named_pexpr_t
;
312 tmp
->name
= lex_strings.make
($1);
317 | IDENTIFIER
'=' expression
319 if
(!pform_expression_is_constant
(tmp
)) {
320 yyerror(@
3, "error: attribute value "
321 "expression must be constant.");
325 named_pexpr_t
*tmp2
= new named_pexpr_t
;
326 tmp2
->name
= lex_strings.make
($1);
334 /* The block_item_decl is used in function definitions, task
335 definitions, module definitions and named blocks. Wherever a new
336 scope is entered, the source may declare new registers and
337 integers. This rule matches those declarations. The containing
338 rule has presumably set up the scope. */
341 : attribute_list_opt K_reg
342 primitive_type_opt signed_opt range
343 register_variable_list
';'
344 { ivl_variable_type_t dtype
= $3;
345 if
(dtype
== IVL_VT_NO_TYPE
)
346 dtype
= IVL_VT_LOGIC
;
347 pform_set_net_range
($6, $5, $4, dtype
);
351 /* This differs from the above pattern only in the absence of the
352 range. This is the rule for a scalar. */
354 | attribute_list_opt K_reg
355 primitive_type_opt signed_opt
356 register_variable_list
';'
357 { ivl_variable_type_t dtype
= $3;
358 if
(dtype
== IVL_VT_NO_TYPE
)
359 dtype
= IVL_VT_LOGIC
;
360 pform_set_net_range
($5, 0, $4, dtype
);
364 /* Integer declarations are simpler in that they do not have all the
365 trappings of a general variable declaration. All of that is
366 implicit in the "integer" of the declaratin. */
368 | attribute_list_opt K_integer register_variable_list
';'
369 { pform_set_reg_integer
($3);
373 | attribute_list_opt K_time register_variable_list
';'
374 { pform_set_reg_time
($3);
377 /* real declarations are fairly simple as there is no range of
378 signed flag in the declaration. Create the real as a NetNet::REG
379 with real value. Note that real and realtime are interchangable
382 | attribute_list_opt K_real real_variable_list
';'
384 | attribute_list_opt K_realtime real_variable_list
';'
387 | K_parameter parameter_assign_decl
';'
388 | K_localparam localparam_assign_decl
';'
390 /* Recover from errors that happen within variable lists. Use the
391 trailing semi-colon to resync the parser. */
393 | attribute_list_opt K_reg
error ';'
394 { yyerror(@
2, "error: syntax error in reg variable list.");
398 | attribute_list_opt K_integer
error ';'
399 { yyerror(@
2, "error: syntax error in integer variable list.");
403 | attribute_list_opt K_time
error ';'
404 { yyerror(@
2, "error: syntax error in time variable list.");
407 | attribute_list_opt K_real
error ';'
408 { yyerror(@
2, "error: syntax error in real variable list.");
411 | attribute_list_opt K_realtime
error ';'
412 { yyerror(@
1, "error: syntax error in realtime variable list.");
415 | K_parameter
error ';'
416 { yyerror(@
1, "error: syntax error in parameter list.");
419 | K_localparam
error ';'
420 { yyerror(@
1, "error: syntax error localparam list.");
427 | block_item_decls block_item_decl
436 : expression_list_proper
':' statement_or_null
437 { PCase
::Item
*tmp
= new PCase
::Item
;
443 | K_default
':' statement_or_null
444 { PCase
::Item
*tmp
= new PCase
::Item
;
448 | K_default statement_or_null
449 { PCase
::Item
*tmp
= new PCase
::Item
;
453 |
error ':' statement_or_null
454 { yyerror(@
1, "error: Incomprehensible case expression.");
460 : case_items case_item
461 { svector
<PCase
::Item
*>*tmp
;
462 tmp
= new svector
<PCase
::Item
*>(*$1, $2);
467 { svector
<PCase
::Item
*>*tmp
= new svector
<PCase
::Item
*>(1);
485 : heirarchy_identifier
'=' expression
487 if
(!pform_expression_is_constant
(tmp
)) {
488 yyerror(@
3, "error: parameter value "
489 "must be constant.");
493 pform_set_defparam
(*$1, $3);
500 | range defparam_assign
501 { yyerror(@
1, "error: defparam may not include a range.");
504 | defparam_assign_list
',' defparam_assign
508 : '#' delay_value_simple
509 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
513 |
'#' '(' delay_value
')'
514 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
521 : '#' delay_value_simple
522 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
526 |
'#' '(' delay_value
')'
527 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
531 |
'#' '(' delay_value
',' delay_value
')'
532 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
537 |
'#' '(' delay_value
',' delay_value
',' delay_value
')'
538 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(3);
547 : delay3
{ $$
= $1; }
553 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
557 | delay_value_list
',' delay_value
558 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
569 | expression
':' expression
':' expression
570 { $$
= pform_select_mtm_expr
($1, $3, $5); }
578 yyerror(@
1, "internal error: delay.");
581 $$
= new PENumber
(tmp
);
582 $$
->set_file
(@
1.text
);
583 $$
->set_lineno
(@
1.first_line
);
589 yyerror(@
1, "internal error: delay.");
592 $$
= new PEFNumber
(tmp
);
593 $$
->set_file
(@
1.text
);
594 $$
->set_lineno
(@
1.first_line
);
598 { PEIdent
*tmp
= new PEIdent
(lex_strings.make
($1));
599 tmp
->set_file
(@
1.text
);
600 tmp
->set_lineno
(@
1.first_line
);
609 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')'
610 { perm_string tmp3
= lex_strings.make
($3);
611 pform_set_type_attrib
(tmp3
, $5, $7);
618 : '(' dr_strength0
',' dr_strength1
')'
622 |
'(' dr_strength1
',' dr_strength0
')'
626 |
'(' dr_strength0
',' K_highz1
')'
628 $$.str1
= PGate
::HIGHZ
;
630 |
'(' dr_strength1
',' K_highz0
')'
631 { $$.str0
= PGate
::HIGHZ
;
634 |
'(' K_highz1
',' dr_strength0
')'
636 $$.str1
= PGate
::HIGHZ
;
638 |
'(' K_highz0
',' dr_strength1
')'
639 { $$.str0
= PGate
::HIGHZ
;
645 : drive_strength
{ $$
= $1; }
646 |
{ $$.str0
= PGate
::STRONG
; $$.str1
= PGate
::STRONG
; }
650 : K_supply0
{ $$.str0
= PGate
::SUPPLY
; }
651 | K_strong0
{ $$.str0
= PGate
::STRONG
; }
652 | K_pull0
{ $$.str0
= PGate
::PULL
; }
653 | K_weak0
{ $$.str0
= PGate
::WEAK
; }
657 : K_supply1
{ $$.str1
= PGate
::SUPPLY
; }
658 | K_strong1
{ $$.str1
= PGate
::STRONG
; }
659 | K_pull1
{ $$.str1
= PGate
::PULL
; }
660 | K_weak1
{ $$.str1
= PGate
::WEAK
; }
664 : '@' heirarchy_identifier
665 { PEIdent
*tmpi
= new PEIdent
(*$2);
666 PEEvent
*tmpe
= new PEEvent
(PEEvent
::ANYEDGE
, tmpi
);
667 PEventStatement
*tmps
= new PEventStatement
(tmpe
);
668 tmps
->set_file
(@
1.text
);
669 tmps
->set_lineno
(@
1.first_line
);
673 |
'@' '(' event_expression_list
')'
674 { PEventStatement
*tmp
= new PEventStatement
(*$3);
675 tmp
->set_file
(@
1.text
);
676 tmp
->set_lineno
(@
1.first_line
);
681 { yyerror(@
1, "error: Malformed event control expression.");
686 event_expression_list
689 | event_expression_list K_or event_expression
690 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
695 | event_expression_list
',' event_expression
696 { svector
<PEEvent
*>*tmp
= new svector
<PEEvent
*>(*$1, *$3);
704 : K_posedge expression
705 { PEEvent
*tmp
= new PEEvent
(PEEvent
::POSEDGE
, $2);
706 tmp
->set_file
(@
1.text
);
707 tmp
->set_lineno
(@
1.first_line
);
708 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
712 | K_negedge expression
713 { PEEvent
*tmp
= new PEEvent
(PEEvent
::NEGEDGE
, $2);
714 tmp
->set_file
(@
1.text
);
715 tmp
->set_lineno
(@
1.first_line
);
716 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
721 { PEEvent
*tmp
= new PEEvent
(PEEvent
::ANYEDGE
, $1);
722 tmp
->set_file
(@
1.text
);
723 tmp
->set_lineno
(@
1.first_line
);
724 svector
<PEEvent
*>*tl
= new svector
<PEEvent
*>(1);
733 |
'+' expr_primary %prec UNARY_PREC
735 |
'-' expr_primary %prec UNARY_PREC
736 { PEUnary
*tmp
= new PEUnary
('-', $2);
737 tmp
->set_file
(@
2.text
);
738 tmp
->set_lineno
(@
2.first_line
);
741 |
'~' expr_primary %prec UNARY_PREC
742 { PEUnary
*tmp
= new PEUnary
('~', $2);
743 tmp
->set_file
(@
2.text
);
744 tmp
->set_lineno
(@
2.first_line
);
747 |
'&' expr_primary %prec UNARY_PREC
748 { PEUnary
*tmp
= new PEUnary
('&', $2);
749 tmp
->set_file
(@
2.text
);
750 tmp
->set_lineno
(@
2.first_line
);
753 |
'!' expr_primary %prec UNARY_PREC
754 { PEUnary
*tmp
= new PEUnary
('!', $2);
755 tmp
->set_file
(@
2.text
);
756 tmp
->set_lineno
(@
2.first_line
);
759 |
'|' expr_primary %prec UNARY_PREC
760 { PEUnary
*tmp
= new PEUnary
('|', $2);
761 tmp
->set_file
(@
2.text
);
762 tmp
->set_lineno
(@
2.first_line
);
765 |
'^' expr_primary %prec UNARY_PREC
766 { PEUnary
*tmp
= new PEUnary
('^', $2);
767 tmp
->set_file
(@
2.text
);
768 tmp
->set_lineno
(@
2.first_line
);
771 | K_NAND expr_primary %prec UNARY_PREC
772 { PEUnary
*tmp
= new PEUnary
('A', $2);
773 tmp
->set_file
(@
2.text
);
774 tmp
->set_lineno
(@
2.first_line
);
777 | K_NOR expr_primary %prec UNARY_PREC
778 { PEUnary
*tmp
= new PEUnary
('N', $2);
779 tmp
->set_file
(@
2.text
);
780 tmp
->set_lineno
(@
2.first_line
);
783 | K_NXOR expr_primary %prec UNARY_PREC
784 { PEUnary
*tmp
= new PEUnary
('X', $2);
785 tmp
->set_file
(@
2.text
);
786 tmp
->set_lineno
(@
2.first_line
);
789 |
'!' error %prec UNARY_PREC
790 { yyerror(@
1, "error: Operand of unary ! "
791 "is not a primary expression.");
794 |
'^' error %prec UNARY_PREC
795 { yyerror(@
1, "error: Operand of reduction ^ "
796 "is not a primary expression.");
799 | expression
'^' expression
800 { PEBinary
*tmp
= new PEBinary
('^', $1, $3);
801 tmp
->set_file
(@
2.text
);
802 tmp
->set_lineno
(@
2.first_line
);
805 | expression K_POW expression
806 { PEBinary
*tmp
= new PEBinary
('p', $1, $3);
807 tmp
->set_file
(@
2.text
);
808 tmp
->set_lineno
(@
2.first_line
);
811 | expression
'*' expression
812 { PEBinary
*tmp
= new PEBinary
('*', $1, $3);
813 tmp
->set_file
(@
2.text
);
814 tmp
->set_lineno
(@
2.first_line
);
817 | expression
'/' expression
818 { PEBinary
*tmp
= new PEBinary
('/', $1, $3);
819 tmp
->set_file
(@
2.text
);
820 tmp
->set_lineno
(@
2.first_line
);
823 | expression
'%' expression
824 { PEBinary
*tmp
= new PEBinary
('%', $1, $3);
825 tmp
->set_file
(@
2.text
);
826 tmp
->set_lineno
(@
2.first_line
);
829 | expression
'+' expression
830 { PEBinary
*tmp
= new PEBinary
('+', $1, $3);
831 tmp
->set_file
(@
2.text
);
832 tmp
->set_lineno
(@
2.first_line
);
835 | expression
'-' expression
836 { PEBinary
*tmp
= new PEBinary
('-', $1, $3);
837 tmp
->set_file
(@
2.text
);
838 tmp
->set_lineno
(@
2.first_line
);
841 | expression
'&' expression
842 { PEBinary
*tmp
= new PEBinary
('&', $1, $3);
843 tmp
->set_file
(@
2.text
);
844 tmp
->set_lineno
(@
2.first_line
);
847 | expression
'|' expression
848 { PEBinary
*tmp
= new PEBinary
('|', $1, $3);
849 tmp
->set_file
(@
2.text
);
850 tmp
->set_lineno
(@
2.first_line
);
853 | expression K_NAND expression
854 { PEBinary
*tmp
= new PEBinary
('A', $1, $3);
855 tmp
->set_file
(@
2.text
);
856 tmp
->set_lineno
(@
2.first_line
);
859 | expression K_NOR expression
860 { PEBinary
*tmp
= new PEBinary
('O', $1, $3);
861 tmp
->set_file
(@
2.text
);
862 tmp
->set_lineno
(@
2.first_line
);
865 | expression K_NXOR expression
866 { PEBinary
*tmp
= new PEBinary
('X', $1, $3);
867 tmp
->set_file
(@
2.text
);
868 tmp
->set_lineno
(@
2.first_line
);
871 | expression
'<' expression
872 { PEBinary
*tmp
= new PEBComp
('<', $1, $3);
873 tmp
->set_file
(@
2.text
);
874 tmp
->set_lineno
(@
2.first_line
);
877 | expression
'>' expression
878 { PEBinary
*tmp
= new PEBComp
('>', $1, $3);
879 tmp
->set_file
(@
2.text
);
880 tmp
->set_lineno
(@
2.first_line
);
883 | expression K_LS expression
884 { PEBinary
*tmp
= new PEBShift
('l', $1, $3);
885 tmp
->set_file
(@
2.text
);
886 tmp
->set_lineno
(@
2.first_line
);
889 | expression K_RS expression
890 { PEBinary
*tmp
= new PEBShift
('r', $1, $3);
891 tmp
->set_file
(@
2.text
);
892 tmp
->set_lineno
(@
2.first_line
);
895 | expression K_RSS expression
896 { PEBinary
*tmp
= new PEBShift
('R', $1, $3);
897 tmp
->set_file
(@
2.text
);
898 tmp
->set_lineno
(@
2.first_line
);
901 | expression K_EQ expression
902 { PEBinary
*tmp
= new PEBComp
('e', $1, $3);
903 tmp
->set_file
(@
2.text
);
904 tmp
->set_lineno
(@
2.first_line
);
907 | expression K_CEQ expression
908 { PEBinary
*tmp
= new PEBComp
('E', $1, $3);
909 tmp
->set_file
(@
2.text
);
910 tmp
->set_lineno
(@
2.first_line
);
913 | expression K_LE expression
914 { PEBinary
*tmp
= new PEBComp
('L', $1, $3);
915 tmp
->set_file
(@
2.text
);
916 tmp
->set_lineno
(@
2.first_line
);
919 | expression K_GE expression
920 { PEBinary
*tmp
= new PEBComp
('G', $1, $3);
921 tmp
->set_file
(@
2.text
);
922 tmp
->set_lineno
(@
2.first_line
);
925 | expression K_NE expression
926 { PEBinary
*tmp
= new PEBComp
('n', $1, $3);
927 tmp
->set_file
(@
2.text
);
928 tmp
->set_lineno
(@
2.first_line
);
931 | expression K_CNE expression
932 { PEBinary
*tmp
= new PEBComp
('N', $1, $3);
933 tmp
->set_file
(@
2.text
);
934 tmp
->set_lineno
(@
2.first_line
);
937 | expression K_LOR expression
938 { PEBinary
*tmp
= new PEBinary
('o', $1, $3);
939 tmp
->set_file
(@
2.text
);
940 tmp
->set_lineno
(@
2.first_line
);
943 | expression K_LAND expression
944 { PEBinary
*tmp
= new PEBinary
('a', $1, $3);
945 tmp
->set_file
(@
2.text
);
946 tmp
->set_lineno
(@
2.first_line
);
949 | expression
'?' expression
':' expression
950 { PETernary
*tmp
= new PETernary
($1, $3, $5);
951 tmp
->set_file
(@
2.text
);
952 tmp
->set_lineno
(@
2.first_line
);
960 | expression
':' expression
':' expression
961 { switch
(min_typ_max_flag
) {
982 /* Many contexts take a comma separated list of expressions. Null
983 expressions can happen anywhere in the list, so there are two
984 extra rules in expression_list_with_nuls for parsing and
985 installing those nulls.
987 The expression_list_proper rules do not allow null items in the
988 expression list, so can be used where nul expressions are not allowed. */
990 expression_list_with_nuls
991 : expression_list_with_nuls
',' expression
992 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
997 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1002 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1007 | expression_list_with_nuls
','
1008 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, 0);
1014 expression_list_proper
1015 : expression_list_proper
',' expression
1016 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, $3);
1021 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
1030 PENumber
*tmp
= new PENumber
($1);
1031 tmp
->set_file
(@
1.text
);
1032 tmp
->set_lineno
(@
1.first_line
);
1036 { PEFNumber
*tmp
= new PEFNumber
($1);
1037 tmp
->set_file
(@
1.text
);
1038 tmp
->set_lineno
(@
1.first_line
);
1042 { PEString
*tmp
= new PEString
($1);
1043 tmp
->set_file
(@
1.text
);
1044 tmp
->set_lineno
(@
1.first_line
);
1048 { perm_string tn
= lex_strings.make
($1);
1049 PECallFunction
*tmp
= new PECallFunction
(tn
);
1050 tmp
->set_file
(@
1.text
);
1051 tmp
->set_lineno
(@
1.first_line
);
1056 /* The heirarchy_identifier rule matches simple identifiers as well as
1057 indexed arrays and part selects */
1059 | heirarchy_identifier
1060 { PEIdent
*tmp
= new PEIdent
(*$1);
1061 tmp
->set_file
(@
1.text
);
1062 tmp
->set_lineno
(@
1.first_line
);
1067 /* An identifer followed by an expression list in parentheses is a
1068 function call. If a system identifier, then a system function
1071 | heirarchy_identifier
'(' expression_list_proper
')'
1072 { PECallFunction
*tmp
= new PECallFunction
(*$1, *$3);
1073 tmp
->set_file
(@
1.text
);
1074 tmp
->set_lineno
(@
1.first_line
);
1078 | SYSTEM_IDENTIFIER
'(' expression_list_proper
')'
1079 { perm_string tn
= lex_strings.make
($1);
1080 PECallFunction
*tmp
= new PECallFunction
(tn
, *$3);
1081 tmp
->set_file
(@
1.text
);
1082 tmp
->set_lineno
(@
1.first_line
);
1086 /* Parenthesized expressions are primaries. */
1088 |
'(' expr_mintypmax
')'
1091 /* Various kinds of concatenation expressions. */
1093 |
'{' expression_list_proper
'}'
1094 { PEConcat
*tmp
= new PEConcat
(*$2);
1095 tmp
->set_file
(@
1.text
);
1096 tmp
->set_lineno
(@
1.first_line
);
1100 |
'{' expression
'{' expression_list_proper
'}' '}'
1102 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1103 tmp
->set_file
(@
1.text
);
1104 tmp
->set_lineno
(@
1.first_line
);
1108 |
'{' expression
'{' expression_list_proper
'}' error '}'
1110 PEConcat
*tmp
= new PEConcat
(*$4, rep
);
1111 tmp
->set_file
(@
1.text
);
1112 tmp
->set_lineno
(@
1.first_line
);
1115 yyerror(@
5, "error: Syntax error between internal '}' "
1116 "and closing '}' of repeat concatenation.");
1121 /* A function_item is either a block item (i.e. a reg or integer
1122 declaration) or an input declaration. There are no output or
1125 : K_input signed_opt range_opt list_of_identifiers
';'
1126 { svector
<PWire
*>*tmp
1127 = pform_make_task_ports
(NetNet
::PINPUT
,
1130 @
1.text
, @
1.first_line
);
1133 | K_output signed_opt range_opt list_of_identifiers
';'
1134 { svector
<PWire
*>*tmp
1135 = pform_make_task_ports
(NetNet
::PINPUT
,
1138 @
1.text
, @
1.first_line
);
1140 yyerror(@
1, "Functions may not have output ports.");
1142 | K_inout signed_opt range_opt list_of_identifiers
';'
1143 { svector
<PWire
*>*tmp
1144 = pform_make_task_ports
(NetNet
::PINPUT
,
1147 @
1.text
, @
1.first_line
);
1149 yyerror(@
1, "Functions may not have inout ports.");
1152 /* When the port is an integer, infer a signed vector of the integer
1153 shape. Generate a range to make it work. */
1155 | K_input K_integer list_of_identifiers
';'
1156 { svector
<PExpr
*>*range_stub
1157 = new svector
<PExpr
*>(2);
1159 re
= new PENumber
(new verinum
(integer_width
-1,
1161 (*range_stub
)[0] = re
;
1162 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
1163 (*range_stub
)[1] = re
;
1165 = pform_make_task_ports
(NetNet
::PINPUT
,
1168 @
1.text
, @
1.first_line
);
1172 /* Ports can be real. */
1174 | K_input K_real list_of_identifiers
';'
1175 { svector
<PWire
*>*tmp
1176 = pform_make_task_ports
(NetNet
::PINPUT
,
1179 @
1.text
, @
1.first_line
);
1187 /* A function_item_list only lists the input/output/inout
1188 declarations. The integer and reg declarations are handled in
1189 place, so are not listed. The list builder needs to account for
1190 the possibility that the various parts may be NULL. */
1194 | function_item_list function_item
1196 svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
1208 /* A gate_instance is a module instantiation or a built in part
1209 type. In any case, the gate has a set of connections to ports. */
1211 : IDENTIFIER
'(' expression_list_with_nuls
')'
1212 { lgate
*tmp
= new lgate
;
1215 tmp
->file
= @
1.text
;
1216 tmp
->lineno
= @
1.first_line
;
1221 | IDENTIFIER range
'(' expression_list_with_nuls
')'
1222 { lgate
*tmp
= new lgate
;
1223 svector
<PExpr
*>*rng
= $2;
1226 tmp
->range
[0] = (*rng
)[0];
1227 tmp
->range
[1] = (*rng
)[1];
1228 tmp
->file
= @
1.text
;
1229 tmp
->lineno
= @
1.first_line
;
1234 |
'(' expression_list_with_nuls
')'
1235 { lgate
*tmp
= new lgate
;
1238 tmp
->file
= @
1.text
;
1239 tmp
->lineno
= @
1.first_line
;
1243 /* Degenerate modules can have no ports. */
1246 { lgate
*tmp
= new lgate
;
1247 svector
<PExpr
*>*rng
= $2;
1250 tmp
->parms_by_name
= 0;
1251 tmp
->range
[0] = (*rng
)[0];
1252 tmp
->range
[1] = (*rng
)[1];
1253 tmp
->file
= @
1.text
;
1254 tmp
->lineno
= @
1.first_line
;
1260 /* Modules can also take ports by port-name expressions. */
1262 | IDENTIFIER
'(' port_name_list
')'
1263 { lgate
*tmp
= new lgate
;
1266 tmp
->parms_by_name
= $3;
1267 tmp
->file
= @
1.text
;
1268 tmp
->lineno
= @
1.first_line
;
1273 | IDENTIFIER range
'(' port_name_list
')'
1274 { lgate
*tmp
= new lgate
;
1275 svector
<PExpr
*>*rng
= $2;
1278 tmp
->parms_by_name
= $4;
1279 tmp
->range
[0] = (*rng
)[0];
1280 tmp
->range
[1] = (*rng
)[1];
1281 tmp
->file
= @
1.text
;
1282 tmp
->lineno
= @
1.first_line
;
1290 : gate_instance_list
',' gate_instance
1291 { svector
<lgate
>*tmp1
= $1;
1293 svector
<lgate
>*out
= new svector
<lgate
> (*tmp1
, *tmp2
);
1299 { svector
<lgate
>*tmp
= new svector
<lgate
>(1);
1307 : K_and
{ $$
= PGBuiltin
::AND
; }
1308 | K_nand
{ $$
= PGBuiltin
::NAND
; }
1309 | K_or
{ $$
= PGBuiltin
::OR
; }
1310 | K_nor
{ $$
= PGBuiltin
::NOR
; }
1311 | K_xor
{ $$
= PGBuiltin
::XOR
; }
1312 | K_xnor
{ $$
= PGBuiltin
::XNOR
; }
1313 | K_buf
{ $$
= PGBuiltin
::BUF
; }
1314 | K_bufif0
{ $$
= PGBuiltin
::BUFIF0
; }
1315 | K_bufif1
{ $$
= PGBuiltin
::BUFIF1
; }
1316 | K_not
{ $$
= PGBuiltin
::NOT
; }
1317 | K_notif0
{ $$
= PGBuiltin
::NOTIF0
; }
1318 | K_notif1
{ $$
= PGBuiltin
::NOTIF1
; }
1319 | K_nmos
{ $$
= PGBuiltin
::NMOS
; }
1320 | K_rnmos
{ $$
= PGBuiltin
::RNMOS
; }
1321 | K_pmos
{ $$
= PGBuiltin
::PMOS
; }
1322 | K_rpmos
{ $$
= PGBuiltin
::RPMOS
; }
1323 | K_cmos
{ $$
= PGBuiltin
::CMOS
; }
1324 | K_rcmos
{ $$
= PGBuiltin
::RCMOS
; }
1325 | K_tran
{ $$
= PGBuiltin
::TRAN
; }
1326 | K_rtran
{ $$
= PGBuiltin
::RTRAN
; }
1327 | K_tranif0
{ $$
= PGBuiltin
::TRANIF0
; }
1328 | K_tranif1
{ $$
= PGBuiltin
::TRANIF1
; }
1329 | K_rtranif0
{ $$
= PGBuiltin
::RTRANIF0
; }
1330 | K_rtranif1
{ $$
= PGBuiltin
::RTRANIF1
; }
1334 /* A general identifier is a hierarchical name, with the right most
1335 name the base of the identifier. This rule builds up a
1336 hierarchical name from the left to the right, forming a list of
1339 heirarchy_identifier
1341 { $$
= new pform_name_t
;
1342 $$
->push_back
(name_component_t
(lex_strings.make
($1)));
1345 | heirarchy_identifier
'.' IDENTIFIER
1346 { pform_name_t
* tmp
= $1;
1347 tmp
->push_back
(name_component_t
(lex_strings.make
($3)));
1351 | heirarchy_identifier
'[' expression
']'
1352 { pform_name_t
* tmp
= $1;
1353 name_component_t
&tail
= tmp
->back
();
1354 index_component_t itmp
;
1355 itmp.sel
= index_component_t
::SEL_BIT
;
1357 tail.index.push_back
(itmp
);
1360 | heirarchy_identifier
'[' expression
':' expression
']'
1361 { pform_name_t
* tmp
= $1;
1362 name_component_t
&tail
= tmp
->back
();
1363 index_component_t itmp
;
1364 itmp.sel
= index_component_t
::SEL_PART
;
1367 tail.index.push_back
(itmp
);
1370 | heirarchy_identifier
'[' expression K_PO_POS expression
']'
1371 { pform_name_t
* tmp
= $1;
1372 name_component_t
&tail
= tmp
->back
();
1373 index_component_t itmp
;
1374 itmp.sel
= index_component_t
::SEL_IDX_UP
;
1377 tail.index.push_back
(itmp
);
1380 | heirarchy_identifier
'[' expression K_PO_NEG expression
']'
1381 { pform_name_t
* tmp
= $1;
1382 name_component_t
&tail
= tmp
->back
();
1383 index_component_t itmp
;
1384 itmp.sel
= index_component_t
::SEL_IDX_DO
;
1387 tail.index.push_back
(itmp
);
1392 /* This is a list of identifiers. The result is a list of strings,
1393 each one of the identifiers in the list. These are simple,
1394 non-hierarchical names separated by ',' characters. */
1397 { $$
= list_from_identifier
($1); }
1398 | list_of_identifiers
',' IDENTIFIER
1399 { $$
= list_from_identifier
($1, $3); }
1403 /* The list_of_ports and list_of_port_declarations rules are the
1404 port list formats for module ports. The list_of_ports_opt rule is
1405 only used by the module start rule.
1407 The first, the list_of_ports, is the 1364-1995 format, a list of
1408 port names, including .name() syntax.
1410 The list_of_port_declarations the 1364-2001 format, an in-line
1411 declaration of the ports.
1413 In both cases, the list_of_ports and list_of_port_declarations
1414 returns an array of Module::port_t* items that include the name
1415 of the port internally and externally. The actual creation of the
1416 nets/variables is done in the declaration, whether internal to
1417 the port list or in amongst the module items. */
1421 { svector
<Module
::port_t
*>*tmp
1422 = new svector
<Module
::port_t
*>(1);
1426 | list_of_ports
',' port_opt
1427 { svector
<Module
::port_t
*>*tmp
1428 = new svector
<Module
::port_t
*>(*$1, $3);
1434 list_of_port_declarations
1436 { svector
<Module
::port_t
*>*tmp
1437 = new svector
<Module
::port_t
*>(1);
1440 * Uncommenting this makes lopd always fully specified.
1441 * Some wanted an implicit net to not be fully defined.
1443 * pform_set_net_range($1[0].name);
1447 | list_of_port_declarations
',' port_declaration
1448 { svector
<Module
::port_t
*>*tmp
1449 = new svector
<Module
::port_t
*>(*$1, $3);
1454 * pform_set_net_range($3[0].name);
1458 | list_of_port_declarations
',' IDENTIFIER
1459 { Module
::port_t
*ptmp
;
1460 ptmp
= pform_module_port_reference
($3, @
3.text
,
1462 svector
<Module
::port_t
*>*tmp
1463 = new svector
<Module
::port_t
*>(*$1, ptmp
);
1465 /* Get the port declaration details, the port type
1466 and what not, from context data stored by the
1467 last port_declaration rule. */
1468 pform_module_define_port
(@
3, $3,
1469 port_declaration_context.port_type
,
1470 port_declaration_context.port_net_type
,
1471 port_declaration_context.sign_flag
,
1472 port_declaration_context.range
, 0);
1477 * pform_set_net_range($3);
1484 : attribute_list_opt
1485 K_input net_type_opt signed_opt range_opt IDENTIFIER
1486 { Module
::port_t
*ptmp
;
1487 ptmp
= pform_module_port_reference
($6, @
2.text
,
1489 pform_module_define_port
(@
2, $6, NetNet
::PINPUT
,
1491 port_declaration_context.port_type
= NetNet
::PINPUT
;
1492 port_declaration_context.port_net_type
= $3;
1493 port_declaration_context.sign_flag
= $4;
1494 port_declaration_context.range
= $5;
1499 | attribute_list_opt
1500 K_inout net_type_opt signed_opt range_opt IDENTIFIER
1501 { Module
::port_t
*ptmp
;
1502 ptmp
= pform_module_port_reference
($6, @
2.text
,
1504 pform_module_define_port
(@
2, $6, NetNet
::PINOUT
,
1506 port_declaration_context.port_type
= NetNet
::PINOUT
;
1507 port_declaration_context.port_net_type
= $3;
1508 port_declaration_context.sign_flag
= $4;
1509 port_declaration_context.range
= $5;
1514 | attribute_list_opt
1515 K_output net_type_opt signed_opt range_opt IDENTIFIER
1516 { Module
::port_t
*ptmp
;
1517 ptmp
= pform_module_port_reference
($6, @
2.text
,
1519 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1521 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1522 port_declaration_context.port_net_type
= $3;
1523 port_declaration_context.sign_flag
= $4;
1524 port_declaration_context.range
= $5;
1529 | attribute_list_opt
1530 K_output var_type signed_opt range_opt IDENTIFIER
1531 { Module
::port_t
*ptmp
;
1532 ptmp
= pform_module_port_reference
($6, @
2.text
,
1534 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1536 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1537 port_declaration_context.port_net_type
= $3;
1538 port_declaration_context.sign_flag
= $4;
1539 port_declaration_context.range
= $5;
1544 | attribute_list_opt
1545 K_output var_type signed_opt range_opt IDENTIFIER
'=' expression
1546 { Module
::port_t
*ptmp
;
1547 ptmp
= pform_module_port_reference
($6, @
2.text
,
1549 pform_module_define_port
(@
2, $6, NetNet
::POUTPUT
,
1551 port_declaration_context.port_type
= NetNet
::POUTPUT
;
1552 port_declaration_context.port_net_type
= $3;
1553 port_declaration_context.sign_flag
= $4;
1554 port_declaration_context.range
= $5;
1556 if
(! pform_expression_is_constant
($8))
1557 yyerror(@
8, "error: register declaration assignment"
1558 " value must be a constant expression.");
1559 pform_make_reginit
(@
6, $6, $8);
1570 : net_type
{ $$
= $1; }
1571 |
{ $$
= NetNet
::IMPLICIT
; }
1574 signed_opt
: K_signed
{ $$
= true
; } |
{$$
= false
; } ;
1576 /* An lpvalue is the expression that can go on the left side of a
1577 procedural assignment. This rule handles only procedural
1578 assignments. It is more limited then the general expr_primary
1579 rule to reflect the rules for assignment l-values. */
1581 : heirarchy_identifier
1582 { PEIdent
*tmp
= new PEIdent
(*$1);
1583 tmp
->set_file
(@
1.text
);
1584 tmp
->set_lineno
(@
1.first_line
);
1588 |
'{' expression_list_proper
'}'
1589 { PEConcat
*tmp
= new PEConcat
(*$2);
1590 tmp
->set_file
(@
1.text
);
1591 tmp
->set_lineno
(@
1.first_line
);
1598 /* Continuous assignments have a list of individual assignments. */
1601 : lpvalue
'=' expression
1602 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(2);
1610 : cont_assign_list
',' cont_assign
1611 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(*$1, *$3);
1621 /* This is the global structure of a module. A module in a start
1622 section, with optional ports, then an optional list of module
1623 items, and finally an end marker. */
1625 module
: attribute_list_opt module_start IDENTIFIER
1626 { pform_startmodule
($3, @
2.text
, @
2.first_line
, $1); }
1627 module_parameter_port_list_opt
1628 module_port_list_opt
';'
1629 { pform_module_set_ports
($6); }
1630 module_item_list_opt
1632 { pform_endmodule
($3);
1638 module_start
: K_module | K_macromodule
;
1640 module_port_list_opt
1641 : '(' list_of_ports
')' { $$
= $2; }
1642 |
'(' list_of_port_declarations
')' { $$
= $2; }
1646 /* Module declarations include optional ANSII style module parameter
1647 ports. These are simply advance ways to declare parameters, so
1648 that the port declarations may use them. */
1649 module_parameter_port_list_opt
1651 |
'#' '(' module_parameter_port_list
')'
1654 module_parameter_port_list
1655 : K_parameter parameter_assign
1656 | module_parameter_port_list
',' parameter_assign
1657 | module_parameter_port_list
',' K_parameter parameter_assign
1662 /* This rule detects net declarations that possibly include a
1663 primitive type, an optional vector range and signed flag. This
1664 also includes an optional delay set. The values are then applied
1665 to a list of names. If the primitive type is not specified, then
1666 resort to the default type LOGIC. */
1668 : attribute_list_opt net_type
1669 primitive_type_opt signed_opt range_opt
1671 net_variable_list
';'
1673 { ivl_variable_type_t dtype
= $3;
1674 if
(dtype
== IVL_VT_NO_TYPE
)
1675 dtype
= IVL_VT_LOGIC
;
1676 pform_makewire
(@
2, $5, $4, $7, $2,
1677 NetNet
::NOT_A_PORT
, dtype
, $1);
1679 yyerror(@
6, "sorry: net delays not supported.");
1685 /* Very similar to the rule above, but this takes a list of
1686 net_decl_assigns, which are <name> = <expr> assignment
1689 | attribute_list_opt net_type
1690 primitive_type_opt signed_opt range_opt
1691 delay3_opt net_decl_assigns
';'
1693 { ivl_variable_type_t dtype
= $3;
1694 if
(dtype
== IVL_VT_NO_TYPE
)
1695 dtype
= IVL_VT_LOGIC
;
1696 pform_makewire
(@
2, $5, $4, $6,
1697 str_strength
, $7, $2, dtype
);
1699 yyerror(@
2, "sorry: Attributes not supported "
1700 "on net declaration assignments.");
1705 /* This form doesn't have the range, but does have strengths. This
1706 gives strength to the assignment drivers. */
1708 | attribute_list_opt net_type
1709 primitive_type_opt signed_opt
1710 drive_strength net_decl_assigns
';'
1712 { ivl_variable_type_t dtype
= $3;
1713 if
(dtype
== IVL_VT_NO_TYPE
)
1714 dtype
= IVL_VT_LOGIC
;
1715 pform_makewire
(@
2, 0, $4, 0, $5, $6, $2, dtype
);
1717 yyerror(@
2, "sorry: Attributes not supported "
1718 "on net declaration assignments.");
1723 | K_trireg charge_strength_opt range_opt delay3_opt list_of_identifiers
';'
1724 { yyerror(@
1, "sorry: trireg nets not supported.");
1729 | port_type signed_opt range_opt delay3_opt list_of_identifiers
';'
1730 { pform_set_port_type
(@
1, $5, $3, $2, $1);
1733 /* The next two rules handle Verilog 2001 statements of the form:
1734 input wire signed [h:l] <list>;
1735 This creates the wire and sets the port type all at once. */
1737 | port_type net_type signed_opt range_opt list_of_identifiers
';'
1738 { pform_makewire
(@
1, $4, $3, $5, $2, $1, IVL_VT_NO_TYPE
, 0,
1742 | K_output var_type signed_opt range_opt list_of_identifiers
';'
1743 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::POUTPUT
,
1744 IVL_VT_NO_TYPE
, 0, SR_BOTH
);
1747 /* var_type declaration (reg variables) cannot be input or output,
1748 because the port declaration implies an external driver, which
1749 cannot be attached to a reg. These rules catch that error early. */
1751 | K_input var_type signed_opt range_opt list_of_identifiers
';'
1752 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINPUT
,
1754 yyerror(@
2, "error: reg variables cannot be inputs.");
1757 | K_inout var_type signed_opt range_opt list_of_identifiers
';'
1758 { pform_makewire
(@
1, $4, $3, $5, $2, NetNet
::PINOUT
,
1760 yyerror(@
2, "error: reg variables cannot be inouts.");
1763 | port_type signed_opt range_opt delay3_opt
error ';'
1764 { yyerror(@
1, "error: Invalid variable list"
1765 " in port declaration.");
1771 /* block_item_decl rule is shared with task blocks and named
1778 | K_defparam defparam_assign_list
';'
1779 | K_event list_of_identifiers
';'
1780 { pform_make_events
($2, @
1.text
, @
1.first_line
);
1783 /* Most gate types have an optional drive strength and optional
1784 three-value delay. These rules handle the different cases. */
1786 | attribute_list_opt gatetype gate_instance_list
';'
1787 { pform_makegates
($2, str_strength
, 0, $3, $1);
1790 | attribute_list_opt gatetype delay3 gate_instance_list
';'
1791 { pform_makegates
($2, str_strength
, $3, $4, $1);
1794 | attribute_list_opt gatetype drive_strength gate_instance_list
';'
1795 { pform_makegates
($2, $3, 0, $4, $1);
1798 | attribute_list_opt gatetype drive_strength delay3 gate_instance_list
';'
1799 { pform_makegates
($2, $3, $4, $5, $1);
1802 /* Pullup and pulldown devices cannot have delays, and their
1803 strengths are limited. */
1805 | K_pullup gate_instance_list
';'
1806 { pform_makegates
(PGBuiltin
::PULLUP
, pull_strength
, 0,
1809 | K_pulldown gate_instance_list
';'
1810 { pform_makegates
(PGBuiltin
::PULLDOWN
, pull_strength
,
1814 | K_pullup
'(' dr_strength1
')' gate_instance_list
';'
1815 { pform_makegates
(PGBuiltin
::PULLUP
, $3, 0, $5, 0);
1818 | K_pulldown
'(' dr_strength0
')' gate_instance_list
';'
1819 { pform_makegates
(PGBuiltin
::PULLDOWN
, $3, 0, $5, 0);
1822 /* This rule handles instantiations of modules and user defined
1823 primitives. These devices to not have delay lists or strengths,
1824 but then can have parameter lists. */
1826 | attribute_list_opt
1827 IDENTIFIER parameter_value_opt gate_instance_list
';'
1828 { perm_string tmp1
= lex_strings.make
($2);
1829 pform_make_modgates
(tmp1
, $3, $4);
1834 | attribute_list_opt
1835 IDENTIFIER parameter_value_opt
error ';'
1836 { yyerror(@
2, "error: Invalid module instantiation");
1840 /* Continuous assignment can have an optional drive strength, then
1841 an optional delay3 that applies to all the assignments in the
1842 cont_assign_list. */
1844 | K_assign drive_strength_opt delay3_opt cont_assign_list
';'
1845 { pform_make_pgassign_list
($4, $3, $2, @
1.text
, @
1.first_line
); }
1847 /* Always and initial items are behavioral processes. */
1849 | attribute_list_opt K_always statement
1850 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_ALWAYS
,
1852 tmp
->set_file
(@
2.text
);
1853 tmp
->set_lineno
(@
2.first_line
);
1855 | attribute_list_opt K_initial statement
1856 { PProcess
*tmp
= pform_make_behavior
(PProcess
::PR_INITIAL
,
1858 tmp
->set_file
(@
2.text
);
1859 tmp
->set_lineno
(@
2.first_line
);
1862 /* The task declaration rule matches the task declaration
1863 header, then pushes the function scope. This causes the
1864 definitions in the task_body to take on the scope of the task
1865 instead of the module. Note that these runs accept for the task
1866 body statement_or_null, although the standard does not allow null
1867 statements in the task body. But we continue to accept it as an
1870 | K_task IDENTIFIER
';'
1871 { pform_push_scope
($2); }
1875 { PTask
*tmp
= new PTask
;
1876 perm_string tmp2
= lex_strings.make
($2);
1877 tmp
->set_file
(@
1.text
);
1878 tmp
->set_lineno
(@
1.first_line
);
1880 tmp
->set_statement
($6);
1881 pform_set_task
(tmp2
, tmp
);
1887 { pform_push_scope
($2); }
1888 '(' task_port_decl_list
')' ';'
1892 { PTask
*tmp
= new PTask
;
1893 perm_string tmp2
= lex_strings.make
($2);
1894 tmp
->set_file
(@
1.text
);
1895 tmp
->set_lineno
(@
1.first_line
);
1897 tmp
->set_statement
($9);
1898 pform_set_task
(tmp2
, tmp
);
1903 /* The function declaration rule matches the function declaration
1904 header, then pushes the function scope. This causes the
1905 definitions in the func_body to take on the scope of the function
1906 instead of the module. */
1908 | K_function function_range_or_type_opt IDENTIFIER
';'
1909 { pform_push_scope
($3); }
1910 function_item_list statement
1912 { perm_string name
= lex_strings.make
($3);
1913 PFunction
*tmp
= new PFunction
(name
);
1914 tmp
->set_file
(@
1.text
);
1915 tmp
->set_lineno
(@
1.first_line
);
1917 tmp
->set_statement
($7);
1918 tmp
->set_return
($2);
1919 pform_set_function
(name
, tmp
);
1924 /* A generate region can contain further module items. Actually, it
1925 is supposed to be limited to certain kinds of module items, but
1926 the semantic tests will check that for us. */
1928 | K_generate module_item_list_opt K_endgenerate
1930 | K_genvar list_of_identifiers
';'
1931 { pform_genvars
($2); }
1933 | K_for
'(' IDENTIFIER
'=' expression
';'
1935 IDENTIFIER
'=' expression
')'
1936 { pform_start_generate_for
(@
1, $3, $5, $7, $9, $11); }
1938 { pform_endgenerate
(); }
1943 { pform_start_generate_else
(@
1); }
1945 { pform_endgenerate
(); }
1948 generate_block_opt %prec less_than_K_else
1949 { pform_endgenerate
(); }
1951 /* specify blocks are parsed but ignored. */
1953 | K_specify K_endspecify
1954 { /* empty lists are legal syntax. */ }
1956 | K_specify specify_item_list K_endspecify
1960 | K_specify
error K_endspecify
1961 { yyerror(@
1, "error: syntax error in specify block");
1965 /* These rules match various errors that the user can type into
1966 module items. These rules try to catch them at a point where a
1967 reasonable error message can be produced. */
1969 | K_module
error ';'
1970 { yyerror(@
2, "error: missing endmodule or attempt to "
1972 pform_error_nested_modules
();
1977 { yyerror(@
2, "error: invalid module item.");
1981 | K_assign
error '=' expression
';'
1982 { yyerror(@
1, "error: syntax error in left side "
1983 "of continuous assignment.");
1987 | K_assign
error ';'
1988 { yyerror(@
1, "error: syntax error in "
1989 "continuous assignment");
1993 | K_function
error K_endfunction
1994 { yyerror(@
1, "error: I give up on this "
1995 "function definition.");
1999 /* These rules are for the Icarus Verilog specific $attribute
2000 extensions. Then catch the parameters of the $attribute keyword. */
2002 | KK_attribute
'(' IDENTIFIER
',' STRING
',' STRING
')' ';'
2003 { perm_string tmp3
= lex_strings.make
($3);
2004 perm_string tmp5
= lex_strings.make
($5);
2005 pform_set_attrib
(tmp3
, tmp5
, $7);
2009 | KK_attribute
'(' error ')' ';'
2010 { yyerror(@
1, "error: Malformed $attribute parameter list."); }
2013 generate_if
: K_if
'(' expression
')' { pform_start_generate_if
(@
1, $3); }
2016 : module_item_list module_item
2020 module_item_list_opt
2025 /* A generate block is the thing within a generate scheme. It may be
2026 a single module item, an anonymous block of module items, or a
2027 named module item. In all cases, the meat is in the module items
2028 inside, and the processing is done by the module_item rules. We
2029 only need to take note here of the scope name, if any. */
2033 | K_begin module_item_list_opt K_end
2034 | K_begin
':' IDENTIFIER module_item_list_opt K_end
2035 { pform_generate_block_name
($3); }
2038 generate_block_opt
: generate_block |
';' ;
2041 /* A net declaration assignment allows the programmer to combine the
2042 net declaration and the continuous assignment into a single
2045 Note that the continuous assignment statement is generated as a
2046 side effect, and all I pass up is the name of the l-value. */
2049 : IDENTIFIER
'=' expression
2050 { net_decl_assign_t
*tmp
= new net_decl_assign_t
;
2059 : net_decl_assigns
',' net_decl_assign
2060 { net_decl_assign_t
*tmp
= $1;
2061 $3->next
= tmp
->next
;
2071 : K_logic
{ $$
= IVL_VT_LOGIC
; }
2072 | K_bool
{ $$
= IVL_VT_BOOL
; }
2073 | K_real
{ $$
= IVL_VT_REAL
; }
2076 primitive_type_opt
: primitive_type
{ $$
= $1; } |
{ $$
= IVL_VT_NO_TYPE
; } ;
2079 : K_wire
{ $$
= NetNet
::WIRE
; }
2080 | K_tri
{ $$
= NetNet
::TRI
; }
2081 | K_tri1
{ $$
= NetNet
::TRI1
; }
2082 | K_supply0
{ $$
= NetNet
::SUPPLY0
; }
2083 | K_wand
{ $$
= NetNet
::WAND
; }
2084 | K_triand
{ $$
= NetNet
::TRIAND
; }
2085 | K_tri0
{ $$
= NetNet
::TRI0
; }
2086 | K_supply1
{ $$
= NetNet
::SUPPLY1
; }
2087 | K_wor
{ $$
= NetNet
::WOR
; }
2088 | K_trior
{ $$
= NetNet
::TRIOR
; }
2089 | K_wone
{ $$
= NetNet
::WONE
; }
2093 : K_reg
{ $$
= NetNet
::REG
; }
2096 /* In this rule we have matched the "parameter" keyword. The rule
2097 generates a type (optional) and a list of assignments. */
2099 parameter_assign_decl
2100 : parameter_assign_list
2101 | range
{ active_range
= $1; active_signed
= false
; }
2102 parameter_assign_list
2104 active_signed
= false
;
2106 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2107 parameter_assign_list
2109 active_signed
= false
;
2111 | K_integer
{ active_range
= 0; active_signed
= true
; }
2112 parameter_assign_list
2114 active_signed
= false
;
2118 parameter_assign_list
2120 | parameter_assign_list
',' parameter_assign
2124 : IDENTIFIER
'=' expression
2126 if
(!pform_expression_is_constant
(tmp
)) {
2127 yyerror(@
3, "error: parameter value "
2128 "must be a constant expression.");
2132 pform_set_parameter
(lex_strings.make
($1),
2140 /* Localparam assignments and assignment lists are broken into
2141 separate BNF so that I can call slightly different parameter
2142 handling code. They parse the same as parameters, they just
2143 behave differently when someone tries to override them. */
2146 : IDENTIFIER
'=' expression
2148 if
(!pform_expression_is_constant
(tmp
)) {
2149 yyerror(@
3, "error: parameter value "
2150 "must be constant.");
2154 pform_set_localparam
(lex_strings.make
($1),
2162 localparam_assign_decl
2163 : localparam_assign_list
2164 | range
{ active_range
= $1; active_signed
= false
; }
2165 localparam_assign_list
2167 active_signed
= false
;
2169 | K_signed range
{ active_range
= $2; active_signed
= true
; }
2170 localparam_assign_list
2172 active_signed
= false
;
2176 localparam_assign_list
2178 | localparam_assign_list
',' localparam_assign
2183 /* The parameters of a module instance can be overridden by writing
2184 a list of expressions in a syntax much like a delay list. (The
2185 difference being the list can have any length.) The pform that
2186 attaches the expression list to the module checks that the
2187 expressions are constant.
2189 Although the BNF in IEEE1364-1995 implies that parameter value
2190 lists must be in parentheses, in practice most compilers will
2191 accept simple expressions outside of parentheses if there is only
2192 one value, so I'll accept simple numbers here.
2194 The parameter value by name syntax is OVI enhancement BTF-B06 as
2195 approved by WG1364 on 6/28/1998. */
2198 : '#' '(' expression_list_with_nuls
')'
2199 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2204 |
'#' '(' parameter_value_byname_list
')'
2205 { struct parmvalue_t
*tmp
= new
struct parmvalue_t
;
2212 PENumber
*tmp
= new PENumber
($2);
2213 tmp
->set_file
(@
1.text
);
2214 tmp
->set_lineno
(@
1.first_line
);
2216 struct parmvalue_t
*lst
= new
struct parmvalue_t
;
2217 lst
->by_order
= new svector
<PExpr
*>(1);
2218 (*lst
->by_order
)[0] = tmp
;
2223 { yyerror(@
1, "error: syntax error in parameter value "
2224 "assignment list.");
2231 parameter_value_byname
2232 : '.' IDENTIFIER
'(' expression
')'
2233 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2234 tmp
->name
= lex_strings.make
($2);
2239 |
'.' IDENTIFIER
'(' ')'
2240 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2241 tmp
->name
= lex_strings.make
($2);
2248 parameter_value_byname_list
2249 : parameter_value_byname
2250 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2254 | parameter_value_byname_list
',' parameter_value_byname
2255 { svector
<named_pexpr_t
*>*tmp
=
2256 new svector
<named_pexpr_t
*>(*$1,$3);
2263 /* The port (of a module) is a fairly complex item. Each port is
2264 handled as a Module::port_t object. A simple port reference has a
2265 name and a PExpr object, but more complex constructs are possible
2266 where the name can be attached to a list of PWire objects.
2268 The port_reference returns a Module::port_t, and so does the
2269 port_reference_list. The port_reference_list may have built up a
2270 list of PWires in the port_t object, but it is still a single
2271 Module::port_t object.
2273 The port rule below takes the built up Module::port_t object and
2274 tweaks its name as needed. */
2280 /* This syntax attaches an external name to the port reference so
2281 that the caller can bind by name to non-trivial port
2282 references. The port_t object gets its PWire from the
2283 port_reference, but its name from the IDENTIFIER. */
2285 |
'.' IDENTIFIER
'(' port_reference
')'
2286 { Module
::port_t
*tmp
= $4;
2287 tmp
->name
= lex_strings.make
($2);
2292 /* A port can also be a concatenation of port references. In this
2293 case the port does not have a name available to the outside, only
2294 positional parameter passing is possible here. */
2296 |
'{' port_reference_list
'}'
2297 { Module
::port_t
*tmp
= $2;
2298 tmp
->name
= perm_string
();
2302 /* This attaches a name to a port reference concatenation list so
2303 that parameter passing be name is possible. */
2305 |
'.' IDENTIFIER
'(' '{' port_reference_list
'}' ')'
2306 { Module
::port_t
*tmp
= $5;
2307 tmp
->name
= lex_strings.make
($2);
2319 /* A port reference is an internal (to the module) name of the port,
2320 possibly with a part of bit select to attach it to specific bits
2321 of a signal fully declared inside the module.
2323 The parser creates a PEIdent for every port reference, even if the
2324 signal is bound to different ports. The elaboration figures out
2325 the mess that this creates. The port_reference (and the
2326 port_reference_list below) puts the port reference PEIdent into the
2327 port_t object to pass it up to the module declaration code. */
2332 { Module
::port_t
*ptmp
;
2333 ptmp
= pform_module_port_reference
($1, @
1.text
, @
1.first_line
);
2338 | IDENTIFIER
'[' expression
':' expression
']'
2339 { if
(!pform_expression_is_constant
($3)) {
2340 yyerror(@
3, "error: msb expression of "
2341 "port part select must be constant.");
2343 if
(!pform_expression_is_constant
($5)) {
2344 yyerror(@
5, "error: lsb expression of "
2345 "port part select must be constant.");
2347 index_component_t itmp
;
2348 itmp.sel
= index_component_t
::SEL_PART
;
2352 name_component_t ntmp
(lex_strings.make
($1));
2353 ntmp.index.push_back
(itmp
);
2356 pname.push_back
(ntmp
);
2358 PEIdent
*wtmp
= new PEIdent
(pname
);
2359 wtmp
->set_file
(@
1.text
);
2360 wtmp
->set_lineno
(@
1.first_line
);
2362 Module
::port_t
*ptmp
= new Module
::port_t
;
2363 ptmp
->name
= perm_string
();
2364 ptmp
->expr
= svector
<PEIdent
*>(1);
2365 ptmp
->expr
[0] = wtmp
;
2371 | IDENTIFIER
'[' expression
']'
2372 { if
(!pform_expression_is_constant
($3)) {
2373 yyerror(@
3, "error: port bit select "
2374 "must be constant.");
2376 index_component_t itmp
;
2377 itmp.sel
= index_component_t
::SEL_BIT
;
2381 name_component_t ntmp
(lex_strings.make
($1));
2382 ntmp.index.push_back
(itmp
);
2385 pname.push_back
(ntmp
);
2387 PEIdent
*tmp
= new PEIdent
(pname
);
2388 tmp
->set_file
(@
1.text
);
2389 tmp
->set_lineno
(@
1.first_line
);
2391 Module
::port_t
*ptmp
= new Module
::port_t
;
2392 ptmp
->name
= perm_string
();
2393 ptmp
->expr
= svector
<PEIdent
*>(1);
2394 ptmp
->expr
[0] = tmp
;
2399 | IDENTIFIER
'[' error ']'
2400 { yyerror(@
1, "error: invalid port bit select");
2401 Module
::port_t
*ptmp
= new Module
::port_t
;
2402 PEIdent
*wtmp
= new PEIdent
(lex_strings.make
($1));
2403 wtmp
->set_file
(@
1.text
);
2404 wtmp
->set_lineno
(@
1.first_line
);
2405 ptmp
->name
= lex_strings.make
($1);
2406 ptmp
->expr
= svector
<PEIdent
*>(1);
2407 ptmp
->expr
[0] = wtmp
;
2417 | port_reference_list
',' port_reference
2418 { Module
::port_t
*tmp
= $1;
2419 tmp
->expr
= svector
<PEIdent
*>(tmp
->expr
, $3->expr
);
2425 /* The port_name rule is used with a module is being *instantiated*,
2426 and not when it is being declared. See the port rule if you are
2427 looking for the ports of a module declaration. */
2430 : '.' IDENTIFIER
'(' expression
')'
2431 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2432 tmp
->name
= lex_strings.make
($2);
2437 |
'.' IDENTIFIER
'(' error ')'
2438 { yyerror(@
4, "error: invalid port connection expression.");
2439 named_pexpr_t
*tmp
= new named_pexpr_t
;
2440 tmp
->name
= lex_strings.make
($2);
2445 |
'.' IDENTIFIER
'(' ')'
2446 { named_pexpr_t
*tmp
= new named_pexpr_t
;
2447 tmp
->name
= lex_strings.make
($2);
2455 : port_name_list
',' port_name
2456 { svector
<named_pexpr_t
*>*tmp
;
2457 tmp
= new svector
<named_pexpr_t
*>(*$1, $3);
2462 { svector
<named_pexpr_t
*>*tmp
= new svector
<named_pexpr_t
*>(1);
2469 : K_input
{ $$
= NetNet
::PINPUT
; }
2470 | K_output
{ $$
= NetNet
::POUTPUT
; }
2471 | K_inout
{ $$
= NetNet
::PINOUT
; }
2475 : '[' expression
':' expression
']'
2476 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*> (2);
2477 if
(!pform_expression_is_constant
($2))
2478 yyerror(@
2, "error: msb of range must be constant.");
2482 if
(!pform_expression_is_constant
($4))
2483 yyerror(@
4, "error: lsb of range must be constant.");
2496 /* This is used to express the return type of a function. */
2497 function_range_or_type_opt
2498 : range
{ $$.range
= $1; $$.type
= PTF_REG
; }
2499 | K_signed range
{ $$.range
= $2; $$.type
= PTF_REG_S
; }
2500 | K_integer
{ $$.range
= 0; $$.type
= PTF_INTEGER
; }
2501 | K_real
{ $$.range
= 0; $$.type
= PTF_REAL
; }
2502 | K_realtime
{ $$.range
= 0; $$.type
= PTF_REALTIME
; }
2503 | K_time
{ $$.range
= 0; $$.type
= PTF_TIME
; }
2504 |
{ $$.range
= 0; $$.type
= PTF_REG
; }
2507 /* The register_variable rule is matched only when I am parsing
2508 variables in a "reg" definition. I therefore know that I am
2509 creating registers and I do not need to let the containing rule
2510 handle it. The register variable list simply packs them together
2511 so that bit ranges can be assigned. */
2514 { pform_makewire
(@
1, $1, NetNet
::REG
,
2519 | IDENTIFIER
'=' expression
2520 { pform_makewire
(@
1, $1, NetNet
::REG
,
2523 if
(! pform_expression_is_constant
($3))
2524 yyerror(@
3, "error: register declaration assignment"
2525 " value must be a constant expression.");
2526 pform_make_reginit
(@
1, $1, $3);
2529 | IDENTIFIER
'[' expression
':' expression
']'
2530 { pform_makewire
(@
1, $1, NetNet
::REG
,
2533 if
(! pform_expression_is_constant
($3))
2534 yyerror(@
3, "error: msb of register range must be constant.");
2535 if
(! pform_expression_is_constant
($5))
2536 yyerror(@
3, "error: lsb of register range must be constant.");
2537 pform_set_reg_idx
($1, $3, $5);
2542 register_variable_list
2544 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2545 tmp
->push_back
(lex_strings.make
($1));
2549 | register_variable_list
',' register_variable
2550 { list
<perm_string
>*tmp
= $1;
2551 tmp
->push_back
(lex_strings.make
($3));
2559 { pform_makewire
(@
1, $1, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2562 | IDENTIFIER
'=' expression
2563 { pform_makewire
(@
1, $1, NetNet
::REG
, NetNet
::NOT_A_PORT
, IVL_VT_REAL
, 0);
2564 pform_make_reginit
(@
1, $1, $3);
2571 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2572 tmp
->push_back
(lex_strings.make
($1));
2576 | real_variable_list
',' real_variable
2577 { list
<perm_string
>*tmp
= $1;
2578 tmp
->push_back
(lex_strings.make
($3));
2586 { pform_makewire
(@
1, $1, NetNet
::IMPLICIT
,
2591 | IDENTIFIER
'[' expression
':' expression
']'
2592 { pform_makewire
(@
1, $1, NetNet
::IMPLICIT
,
2595 if
(! pform_expression_is_constant
($3))
2596 yyerror(@
3, "error: msb of net range must be constant.");
2597 if
(! pform_expression_is_constant
($5))
2598 yyerror(@
3, "error: lsb of net range must be constant.");
2599 pform_set_reg_idx
($1, $3, $5);
2605 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2606 tmp
->push_back
(lex_strings.make
($1));
2610 | net_variable_list
',' net_variable
2611 { list
<perm_string
>*tmp
= $1;
2612 tmp
->push_back
(lex_strings.make
($3));
2619 : K_specparam specparam_list
';'
2620 | specify_simple_path_decl
';'
2621 { pform_module_specify_path
($1);
2623 | specify_edge_path_decl
';'
2624 { pform_module_specify_path
($1);
2626 | K_if
'(' expression
')' specify_simple_path_decl
';'
2627 { PSpecPath
*tmp
= $5;
2629 tmp
->conditional
= true
;
2630 tmp
->condition
= $3;
2632 pform_module_specify_path
(tmp
);
2634 | K_if
'(' expression
')' specify_edge_path_decl
';'
2635 { PSpecPath
*tmp
= $5;
2637 tmp
->conditional
= true
;
2638 tmp
->condition
= $3;
2640 pform_module_specify_path
(tmp
);
2642 | K_ifnone specify_simple_path_decl
';'
2643 { PSpecPath
*tmp
= $2;
2645 tmp
->conditional
= true
;
2648 pform_module_specify_path
(tmp
);
2650 | K_Shold
'(' spec_reference_event
',' spec_reference_event
2651 ',' delay_value spec_notifier_opt
')' ';'
2654 | K_Speriod
'(' spec_reference_event
',' delay_value
2655 spec_notifier_opt
')' ';'
2658 | K_Srecovery
'(' spec_reference_event
',' spec_reference_event
2659 ',' delay_value spec_notifier_opt
')' ';'
2662 | K_Ssetup
'(' spec_reference_event
',' spec_reference_event
2663 ',' delay_value spec_notifier_opt
')' ';'
2666 | K_Ssetuphold
'(' spec_reference_event
',' spec_reference_event
2667 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2671 | K_Srecrem
'(' spec_reference_event
',' spec_reference_event
2672 ',' delay_value
',' delay_value spec_notifier_opt
')' ';'
2676 | K_Swidth
'(' spec_reference_event
',' delay_value
',' expression
2677 spec_notifier_opt
')' ';'
2681 | K_Swidth
'(' spec_reference_event
',' delay_value
')' ';'
2688 | specify_item_list specify_item
2691 specify_edge_path_decl
2692 : specify_edge_path
'=' '(' delay_value_list
')'
2693 { $$
= pform_assign_path_delay
($1, $4); }
2694 | specify_edge_path
'=' delay_value_simple
2695 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2697 $$
= pform_assign_path_delay
($1, tmp
);
2701 edge_operator
: K_posedge
{ $$
= true
; } | K_negedge
{ $$
= false
; } ;
2704 : '(' specify_path_identifiers spec_polarity
2705 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2706 { int edge_flag
= 0;
2707 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, false
, $6, $8); }
2708 |
'(' edge_operator specify_path_identifiers spec_polarity
2709 K_EG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2710 { int edge_flag
= $2?
1 : -1;
2711 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, false
, $7, $9);}
2712 |
'(' specify_path_identifiers spec_polarity
2713 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2714 { int edge_flag
= 0;
2715 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $2, $3, true
, $6, $8); }
2716 |
'(' edge_operator specify_path_identifiers spec_polarity
2717 K_SG
'(' specify_path_identifiers polarity_operator expression
')' ')'
2718 { int edge_flag
= $2?
1 : -1;
2719 $$
= pform_make_specify_edge_path
(@
1, edge_flag
, $3, $4, true
, $7, $9); }
2728 specify_simple_path_decl
2729 : specify_simple_path
'=' '(' delay_value_list
')'
2730 { $$
= pform_assign_path_delay
($1, $4); }
2731 | specify_simple_path
'=' delay_value_simple
2732 { svector
<PExpr
*>*tmp
= new svector
<PExpr
*>(1);
2734 $$
= pform_assign_path_delay
($1, tmp
);
2736 | specify_simple_path
'=' '(' error ')'
2737 { yyerror(@
2, "Syntax error in delay value list.");
2744 : '(' specify_path_identifiers spec_polarity
2745 K_EG specify_path_identifiers
')'
2746 { $$
= pform_make_specify_path
(@
1, $2, $3, false
, $5); }
2747 |
'(' specify_path_identifiers spec_polarity
2748 K_SG specify_path_identifiers
')'
2749 { $$
= pform_make_specify_path
(@
1, $2, $3, true
, $5); }
2751 { yyerror(@
2, "Invalid simple path");
2756 specify_path_identifiers
2758 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2759 tmp
->push_back
(lex_strings.make
($1));
2763 | IDENTIFIER
'[' expr_primary
']'
2764 { list
<perm_string
>*tmp
= new list
<perm_string
>;
2765 tmp
->push_back
(lex_strings.make
($1));
2769 | specify_path_identifiers
',' IDENTIFIER
2770 { list
<perm_string
>*tmp
= $1;
2771 tmp
->push_back
(lex_strings.make
($3));
2775 | specify_path_identifiers
',' IDENTIFIER
'[' expr_primary
']'
2776 { list
<perm_string
>*tmp
= $1;
2777 tmp
->push_back
(lex_strings.make
($3));
2784 : IDENTIFIER
'=' expression
2786 pform_set_specparam
(lex_strings.make
($1), tmp
);
2789 | IDENTIFIER
'=' expression
':' expression
':' expression
2791 switch
(min_typ_max_flag
) {
2808 pform_set_specparam
(lex_strings.make
($1), tmp
);
2811 | PATHPULSE_IDENTIFIER
'=' expression
2815 | PATHPULSE_IDENTIFIER
'=' '(' expression
',' expression
')'
2824 | specparam_list
',' specparam
2833 spec_reference_event
2834 : K_posedge expression
2836 | K_negedge expression
2838 | K_posedge expr_primary K_TAND expression
2842 | K_negedge expr_primary K_TAND expression
2846 | K_edge
'[' edge_descriptor_list
']' expr_primary K_TAND expression
2850 | expr_primary K_TAND expression
2858 /* The edge_descriptor is detected by the lexor as the various
2859 2-letter edge sequences that are supported here. For now, we
2860 don't care what they are, because we do not yet support specify
2862 edge_descriptor_list
2863 : edge_descriptor_list
',' K_edge_descriptor
2876 |
',' heirarchy_identifier
2880 | spec_notifier
',' heirarchy_identifier
2889 /* assign and deassign statements are procedural code to do
2890 structural assignments, and to turn that structural assignment
2891 off. This stronger then any other assign, but weaker then the
2892 force assignments. */
2894 : K_assign lpvalue
'=' expression
';'
2895 { PCAssign
*tmp
= new PCAssign
($2, $4);
2896 tmp
->set_file
(@
1.text
);
2897 tmp
->set_lineno
(@
1.first_line
);
2901 | K_deassign lpvalue
';'
2902 { PDeassign
*tmp
= new PDeassign
($2);
2903 tmp
->set_file
(@
1.text
);
2904 tmp
->set_lineno
(@
1.first_line
);
2909 /* Force and release statements are similar to assignments,
2910 syntactically, but they will be elaborated differently. */
2912 | K_force lpvalue
'=' expression
';'
2913 { PForce
*tmp
= new PForce
($2, $4);
2914 tmp
->set_file
(@
1.text
);
2915 tmp
->set_lineno
(@
1.first_line
);
2918 | K_release lpvalue
';'
2919 { PRelease
*tmp
= new PRelease
($2);
2920 tmp
->set_file
(@
1.text
);
2921 tmp
->set_lineno
(@
1.first_line
);
2925 /* begin-end blocks come in a variety of forms, including named and
2926 anonymous. The named blocks can also carry their own reg
2927 variables, which are placed in the scope created by the block
2928 name. These are handled by pushing the scope name then matching
2929 the declarations. The scope is popped at the end of the block. */
2931 | K_begin statement_list K_end
2932 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
, *$2);
2933 tmp
->set_file
(@
1.text
);
2934 tmp
->set_lineno
(@
1.first_line
);
2938 | K_begin
':' IDENTIFIER
2939 { pform_push_scope
($3); }
2940 block_item_decls_opt
2941 statement_list K_end
2942 { pform_pop_scope
();
2943 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
2944 PBlock
::BL_SEQ
, *$6);
2945 tmp
->set_file
(@
1.text
);
2946 tmp
->set_lineno
(@
1.first_line
);
2952 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2953 tmp
->set_file
(@
1.text
);
2954 tmp
->set_lineno
(@
1.first_line
);
2957 | K_begin
':' IDENTIFIER K_end
2958 { PBlock
*tmp
= new PBlock
(PBlock
::BL_SEQ
);
2959 tmp
->set_file
(@
1.text
);
2960 tmp
->set_lineno
(@
1.first_line
);
2963 | K_begin
error K_end
2966 /* fork-join blocks are very similar to begin-end blocks. In fact,
2967 from the parser's perspective there is no real difference. All we
2968 need to do is remember that this is a parallel block so that the
2969 code generator can do the right thing. */
2971 | K_fork
':' IDENTIFIER
2972 { pform_push_scope
($3); }
2973 block_item_decls_opt
2974 statement_list K_join
2975 { pform_pop_scope
();
2976 PBlock
*tmp
= new PBlock
(lex_strings.make
($3),
2977 PBlock
::BL_PAR
, *$6);
2978 tmp
->set_file
(@
1.text
);
2979 tmp
->set_lineno
(@
1.first_line
);
2985 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
2986 tmp
->set_file
(@
1.text
);
2987 tmp
->set_lineno
(@
1.first_line
);
2990 | K_fork
':' IDENTIFIER K_join
2991 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
);
2992 tmp
->set_file
(@
1.text
);
2993 tmp
->set_lineno
(@
1.first_line
);
2998 | K_disable heirarchy_identifier
';'
2999 { PDisable
*tmp
= new PDisable
(*$2);
3000 tmp
->set_file
(@
1.text
);
3001 tmp
->set_lineno
(@
1.first_line
);
3005 | K_TRIGGER heirarchy_identifier
';'
3006 { PTrigger
*tmp
= new PTrigger
(*$2);
3007 tmp
->set_file
(@
2.text
);
3008 tmp
->set_lineno
(@
2.first_line
);
3012 | K_forever statement
3013 { PForever
*tmp
= new PForever
($2);
3014 tmp
->set_file
(@
1.text
);
3015 tmp
->set_lineno
(@
1.first_line
);
3018 | K_fork statement_list K_join
3019 { PBlock
*tmp
= new PBlock
(PBlock
::BL_PAR
, *$2);
3020 tmp
->set_file
(@
1.text
);
3021 tmp
->set_lineno
(@
1.first_line
);
3025 | K_repeat
'(' expression
')' statement
3026 { PRepeat
*tmp
= new PRepeat
($3, $5);
3027 tmp
->set_file
(@
1.text
);
3028 tmp
->set_lineno
(@
1.first_line
);
3031 | K_case
'(' expression
')' case_items K_endcase
3032 { PCase
*tmp
= new PCase
(NetCase
::EQ
, $3, $5);
3033 tmp
->set_file
(@
1.text
);
3034 tmp
->set_lineno
(@
1.first_line
);
3037 | K_casex
'(' expression
')' case_items K_endcase
3038 { PCase
*tmp
= new PCase
(NetCase
::EQX
, $3, $5);
3039 tmp
->set_file
(@
1.text
);
3040 tmp
->set_lineno
(@
1.first_line
);
3043 | K_casez
'(' expression
')' case_items K_endcase
3044 { PCase
*tmp
= new PCase
(NetCase
::EQZ
, $3, $5);
3045 tmp
->set_file
(@
1.text
);
3046 tmp
->set_lineno
(@
1.first_line
);
3049 | K_case
'(' expression
')' error K_endcase
3051 | K_casex
'(' expression
')' error K_endcase
3053 | K_casez
'(' expression
')' error K_endcase
3055 | K_if
'(' expression
')' statement_or_null %prec less_than_K_else
3056 { PCondit
*tmp
= new PCondit
($3, $5, 0);
3057 tmp
->set_file
(@
1.text
);
3058 tmp
->set_lineno
(@
1.first_line
);
3061 | K_if
'(' expression
')' statement_or_null K_else statement_or_null
3062 { PCondit
*tmp
= new PCondit
($3, $5, $7);
3063 tmp
->set_file
(@
1.text
);
3064 tmp
->set_lineno
(@
1.first_line
);
3067 | K_if
'(' error ')' statement_or_null %prec less_than_K_else
3068 { yyerror(@
1, "error: Malformed conditional expression.");
3071 | K_if
'(' error ')' statement_or_null K_else statement_or_null
3072 { yyerror(@
1, "error: Malformed conditional expression.");
3075 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3076 lpvalue
'=' expression
')' statement
3077 { PForStatement
*tmp
= new PForStatement
($3, $5, $7, $9, $11, $13);
3078 tmp
->set_file
(@
1.text
);
3079 tmp
->set_lineno
(@
1.first_line
);
3082 | K_for
'(' lpvalue
'=' expression
';' expression
';'
3085 yyerror(@
9, "error: Error in for loop step assignment.");
3087 | K_for
'(' lpvalue
'=' expression
';' error ';'
3088 lpvalue
'=' expression
')' statement
3090 yyerror(@
7, "error: Error in for loop condition expression.");
3092 | K_for
'(' error ')' statement
3094 yyerror(@
3, "error: Incomprehensible for loop.");
3096 | K_while
'(' expression
')' statement
3097 { PWhile
*tmp
= new PWhile
($3, $5);
3100 | K_while
'(' error ')' statement
3102 yyerror(@
3, "error: Error in while loop condition.");
3104 | delay1 statement_or_null
3105 { PExpr
*del
= (*$1)[0];
3106 assert
($1->count
() == 1);
3107 PDelayStatement
*tmp
= new PDelayStatement
(del
, $2);
3108 tmp
->set_file
(@
1.text
);
3109 tmp
->set_lineno
(@
1.first_line
);
3112 | event_control statement_or_null
3113 { PEventStatement
*tmp
= $1;
3115 yyerror(@
1, "error: Invalid event control.");
3118 tmp
->set_statement
($2);
3122 |
'@' '*' statement_or_null
3123 { PEventStatement
*tmp
= new PEventStatement
;
3124 tmp
->set_file
(@
1.text
);
3125 tmp
->set_lineno
(@
1.first_line
);
3126 tmp
->set_statement
($3);
3129 |
'@' '(' '*' ')' statement_or_null
3130 { PEventStatement
*tmp
= new PEventStatement
;
3131 tmp
->set_file
(@
1.text
);
3132 tmp
->set_lineno
(@
1.first_line
);
3133 tmp
->set_statement
($5);
3136 | lpvalue
'=' expression
';'
3137 { PAssign
*tmp
= new PAssign
($1,$3);
3138 tmp
->set_file
(@
1.text
);
3139 tmp
->set_lineno
(@
1.first_line
);
3142 |
error '=' expression
';'
3143 { yyerror(@
1, "Syntax in assignment statement l-value.");
3147 | lpvalue K_LE expression
';'
3148 { PAssignNB
*tmp
= new PAssignNB
($1,$3);
3149 tmp
->set_file
(@
1.text
);
3150 tmp
->set_lineno
(@
1.first_line
);
3153 |
error K_LE expression
';'
3154 { yyerror(@
1, "Syntax in assignment statement l-value.");
3158 | lpvalue
'=' delay1 expression
';'
3159 { assert
($3->count
() == 1);
3160 PExpr
*del
= (*$3)[0];
3161 PAssign
*tmp
= new PAssign
($1,del
,$4);
3162 tmp
->set_file
(@
1.text
);
3163 tmp
->set_lineno
(@
1.first_line
);
3166 | lpvalue K_LE delay1 expression
';'
3167 { assert
($3->count
() == 1);
3168 PExpr
*del
= (*$3)[0];
3169 PAssignNB
*tmp
= new PAssignNB
($1,del
,$4);
3170 tmp
->set_file
(@
1.text
);
3171 tmp
->set_lineno
(@
1.first_line
);
3174 | lpvalue
'=' event_control expression
';'
3175 { PAssign
*tmp
= new PAssign
($1,$3,$4);
3176 tmp
->set_file
(@
1.text
);
3177 tmp
->set_lineno
(@
1.first_line
);
3180 | lpvalue
'=' K_repeat
'(' expression
')' event_control expression
';'
3181 { PAssign
*tmp
= new PAssign
($1,$7,$8);
3182 tmp
->set_file
(@
1.text
);
3183 tmp
->set_lineno
(@
1.first_line
);
3184 yyerror(@
3, "sorry: repeat event control not supported.");
3188 | lpvalue K_LE event_control expression
';'
3189 { yyerror(@
1, "sorry: Event controls not supported here.");
3190 PAssignNB
*tmp
= new PAssignNB
($1,$4);
3191 tmp
->set_file
(@
1.text
);
3192 tmp
->set_lineno
(@
1.first_line
);
3195 | lpvalue K_LE K_repeat
'(' expression
')' event_control expression
';'
3196 { yyerror(@
1, "sorry: Event controls not supported here.");
3198 PAssignNB
*tmp
= new PAssignNB
($1,$8);
3199 tmp
->set_file
(@
1.text
);
3200 tmp
->set_lineno
(@
1.first_line
);
3203 | K_wait
'(' expression
')' statement_or_null
3204 { PEventStatement
*tmp
;
3205 PEEvent
*etmp
= new PEEvent
(PEEvent
::POSITIVE
, $3);
3206 tmp
= new PEventStatement
(etmp
);
3207 tmp
->set_file
(@
1.text
);
3208 tmp
->set_lineno
(@
1.first_line
);
3209 tmp
->set_statement
($5);
3212 | SYSTEM_IDENTIFIER
'(' expression_list_with_nuls
')' ';'
3213 { PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), *$3);
3214 tmp
->set_file
(@
1.text
);
3215 tmp
->set_lineno
(@
1.first_line
);
3220 | SYSTEM_IDENTIFIER
';'
3221 { svector
<PExpr
*>pt
(0);
3222 PCallTask
*tmp
= new PCallTask
(lex_strings.make
($1), pt
);
3223 tmp
->set_file
(@
1.text
);
3224 tmp
->set_lineno
(@
1.first_line
);
3228 | heirarchy_identifier
'(' expression_list_proper
')' ';'
3229 { PCallTask
*tmp
= new PCallTask
(*$1, *$3);
3230 tmp
->set_file
(@
1.text
);
3231 tmp
->set_lineno
(@
1.first_line
);
3237 /* NOTE: The standard doesn't really support an empty argument list
3238 between parentheses, but it seems natural, and people commonly
3239 want it. So accept it explicitly. */
3241 | heirarchy_identifier
'(' ')' ';'
3242 { svector
<PExpr
*>pt
(0);
3243 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3244 tmp
->set_file
(@
1.text
);
3245 tmp
->set_lineno
(@
1.first_line
);
3249 | heirarchy_identifier
';'
3250 { svector
<PExpr
*>pt
(0);
3251 PCallTask
*tmp
= new PCallTask
(*$1, pt
);
3252 tmp
->set_file
(@
1.text
);
3253 tmp
->set_lineno
(@
1.first_line
);
3258 { yyerror(@
1, "error: malformed statement");
3265 : statement_list statement
3266 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(*$1, $2);
3271 { svector
<Statement
*>*tmp
= new svector
<Statement
*>(1);
3282 /* Task items are, other than the statement, task port items and
3283 other block items. */
3285 : block_item_decl
{ $$
= new svector
<PWire
*>(0); }
3286 | task_port_item
{ $$
= $1; }
3291 : K_input signed_opt range_opt list_of_identifiers
';'
3292 { svector
<PWire
*>*tmp
3293 = pform_make_task_ports
(NetNet
::PINPUT
,
3296 @
1.text
, @
1.first_line
);
3299 | K_output signed_opt range_opt list_of_identifiers
';'
3300 { svector
<PWire
*>*tmp
3301 = pform_make_task_ports
(NetNet
::POUTPUT
,
3304 @
1.text
, @
1.first_line
);
3307 | K_inout signed_opt range_opt list_of_identifiers
';'
3308 { svector
<PWire
*>*tmp
3309 = pform_make_task_ports
(NetNet
::PINOUT
,
3312 @
1.text
, @
1.first_line
);
3316 /* When the port is an integer, infer a signed vector of the integer
3317 shape. Generate a range to make it work. */
3319 | K_input K_integer list_of_identifiers
';'
3320 { svector
<PExpr
*>*range_stub
3321 = new svector
<PExpr
*>(2);
3323 re
= new PENumber
(new verinum
(integer_width
-1,
3325 (*range_stub
)[0] = re
;
3326 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3327 (*range_stub
)[1] = re
;
3329 = pform_make_task_ports
(NetNet
::PINPUT
,
3332 @
1.text
, @
1.first_line
);
3335 | K_output K_integer list_of_identifiers
';'
3336 { svector
<PExpr
*>*range_stub
3337 = new svector
<PExpr
*>(2);
3339 re
= new PENumber
(new verinum
(integer_width
-1,
3341 (*range_stub
)[0] = re
;
3342 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3343 (*range_stub
)[1] = re
;
3345 = pform_make_task_ports
(NetNet
::POUTPUT
,
3348 @
1.text
, @
1.first_line
);
3351 | K_inout K_integer list_of_identifiers
';'
3352 { svector
<PExpr
*>*range_stub
3353 = new svector
<PExpr
*>(2);
3355 re
= new PENumber
(new verinum
(integer_width
-1,
3357 (*range_stub
)[0] = re
;
3358 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3359 (*range_stub
)[1] = re
;
3361 = pform_make_task_ports
(NetNet
::PINOUT
,
3364 @
1.text
, @
1.first_line
);
3368 /* Ports can be real. */
3370 | K_input K_real list_of_identifiers
';'
3371 { svector
<PWire
*>*tmp
3372 = pform_make_task_ports
(NetNet
::PINPUT
,
3375 @
1.text
, @
1.first_line
);
3378 | K_output K_real list_of_identifiers
';'
3379 { svector
<PWire
*>*tmp
3380 = pform_make_task_ports
(NetNet
::POUTPUT
,
3383 @
1.text
, @
1.first_line
);
3386 | K_inout K_real list_of_identifiers
';'
3387 { svector
<PWire
*>*tmp
3388 = pform_make_task_ports
(NetNet
::PINOUT
,
3391 @
1.text
, @
1.first_line
);
3397 : task_item_list task_item
3398 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3416 : K_input signed_opt range_opt IDENTIFIER
3417 { svector
<PWire
*>*tmp
3418 = pform_make_task_ports
(NetNet
::PINPUT
,
3420 $3, list_from_identifier
($4),
3421 @
1.text
, @
1.first_line
);
3425 | K_output signed_opt range_opt IDENTIFIER
3426 { svector
<PWire
*>*tmp
3427 = pform_make_task_ports
(NetNet
::POUTPUT
,
3429 $3, list_from_identifier
($4),
3430 @
1.text
, @
1.first_line
);
3433 | K_inout signed_opt range_opt IDENTIFIER
3434 { svector
<PWire
*>*tmp
3435 = pform_make_task_ports
(NetNet
::PINOUT
,
3437 $3, list_from_identifier
($4),
3438 @
1.text
, @
1.first_line
);
3442 | K_input K_integer IDENTIFIER
3443 { svector
<PExpr
*>*range_stub
3444 = new svector
<PExpr
*>(2);
3446 re
= new PENumber
(new verinum
(integer_width
-1,
3448 (*range_stub
)[0] = re
;
3449 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3450 (*range_stub
)[1] = re
;
3452 = pform_make_task_ports
(NetNet
::PINPUT
,
3455 list_from_identifier
($3),
3456 @
1.text
, @
1.first_line
);
3459 | K_output K_integer IDENTIFIER
3460 { svector
<PExpr
*>*range_stub
3461 = new svector
<PExpr
*>(2);
3463 re
= new PENumber
(new verinum
(integer_width
-1,
3465 (*range_stub
)[0] = re
;
3466 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3467 (*range_stub
)[1] = re
;
3469 = pform_make_task_ports
(NetNet
::POUTPUT
,
3472 list_from_identifier
($3),
3473 @
1.text
, @
1.first_line
);
3476 | K_inout K_integer IDENTIFIER
3477 { svector
<PExpr
*>*range_stub
3478 = new svector
<PExpr
*>(2);
3480 re
= new PENumber
(new verinum
(integer_width
-1,
3482 (*range_stub
)[0] = re
;
3483 re
= new PENumber
(new verinum
((uint64_t)0, integer_width
));
3484 (*range_stub
)[1] = re
;
3486 = pform_make_task_ports
(NetNet
::PINOUT
,
3489 list_from_identifier
($3),
3490 @
1.text
, @
1.first_line
);
3494 /* Ports can be real. */
3496 | K_input K_real IDENTIFIER
3497 { svector
<PWire
*>*tmp
3498 = pform_make_task_ports
(NetNet
::PINPUT
,
3500 0, list_from_identifier
($3),
3501 @
1.text
, @
1.first_line
);
3504 | K_output K_real IDENTIFIER
3505 { svector
<PWire
*>*tmp
3506 = pform_make_task_ports
(NetNet
::POUTPUT
,
3508 0, list_from_identifier
($3),
3509 @
1.text
, @
1.first_line
);
3512 | K_inout K_real IDENTIFIER
3513 { svector
<PWire
*>*tmp
3514 = pform_make_task_ports
(NetNet
::PINOUT
,
3516 0, list_from_identifier
($3),
3517 @
1.text
, @
1.first_line
);
3523 : task_port_decl_list
',' task_port_decl
3524 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$3);
3534 : K_table
{ lex_start_table
(); }
3536 K_endtable
{ lex_end_table
(); $$
= $3; }
3540 : udp_comb_entry_list
3541 | udp_sequ_entry_list
3545 : udp_input_list
':' udp_output_sym
';'
3546 { char*tmp
= new
char[strlen
($1)+3];
3548 char*tp
= tmp
+strlen
(tmp
);
3559 { list
<string>*tmp
= new list
<string>;
3564 | udp_comb_entry_list udp_comb_entry
3565 { list
<string>*tmp
= $1;
3574 { list
<string>*tmp
= new list
<string>;
3579 | udp_sequ_entry_list udp_sequ_entry
3580 { list
<string>*tmp
= $1;
3588 : udp_input_list
':' udp_input_sym
':' udp_output_sym
';'
3589 { char*tmp
= new
char[strlen
($1)+5];
3591 char*tp
= tmp
+strlen
(tmp
);
3602 : K_initial IDENTIFIER
'=' number
';'
3603 { PExpr
*etmp
= new PENumber
($4);
3604 PEIdent
*itmp
= new PEIdent
(lex_strings.make
($2));
3605 PAssign
*atmp
= new PAssign
(itmp
, etmp
);
3606 atmp
->set_file
(@
2.text
);
3607 atmp
->set_lineno
(@
2.first_line
);
3614 : udp_initial
{ $$
= $1; }
3620 { char*tmp
= new
char[2];
3625 | udp_input_list udp_input_sym
3626 { char*tmp
= new
char[strlen
($1)+2];
3628 char*tp
= tmp
+strlen
(tmp
);
3669 /* Port declarations create wires for the inputs and the output. The
3670 makes for these ports are scoped within the UDP, so there is no
3671 heirarchy involved. */
3673 : K_input list_of_identifiers
';'
3674 { $$
= pform_make_udp_input_ports
($2); }
3675 | K_output IDENTIFIER
';'
3676 { pform_name_t pname
;
3677 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3678 PWire
*pp
= new PWire
(pname
, NetNet
::IMPLICIT
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3679 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3684 | K_reg IDENTIFIER
';'
3685 { pform_name_t pname
;
3686 pname.push_back
(name_component_t
(lex_strings.make
($2)));
3687 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::PIMPLICIT
, IVL_VT_LOGIC
);
3688 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3693 | K_reg K_output IDENTIFIER
';'
3694 { pform_name_t pname
;
3695 pname.push_back
(name_component_t
(lex_strings.make
($3)));
3696 PWire
*pp
= new PWire
(pname
, NetNet
::REG
, NetNet
::POUTPUT
, IVL_VT_LOGIC
);
3697 svector
<PWire
*>*tmp
= new svector
<PWire
*>(1);
3707 | udp_port_decls udp_port_decl
3708 { svector
<PWire
*>*tmp
= new svector
<PWire
*>(*$1, *$2);
3717 { list
<string>*tmp
= new list
<string>;
3722 | udp_port_list
',' IDENTIFIER
3723 { list
<string>*tmp
= $1;
3730 udp_reg_opt: K_reg
{ $$
= true
; } |
{ $$
= false
; };
3732 udp_initial_expr_opt
3733 : '=' expression
{ $$
= $2; }
3737 udp_input_declaration_list
3738 : K_input IDENTIFIER
3739 { list
<perm_string
>*tmp
= new list
<perm_string
>;
3740 tmp
->push_back
(lex_strings.make
($2));
3744 | udp_input_declaration_list
',' K_input IDENTIFIER
3745 { list
<perm_string
>*tmp
= $1;
3746 tmp
->push_back
(lex_strings.make
($4));
3753 /* This is the syntax for primitives that uses the IEEE1364-1995
3754 format. The ports are simply names in the port list, and the
3755 declarations are in the body. */
3757 : K_primitive IDENTIFIER
'(' udp_port_list
')' ';'
3763 { perm_string tmp2
= lex_strings.make
($2);
3764 pform_make_udp
(tmp2
, $4, $7, $9, $8,
3765 @
2.text
, @
2.first_line
);
3769 /* This is the syntax for IEEE1364-2001 format definitions. The port
3770 names and declarations are all in the parameter list. */
3772 | K_primitive IDENTIFIER
3773 '(' K_output udp_reg_opt IDENTIFIER udp_initial_expr_opt
','
3774 udp_input_declaration_list
')' ';'
3778 { perm_string tmp2
= lex_strings.make
($2);
3779 perm_string tmp6
= lex_strings.make
($6);
3780 pform_make_udp
(tmp2
, $5, tmp6
, $7, $9, $12,
3781 @
2.text
, @
2.first_line
);