@@ -54,7 +54,6 @@ int yylex(void);
54
54
%token vALWAYS vAUTOMATIC vINITIAL vSPECIFY vAND vASSIGN vBEGIN vCASE vDEFAULT vDEFINE vELSE vEND vENDCASE
55
55
%token vENDMODULE vENDSPECIFY vENDGENERATE vENDFUNCTION vENDTASK vIF vINOUT vINPUT vMODULE vGENERATE vFUNCTION vTASK
56
56
%token vOUTPUT vPARAMETER vLOCALPARAM vPOSEDGE vXNOR vXOR vDEFPARAM voANDAND vNAND vNEGEDGE vNOR vNOT vOR vFOR
57
-
58
57
%token voOROR voLTE voGTE voPAL voSLEFT voSRIGHT voASRIGHT voEQUAL voNOTEQUAL voCASEEQUAL
59
58
%token voCASENOTEQUAL voXNOR voNAND voNOR vWHILE vINTEGER vCLOG2 vGENVAR
60
59
%token vPLUS_COLON vMINUS_COLON vSPECPARAM voUNSIGNED voSIGNED vSIGNED vCFUNC
@@ -105,14 +104,14 @@ int yylex(void);
105
104
%type <node> io_declaration variable_list function_output_variable function_id_and_output_variable
106
105
%type <node> integer_type_variable_list variable integer_type_variable
107
106
%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
107
+ %type <node> procedural_continuous_assignment multiple_inputs_gate_instance list_of_single_input_gate_declaration_instance
109
108
%type <node> list_of_multiple_inputs_gate_declaration_instance list_of_module_instance
110
109
%type <node> gate_declaration single_input_gate_instance
111
110
%type <node> module_instantiation module_instance function_instance task_instance list_of_module_connections list_of_function_connections list_of_task_connections
112
111
%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
112
+ %type <node> module_connection always statement function_statement function_statement_items task_statement blocking_assignment
113
+ %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
114
+ %type <node> stmt_list function_stmt_list delay_control event_expression_list event_expression loop_statement function_loop_statement
116
115
%type <node> expression primary expression_list module_parameter
117
116
%type <node> list_of_module_parameters localparam_declaration
118
117
%type <node> specify_block list_of_specify_items
@@ -199,23 +198,22 @@ list_of_generate_items:
199
198
;
200
199
201
200
generate_item :
202
- localparam_declaration {$$ = $1 ;}
203
- | net_declaration {$$ = $1 ;}
204
- | genvar_declaration {$$ = $1 ;}
205
- | integer_declaration {$$ = $1 ;}
206
- | continuous_assign {$$ = $1 ;}
207
- | gate_declaration {$$ = $1 ;}
208
- | module_instantiation {$$ = $1 ;}
209
- | function_declaration {$$ = $1 ;}
210
- | task_declaration {$$ = $1 ;}
211
- | initial_block {$$ = $1 ;}
212
- | task_instantiation {$$ = $1 ;}
213
- | always {$$ = $1 ;}
214
- | defparam_declaration {$$ = $1 ;}
215
- | c_function ' ;' {$$ = $1 ;}
216
- | if_generate_construct {$$ = $1 ;}
217
- | case_generate_construct {$$ = $1 ;}
218
- | loop_generate_construct {$$ = $1 ;}
201
+ localparam_declaration {$$ = $1 ;}
202
+ | net_declaration {$$ = $1 ;}
203
+ | genvar_declaration {$$ = $1 ;}
204
+ | integer_declaration {$$ = $1 ;}
205
+ | procedural_continuous_assignment {$$ = $1 ;}
206
+ | gate_declaration {$$ = $1 ;}
207
+ | module_instantiation {$$ = $1 ;}
208
+ | function_declaration {$$ = $1 ;}
209
+ | task_declaration {$$ = $1 ;}
210
+ | initial_block {$$ = $1 ;}
211
+ | always {$$ = $1 ;}
212
+ | defparam_declaration {$$ = $1 ;}
213
+ | c_function ' ;' {$$ = $1 ;}
214
+ | if_generate_construct {$$ = $1 ;}
215
+ | case_generate_construct {$$ = $1 ;}
216
+ | loop_generate_construct {$$ = $1 ;}
219
217
;
220
218
221
219
function_declaration :
@@ -285,9 +283,8 @@ function_item:
285
283
| function_input_declaration {$$ = $1 ;}
286
284
| net_declaration {$$ = $1 ;}
287
285
| integer_declaration {$$ = $1 ;}
288
- | continuous_assign {$$ = $1 ;}
289
286
| defparam_declaration {$$ = $1 ;}
290
- | function_statement {$$ = $1 ;} // TODO It ` s temporary
287
+ | function_statement {$$ = $1 ;}
291
288
| error ' ;' {$$ = NULL ;}
292
289
;
293
290
@@ -298,9 +295,8 @@ task_item:
298
295
| task_inout_declaration {$$ = $1 ;}
299
296
| net_declaration {$$ = $1 ;}
300
297
| integer_declaration {$$ = $1 ;}
301
- | continuous_assign {$$ = $1 ;}
302
298
| defparam_declaration {$$ = $1 ;}
303
- | task_statement {$$ = $1 ;} // TODO It ` s temporary
299
+ | task_statement {$$ = $1 ;}
304
300
;
305
301
306
302
function_input_declaration :
@@ -382,7 +378,7 @@ integer_type_variable:
382
378
| vSYMBOL_ID ' =' primary {$$ = newIntegerTypeVarDeclare($1 , NULL , NULL , NULL , NULL , $3 , my_yylineno);} // ONLY FOR PARAMETER
383
379
;
384
380
385
- continuous_assign :
381
+ procedural_continuous_assignment :
386
382
vASSIGN list_of_blocking_assignment ' ;' {$$ = $2 ;}
387
383
;
388
384
@@ -533,11 +529,11 @@ generate_block:
533
529
;
534
530
535
531
function_statement :
536
- statement {$$ = newAlways( NULL , $1 , my_yylineno);}
532
+ function_statement_items {$$ = newStatement( $1 , my_yylineno);}
537
533
;
538
534
539
535
task_statement :
540
- statement {$$ = newAlways( NULL , $1 , my_yylineno);}
536
+ statement {$$ = newStatement( $1 , my_yylineno);}
541
537
;
542
538
543
539
statement :
@@ -546,12 +542,38 @@ statement:
546
542
| c_function ' ;' {$$ = $1 ;}
547
543
| blocking_assignment ' ;' {$$ = $1 ;}
548
544
| non_blocking_assignment ' ;' {$$ = $1 ;}
545
+ | procedural_continuous_assignment {$$ = $1 ;}
549
546
| conditional_statement {$$ = $1 ;}
550
547
| case_statement {$$ = $1 ;}
551
548
| loop_statement {$$ = newList(BLOCK, $1 , my_yylineno);}
552
549
| ' ;' {$$ = NULL ;}
553
550
;
554
551
552
+ function_statement_items :
553
+ function_seq_block {$$ = $1 ;}
554
+ | c_function ' ;' {$$ = $1 ;}
555
+ | blocking_assignment ' ;' {$$ = $1 ;}
556
+ | function_conditional_statement {$$ = $1 ;}
557
+ | function_case_statement {$$ = $1 ;}
558
+ | function_loop_statement {$$ = newList(BLOCK, $1 , my_yylineno);}
559
+ | ' ;' {$$ = NULL ;}
560
+ ;
561
+
562
+ function_seq_block :
563
+ vBEGIN function_stmt_list vEND {$$ = $2 ;}
564
+ | vBEGIN ' :' vSYMBOL_ID function_stmt_list vEND {free($3 ); $$ = $4 ;}
565
+ ;
566
+
567
+ function_stmt_list :
568
+ function_stmt_list function_statement_items {$$ = newList_entry($1 , $2 );}
569
+ | function_statement_items {$$ = newList(BLOCK, $1 , my_yylineno);}
570
+ ;
571
+
572
+ function_loop_statement :
573
+ vFOR ' (' blocking_assignment ' ;' expression ' ;' blocking_assignment ' )' function_statement_items {$$ = newFor($3 , $5 , $7 , $9 , my_yylineno);}
574
+ | vWHILE ' (' expression ' )' function_statement_items {$$ = newWhile($3 , $5 , my_yylineno);}
575
+ ;
576
+
555
577
loop_statement :
556
578
vFOR ' (' blocking_assignment ' ;' expression ' ;' blocking_assignment ' )' statement {$$ = newFor($3 , $5 , $7 , $9 , my_yylineno);}
557
579
| vWHILE ' (' expression ' )' statement {$$ = newWhile($3 , $5 , my_yylineno);}
@@ -561,6 +583,15 @@ case_statement:
561
583
vCASE ' (' expression ' )' case_item_list vENDCASE {$$ = newCase($3 , $5 , my_yylineno);}
562
584
;
563
585
586
+ function_case_statement :
587
+ vCASE ' (' expression ' )' function_case_item_list vENDCASE {$$ = newCase($3 , $5 , my_yylineno);}
588
+ ;
589
+
590
+ function_conditional_statement :
591
+ vIF ' (' expression ' )' function_statement_items %prec LOWER_THAN_ELSE {$$ = newIf($3 , $5 , NULL , my_yylineno);}
592
+ | vIF ' (' expression ' )' function_statement_items vELSE function_statement_items {$$ = newIf($3 , $5 , $7 , my_yylineno);}
593
+ ;
594
+
564
595
conditional_statement :
565
596
vIF ' (' expression ' )' statement %prec LOWER_THAN_ELSE {$$ = newIf($3 , $5 , NULL , my_yylineno);}
566
597
| vIF ' (' expression ' )' statement vELSE statement {$$ = newIf($3 , $5 , $7 , my_yylineno);}
@@ -582,11 +613,21 @@ case_item_list:
582
613
| case_items {$$ = newList(CASE_LIST, $1 , my_yylineno);}
583
614
;
584
615
616
+ function_case_item_list :
617
+ function_case_item_list function_case_items {$$ = newList_entry($1 , $2 );}
618
+ | function_case_items {$$ = newList(CASE_LIST, $1 , my_yylineno);}
619
+ ;
620
+
621
+ function_case_items :
622
+ expression ' :' function_statement_items {$$ = newCaseItem($1 , $3 , my_yylineno);}
623
+ | vDEFAULT ' :' function_statement_items {$$ = newDefaultCase($3 , my_yylineno);}
624
+ ;
625
+
585
626
case_items :
586
627
expression ' :' statement {$$ = newCaseItem($1 , $3 , my_yylineno);}
587
628
| vDEFAULT ' :' statement {$$ = newDefaultCase($3 , my_yylineno);}
588
629
;
589
-
630
+
590
631
seq_block :
591
632
vBEGIN stmt_list vEND {$$ = $2 ;}
592
633
| vBEGIN ' :' vSYMBOL_ID stmt_list vEND {free($3 ); $$ = $4 ;}
0 commit comments