@@ -105,14 +105,14 @@ int yylex(void);
105
105
%type <node> io_declaration variable_list function_output_variable function_id_and_output_variable
106
106
%type <node> integer_type_variable_list variable integer_type_variable
107
107
%type <node> net_declaration integer_declaration function_instantiation task_instantiation genvar_declaration
108
- %type <node> continuous_assign multiple_inputs_gate_instance list_of_single_input_gate_declaration_instance
108
+ %type <node> continuous_assign procedural_continuous_assignment multiple_inputs_gate_instance list_of_single_input_gate_declaration_instance
109
109
%type <node> list_of_multiple_inputs_gate_declaration_instance list_of_module_instance
110
110
%type <node> gate_declaration single_input_gate_instance
111
111
%type <node> module_instantiation module_instance function_instance task_instance list_of_module_connections list_of_function_connections list_of_task_connections
112
112
%type <node> list_of_multiple_inputs_gate_connections
113
- %type <node> module_connection always statement function_statement task_statement blocking_assignment
114
- %type <node> non_blocking_assignment conditional_statement case_statement case_item_list case_items seq_block
115
- %type <node> stmt_list delay_control event_expression_list event_expression loop_statement
113
+ %type <node> module_connection always statement function_statement function_statement_items task_statement blocking_assignment
114
+ %type <node> non_blocking_assignment conditional_statement function_conditional_statement case_statement function_case_statement case_item_list function_case_item_list case_items function_case_items seq_block function_seq_block
115
+ %type <node> stmt_list function_stmt_list delay_control event_expression_list event_expression loop_statement function_loop_statement
116
116
%type <node> expression primary expression_list module_parameter
117
117
%type <node> list_of_module_parameters localparam_declaration
118
118
%type <node> specify_block list_of_specify_items
@@ -209,7 +209,6 @@ generate_item:
209
209
| function_declaration {$$ = $1 ;}
210
210
| task_declaration {$$ = $1 ;}
211
211
| initial_block {$$ = $1 ;}
212
- | task_instantiation {$$ = $1 ;}
213
212
| always {$$ = $1 ;}
214
213
| defparam_declaration {$$ = $1 ;}
215
214
| c_function ' ;' {$$ = $1 ;}
@@ -285,9 +284,8 @@ function_item:
285
284
| function_input_declaration {$$ = $1 ;}
286
285
| net_declaration {$$ = $1 ;}
287
286
| integer_declaration {$$ = $1 ;}
288
- | continuous_assign {$$ = $1 ;}
289
287
| defparam_declaration {$$ = $1 ;}
290
- | function_statement {$$ = $1 ;} // TODO It ` s temporary
288
+ | function_statement {$$ = $1 ;}
291
289
| error ' ;' {$$ = NULL ;}
292
290
;
293
291
@@ -298,9 +296,8 @@ task_item:
298
296
| task_inout_declaration {$$ = $1 ;}
299
297
| net_declaration {$$ = $1 ;}
300
298
| integer_declaration {$$ = $1 ;}
301
- | continuous_assign {$$ = $1 ;}
302
299
| defparam_declaration {$$ = $1 ;}
303
- | task_statement {$$ = $1 ;} // TODO It ` s temporary
300
+ | task_statement {$$ = $1 ;}
304
301
;
305
302
306
303
function_input_declaration :
@@ -386,6 +383,10 @@ continuous_assign:
386
383
vASSIGN list_of_blocking_assignment ' ;' {$$ = $2 ;}
387
384
;
388
385
386
+ procedural_continuous_assignment :
387
+ vASSIGN blocking_assignment ' ;' {$$ = $2 ;}
388
+ ;
389
+
389
390
list_of_blocking_assignment :
390
391
list_of_blocking_assignment ' ,' blocking_assignment {$$ = newList_entry($1 , $3 );}
391
392
| blocking_assignment {$$ = newList(ASSIGN, $1 , my_yylineno);}
@@ -533,11 +534,11 @@ generate_block:
533
534
;
534
535
535
536
function_statement :
536
- statement {$$ = newAlways( NULL , $1 , my_yylineno);}
537
+ function_statement_items {$$ = newStatement( $1 , my_yylineno);}
537
538
;
538
539
539
540
task_statement :
540
- statement {$$ = newAlways( NULL , $1 , my_yylineno);}
541
+ statement {$$ = newStatement( $1 , my_yylineno);}
541
542
;
542
543
543
544
statement :
@@ -546,12 +547,38 @@ statement:
546
547
| c_function ' ;' {$$ = $1 ;}
547
548
| blocking_assignment ' ;' {$$ = $1 ;}
548
549
| non_blocking_assignment ' ;' {$$ = $1 ;}
550
+ | procedural_continuous_assignment {$$ = $1 ;}
549
551
| conditional_statement {$$ = $1 ;}
550
552
| case_statement {$$ = $1 ;}
551
- | loop_statement {$$ = newList(BLOCK, $1 , my_yylineno) ;}
553
+ | loop_statement {$$ = $1 ;}
552
554
| ' ;' {$$ = NULL ;}
553
555
;
554
556
557
+ function_statement_items :
558
+ function_seq_block {$$ = $1 ;}
559
+ | c_function ' ;' {$$ = $1 ;}
560
+ | blocking_assignment ' ;' {$$ = $1 ;}
561
+ | function_conditional_statement {$$ = $1 ;}
562
+ | function_case_statement {$$ = $1 ;}
563
+ | function_loop_statement {$$ = $1 ;}
564
+ | ' ;' {$$ = NULL ;}
565
+ ;
566
+
567
+ function_seq_block :
568
+ vBEGIN function_stmt_list vEND {$$ = $2 ;}
569
+ | vBEGIN ' :' vSYMBOL_ID function_stmt_list vEND {free($3 ); $$ = $4 ;}
570
+ ;
571
+
572
+ function_stmt_list :
573
+ function_stmt_list function_statement_items {$$ = newList_entry($1 , $2 );}
574
+ | function_statement_items {$$ = newList(BLOCK, $1 , my_yylineno);}
575
+ ;
576
+
577
+ function_loop_statement :
578
+ vFOR ' (' blocking_assignment ' ;' expression ' ;' blocking_assignment ' )' function_statement_items {$$ = newFor($3 , $5 , $7 , $9 , my_yylineno);}
579
+ | vWHILE ' (' expression ' )' function_statement_items {$$ = newWhile($3 , $5 , my_yylineno);}
580
+ ;
581
+
555
582
loop_statement :
556
583
vFOR ' (' blocking_assignment ' ;' expression ' ;' blocking_assignment ' )' statement {$$ = newFor($3 , $5 , $7 , $9 , my_yylineno);}
557
584
| vWHILE ' (' expression ' )' statement {$$ = newWhile($3 , $5 , my_yylineno);}
@@ -561,6 +588,15 @@ case_statement:
561
588
vCASE ' (' expression ' )' case_item_list vENDCASE {$$ = newCase($3 , $5 , my_yylineno);}
562
589
;
563
590
591
+ function_case_statement :
592
+ vCASE ' (' expression ' )' function_case_item_list vENDCASE {$$ = newCase($3 , $5 , my_yylineno);}
593
+ ;
594
+
595
+ function_conditional_statement :
596
+ vIF ' (' expression ' )' function_statement_items %prec LOWER_THAN_ELSE {$$ = newIf($3 , $5 , NULL , my_yylineno);}
597
+ | vIF ' (' expression ' )' function_statement_items vELSE function_statement_items {$$ = newIf($3 , $5 , $7 , my_yylineno);}
598
+ ;
599
+
564
600
conditional_statement :
565
601
vIF ' (' expression ' )' statement %prec LOWER_THAN_ELSE {$$ = newIf($3 , $5 , NULL , my_yylineno);}
566
602
| vIF ' (' expression ' )' statement vELSE statement {$$ = newIf($3 , $5 , $7 , my_yylineno);}
@@ -582,11 +618,21 @@ case_item_list:
582
618
| case_items {$$ = newList(CASE_LIST, $1 , my_yylineno);}
583
619
;
584
620
621
+ function_case_item_list :
622
+ function_case_item_list function_case_items {$$ = newList_entry($1 , $2 );}
623
+ | function_case_items {$$ = newList(CASE_LIST, $1 , my_yylineno);}
624
+ ;
625
+
626
+ function_case_items :
627
+ expression ' :' function_statement_items {$$ = newCaseItem($1 , $3 , my_yylineno);}
628
+ | vDEFAULT ' :' function_statement_items {$$ = newDefaultCase($3 , my_yylineno);}
629
+ ;
630
+
585
631
case_items :
586
632
expression ' :' statement {$$ = newCaseItem($1 , $3 , my_yylineno);}
587
633
| vDEFAULT ' :' statement {$$ = newDefaultCase($3 , my_yylineno);}
588
634
;
589
-
635
+
590
636
seq_block :
591
637
vBEGIN stmt_list vEND {$$ = $2 ;}
592
638
| vBEGIN ' :' vSYMBOL_ID stmt_list vEND {free($3 ); $$ = $4 ;}
0 commit comments