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 pathtree.h
1485 lines (1226 loc) · 50.9 KB
/
tree.h
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
*****************************************************************************/
/* TREE.H - Tree structures and routine prototypes
/* This is here as a placeholder since not all modules that include
tree.h will also include decl.h
*/
#ifndef TREE_H
#define TREE_H
#include "veriuser.h"
/* codes of tree nodes */
#define DEFTREECODE(SYM, STRING, TYPE, NARGS) SYM,
enum tree_code {
#include "tree.def"
LAST_AND_UNUSED_TREE_CODE /* A convienent way to get a value for
NUM_TREE_CODE. */
};
#undef DEFTREECODE
/* Number of tree codes. */
#define NUM_TREE_CODES ((int)LAST_AND_UNUSED_TREE_CODE)
/* Indexed by enum tree_code, contains a character which is
`e' for an expression, `r' for a reference, `c' for a constant,
`d' for a decl, `s' for a statement, `b' for a block,
and `x' for anything else (TREE_LIST, IDENTIFIER, etc). */
extern char *tree_code_type[];
/* Number of argument-words in each kind of tree-node. */
extern int tree_code_length[];
/* Name of tree node */
extern char *tree_code_name[];
enum tree_type {
NO_TYPE,
MODULE_TYPE,
FUNCTION_TYPE,
TASK_TYPE,
REG_TYPE,
INTEGER_TYPE,
EVENT_TYPE,
TIME_TYPE,
REAL_TYPE,
NET_TRI_TYPE,
NET_WIRE_TYPE,
NET_TRIOR_TYPE,
NET_WOR_TYPE,
NET_TRIAND_TYPE,
NET_WAND_TYPE,
NET_TRIREG_TYPE,
NET_TRI0_TYPE,
NET_TRI1_TYPE,
NET_SUPPLY0_TYPE,
NET_SUPPLY1_TYPE,
NAMED_BLOCK_TYPE,
GATE_AND_TYPE,
GATE_NAND_TYPE,
GATE_OR_TYPE,
GATE_NOR_TYPE,
GATE_XOR_TYPE,
GATE_XNOR_TYPE,
GATE_BUF_TYPE,
GATE_NOT_TYPE,
GATE_BUFIF0_TYPE,
GATE_BUFIF1_TYPE,
GATE_NOTIF0_TYPE,
GATE_NOTIF1_TYPE,
GATE_NMOS_TYPE,
GATE_PMOS_TYPE,
GATE_RNMOS_TYPE,
GATE_RPMOS_TYPE,
GATE_CMOS_TYPE,
GATE_RCMOS_TYPE,
GATE_PULLUP_TYPE,
GATE_PULLDN_TYPE,
GATE_TRAN_TYPE,
GATE_RTRAN_TYPE,
GATE_TRANIF0_TYPE,
GATE_TRANIF1_TYPE,
GATE_RTRANIF0_TYPE,
GATE_RTRANIF1_TYPE,
GATE_UDP_TYPE,
STRENGTH_SUPPLY0_TYPE,
STRENGTH_SUPPLY1_TYPE,
STRENGTH_STRONG0_TYPE,
STRENGTH_STRONG1_TYPE,
STRENGTH_PULL0_TYPE,
STRENGTH_PULL1_TYPE,
STRENGTH_HIGHZ0_TYPE,
STRENGTH_HIGHZ1_TYPE,
STRENGTH_WEAK0_TYPE,
STRENGTH_WEAK1_TYPE
};
enum delay_type {
MIN_DELAY,
TYP_DELAY,
MAX_DELAY
};
enum lval_type {
LVAL_REG,
LVAL_NEW_NET,
LVAL_NET,
LVAL_REG_NET,
LVAL_GATE
};
/* Codes that identify the various built in functions
so that expand_call can identify them quickly. */
/* May use this later for $display, etc. */
//enum built_in_function
//{
// DISPLAY,
// DISPLAYH,
// DISPLAYO,
// DISPLAYB
//};
/* The definition of tree nodes fills the next several pages. */
/* A tree node can represent a variable, an expression
or a statement. Each node has a TREE_CODE which says what kind of
thing it represents. Some common codes are:
INTEGER_TYPE -- represents a type of integers.
VAR_DECL -- represents a declared variable.
INTEGER_CST -- represents a constant integer value.
PLUS_EXPR -- represents a sum (an expression).
As for the contents of a tree node: there are some fields
that all nodes share. Each TREE_CODE has various special-purpose
fields as well. The fields of a node are never accessed directly,
always through accessor macros. */
/* This type is used everywhere to refer to a tree node. */
typedef union tree_node *tree;
#define NULL_TREE (tree) NULL
/* forward defines for Metrowerks */
struct Marker;
struct timeq_tag;
/* Every kind of tree node starts with this structure,
so all nodes have these fields.
See the accessor macros, defined below, for documentation of the fields. */
struct tree_common {
union tree_node *chain;
nbits_t nbits;
unsigned char type:8;
unsigned char code:8;
unsigned int label:8;
unsigned int sub_label:8;
unsigned constant:1;
unsigned integer:1;
// unsigned signed_attr : 1;
// unsigned self_determined : 1;
unsigned port_input:1;
unsigned port_output:1;
unsigned port_redefined:1;
unsigned port_collapsed:1;
unsigned case_default:1;
/*unsigned parameter_override : 1; *//* uses case_default */
/*unsigned lib_module : 1; *//* uses case_default */
/*unsigned net_assign : 1; *//* uses case_default */
unsigned net_scalared:1;
unsigned net_vectored:1;
unsigned stmt_surrogate:1;
unsigned vector_direction:1;
unsigned named_port:1;
/* unsigned port_immediate : 1; *//* uses named_port */
unsigned interrupt_flag:1; /* Used only by CASE */
/* unsigned real : 1; *//* uses interrupt_flag */
unsigned hierarchical:1;
unsigned initialized:1;
unsigned referenced:1;
/* There is room for 0 more attributes. */
/* -------------------- */
unsigned unknown_type:1;
unsigned udp:1;
unsigned pli_asynch:1;
unsigned pad:13;
/* There is room for 14 more attributes. */
//#ifdef ALIGN_32
// short pad; /* align to 32 bits */
//#endif
};
/* Define accessors for the fields that all tree nodes have
(though some fields are not used for all kinds of nodes). */
/* The tree-code says what kind of node it is.
Codes are defined in tree.def. */
#define TREE_CODE(NODE) ((enum tree_code) (NODE)->common.code)
#define TREE_SET_CODE(NODE, VALUE) ((NODE)->common.code = (int) (VALUE))
/* In all nodes that are expressions, this is the data type of the expression.
In declarations, this is the declaration data type.
In NET declarations, this is the NET subtype (WIRE, TRI0, etc.) */
#define TREE_TYPE(NODE) ((NODE)->common.type)
#define TREE_SET_TYPE(NODE, VALUE) ((NODE)->common.type = (int) (VALUE))
/* In all nodes that are expressions, assign a "label" that will determine
the order of execution and the required depth of the stack for that
expression (From Aho 1986) */
#define TREE_LABEL(NODE) ((NODE)->common.label)
/* In all nodes that are expressions, assign a "sub-label" that is used
to determin the depth of the stack for a subexpression using the same
expression length (reduction, conditional, etc. operations may change
the expression length and will thus reset this value within an
expression. */
#define TREE_SUB_LABEL(NODE) ((NODE)->common.sub_label)
/* In all nodes that are expressions, "nbits" is the number of bits
in the result taking into account context dependent-ness. */
#define TREE_NBITS(NODE) ((NODE)->common.nbits)
/* Nodes are chained together for many purposes.
Decls in the same scope are chained together to record the contents
of the scope.
Statement nodes for successive statements used to be chained together.
Often lists of things are represented by TREE_LIST nodes that
are chained together. */
#define TREE_CHAIN(NODE) ((NODE)->common.chain)
/* Define many boolean fields that all tree nodes have. */
/* For expression nodes, this determines if the expression tree represents
a constant expression. */
#define TREE_CONSTANT_ATTR(NODE) ((NODE)->common.constant)
/* For expression nodes, this determines if the expression tree represents
an integer expression. */
#define TREE_INTEGER_ATTR(NODE) ((NODE)->common.integer)
/* Also, determine if expression/constant/ref is signed or unsigned */
#define TREE_SIGNED_ATTR(NODE) ((NODE)->common.signed_attr)
/* Certain operators are defined as have self-determined or context-determined
lengths as a result. */
#define TREE_SELF_DETERMINED_ATTR(NODE) ((NODE)->common.self_determined)
/* For ports and function/task arguments, define it as being an input,
output or inout. */
#define PORT_INPUT_ATTR(NODE) ((NODE)->common.port_input)
#define PORT_OUTPUT_ATTR(NODE) ((NODE)->common.port_output)
#define PORT_REDEFINED_ATTR(NODE) ((NODE)->common.port_redefined)
/* For NETs (applied to all DECLs, but should always be 0), mark if a
source to a net is a collapsed port. If so, it will be scheduled
immediately. */
#define PORT_COLLAPSED_ATTR(NODE) ((NODE)->common.port_collapsed)
/* For NETS that are collapsed, indicate this fact in the port argument
in the instance statement. It cannot be labeled as PORT_COLLAPSE
because do_net_eval uses that to ignore it for calculating the value
to be propigated to the output port. */
#define PORT_IMMEDIATE_ATTR(NODE) ((NODE)->common.named_port)
/* For case statements, mark the statement as having seen a default case
to flag multiple default cases. */
#define CASE_DEFAULT_ATTR(NODE) ((NODE)->common.case_default)
/* For parameter assignments, indicates that this assignment has
been overridden. Use the override rval. */
#define PARAMETER_OVERRIDE_ATTR(NODE) ((NODE)->common.case_default)
/* Modules that have been found in the library are tagged as such since
the same module name might be used for several library modules, each
a different number of arguments */
#define LIB_MODULE_ATTR(NODE) ((NODE)->common.case_default)
/* Net assignments get evaluated immediately, as opposed to continuous
assignements which are scheduled. Use this attribute to distinguish
the difference. */
#define NET_ASSIGN_ATTR(NODE) ((NODE)->common.case_default)
/* For nets, indicate if declaration is forcing expansion or forcing
no expansion. */
#define NET_SCALARED_ATTR(NODE) ((NODE)->common.net_scalared)
#define NET_VECTORED_ATTR(NODE) ((NODE)->common.net_vectored)
/* In a FOR statement, there are two nodes generated, on for the initial
expression/condition, and one for the iteration expression/condition.
Mark the interation node so that it can be fixed up in pass 3. */
/* In certain statements, entering it for the first time has a different
effect that re-entering after a loop or returning after an event.
Such statements include FOR. */
#define STMT_SURROGATE_ATTR(NODE) ((NODE)->common.stmt_surrogate)
/* In a repeat statement, this it toggled at runtime to determine of the
expression should be evaluated (first time through), or if the top
of the stack should be decremented. */
//#define REPEAT_1ST_ATTR(NODE) ((NODE)->common.repeat_1st)
/* In a vectored data type, this is set if the msb is greater than the
lsb (usual case) */
#define VECTOR_DIRECTION_ATTR(NODE) ((NODE)->common.vector_direction)
/* In module instances and module declarations, NAMED_PORT_ATTR indicates
that named ports are being used and in the port list, TREE_VALUE
points to an IDENTIFIER_NODE that is the name of the port. */
#define NAMED_PORT_ATTR(NODE) ((NODE) -> common.named_port)
/* Determines if this decl is a REAL number */
#define TREE_REAL_ATTR(NODE) ((NODE) -> common.interrupt_flag)
/* For case statements (and maybe others in the future), the statement could
be interrupted in the middle of processing by control C or single step.
This is intself is OK, but if another statment is executed, then the state
needs to be staved. INTERRUPT_FLAG tells exec to redo the command without
tracing. */
#define INTERRUPT_FLAG_ATTR(NODE) ((NODE) -> common.interrupt_flag)
/* If an IDENTIFIER_NODE (as well as TASK and FUNCTION nodes)
contains a hierarchical reference (xx.xxx.xxx...)
then it will be tagged as such in parse.y. */
#define HIERARCHICAL_ATTR(NODE) ((NODE) -> common.hierarchical)
/* When a block node or decl node has been initialized in pass2 (or pass3),
set INITIALIZED_ATTR for debugging and sanity check and, in the case of
module blocks, to avoid being initialized twice. */
#define INITIALIZED_ATTR(NODE) ((NODE) -> common.initialized)
/* When a decl node is referenced, mark it as such. For now, if a port
is declared, then referenced, then redeclared, we can't handle this,
so flag it. */
#define REFERENCED_ATTR(NODE) ((NODE) -> common.referenced)
/* If there is a hierarchical name or a function in an expression, then
compile-time type conversion won't work. Do some extra work in pass3.c */
#define UNKNOWN_TYPE_ATTR(NODE) ((NODE) -> common.unknown_type)
/* If module definition is really for a udp flag, set this flag */
#define UDP_ATTR(NODE) ((NODE) -> common.udp)
/* If pli async is enabled set this flag */
#define ASYNCH_ATTR(NODE) ((NODE) -> common.pli_asynch)
/* Define additional fields and accessors for nodes representing constants. */
/* In an INTEGER_CST node. This represents a signed 32-bit constant. */
#define INT_CST_HIGH(node) ((node)->int_cst.high)
#define INT_CST_LOW(node) ((node)->int_cst.low)
#define INT_CST_DATA(NODE) ((NODE)->int_cst.data)
struct tree_int_cst {
char common[sizeof(struct tree_common)];
signed_32_t data;
};
#define REAL_CST_DATA(NODE) ((NODE)->real_cst.data)
struct tree_real_cst {
char common[sizeof(struct tree_common)];
double data;
};
/* Bit constants are unsigned, of any length. TREE_BIT_LENGTH is the
size of the constant in bits; TREE_BITVAL_POINTER points to a bitval
structure that stores the value. */
enum radii { BIN, HEX, OCT, DEC, STRING_, CHAR_, EXP_, FLOAT_, EXPFLOAT_,
TIME_ };
#define BIT_CST_GROUP(NODE) ((NODE)->bit_cst.group)
#define BIT_CST_RADIX(NODE) ((NODE)->bit_cst.radix)
#define BIT_CST_SET_RADIX(NODE, VALUE) ((NODE)->bit_cst.radix = (enum radii) (VALUE))
#define BIT_CST_NBITS(NODE) ((NODE)->bit_cst.nbits)
//#define BIT_CST_NGROUPS(NODE) (((NODE)->bit_cst.nbits) >> GROUP_SHIFT_BITS)
struct tree_bit_cst {
char common[sizeof(struct tree_common)];
enum radii radix;
nbits_t nbits;
union group *group;
};
/* In a STRING_CST */
#define TREE_STRING_LENGTH(NODE) ((NODE)->string.length)
#define TREE_STRING_POINTER(NODE) ((NODE)->string.pointer)
struct tree_string {
char common[sizeof(struct tree_common)];
int length;
char *pointer;
};
/* Define fields and accessors for some special-purpose tree nodes. */
#define IDENTIFIER_LENGTH(NODE) ((NODE)->identifier.length)
#define IDENTIFIER_POINTER(NODE) ((NODE)->identifier.pointer)
#define IDENT(NODE) ((NODE)->identifier.pointer)
#define IDENT_CURRENT_DECL(NODE) ((NODE)->identifier.current_decl)
struct tree_identifier {
char common[sizeof(struct tree_common)];
int length;
char *pointer;
union tree_node *current_decl;
};
/* In a TREE_LIST node. */
#define TREE_PURPOSE(NODE) ((NODE)->list.purpose)
#define TREE_VALUE(NODE) ((NODE)->list.value)
#define TREE_3RD(NODE) ((NODE)->list.third.exp)
/* Alternate reference method */
#define TREE_EXPR(NODE) ((NODE)->list.purpose)
#define TREE_STMT(NODE) ((NODE)->list.value)
#define TREE_EXPR_CODE(NODE) ((NODE)->list.third.exp_code)
/* Another reference for tmp vars for PLI arguments */
#define TREE_PLIINFO(NODE) ((NODE)->list.value)
struct tree_list {
char common[sizeof(struct tree_common)];
union tree_node *purpose;
union tree_node *value;
union {
union tree_node *exp;
union tree_node **exp_code;
} third;
};
/* Define fields and accessors for some nodes that represent expressions. */
/* In expression and reference nodes. */
#define TREE_OPERAND(NODE, I) ((NODE)->exp.operands[I].exp)
#define REF_NAME(NODE) ((NODE)->exp.operands[0].exp)
#define TRUTH_EXPR_CODE(NODE) ((NODE)->exp.operands[2].exp_code)
#define BIT_REF_DECL(NODE) ((NODE)->exp.operands[0].exp)
#define BIT_EXPR(NODE) ((NODE)->exp.operands[1].exp)
#define BIT_EXPR_CODE(NODE) ((NODE)->exp.operands[2].exp_code)
#define BIT_REF_NAME(NODE) ((NODE)->exp.operands[3].exp)
#define ARRAY_REF_DECL(NODE) ((NODE)->exp.operands[0].exp)
#define ARRAY_EXPR(NODE) ((NODE)->exp.operands[1].exp)
#define ARRAY_EXPR_CODE(NODE) ((NODE)->exp.operands[2].exp_code)
#define ARRAY_REF_NAME(NODE) ((NODE)->exp.operands[3].exp)
#define FUNC_REF_NAME(NODE) ((NODE)->func.name)
#define FUNC_REF_ARGS(NODE) ((NODE)->func.args)
#define FUNC_REF_FUNC(NODE) ((NODE)->func.type.func)
#define FUNC_REF_INASSIGN(NODE) ((NODE)->func.inassign)
#define FUNC_REF_LINE(NODE) ((lineno_t)(NODE)->func.line)
#define FUNC_REF_FILE(NODE) ((NODE)->func.file)
#define FUNC_REF_CONTEXT(NODE) ((NODE)->func.context)
#define FUNC_REF_SYSTYPE(NODE) ((enum sysfunction_type)(NODE)->func.type.systype)
#define SET_FUNC_REF_SYSTYPE(NODE, VALUE) ((NODE)->func.type.systype = \
(int)(VALUE))
#define FUNC_REF_USERTF(NODE) ((NODE)->func.usertf)
#define FUNC_REF_WORKAREA(NODE) ((NODE)->func.workArea)
#define FUNC_REF_DELAYSCB(NODE) ((NODE)->func.delaySCB)
#define FUNC_REF_RETURNDECL(NODE) ((NODE)->func.returndecl)
#define FUNC_REF_NEXT(NODE) ((NODE)->func.nextinstance)
struct tree_func {
char common[sizeof(struct tree_common)];
char *name;
union tree_node *args;
union {
union tree_node *func;
int systype;
// enum sysfunction_type systype;
} type;
union tree_node *inassign;
lineno_t line;
char *file;
union tree_node *context;
p_tfcell usertf; /* PLI user_tf pointer (0 if not PLI) */
char *workArea; /* used by pli routines */
struct SCB *delaySCB; /* used for tf_setdelay */
union tree_node *returndecl; /* decl holding return value */
union tree_node *nextinstance; /* linked list of all pli instances */
};
#define HIERARCHICAL_REF_IDENT(NODE) ((NODE)->exp.operands[0].exp)
#define SHIFT_OPERAND(NODE) ((NODE)->shift.operand)
#define SHIFT_COUNT(NODE) ((NODE)->shift.count)
#define SHIFT_NBITS(NODE) ((NODE)->shift.nbits)
struct tree_shift {
char common[sizeof(struct tree_common)];
union tree_node *operand;
union tree_node *count;
nbits_t nbits;
};
/* This is used for part-selects and conatenations */
#define PART_RMASK(NODE) ((NODE)->rmask)
#define PART_LMASK1(NODE) ((NODE)->lmask1)
#define PART_LMASK2(NODE) ((NODE)->lmask2)
#define PART_NGROUPS(NODE) ((NODE)->ngroups)
#define PART_SHIFT(NODE) ((NODE)->shift)
#define PART_NEXT(NODE) ((NODE)->next)
#define PART_ALIGNED(NODE) ((NODE)->aligned)
struct part_info {
Bit rmask;
Bit lmask1;
Bit lmask2;
ngroups_t ngroups;
int shift;
ngroups_t next;
unsigned aligned:1;
};
#define COND_EXPR(NODE) ((NODE)->exp.operands[0].exp)
#define COND_EXPR_CODE(NODE) ((NODE)->exp.operands[1].exp_code)
#define COND_TRUE(NODE) ((NODE)->exp.operands[2].exp)
#define COND_TRUE_CODE(NODE) ((NODE)->exp.operands[3].exp_code)
#define COND_FALSE(NODE) ((NODE)->exp.operands[4].exp)
#define COND_FALSE_CODE(NODE) ((NODE)->exp.operands[5].exp_code)
#define PART_INFO(NODE) ((NODE)->part.info)
#define PART_DECL(NODE) ((NODE)->part.decl)
#define PART_MSB_(NODE) ((NODE)->part.msb_)
#define PART_LSB_(NODE) ((NODE)->part.lsb_)
#define PART_MSB(NODE) ((NODE)->part.msb)
#define PART_LSB(NODE) ((NODE)->part.lsb)
#define PART_STORAGE(NODE) ((NODE)->part.storage)
#define PART_NAME(NODE) ((NODE)->part.name)
struct tree_part {
char common[sizeof(struct tree_common)];
struct part_info *info;
union tree_node *decl;
union tree_node *msb_;
union tree_node *lsb_;
nbits_t msb;
nbits_t lsb;
Group *storage;
union tree_node *name;
};
#define CONCAT_LIST(NODE) ((NODE)->concat.list)
#define CONCAT_NBITS(NODE) ((NODE)->concat.nbits)
#define CONCAT_EXPR(NODE) ((NODE)->concat.expr)
#define CONCAT_COUNT(NODE) ((NODE)->concat.count)
struct tree_concat {
char common[sizeof(struct tree_common)];
union tree_node *list;
nbits_t nbits;
union tree_node *expr; /* for repeat counts */
unsigned_32_t count; /* ditto */
};
struct tree_exp {
char common[sizeof(struct tree_common)];
union {
int value;
union tree_node *exp;
union tree_node **exp_code;
} operands[1];
};
/* Define fields and accessors for nodes representing declared names. */
#define DECL_NAME(NODE) ((NODE)->decl_common.name)
#define DECL_CONTEXT(NODE) ((NODE)->decl_common.context)
#define DECL_RESULT(NODE) ((NODE)->decl_common.result)
#define DECL_INITIAL(NODE) ((NODE)->decl_common.initial)
#define DECL_SOURCE_FILE(NODE) ((NODE)->decl_common.filename)
#define DECL_SOURCE_LINE(NODE) ((NODE)->decl_common.linenum)
#define DECL_SIZE(NODE) ((NODE)->decl_common.size)
//#define DECL_ACTIVE(NODE) ((NODE)->decl_common.active)
#define DECL_UNUSED_FLAG(NODE) ((NODE)->common.parameter1_attr)
#define DECL_STORAGE(NODE) ((NODE)->decl_common.storage)
//#define DECL_ARRAY(NODE) ((NODE)->common.flag2)
#define DECL_MSB(NODE) ((NODE)->decl_common.msb_)
#define DECL_LSB(NODE) ((NODE)->decl_common.lsb_)
//#define DECL_NBITS(NODE) ((NODE)->decl_common.nbits)
#define DECL_STORAGE(NODE) ((NODE)->decl_common.storage)
#define DECL_EVENT_CHAIN(NODE) ((NODE)->decl_common.event_chain)
#define DECL_EVENT_NOCAST(NODE) ((NODE)->decl_common.event_chain)
#define DECL_STATE(NODE) ((enum logical_value) (NODE)->decl_common.state)
#define SET_DECL_STATE(NODE, VALUE) ((NODE)->decl_common.state = (enum logical_value)(VALUE))
#define DECL_THREAD(NODE) ((NODE)->decl_common.thread)
#define DECL_UPDATE_FILE(NODE) ((NODE)->decl_common.update_file)
#define DECL_UPDATE_LINE(NODE) ((NODE)->decl_common.update_line)
#define DECL_UPDATE_TIME(NODE) ((NODE)->decl_common.update_time)
#define MSB(NODE) ((NODE)->decl_common.msb)
#define LSB(NODE) ((NODE)->decl_common.lsb)
struct tree_decl_common {
char common[sizeof(struct tree_common)];
char *filename;
lineno_t linenum;
int size;
union tree_node *name;
union tree_node *context;
union tree_node *msb_;
union tree_node *lsb_;
nbits_t msb;
nbits_t lsb;
// nbits_t nbits;
union group *storage;
struct Marker *event_chain;
// void *event_chain;
int state;
// enum logical_value state;
union tree_node *thread;
char *update_file;
lineno_t update_line;
time64 update_time;
};
/* In a PLI_DELAY node */
#define PLI_DELAY_NEXT(NODE) ((NODE)->pli_delay.next)
#define PLI_DELAY_NODE(NODE) ((NODE)->pli_delay.node)
#define PLI_DELAY_TIME(NODE) ((NODE)->pli_delay.time)
#define PLI_DELAY_STORAGE(NODE) ((NODE)->pli_delay.storage)
#define PLI_DELAY_LVAL(NODE) ((NODE)->pli_delay.lval)
struct tree_pli_delay {
char common[sizeof(struct tree_common)];
union tree_node *next;
union tree_node *node;
time64 time;
union group *storage;
union tree_node *lval;
};
/* In a PATH_INPUT_TERMINAL (TREE_LIST) */
#define MODPATH_INPUT_TERMINAL_PARENT(NODE) TREE_STMT(NODE)
/* In a PATH_NODE node. */
#define PATH_SOURCE_FILE(NODE) ((NODE)->path.filename)
#define PATH_SOURCE_LINE(NODE) ((NODE)->path.linenum)
#define PATH_DELAYS(NODE) ((NODE)->path.delays)
#define PATH_INPUTS(NODE) ((NODE)->path.inputs)
#define PATH_OUTPUTS(NODE) ((NODE)->path.outputs)
#define PATH_PARALLEL(NODE) ((NODE)->path.parallel)
#define PATH_SOURCE(NODE) ((NODE)->path.source)
#define PATH_CONDITION(NODE) ((NODE)->path.condition)
#define PATH_EDGE(NODE) ((NODE)->path.edge)
#define PATH_POLARITY(NODE) ((NODE)->path.polarity)
struct tree_path {
char common[sizeof(struct tree_common)];
char *filename;
lineno_t linenum;
union tree_node *delays;
union tree_node *inputs;
union tree_node *outputs;
union tree_node *source;
union tree_node *condition;
int parallel;
int edge;
int polarity;
};
/* in PATH_INSTANCE */
#define PATH_INSTANCE_MODULE(NODE) ((NODE)->path_instance.module)
#define PATH_INSTANCE_PATHDESC(NODE) ((NODE)->path_instance.pathdesc)
struct tree_path_instance {
char common[sizeof(struct tree_common)];
union tree_node *module; /* points to containing module */
union tree_node *pathdesc; /* path description */
};
/* in PATH_OUTPUT */
#define PATH_OUTPUT_GATE(NODE) ((NODE)->path_output.gate)
#define PATH_OUTPUT_VALUE(NODE) ((NODE)->path_output.value)
#define PATH_OUTPUT_PATHDESC(NODE) ((NODE)->path_output.pathdesc)
#define PATH_OUTPUT_CONSTRAINTS(NODE) ((NODE)->path_output.constraints)
#define PATH_OUTPUT_SCB(NODE) ((NODE)->path_output.scb)
#define PATH_OUTPUT_CURRENT_VALUE(NODE) ((NODE)->path_output.current_value)
struct tree_path_output {
char common[sizeof(struct tree_common)];
union tree_node *gate; /* points to associated gate */
enum logical_value value; /* keeps track of value to be propagated */
union tree_node *pathdesc; /* list of path descriptions */
union tree_node *constraints; /* list of path constraints */
struct SCB *scb; /* scb for specify path */
enum logical_value current_value; /* keeps track of current value */
};
#define PATH_CONSTRAINT_DELAY(NODE,FROM,TO) ((NODE)->path_constraint.delays[((FROM)<<2)|(TO)])
#define PATH_CONSTRAINT_DEPENDENCIES(NODE) ((NODE)->path_constraint.dependencies)
#define PATH_CONSTRAINT_PATHDESC(NODE) ((NODE)->path_constraint.pathdesc)
#define PATH_CONSTRAINT_INSTANCE(NODE) ((NODE)->path_constraint.instance)
#define PATH_CONSTRAINT_OUTPUT_NUMBER(NODE) ((NODE)->common.sub_label)
struct tree_path_constraint {
char common[sizeof(struct tree_common)];
union tree_node *dependencies;
union tree_node *pathdesc;
union tree_node *instance;
unsigned delays[16];
};
/* timing check specification */
#define CHECK_SPEC_EVENT1(NODE) ((NODE)->check_spec.event1)
#define CHECK_SPEC_EVENT2(NODE) ((NODE)->check_spec.event2)
#define CHECK_SPEC_PARAM1(NODE) ((NODE)->check_spec.param1)
#define CHECK_SPEC_PARAM2(NODE) ((NODE)->check_spec.param2)
#define CHECK_SPEC_NOTIFIER(NODE) ((NODE)->check_spec.notifier)
#define CHECK_SPEC_CHECKTYPE(NODE) ((NODE)->check_spec.checkType)
struct tree_check_spec {
char common[sizeof(struct tree_common)];
char *filename;
lineno_t linenum;
union tree_node *event1;
union tree_node *event2;
union tree_node *param1;
union tree_node *param2;
union tree_node *notifier;
unsigned checkType;
};
/* specify timing event specification */
#define TIMING_EVENT_EXPRESSION(NODE) ((NODE)->timing_event.expression)
#define TIMING_EVENT_CONDITION(NODE) ((NODE)->timing_event.condition)
#define TIMING_EVENT_EDGESPEC(NODE) ((NODE)->timing_event.edgeSpec)
struct tree_timing_event {
char common[sizeof(struct tree_common)];
union tree_node *expression;
union tree_node *condition;
unsigned edgeSpec;
};
/* timing check terminal */
#define TIMING_TERMINAL_CHECK(NODE) (TREE_STMT(NODE))
/* timing check node */
#define TIMING_CHECK_PARAM1(NODE) ((NODE)->timing_check.param1)
#define TIMING_CHECK_PARAM2(NODE) ((NODE)->timing_check.param2)
#define TIMING_CHECK_EXPRESSIONCODE(NODE,I) ((NODE)->timing_check.expressionCode[I])
#define TIMING_CHECK_EXPRESSION(NODE,I) ((NODE)->timing_check.expression[I])
#define TIMING_CHECK_NOTIFIER(NODE) ((NODE)->timing_check.notifier)
#define TIMING_CHECK_CURRENTVALUE(NODE,I) ((NODE)->timing_check.currentValue[I])
#define TIMING_CHECK_CHANGETIME(NODE,I) ((NODE)->timing_check.changeTime[I])
#define TIMING_CHECK_CONDITION(NODE,I) ((NODE)->timing_check.condition[I])
#define TIMING_CHECK_CONDITIONCODE(NODE,I) ((NODE)->timing_check.conditionCode[I])
#define TIMING_CHECK_EDGESPEC(NODE,I) ((NODE)->timing_check.edgeSpec[I])
#define TIMING_CHECK_CHECKSPEC(NODE) ((NODE)->timing_check.checkSpec)
#define TIMING_CHECK_MODULE(NODE) ((NODE)->timing_check.module)
struct tree_timing_check {
char common[sizeof(struct tree_common)];
int param1;
int param2;
union tree_node *expression[2];
union tree_node **expressionCode[2];
union tree_node *notifier;
int currentValue[2];
time64 changeTime[2];
union tree_node *condition[2];
union tree_node **conditionCode[2];
unsigned int edgeSpec[2];
union tree_node *checkSpec;
union tree_node *module;
};
#define NOTIFIER_DECL(NODE) ((NODE)->common.chain)
#define NOTIFIER_TIMESTAMP(NODE) ((NODE)->notifier.timeStamp)
struct tree_notifier {
char common[sizeof(struct tree_common)];
time64 timeStamp;
};
#define UDP_STRING_STRING(NODE) ((NODE)->udp_string.string)
#define UDP_STRING_FILE(NODE) ((NODE)->udp_string.filename)
#define UDP_STRING_LINE(NODE) ((NODE)->udp_string.linenum)
struct tree_udp_string {
char common[sizeof(struct tree_common)];
char *filename;
lineno_t linenum;
char string[28];
};
#define UDP_TABLE_ARRAY(NODE,I) ((NODE)->udp_table.array[I])
struct tree_udp_table {
char common[sizeof(struct tree_common)];
char *array[10];
};
/* Array is used as a modifier; noun points to decl node. Array is used
for regs (scalar and vector), int, time and real (eventually) */
//#define ARRAY_DECL(NODE) ((NODE)->decl_array.decl)
#define ARRAY_CODE(NODE) ((NODE)->decl_array.code)
#define ARRAY_HI_EXPR(NODE) ((NODE)->decl_array.hi_expr)
#define ARRAY_LO_EXPR(NODE) ((NODE)->decl_array.lo_expr)
#define ARRAY_HI(NODE) ((NODE)->decl_array.hi)
#define ARRAY_LO(NODE) ((NODE)->decl_array.lo)
/* Recast storage to be array of pointers */
//#define ARRAY_STORAGE(NODE) ((Group **)(NODE)->decl_common.storage)
struct tree_decl_array {
char decl_common[sizeof(struct tree_decl_common)];
// union tree_node *decl;
enum tree_code code;
union tree_node *lo_expr;
union tree_node *hi_expr;
nbits_t lo;
nbits_t hi;
};
/* For net declarations. STMT_SURROGATE_ATTR indicates that the net is one
of many sources to the net and holds the value for that source. */
#define NET_DELAY(NODE) ((NODE)->decl_net.delay)
#define NET_SOURCE(NODE) ((NODE)->decl_net.source)
#define NET_ASSIGNMENT(NODE) ((NODE)->decl_net.assignment)
struct tree_decl_net {
char decl_common[sizeof(struct tree_decl_common)];
union tree_node *delay; /* points to delay expression for the net */
union tree_node *source; /* points to other sources to this net */
union tree_node *assignment; /* points to con't ass't for this net */
};
/* This is used for port terminal connections */
#define PORT_TERMINAL_HICONN(NODE) (TREE_VALUE(NODE))
/* This is used for module ports and function/task arguments */
#define DECL_PORT_NOUN(NODE) ((NODE)->tree_decl_port.noun)
#define DECL_TASK_NOUN(NODE) ((NODE)->tree_decl_port.noun)
#define DECL_PORT_MSB(NODE) ((NODE)->tree_decl_port_vector.msb)
#define DECL_PORT_LSB(NODE) ((NODE)->tree_decl_port_vector.lsb)
struct tree_decl_port {
char decl_common[sizeof(struct tree_decl_common)];
union tree_node *noun;
};
struct tree_decl_port_vector {
char decl_port[sizeof(struct tree_decl_port)];
union tree_node *msb;
union tree_node *lsb;
};
/* Parameter declaration. Points to constant expression that represents
default value. */
//#define DECL_PARAM_INIT(NODE) ((NODE)->decl_parameter.initial)
#define DECL_PARAM_RVAL(NODE) ((NODE)->decl_parameter.rval)
#define DECL_PARAM_RVAL_CODE(NODE) ((NODE)->decl_parameter.rval_code)
#define DECL_PARAM_REDIRECT(NODE) ((NODE)->decl_parameter.redirect)
struct tree_decl_parameter {
char decl_common[sizeof(struct tree_decl_common)];
union tree_node *rval;
union tree_node **rval_code;
union tree_node *redirect;
};
/* This is used at runtime to keep track of which SCB is in which scope.
It is needed for disable and for future $list */
struct context_member {
struct context_member *next;
struct context_member **prev;
struct context_member *shadow; /* context_member of previous context */
struct SCB *scb; /* Owner */
union tree_node *pc; /* PC to which to return upon leaving */
union tree_node *scope; /* Pointer to scoping block */
};
/* Define scoping block nodes */
#define BLOCK_SOURCE_LINE(NODE) ((NODE)->block_common.linenum)
#define BLOCK_SOURCE_FILE(NODE) ((NODE)->block_common.filename)
#define BLOCK_NAME(NODE) ((NODE)->block_common.name)
#define BLOCK_DECL(NODE) ((NODE)->block_common.decl)
#define BLOCK_PORTS(NODE) ((NODE)->block_common.ports)
#define BLOCK_ARGS(NODE) ((NODE)->block_common.ports)
#define BLOCK_PARAM(NODE) ((NODE)->block_common.param)
#define BLOCK_DOWN(NODE) ((NODE)->block_common.down)
#define BLOCK_UP(NODE) ((NODE)->block_common.up)
#define BLOCK_BODY(NODE) ((NODE)->block_common.body)
#define BLOCK_CONTEXT_LIST(NODE) ((NODE)->block_common.context_list)
#define BLOCK_LCB_LIST(NODE) ((NODE)->block_common.lcb)
struct tree_block_common {
char common[sizeof(struct tree_common)];
char *filename;
lineno_t linenum;
union tree_node *name;
union tree_node *decl;
union tree_node *param;
union tree_node *ports; // Maybe merge w/decl later?
union tree_node *down;
union tree_node *up;
union tree_node *body;
struct context_member *context_list;
union tree_node *lcb; // line execution call back list
// union tree_node *scb_list;
};
#define MODULE_PORT_LIST(NODE) ((NODE)->block_module.port_list)
//#define MODULE_INSTANCES(NODE) ((NODE)->block_module.common.module.instances)
#define MODULE_INSTANCES(NODE) ((NODE)->block_common.body)
#define MODULE_ASSIGNMENTS(NODE) ((NODE)->block_module.common.module.assignments)
#define MODULE_NAME(NODE) ((NODE)->block_module.name)
#define MODULE_DEFPARAMS(NODE) ((NODE)->block_module.common.module.defparams)
#define MODULE_SPECDEFS(NODE) ((NODE)->block_module.common.module.specdefs)
#define MODULE_SPECINST(NODE) ((NODE)->block_module.common.module.specinst)
#define MODULE_TIME_UNIT(NODE) ((NODE)->block_module.time_unit)
#define MODULE_TIME_PREC(NODE) ((NODE)->block_module.time_prec)
/* UDP definitions overlay the same structure and type as modules
UDP will have the UDP_ATTR flag set */
#define UDP_PORT_LIST(NODE) ((NODE)->block_module.port_list)
#define UDP_NAME(NODE) ((NODE)->block_module.name)
#define UDP_REG_NAME(NODE) ((NODE)->block_module.common.udp.reg_name)
#define UDP_INITIAL_VALUE(NODE) ((NODE)->block_module.common.udp.initial_value)
#define UDP_STRING_LIST(NODE) ((NODE)->block_module.common.udp.string_list)
#define UDP_TABLE(NODE) ((NODE)->block_module.common.udp.udp_table)
enum module_code { INITIAL_CODE, ALWAYS_CODE };
struct tree_block_module {
char block_common[sizeof(struct tree_block_common)];
char *name;
union tree_node *port_list;
union tree_node *instances;
union {
struct {
union tree_node *assignments;
union tree_node *defparams;
union tree_node *specinst;
union tree_node *specdefs;
} module;
struct {
union tree_node *reg_name;
union tree_node *initial_value;
union tree_node *string_list;
union tree_node *udp_table;
} udp;
} common;