This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.yy
2699 lines (2470 loc) · 63 KB
/
parse.yy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*****************************************************************************
* Copyright 1994-2005, Elliot Mednick and Mark Hummel
* This file is part of Veriwell.
*
* Veriwell is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Veriwell is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
/* PARSE.Y - BISON/YACC parser for program input */
%{
#define yyparse prog_parse
#define YYERROR_VERBOSE
#define YYDEBUG 2
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "glue.h"
#include "vtypes.h"
#include "tree.h"
#include "decl.h"
#include "flags.h"
#include "io.h"
#include "specify.h"
#include "gates.h"
#include "udp.h"
#include "lex.h"
#include "scope.h"
#include "veriwell.h"
#define syn_warning(TEXT) \
if (synopsys_flag) \
synopsys_warn(TEXT);
#define function_error \
if (in_function) \
error ("Statement not allowed in a function", NULL_CHAR, NULL_CHAR)
/* Used in BISON.SIM */
extern char *token_buffer;
void eat_block (short token);
#include "parse.h"
#ifdef __cplusplus
int yylex (YYSTYPE *);
#endif // __cplusplus
/* list of parsed modules (exported in tree.h) */
tree module_list = NULL_TREE;
/* tree list of hierarchical references to be resolved at pass3 */
tree hierarchical_list;
/* The spec of the current declaration */
tree current_spec;
tree current_module;
tree current_case;
tree current_delay;
enum tree_type current_gatetype;
tree current_instance_module = NULL_TREE;
tree current_instance_param = NULL_TREE;
tree current_udp_string = NULL_TREE;
tree interactive_statement;
tree tmp_tree;
/* Defined in decl.c */
extern tree current_scope;
/* Defined in verilog.c */
extern int is_interactive;
/* Certain constructs are not allowed while inside a function. Also, ports
are treated differently in functions and tasks than for modules. */
int in_function = 0;
int in_tf = 0;
int in_systask = 0;
/* If inside continuous assignment, handle lval differently */
enum lval_type lval_type = LVAL_REG;
/* If inside instantiation port list, allow implicit net declarations. */
int in_instantiation = 0;
/* If inside event statement, accept event types. */
int in_event = 0;
void init_parse()
{
current_instance_module = NULL_TREE;
current_instance_param = NULL_TREE;
current_udp_string = NULL_TREE;
in_function = 0;
in_tf = 0;
in_systask = 0;
lval_type = LVAL_REG;
in_instantiation = 0;
module_list = NULL_TREE;
hierarchical_list = NULL_TREE;
current_spec = NULL_TREE;
current_module = NULL_TREE;
current_case = NULL_TREE;
current_delay = NULL_TREE;
interactive_statement = NULL_TREE;
tmp_tree = NULL_TREE;
}
%}
%pure_parser
%union {
tree ttype; /* pointer to a tree node */
int integer; /* used for integers */
// inst ctype; /* pointer to an instruction node (code) */
// Datum *dtype; /* pointer to a bit string for returning NUMBERs */
lineno_t ltype; /* for passing line numbers */
enum tree_code code; /* for operators */
enum tree_type gtype; /* for gates */
enum tree_type ntype; /* for nets (same as gtype, buy more readable) */
char double_digit[2]; /* structure for parsing edges */
char c; /* char used in udp parsing */
};
%nonassoc LOWEST
%nonassoc IF
%nonassoc ELSE
%right <code> '?' ':'
%left <code> OROR
%left <code> ANDAND
%left <code> ANDANDAND
%left <code> '|'
%left <code> '^' XNOR
%left <code> '&'
%left <code> LOGICAL_EQUALITY LOGICAL_INEQUALITY CASE_EQUALITY CASE_INEQUALITY
%left <code> LT LE GT GE
%left <code> LEFT_SHIFT RIGHT_SHIFT
%left <code> '+' '-'
%left <code> '*' '/' '%'
%left <code> '(' '['
%right <code> '!' '~'
%right <code> REDUCTION_NOR
%right <code> REDUCTION_NAND
%right <code> UNARY
%token <ttype> IDENTIFIER
%token <ttype> HIERARCHY_IDENTIFIER
%token <code> STARARROW
%token <code> EQUALARROW
%token SPECPARAM
%token SETUP
%token HOLD
%token PERIOD
%token WIDTH
%token SKEW
%token RECOVERY
%token SETUPHOLD
%token NOCHANGE
%token MODULE
%token MACROMODULE
%token ENDMODULE
%token SPECIFY
%token ENDSPECIFY
%token PRIMITIVE
%token ENDPRIMITIVE
%token TABLE
%token ENDTABLE
%token TASK
%token ENDTASK
%token FUNCTION
%token ENDFUNCTION
%token PARAMETER
%token INPUT
%token OUTPUT
%token INOUT
%token <ntype> NETTYPE
%token TRIREG
%token SCALARED
%token VECTORED
%token REG
%token TIME
%token INTEGER
%token REAL
%token EVENT
%token ASSIGN
%token DEFPARAM
%token <stype> STRENGTH0 STRENGTH1 SUPPLY0 SUPPLY1
%token <gtype> LOGIC
%token <gtype> BUFFER
%token <gtype> BUFIF
%token <gtype> CMOS
%token <gtype> PULL
%token <gtype> TRAN
%token INITIAL
%token ALWAYS
%token IF
/*%left ELSE */
%token CASE
%token CASEZ
%token CASEX
%token ENDCASE
%token FOREVER
%token REPEAT
%token WHILE
%token FOR
%token WAIT_
%token ARROW_
%token DISABLE
/*%token <sym> ASSIGN*/
%token DEASSIGN
%token FORCE
%token RELEASE
%token DEFAULT
%token BEGIN
%token END
%token FORK
%token JOIN
%token <ttype> SYSTEM_IDENTIFIER
%token <ttype> STRING
%token <ttype> NUMBER
%token <ttype> BASE_NUMBER
%token <code> POSEDGE
%token <code> NEGEDGE
%left OR
%token SMALL
%token MEDIUM
%token LARGE
/* %token STOP_STMT */
%token EDGE
%token <double_digit> DOUBLE_DIGIT
%token <c> UDP_CHAR
%token <c> UDP_ONE
%token <c> UDP_ZERO
%token <c> UDP_X
%token <c> UDP_B
%token <c> UDP_HOOK
%token EOF_
%type <ttype> source_text
%type <ttype> description_list
%type <ttype> description
%type <ttype> module
/* %type <ttype> module_item_list */
/* %type <ttype> module_item */
%type <ttype> list_of_ports_o
%type <ttype> port_clist
%type <ttype> port
%type <ttype> port_expression_o
%type <ttype> port_reference_clist
%type <ttype> port_reference
%type <ttype> UDP
%type <ttype> task
%type <ttype> function function_type
%type <ttype> tf_declaration_list
%type <ttype> tf_declaration
%type <ttype> specify_stuff
%type <ttype> specify_items
%type <ttype> specify_item
%type <ttype> specparam_declaration
%type <ttype> path_declaration
%type <ttype> path_description
%type <ttype> path_delay_value
%type <ttype> specify_input_terminal_descriptor
%type <ttype> specify_output_terminal_descriptor
%type <ttype> list_of_path_inputs
%type <ttype> list_of_path_outputs
%type <ttype> path_delay_expression
%type <integer> path_operator
%type <integer> polarity_operator
%type <ttype> conditional_port_expression
%type <ttype> data_source_expression
%type <integer> edge_identifier
%type <ttype> specify_if_clause
%type <ttype> timing_input_terminal_descriptor
%type <ttype> parameter_declaration
%type <ttype> list_of_param_assignments
%type <ttype> param_assignment
%type <ttype> setspec setnetspec static_declaration port_declaration port_spec
%type <ttype> port_decl_identifiers
%type <ttype> reg_spec event_spec reg_decl_identifiers reg_decl_identifier
%type <ttype> real_spec
%type <ttype> non_reg_decl_identifiers
%type <ttype> decl_identifiers
%type <ttype> net_declaration net_spec trireg_spec
%type <ntype> nettype
%type <ttype> expandrange_o
%type <ttype> continuous_assign assign_spec list_of_assignments
%type <ttype> cont_assignment
%type <ttype> net_assignment list_of_net_assignments
%type <ttype> parameter_override list_of_param_overrides
%type <ttype> charge_strength_o
%type <ttype> drive_strength drive_strength_o
%type <stype> strength0 strength1
%type <ttype> xrange
%type <ttype> range
/* %type <ttype> gate_declaration */
/* %type <ttype> gate_description */
%type <gtype> gatetype
%type <ttype> gate_instance_clist
%type <ttype> gate_instance
%type <ttype> UDP_or_module_instantiation
%type <ttype> xparameter_value_assignment constant_expression_clist
/* %type <ttype> UDP_instance_clist */
/* %type <ttype> UDP_instance */
/* %type <ttype> xterminal_clist */
%type <ttype> terminal_clist
/*%type <ttype> module_instantiation */
%type <ttype> module_instance_clist
%type <ttype> module_instance
%type <ttype> list_of_module_connections_o
%type <ttype> module_port_connection_clist
%type <ttype> module_port_connection
%type <ttype> named_port_connection_clist
%type <ttype> named_port_connection
%type <ttype> system_timing_check
%type <ttype> notify_clause
%type <ttype> notify_register
%type <ttype> timing_check_event
%type <ttype> controlled_timing_check_event
%type <integer> timing_check_event_control
%type <integer> timing_check_event_control_no_empty
%type <ttype> timing_check_condition
%type <ttype> scalar_expression
%type <ttype> scalar_constant
%type <ttype> specify_block
%type <ttype> initial_statement
%type <ttype> always_statement
%type <ttype> statement_or_null
%type <ttype> statement
%type <ttype> elsepart
%type <ttype> case
/* %type <ttype> delay_or_event_control */
%type <ttype> assignment
%type <ttype> case_item_plist
%type <ttype> case_expr
%type <ttype> expression_clist xexpression_clist xexpression
%type <ttype> seq_block
%type <ttype> par_block
%type <ttype> statement_list
%type <ttype> statement_tree_list
%type <ttype> block_declaration_list
%type <ttype> block_declaration
%type <ttype> task_enable
%type <ttype> system_task_enable
%type <ttype> lvalue
%type <ttype> lval_normal
%type <ttype> lval_concat
%type <ttype> lval_clist
%type <ttype> conditional_expression
%type <ttype> constant_expression
%type <ttype> mintypmax_expression
%type <ttype> mintypmax_expression_triplet
%type <ttype> expression
%type <ttype> primary
%type <ttype> concatenation
%type <ttype> function_call
%type <ttype> identifier
%type <ttype> IDENTIFIER_or_OR
%type <ttype> delay_o
%type <ttype> delay
%type <ttype> mintypmax_clist
%type <ttype> delay_control
%type <ttype> event_control
%type <ttype> event_expression
%type <integer> edge_list
%type <ttype> rp
%type <ttype> sc
%type <ttype> UDP_declarations
%type <ttype> UDP_declaration
%type <ttype> UDP_reg_statement
%type <ttype> UDP_initial_statement
%type <ttype> UDP_table_definition
%type <ttype> table_entry_list
%type <ttype> table_entry
%type <ttype> table_digit_list
%type <ttype> table_digit
%type <c> table_digit1
/*
%type <ttype> interactive_command
%type <ttype> execute_command
%type <ttype> disable_command
%type <ttype> continue
%type <ttype> step_no_trace
%type <ttype> step_trace
%type <ttype> where
*/
%type <ttype> error
%%
source_text
: statement { if (!is_interactive)
YYFAIL;
#if VDEBUG != 0
if (vdebug)
printf_error_V ("interactive statement\n");
#endif
interactive_statement = $1;
fix_lastchar();
YYACCEPT;}
| description_list EOF_
| error
{
#if VDEBUG != 0
if (vdebug)
printf ("source error\n");
#endif
if (is_interactive)
YYABORT;
}
| EOF_ {
#if VDEBUG != 0
if (vdebug)
printf_error_V ("EOF\n");
#endif
$$ = NULL; }
;
description_list
: description
| description_list description
{ yyerrok;
#if VDEBUG != 0
if (vdebug)
printf ("description_list\n");
#endif
}
/* | error */
/* | description_list error */
;
description
: module
| UDP
;
module
: MODULE
{ if (is_interactive) {
YYFAIL;
}
}
IDENTIFIER_or_OR
{
current_module = current_scope = build_module ($3);
push_scope ();
/* list of parse modules */
module_list = tree_cons (current_module, NULL_TREE, module_list);
/* for now, assume all to be at lop level */
// top_level = chainon (current_module, top_level);
}
list_of_ports_o sc
{ MODULE_PORT_LIST (current_module) = nreverse ($5); }
module_item_list ENDMODULE
{
current_scope = pop_scope ();
BLOCK_BODY (current_module) = nreverse (BLOCK_BODY (current_module));
BLOCK_DECL (current_module) = nreverse (BLOCK_DECL (current_module));
end_module (current_module);
}
/* | MACROMODULE IDENTIFIER list_of_ports_o sc module_item_list ENDMODULE */
;
module_item_list
: /* empty */
| module_item_list module_item
{ yyerrok; }
| module_item_list error
;
list_of_ports_o
: '(' port_clist rp
{ $$ = $2; }
| /* empty */
{ $$ = NULL; }
;
port_clist
: port
| port_clist ',' port
{ yyerrok;
$$ = chainon ($3, $1);
}
| error
/*
| port_clist error
| port_clist error port
{ yyerrok; }
*/
| port_clist ',' error
;
port
: port_expression_o
{ if ($1)
$$ = build_tree_list ($1, NULL_TREE);
else
$$ = NULL_TREE;
}
| '.' IDENTIFIER '(' port_expression_o rp
{ $$ = build_tree_list ($4, $2); }
;
port_expression_o
: port_reference
| '{' port_reference_clist '}'
{ $$ = $2;
sorry ("Port concatenations not supported in this version");
}
| /* empty */
{ $$ = NULL_TREE; }
;
port_reference_clist
: port_reference
{ $$ = build_tree_list ($1, NULL_TREE); }
| port_reference_clist ',' port_reference
{ $$ = tree_cons ($3, NULL_TREE, $1); }
;
port_reference
: IDENTIFIER
{ set_decl ($1, $1); } /* point to itself to mark as port */
| IDENTIFIER '[' constant_expression ']'
{ $$ = build_bit_ref ($1, $3);
set_decl ($1, $$);
// sorry ("Port bit-select not supported in this version");
}
| IDENTIFIER '[' constant_expression ':' constant_expression ']'
{ $$ = build_part_ref ($1, $3, $5);
set_decl ($1, $$);
// sorry ("Port part-selects not supported in this version");
}
;
module_item
: parameter_declaration
{}
| port_declaration
{}
| net_declaration
{}
| static_declaration
{}
| gate_declaration
| UDP_or_module_instantiation
{}
| parameter_override
{}
| continuous_assign
{}
| specify_block
{}
| initial_statement
{ BLOCK_BODY (current_module) = tree_cons ($1,
(tree)INITIAL_CODE, BLOCK_BODY (current_module));
}
| always_statement
{ BLOCK_BODY (current_module) = tree_cons ($1,
(tree)ALWAYS_CODE, BLOCK_BODY (current_module));
}
| task
{}
| function
{}
;
/*
UDP
: PRIMITIVE IDENTIFIER
{ syn_warning ("primitive definition");
sorry ("User-defined primitives not supported in this version");
eat_block (ENDPRIMITIVE);
$$ = NULL;
}
;
*/
UDP
: PRIMITIVE
{ if (is_interactive) {
YYFAIL;
}
}
IDENTIFIER
{
current_module = current_scope = build_udp ($3);
push_scope ();
/* list of parse modules */
module_list = tree_cons (current_module, NULL_TREE, module_list);
}
list_of_ports_o sc
{ UDP_PORT_LIST (current_module) = nreverse ($5); }
UDP_declarations UDP_initial_statement UDP_table_definition ENDPRIMITIVE
{
current_scope = pop_scope ();
UDP_STRING_LIST (current_module) = nreverse (UDP_STRING_LIST (current_module));
end_primitive (current_module);
}
;
UDP_declarations
: /* empty */
{ $$ = NULL_TREE; }
| UDP_declarations UDP_declaration
{ yyerrok; }
| UDP_declarations error
;
UDP_declaration
: port_declaration
| UDP_reg_statement
;
UDP_reg_statement
: REG IDENTIFIER sc
{
if( strcmp( IDENT($2),
IDENT(DECL_NAME(TREE_PURPOSE(MODULE_PORT_LIST(current_module)))) )!=0 ) {
error( "only the first declared port in a udp can be a reg",
NULL_CHAR, NULL_CHAR );
} else {
UDP_REG_NAME(current_module) = $2;
}
$$ = NULL_TREE;
}
;
UDP_initial_statement
: /* NULL */
{ $$ = NULL_TREE; }
| INITIAL IDENTIFIER '=' scalar_constant sc
{
if( UDP_REG_NAME(current_module)==NULL_TREE ) {
error( "initial statement is no allowed in combinatorial udp's",
NULL_CHAR, NULL_CHAR );
} else if( strcmp(IDENT($2),IDENT(UDP_REG_NAME(current_module)))!=0 ) {
error( "initial statement does not reference port output",
NULL_CHAR, NULL_CHAR );
} else {
UDP_INITIAL_VALUE(current_module) = $4;
}
$$ = NULL_TREE;
}
;
UDP_table_definition
: TABLE
{ extern int enable_udp_parse;
enable_udp_parse = TRUE;
current_udp_string = NULL_TREE;
}
table_entry_list ENDTABLE
{
UDP_STRING_LIST(current_module) = $3;
$$ = NULL_TREE;
}
;
table_entry_list
: table_entry
| table_entry_list table_entry
{
$$ = chainon ($2, $1);
}
;
table_entry
: table_digit_list sc
{
validate_udp_string( current_module, current_udp_string );
$$ = current_udp_string;
current_udp_string = NULL_TREE;
}
;
table_digit_list
: /* NULL */
{ $$ = NULL; }
| table_digit_list table_digit
{ $$ = NULL; }
;
table_digit
: UDP_CHAR
{
append_udp_digits( ¤t_udp_string, $1, $1 );
$$ = NULL;
}
| UDP_HOOK
{
append_udp_digits( ¤t_udp_string,'?','?' );
$$ = NULL;
}
| UDP_ZERO
{
append_udp_digits( ¤t_udp_string,'0','0' );
$$ = NULL;
}
| UDP_ONE
{
append_udp_digits( ¤t_udp_string,'1','1' );
$$ = NULL;
}
| UDP_B
{
append_udp_digits( ¤t_udp_string,'b','b' );
$$ = NULL;
}
| UDP_X
{
append_udp_digits( ¤t_udp_string,'x','x' );
$$ = NULL;
}
| '(' table_digit1 table_digit1 rp
{
/* ? and b must be convert different but equivilent characters
otherwise edges cannot be distinguished from levels */
if( $2=='?' ) {
$2 = '!';
} else if( $2=='b' ) {
$2 = '%';
}
append_udp_digits( ¤t_udp_string,$2, $3 );
$$ = NULL;
}
;
table_digit1
: UDP_X
| UDP_ZERO
| UDP_ONE
| UDP_B
| UDP_HOOK
;
task
: TASK IDENTIFIER sc
{ syn_warning ("Task definition");
tmp_tree = build_task (check_task ($2));
make_block_decl ($3, current_scope, tmp_tree);
current_scope = tmp_tree;
BLOCK_DOWN (current_module) = chainon (current_scope, BLOCK_DOWN (current_module));
BLOCK_UP (current_scope) = current_module;
push_scope ();
in_tf = 1;
}
tf_declaration_list statement_or_null ENDTASK
{ BLOCK_BODY (current_scope) = $6;
in_tf = 0;
BLOCK_PORTS (current_scope) = nreverse (BLOCK_PORTS (current_scope));
BLOCK_DECL (current_scope) = nreverse (BLOCK_DECL (current_scope));
current_scope = pop_scope ();
}
;
function
: FUNCTION function_type IDENTIFIER sc
{ current_scope = build_function (check_function ($3));
make_block_decl ($3, current_module, current_scope);
push_scope (); /* funct name becomes var inside of funct */
FUNCT_DECL (current_scope) = make_decl ($3, $2, NULL_TREE, NULL_TREE);
BLOCK_DOWN (current_module) = chainon (current_scope, BLOCK_DOWN (current_module));
BLOCK_UP (current_scope) = current_module;
in_tf = in_function = 1;
}
tf_declaration_list statement_or_null ENDFUNCTION
{ BLOCK_BODY (current_scope) = $7;
in_tf = in_function = 0;
BLOCK_PORTS (current_scope) = nreverse (BLOCK_PORTS (current_scope));
BLOCK_DECL (current_scope) = nreverse (BLOCK_DECL (current_scope));
current_scope = pop_scope ();
}
;
function_type
: /* empty */
{ $$ = make_reg_spec (NULL_TREE); }
| range
{ $$ = make_reg_spec ($1); }
| INTEGER
{ $$ = make_integer_spec (NULL_TREE); }
| REAL
{ $$ = make_real_spec (NULL_TREE); }
;
tf_declaration_list
: /* empty */
{}
| tf_declaration_list tf_declaration
;
tf_declaration
: parameter_declaration
| port_declaration
| static_declaration
;
/*
A.2 Declarations
*/
parameter_declaration
: PARAMETER xrange
{ current_spec = make_param_spec ($2); }
list_of_param_assignments sc
{ BLOCK_DECL (current_scope) =
chainon ($4, BLOCK_DECL (current_scope));
}
;
list_of_param_assignments
: param_assignment
| list_of_param_assignments ',' param_assignment
{ yyerrok;
$$ = chainon ($3, $1);
}
| error
| list_of_param_assignments error param_assignment
{ yyerrok; }
| list_of_param_assignments ',' error
;
param_assignment
: IDENTIFIER '=' constant_expression
{ $$ = make_param_decl (check_non_reg ($1), current_spec, $3);
}
| IDENTIFIER '=' mintypmax_expression_triplet
{ $$ = make_param_decl (check_non_reg ($1), current_spec, $3);
}
;
setspec
: /* empty */
{}
;
static_declaration
: reg_spec setspec reg_decl_identifiers sc
{ BLOCK_DECL (current_scope) =
chainon ($3, BLOCK_DECL (current_scope)); }
| event_spec setspec non_reg_decl_identifiers sc
{ BLOCK_DECL (current_scope) =
chainon ($3, BLOCK_DECL (current_scope)); }
| real_spec setspec decl_identifiers sc
{ BLOCK_DECL (current_scope) =
chainon ($3, BLOCK_DECL (current_scope)); }
;
/* Used for ports and arguments to tasks and functions. */
port_declaration
: port_spec setspec port_decl_identifiers sc
{ BLOCK_PORTS (current_scope) =
chainon ($3, BLOCK_PORTS (current_scope)); }
;
/* If inside a module, ports are nets by default, so make them so. Inside
of a task or function, ports are REGs. */
port_spec
: INPUT xrange
{ if (in_tf)
$$ = current_spec = make_reg_spec ($2);
else
$$ = current_spec = make_net_spec (default_net_type, $2, NULL_TREE);
PORT_INPUT_ATTR ($$) = 1;
}
| OUTPUT xrange
{ function_error;
if (in_tf)
$$ = current_spec = make_reg_spec ($2);
else
$$ = current_spec = make_net_spec (default_net_type, $2, NULL_TREE);
PORT_OUTPUT_ATTR ($$) = 1;
}
| INOUT xrange
{ function_error;
if (in_tf)
$$ = current_spec = make_reg_spec ($2);
else
$$ = current_spec = make_net_spec (default_net_type, $2, NULL_TREE);
PORT_INPUT_ATTR ($$) = 1;
PORT_OUTPUT_ATTR ($$) = 1;
}
;
port_decl_identifiers
: IDENTIFIER
{ $$ = make_decl (check_port ($1), current_spec, NULL_TREE, NULL_TREE); }
| port_decl_identifiers ',' IDENTIFIER
{ yyerrok;
$$ = chainon (make_decl (check_port ($3), current_spec, NULL_TREE, NULL_TREE), $1);
}
| error
| port_decl_identifiers error
| port_decl_identifiers error IDENTIFIER
{ yyerrok; }
| port_decl_identifiers ',' error
;
reg_spec
: REG xrange
{ current_spec = make_reg_spec ($2); }
| INTEGER xrange
{ if (!$2)
syn_warning ("Integer Range");
current_spec = make_integer_spec ($2);
}
| TIME xrange
{ syn_warning ("TIME");
current_spec = make_time_spec ($2);
}
;
real_spec
: REAL
{ current_spec = make_real_spec (NULL_TREE); }
;
event_spec
: EVENT
{ syn_warning ("EVENT");
current_spec = make_event_spec (); }
;
setnetspec
: /* empty */
{ lval_type = LVAL_NEW_NET; }
;
net_declaration
: net_spec setnetspec decl_identifiers sc
{ BLOCK_DECL (current_scope) =
chainon ($3, BLOCK_DECL (current_scope));
lval_type = LVAL_REG;
current_delay = NULL_TREE;
}
| trireg_spec setspec decl_identifiers sc
| net_spec setnetspec list_of_net_assignments sc
{ lval_type = LVAL_REG;
MODULE_ASSIGNMENTS (current_module) =
chainon ($3, MODULE_ASSIGNMENTS (current_module));
current_delay = NULL_TREE;
}
;
net_spec
: nettype expandrange_o delay_o
{ $$ = current_spec = make_net_spec ($1, $2, $3);
current_delay = $3;
}
;
trireg_spec
: TRIREG
{ syn_warning ("TRIREG net");
sorry ("TRIREG net type is not supported in this version");
}
charge_strength_o expandrange_o delay_o
{ $$ = error_mark_node; }
;
nettype
: NETTYPE
| SUPPLY0
{ syn_warning ("SUPPLY0 net"); }
| SUPPLY1
{ syn_warning ("SUPPLY1 net"); }
;
/*