Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | /* contains the type declarations for expression handling information |
2 | * |
||
3 | * $Header: c:\\cygwin\\cvsroot/Vert03/vertlib/expression.h,v 1.1.1.1 2003/11/04 23:34:57 |
||
4 | * mjames Exp $ |
||
5 | * |
||
6 | * $Log: expression.h,v $ |
||
7 | * Revision 1.1.1.1 2003/11/04 23:34:57 mjames |
||
8 | * Imported into local repositrory |
||
9 | * |
||
10 | * Revision 1.8 2002/10/02 19:37:30 MJAMES |
||
11 | * Moved dummy functions to a separate support file. |
||
12 | * |
||
13 | * Used correct number of arguments to define_pin |
||
14 | * |
||
15 | * Revision 1.7 2002/09/30 13:22:38 MJAMES |
||
16 | * Altered the use and creation of partition |
||
17 | * generics (at evaluation time of expressions within the partition ) |
||
18 | * This still needs checking, as evaluation of the expression may well be |
||
19 | * delayed until after when the partition generics need to be defined. |
||
20 | * |
||
21 | * Revision 1.6 2002/09/09 10:15:54 mjames |
||
22 | * Modified expression parser to match CC as previous one was |
||
23 | * broken |
||
24 | * |
||
25 | * Revision 1.5 2002/08/14 12:04:42 mjames |
||
26 | * Added declaration for eval_expression |
||
27 | * |
||
28 | * Revision 1.5 2002/04/04 14:53:05 mjames |
||
29 | * Added mentor board station reader to the portfolio |
||
30 | * |
||
31 | * Revision 1.4 2001/10/31 22:20:04 mjames |
||
32 | * Tidying up problematical comments caused by CVS |
||
33 | * 'intelligent' comment guessing |
||
34 | * |
||
35 | * Revision 1.3 2001/06/06 12:10:23 mjames |
||
36 | * Move from HPUX |
||
37 | * |
||
38 | * Revision 1.2 2000/11/29 21:51:18 mjames |
||
39 | * Fine tuning of software |
||
40 | * |
||
41 | * Revision 1.1.1.1 2000/10/19 21:58:37 mjames |
||
42 | * Mike put it here |
||
43 | * |
||
44 | * |
||
45 | * Revision 1.19 2000/10/04 10:37:15 10:37:15 mjames (Mike James) |
||
46 | * Modified for Vertical2 : support COMPONENTS and SIGNALS |
||
47 | * |
||
48 | * Revision 1.19 2000/10/04 10:37:15 10:37:15 mjames (Mike James) |
||
49 | * Part of Release PSAVAT01 |
||
50 | * |
||
51 | * Revision 1.18 2000/10/02 11:04:12 11:04:12 mjames (Mike James) |
||
52 | * new_vhdl |
||
53 | * |
||
54 | * Revision 1.17 2000/09/27 14:42:30 14:42:30 mjames (Mike James) |
||
55 | * Part of Release Sep_27_ST_2000 |
||
56 | * |
||
57 | * Revision 1.16 2000/09/21 10:16:00 10:16:00 mjames (Mike James) |
||
58 | * Part of Release Sep21Alpha |
||
59 | * |
||
60 | * Revision 1.15 2000/08/25 09:57:23 09:57:23 mjames (Mike James) |
||
61 | * Part of Release Aug25_alpha |
||
62 | * |
||
63 | * Revision 1.14 2000/08/16 08:57:40 08:57:40 mjames (Mike James) |
||
64 | * Part of Release CD01_Aug2000 |
||
65 | * |
||
66 | * Revision 1.13 2000/08/14 14:45:19 14:45:19 mjames (Mike James) |
||
67 | * Part of Release Aug_14_2000 |
||
68 | * |
||
69 | * Revision 1.12 2000/08/11 08:30:40 08:30:40 mjames (Mike James) |
||
70 | * Part of Release Aug_11_2000 |
||
71 | * |
||
72 | * Revision 1.11 2000/08/09 10:31:57 10:31:57 mjames (Mike James) |
||
73 | * Part of Release Aug__9_2000 |
||
74 | * |
||
75 | * Revision 1.10 2000/05/31 11:43:11 11:43:11 mjames (Mike James) |
||
76 | * Part of Release May_31_2000 |
||
77 | * |
||
78 | * Revision 1.9 2000/05/08 17:01:46 17:01:46 mjames (Mike James) |
||
79 | * Part of Release May__8_2000 |
||
80 | * |
||
81 | * Revision 1.8 2000/05/08 16:59:40 16:59:40 mjames (Mike James) |
||
82 | * Part of Release May__8_2000 |
||
83 | * |
||
84 | * Revision 1.7 2000/05/08 16:57:16 16:57:16 mjames (Mike James) |
||
85 | * Part of Release May__8_2000 |
||
86 | * |
||
87 | * Revision 1.6 2000/03/08 16:18:57 16:18:57 mjames (Mike James) |
||
88 | * New version including PC |
||
89 | * |
||
90 | * Revision 1.3 2000/01/20 15:58:58 15:58:58 mjames (Mike James) |
||
91 | * Part of Release R22 |
||
92 | * |
||
93 | * Revision 1.2 99/12/22 11:15:39 11:15:39 mjames (Mike James) |
||
94 | * Part of Release Dec_22_1999 |
||
95 | * |
||
96 | * Revision 1.1 99/06/25 14:36:23 14:36:23 mjames (Mike James) |
||
97 | * Initial revision |
||
98 | * |
||
99 | |||
100 | |||
101 | #pragma once |
||
102 | #include "generic.h" |
||
103 | * */ |
||
104 | #if !defined _EXPRESSION |
||
105 | #define _EXPRESSION |
||
106 | |||
107 | /* constants for object types found at bottom of expressions */ |
||
108 | #define EXP_CONSTANT 'C' |
||
109 | #define EXP_VAR_REF 'I' |
||
110 | #define EXP_BOOLEAN 'B' |
||
111 | #define EXP_VARIABLE 'V' |
||
112 | #define EXP_STRING 'S' |
||
113 | #define EXP_UNDEF_VAR 'U' |
||
114 | #define EXP_CHAR 'H' |
||
115 | |||
116 | /* decoding recurse_generics |
||
117 | * 0: NO_RECURSE stop expanding generics when a constant encountered |
||
118 | * 1: RECURSE_CONST expand generics until one found which does not contain an expression |
||
119 | * 2: RECURSE_NUMBER: expand generics until all constants are exposed |
||
120 | |||
121 | |||
122 | constant a : integer := 3; |
||
123 | constant b : integer := a + 3; |
||
124 | constant c : integer := b + a; |
||
125 | |||
126 | |||
127 | for values of expand generics : |
||
128 | value 0: |
||
129 | constant a : integer := 3; |
||
130 | constant b : integer := a + 3; |
||
131 | constant c : integer := b + a; |
||
132 | |||
133 | |||
134 | value 1: |
||
135 | constant a : integer := 3; |
||
136 | constant b : integer := a + 3; |
||
137 | constant c : integer := (a+3) + a; |
||
138 | |||
139 | |||
140 | value 2: |
||
141 | constant a : integer := 3; |
||
142 | constant b : integer := (3) + 3; |
||
143 | constant c : integer := ((3)+3) + (3); |
||
144 | |||
145 | |||
146 | |||
147 | |||
148 | */ |
||
149 | |||
150 | typedef enum |
||
151 | { |
||
152 | NO_RECURSE = 0, |
||
153 | RECURSE_CONST, |
||
154 | RECURSE_NUMBER |
||
155 | } generic_print_style; |
||
156 | |||
157 | struct generic_info; |
||
158 | /* see database.h for the description of expression_t */ |
||
159 | /* expression data structures .. see expression.h for handler fns */ |
||
160 | typedef struct exp |
||
161 | { |
||
162 | int opcode; |
||
163 | union |
||
164 | { |
||
165 | char *s; /* pointer to string value */ |
||
166 | struct generic_info *g; /* pointer to generic value */ |
||
167 | int i; /* integer part of expression */ |
||
168 | struct exp *e; |
||
169 | int *ip; /* pointer to an integer somewhere */ |
||
170 | } left; /* values */ |
||
171 | union |
||
172 | { |
||
173 | char *s; /* pointer to name */ |
||
174 | struct exp *e; |
||
175 | } right; /* name or expression */ |
||
176 | |||
177 | } expression_t; |
||
178 | |||
179 | /* place reference to a 'C' variable at the end of the tree branch */ |
||
180 | extern expression_t *compile_variable_reference (int *v, char *s); |
||
181 | |||
182 | /* compiles a variable. When printing expression stop descent of the evaluation tree here */ |
||
183 | extern expression_t *compile_variable (struct generic_info *gen, char *valname); |
||
184 | |||
185 | extern expression_t *compile_string (char *s); |
||
186 | |||
187 | extern expression_t *compile_char (char c); |
||
188 | |||
189 | /* an unelaborated variable reference (link at evaluation time */ |
||
190 | extern expression_t *compile_reference (char *s); |
||
191 | |||
192 | /* compiles an integer constant */ |
||
193 | extern expression_t *compile_constant (int k); |
||
194 | |||
195 | extern expression_t *compile_constant_string (int k, char *s); |
||
196 | |||
197 | /* compiles an boolean constant */ |
||
198 | extern expression_t *compile_bool_constant (int k); |
||
199 | |||
200 | extern expression_t *compile_bool_constant_string (int k, char *s); |
||
201 | |||
202 | extern expression_t *compile_expression (int opcode, expression_t *left, expression_t *right); |
||
203 | |||
204 | extern void print_expression (FILE *f, expression_t *e, generic_print_style recurse_generics); |
||
205 | |||
206 | extern void |
||
207 | print_range_expression (FILE *f, expression_t *e, generic_print_style recurse_generics); |
||
208 | |||
209 | extern void print_msg_expression (FILE *f, char *s, expression_t *e); |
||
210 | |||
211 | /* this is actually returning the type of the generic */ |
||
212 | extern int eval_gen_expression (struct generic_info *gen); |
||
213 | |||
214 | extern int eval_vhdl_expression (expression_t *expr, int *high, int *low); |
||
215 | |||
216 | /*******************************************/ |
||
217 | struct socket; /* pulled in from database.h */ |
||
218 | struct vhdl; |
||
219 | /*******************************************/ |
||
220 | extern expression_t *copy_expression (expression_t *src, struct socket *skt); |
||
221 | |||
222 | extern struct vhdl *copy_vhdl (struct vhdl *vhdl, struct socket *skt); |
||
223 | |||
224 | extern void free_expression (expression_t *expr); |
||
225 | |||
226 | extern int eval_expression (expression_t *e, struct generic_info **generic_list); |
||
227 | |||
228 | #endif |