Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 800 lines (635 sloc) 26.496 kB
3fb7a05 Introduce verilog to CVS.
steve authored
1 #ifndef __PExpr_H
2 #define __PExpr_H
3 /*
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
4 * Copyright (c) 1998-2011 Stephen Williams <steve@icarus.com>
3fb7a05 Introduce verilog to CVS.
steve authored
5 *
6 * This source code is free software; you can redistribute it
7 * and/or modify it in source code form under the terms of the GNU
8 * General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
f5aafc3 @arunpersaud updated FSF-address
arunpersaud authored
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3fb7a05 Introduce verilog to CVS.
steve authored
20 */
21
22 # include <string>
d434dd7 Allow part selects of memory words in l-values.
steve authored
23 # include <vector>
7ec8675 @steveicarus Elaborate concatenation expression put tested widths to use.
authored
24 # include <valarray>
ce49708 Parse OR of event expressions.
steve authored
25 # include "netlist.h"
3fb7a05 Introduce verilog to CVS.
steve authored
26 # include "verinum.h"
5895d3c Add memories to the parse and elaboration phases.
steve authored
27 # include "LineInfo.h"
ddd36ec Rework the heirarchical identifier parse syntax and pform
steve authored
28 # include "pform_types.h"
3fb7a05 Introduce verilog to CVS.
steve authored
29
30 class Design;
10ffaed Redo constant expression detection to happen
steve authored
31 class Module;
f955937 @martinwhitaker Fix for pr2924354.
martinwhitaker authored
32 class LexicalScope;
3fb7a05 Introduce verilog to CVS.
steve authored
33 class NetNet;
34 class NetExpr;
e7efc27 Redesign the implementation of scopes and parameters.
steve authored
35 class NetScope;
3fb7a05 Introduce verilog to CVS.
steve authored
36
37 /*
38 * The PExpr class hierarchy supports the description of
39 * expressions. The parser can generate expression objects from the
40 * source, possibly reducing things that it knows how to reduce.
41 */
42
5895d3c Add memories to the parse and elaboration phases.
steve authored
43 class PExpr : public LineInfo {
b1fd927 Named events really should be expressed with PEIdent
steve authored
44
3fb7a05 Introduce verilog to CVS.
steve authored
45 public:
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
46 enum width_mode_t { SIZED, EXPAND, LOSSLESS, UNSIZED };
47
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
48 // Flag values that can be passed to elaborate_expr.
49 static const unsigned NO_FLAGS = 0x0;
50 static const unsigned NEED_CONST = 0x1;
51 static const unsigned SYS_TASK_ARG = 0x2;
44c5a37 Allow specparam declarations outside specify blocks.
Martin Whitaker authored
52 static const unsigned ANNOTATABLE = 0x4;
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
53
b1fd927 Named events really should be expressed with PEIdent
steve authored
54 PExpr();
3fb7a05 Introduce verilog to CVS.
steve authored
55 virtual ~PExpr();
56
57 virtual void dump(ostream&) const;
31bdb87 separate assign lval elaboration for error checking.
steve authored
58
f955937 @martinwhitaker Fix for pr2924354.
martinwhitaker authored
59 // This method tests whether the expression contains any identifiers
60 // that have not been previously declared in the specified scope or
61 // in any containing scope. Any such identifiers are added to the
62 // specified scope as scalar nets of the specified type.
63 //
64 // This operation must be performed by the parser, to ensure that
65 // subsequent declarations do not affect the decision to create an
66 // implicit net.
67 virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
68
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
69 // This method tests whether the expression contains any
70 // references to automatically allocated variables.
71 virtual bool has_aa_term(Design*des, NetScope*scope) const;
72
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
73 // This method tests the type and width that the expression wants
74 // to be. It should be called before elaborating an expression to
75 // figure out the type and width of the expression. It also figures
76 // out the minimum width that can be used to evaluate the expression
77 // without changing the result. This allows the expression width to
78 // be pruned when not all bits of the result are used.
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
79 //
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
80 // Normally mode should be initialised to SIZED before starting to
81 // test the width of an expression. In SIZED mode the expression
82 // width will be calculated strictly according to the IEEE standard
83 // rules for expression width.
84 // If the expression contains an unsized literal, mode will be
85 // changed to LOSSLESS. In LOSSLESS mode the expression width will
86 // be calculated as the minimum width necessary to avoid arithmetic
87 // overflow or underflow.
88 // If the expression both contains an unsized literal and contains
89 // an operation that coerces a vector operand to a different type
90 // (signed <-> unsigned), mode is changed to UNSIZED. UNSIZED mode
91 // is the same as LOSSLESS, except that the final expression width
92 // will be forced to be at least integer_width. This is necessary
93 // to ensure compatibility with the IEEE standard, which requires
94 // unsized literals to be treated as having the same width as an
95 // integer. The lossless width calculation is inadequate in this
96 // case because coercing an operand to a different type means that
97 // the expression no longer obeys the normal rules of arithmetic.
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
98 //
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
99 // If mode is initialised to EXPAND instead of SIZED, the expression
100 // width will be calculated as the minimum width necessary to avoid
101 // arithmetic overflow or underflow, even if it contains no unsized
102 // literals. mode will be changed LOSSLESS or UNSIZED as described
103 // above. This supports a non-standard mode of expression width
104 // calculation.
3296b1d @steveicarus Include a calculation of the expression type in test_width methods.
authored
105 //
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
106 // When the final value of mode is UNSIZED, the width returned by
107 // this method is the calculated lossless width, but the width
108 // returned by a subsequent call to the expr_width method will be
109 // the final expression width.
2a0d336 @caryr Fix spacing problems.
caryr authored
110 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
111 width_mode_t&mode);
c85eff9 @steveicarus The test_width methods scan and mark expressions with type and size.
authored
112
113 // After the test_width method is complete, these methods
114 // return valid results.
115 ivl_variable_type_t expr_type() const { return expr_type_; }
116 unsigned expr_width() const { return expr_width_; }
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
117 unsigned min_width() const { return min_width_; }
118 bool has_sign() const { return signed_flag_; }
119
120 // This method allows the expression type (signed/unsigned)
121 // to be propagated down to any context-dependant operands.
122 void cast_signed(bool flag) { signed_flag_ = flag; }
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
123
71faebd Make elaborate_expr methods aware of the width that the context
steve authored
124 // Procedural elaboration of the expression. The expr_width is
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
125 // the required width of the expression.
845e74c @steveicarus Evaluate parameter expressions losslessly
authored
126 //
127 // The sys_task_arg flag is true if expressions are allowed to
128 // be incomplete.
6733f76 Detect missing indices to memories (PR#421)
steve authored
129 virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
130 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
131 unsigned flags) const;
e7efc27 Redesign the implementation of scopes and parameters.
steve authored
132
31bdb87 separate assign lval elaboration for error checking.
steve authored
133 // This method elaborates the expression as gates, but
134 // restricted for use as l-values of continuous assignments.
d26ae86 @steveicarus Move implicit net creation from elaboration to elaborate_sig
authored
135 virtual NetNet* elaborate_lnet(Design*des, NetScope*scope) const;
3fb7a05 Introduce verilog to CVS.
steve authored
136
4a8be3d Implement bi-directional part selects.
steve authored
137 // This is similar to elaborate_lnet, except that the
138 // expression is evaluated to be bi-directional. This is
139 // useful for arguments to inout ports of module instances and
140 // ports of tran primitives.
141 virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope) const;
142
b6ce313 move lval elaboration to PExpr virtual methods.
steve authored
143 // Expressions that can be in the l-value of procedural
8f2d679 Unify elaboration of l-values for all proceedural assignments,
steve authored
144 // assignments can be elaborated with this method. If the
145 // is_force flag is true, then the set of valid l-value types
47d6503 @ldoolitt Spelling fixes
ldoolitt authored
146 // is slightly modified to accommodate the Verilog force
8f2d679 Unify elaboration of l-values for all proceedural assignments,
steve authored
147 // statement
148 virtual NetAssign_* elaborate_lval(Design*des,
149 NetScope*scope,
150 bool is_force) const;
b6ce313 move lval elaboration to PExpr virtual methods.
steve authored
151
3fb7a05 Introduce verilog to CVS.
steve authored
152 // This attempts to evaluate a constant expression, and return
153 // a verinum as a result. If the expression cannot be
154 // evaluated, return 0.
8fd42fb Build errors in picky GCC compilers.
steve authored
155 virtual verinum* eval_const(Design*des, NetScope*sc) const;
d27f260 Check net ranges in declarations.
steve authored
156
e01358b @martinwhitaker Fix for pr3194155.
martinwhitaker authored
157 // This method returns true if the expression represents a
158 // structural net that can have multiple drivers. This is
159 // used to test whether an input port connection can be
160 // collapsed to a single wire.
161 virtual bool is_collapsible_net(Design*des, NetScope*scope) const;
162
d27f260 Check net ranges in declarations.
steve authored
163 // This method returns true if that expression is the same as
164 // this expression. This method is used for comparing
165 // expressions that must be structurally "identical".
166 virtual bool is_the_same(const PExpr*that) const;
10ffaed Redo constant expression detection to happen
steve authored
167
c85eff9 @steveicarus The test_width methods scan and mark expressions with type and size.
authored
168 protected:
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
169 unsigned fix_width_(width_mode_t mode);
170
c85eff9 @steveicarus The test_width methods scan and mark expressions with type and size.
authored
171 // The derived class test_width methods should fill these in.
172 ivl_variable_type_t expr_type_;
173 unsigned expr_width_;
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
174 unsigned min_width_;
175 bool signed_flag_;
c85eff9 @steveicarus The test_width methods scan and mark expressions with type and size.
authored
176
b1fd927 Named events really should be expressed with PEIdent
steve authored
177 private: // not implemented
178 PExpr(const PExpr&);
179 PExpr& operator= (const PExpr&);
3fb7a05 Introduce verilog to CVS.
steve authored
180 };
181
182 ostream& operator << (ostream&, const PExpr&);
183
5de9b7c Parse and elaborate the concatenate operator
steve authored
184 class PEConcat : public PExpr {
185
186 public:
cced1e7 @steveicarus Remove some uses of the svector template.
authored
187 PEConcat(const list<PExpr*>&p, PExpr*r =0);
7c2cf8b Add support for the Ternary operator,
steve authored
188 ~PEConcat();
5de9b7c Parse and elaborate the concatenate operator
steve authored
189
8fd42fb Build errors in picky GCC compilers.
steve authored
190 virtual verinum* eval_const(Design*des, NetScope*sc) const;
5de9b7c Parse and elaborate the concatenate operator
steve authored
191 virtual void dump(ostream&) const;
f6507cb Check lvalue of procedural continuous assign (PR#29)
steve authored
192
f955937 @martinwhitaker Fix for pr2924354.
martinwhitaker authored
193 virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
194
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
195 virtual bool has_aa_term(Design*des, NetScope*scope) const;
196
a654bdc @steveicarus Clean up some handling of test_width for ternary expressions.
authored
197 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
198 width_mode_t&mode);
a654bdc @steveicarus Clean up some handling of test_width for ternary expressions.
authored
199
d26ae86 @steveicarus Move implicit net creation from elaboration to elaborate_sig
authored
200 virtual NetNet* elaborate_lnet(Design*des, NetScope*scope) const;
a2c036d Allow concatenations as arguments to inout ports.
steve authored
201 virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope) const;
6733f76 Detect missing indices to memories (PR#421)
steve authored
202 virtual NetExpr*elaborate_expr(Design*des, NetScope*,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
203 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
204 unsigned flags) const;
8f2d679 Unify elaboration of l-values for all proceedural assignments,
steve authored
205 virtual NetAssign_* elaborate_lval(Design*des,
206 NetScope*scope,
207 bool is_force) const;
e01358b @martinwhitaker Fix for pr3194155.
martinwhitaker authored
208 virtual bool is_collapsible_net(Design*des, NetScope*scope) const;
5de9b7c Parse and elaborate the concatenate operator
steve authored
209 private:
a2c036d Allow concatenations as arguments to inout ports.
steve authored
210 NetNet* elaborate_lnet_common_(Design*des, NetScope*scope,
211 bool bidirectional_flag) const;
212 private:
cced1e7 @steveicarus Remove some uses of the svector template.
authored
213 vector<PExpr*>parms_;
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
214 std::valarray<width_mode_t>width_modes_;
7ec8675 @steveicarus Elaborate concatenation expression put tested widths to use.
authored
215
7c2cf8b Add support for the Ternary operator,
steve authored
216 PExpr*repeat_;
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
217 NetScope*tested_scope_;
218 unsigned repeat_count_;
5de9b7c Parse and elaborate the concatenate operator
steve authored
219 };
220
2dd010d Named events as far as the pform.
steve authored
221 /*
222 * Event expressions are expressions that can be combined with the
223 * event "or" operator. These include "posedge foo" and similar, and
224 * also include named events. "edge" events are associated with an
225 * expression, whereas named events simply have a name, which
226 * represents an event variable.
227 */
ce49708 Parse OR of event expressions.
steve authored
228 class PEEvent : public PExpr {
229
230 public:
b1fd927 Named events really should be expressed with PEIdent
steve authored
231 enum edge_t {ANYEDGE, POSEDGE, NEGEDGE, POSITIVE};
232
2dd010d Named events as far as the pform.
steve authored
233 // Use this constructor to create events based on edges or levels.
b1fd927 Named events really should be expressed with PEIdent
steve authored
234 PEEvent(edge_t t, PExpr*e);
2dd010d Named events as far as the pform.
steve authored
235
236 ~PEEvent();
ce49708 Parse OR of event expressions.
steve authored
237
b1fd927 Named events really should be expressed with PEIdent
steve authored
238 edge_t type() const;
239 PExpr* expr() const;
e4ae832 Clean up spurious trailing white space.
steve authored
240
ce49708 Parse OR of event expressions.
steve authored
241 virtual void dump(ostream&) const;
242
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
243 virtual bool has_aa_term(Design*des, NetScope*scope) const;
244
ce49708 Parse OR of event expressions.
steve authored
245 private:
b1fd927 Named events really should be expressed with PEIdent
steve authored
246 edge_t type_;
247 PExpr *expr_;
ce49708 Parse OR of event expressions.
steve authored
248 };
249
084a464 Support decimal constants in behavioral delays.
steve authored
250 /*
251 * This holds a floating point constant in the source.
252 */
253 class PEFNumber : public PExpr {
254
255 public:
256 explicit PEFNumber(verireal*vp);
257 ~PEFNumber();
258
259 const verireal& value() const;
260
261 /* The eval_const method as applied to a floating point number
262 gets the *integer* value of the number. This accounts for
263 any rounding that is needed to get the value. */
8fd42fb Build errors in picky GCC compilers.
steve authored
264 virtual verinum* eval_const(Design*des, NetScope*sc) const;
084a464 Support decimal constants in behavioral delays.
steve authored
265
d3f17f2 @steveicarus Handle widths of real value arguments to user functions.
authored
266 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
267 width_mode_t&mode);
6733f76 Detect missing indices to memories (PR#421)
steve authored
268 virtual NetExpr*elaborate_expr(Design*des, NetScope*,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
269 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
270 unsigned flags) const;
219df16 Generalize the evaluation of floating point delays, and
steve authored
271
084a464 Support decimal constants in behavioral delays.
steve authored
272 virtual void dump(ostream&) const;
273
274 private:
275 verireal*value_;
276 };
277
3fb7a05 Introduce verilog to CVS.
steve authored
278 class PEIdent : public PExpr {
279
280 public:
be67199 @jaredcasper Allow connecting module instance using implicit named port connections.
jaredcasper authored
281 explicit PEIdent(perm_string, bool no_implicit_sig=false);
ddd36ec Rework the heirarchical identifier parse syntax and pform
steve authored
282 explicit PEIdent(const pform_name_t&);
b1fd927 Named events really should be expressed with PEIdent
steve authored
283 ~PEIdent();
3fb7a05 Introduce verilog to CVS.
steve authored
284
47d6503 @ldoolitt Spelling fixes
ldoolitt authored
285 // Add another name to the string of hierarchy that is the
ddd36ec Rework the heirarchical identifier parse syntax and pform
steve authored
286 // current identifier.
287 void append_name(perm_string);
288
3fb7a05 Introduce verilog to CVS.
steve authored
289 virtual void dump(ostream&) const;
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
290
f955937 @martinwhitaker Fix for pr2924354.
martinwhitaker authored
291 virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
292
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
293 virtual bool has_aa_term(Design*des, NetScope*scope) const;
294
c339dc4 Remove last bits of relax_width methods, and use test_width
steve authored
295 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
296 width_mode_t&mode);
31bdb87 separate assign lval elaboration for error checking.
steve authored
297
298 // Identifiers are allowed (with restrictions) is assign l-values.
d26ae86 @steveicarus Move implicit net creation from elaboration to elaborate_sig
authored
299 virtual NetNet* elaborate_lnet(Design*des, NetScope*scope) const;
31bdb87 separate assign lval elaboration for error checking.
steve authored
300
4a8be3d Implement bi-directional part selects.
steve authored
301 virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope) const;
302
b6ce313 move lval elaboration to PExpr virtual methods.
steve authored
303 // Identifiers are also allowed as procedural assignment l-values.
8f2d679 Unify elaboration of l-values for all proceedural assignments,
steve authored
304 virtual NetAssign_* elaborate_lval(Design*des,
305 NetScope*scope,
306 bool is_force) const;
b6ce313 move lval elaboration to PExpr virtual methods.
steve authored
307
6733f76 Detect missing indices to memories (PR#421)
steve authored
308 virtual NetExpr*elaborate_expr(Design*des, NetScope*,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
309 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
310 unsigned flags) const;
31bdb87 separate assign lval elaboration for error checking.
steve authored
311
3676d66 Module ports are really special PEIdent
steve authored
312 // Elaborate the PEIdent as a port to a module. This method
313 // only applies to Ident expressions.
9b3d202 @wackston Extend VPI and build to for SIMetrix cosimulation
wackston authored
314 NetNet* elaborate_subport(Design*des, NetScope*sc) const;
3676d66 Module ports are really special PEIdent
steve authored
315
8fd42fb Build errors in picky GCC compilers.
steve authored
316 verinum* eval_const(Design*des, NetScope*sc) const;
3fb7a05 Introduce verilog to CVS.
steve authored
317
e01358b @martinwhitaker Fix for pr3194155.
martinwhitaker authored
318 virtual bool is_collapsible_net(Design*des, NetScope*scope) const;
319
ddd36ec Rework the heirarchical identifier parse syntax and pform
steve authored
320 const pform_name_t& path() const { return path_; }
321
322 private:
323 pform_name_t path_;
be67199 @jaredcasper Allow connecting module instance using implicit named port connections.
jaredcasper authored
324 bool no_implicit_sig_;
3fb7a05 Introduce verilog to CVS.
steve authored
325
326 private:
b45834f @steveicarus Handle part selects with bad (xz) bits.
authored
327 // Common functions to calculate parts of part/bit
328 // selects. These methods return true if the expressions
329 // elaborate/calculate, or false if there is some sort of
330 // source error.
331
8ea1e49 @steveicarus Improve net bit select calculations.
authored
332 bool calculate_bits_(Design*, NetScope*, long&msb, bool&defined) const;
333
b45834f @steveicarus Handle part selects with bad (xz) bits.
authored
334 // The calculate_parts_ method calculates the range
335 // expressions of a part select for the current object. The
336 // part select expressions are elaborated and evaluated, and
337 // the values written to the msb/lsb arguments. If there are
338 // invalid bits (xz) in either expression, then the defined
339 // flag is set to *false*.
340 bool calculate_parts_(Design*, NetScope*, long&msb, long&lsb, bool&defined) const;
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
341 NetExpr* calculate_up_do_base_(Design*, NetScope*, bool need_const) const;
7aebff2 @steveicarus Fix up parameter name part select
authored
342 bool calculate_param_range_(Design*, NetScope*,
343 const NetExpr*msb_ex, long&msb,
5a0363e @caryr Fix some constant bit/part select bugs and add warnings.
caryr authored
344 const NetExpr*lsb_ex, long&lsb,
345 long length) const;
7aebff2 @steveicarus Fix up parameter name part select
authored
346
c339dc4 Remove last bits of relax_width methods, and use test_width
steve authored
347 bool calculate_up_do_width_(Design*, NetScope*, unsigned long&wid) const;
348
3e4f8b6 @steveicarus Get packed signals working through to simulation in some situations.
authored
349 // Evaluate the prefix indices. All but the final index in a
350 // chain of indices must be a single value and must evaluate
351 // to constants at compile time. For example:
352 // [x] - OK
353 // [1][2][x] - OK
354 // [1][x:y] - OK
355 // [2:0][x] - BAD
356 // [y][x] - BAD
357 // Leave the last index for special handling.
358 bool calculate_packed_indices_(Design*des, NetScope*scope, NetNet*net,
359 std::list<long>&prefix_indices) const;
360
c339dc4 Remove last bits of relax_width methods, and use test_width
steve authored
361 private:
91d84e7 Major rework of array handling. Memories are replaced with the
steve authored
362 NetAssign_*elaborate_lval_net_word_(Design*, NetScope*, NetNet*) const;
30d42e2 @steveicarus Allow l-value part select to be out of bounds.
authored
363 bool elaborate_lval_net_bit_(Design*, NetScope*, NetAssign_*) const;
91d84e7 Major rework of array handling. Memories are replaced with the
steve authored
364 bool elaborate_lval_net_part_(Design*, NetScope*, NetAssign_*) const;
e26b9e7 @caryr More array fixes and down indexed part selects can be a lval.
caryr authored
365 bool elaborate_lval_net_idx_(Design*, NetScope*, NetAssign_*,
366 index_component_t::ctype_t) const;
1243145 @steveicarus Packed struct members in behavioral assign l-values.
authored
367 bool elaborate_lval_net_packed_member_(Design*, NetScope*,
368 NetAssign_*,
369 const perm_string&) const;
fdc92ea @steveicarus Elaborate dynamic array expressions (lval/rval) down to ivl_target.h
authored
370 bool elaborate_lval_darray_bit_(Design*, NetScope*,
371 NetAssign_*) const;
707af78 Fix part selects in l-values.
steve authored
372
373 private:
6e12c1f @steveicarus Elaborate of PGAssign always passes calculated width.
authored
374 NetExpr*elaborate_expr_param_(Design*des,
375 NetScope*scope,
376 const NetExpr*par,
142f661 @caryr Fix the compiler to keep the original file/line information.
caryr authored
377 NetScope*found_in,
6e12c1f @steveicarus Elaborate of PGAssign always passes calculated width.
authored
378 const NetExpr*par_msb,
379 const NetExpr*par_lsb,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
380 unsigned expr_wid,
381 unsigned flags) const;
7aebff2 @steveicarus Fix up parameter name part select
authored
382 NetExpr*elaborate_expr_param_part_(Design*des,
383 NetScope*scope,
384 const NetExpr*par,
142f661 @caryr Fix the compiler to keep the original file/line information.
caryr authored
385 NetScope*found_in,
7aebff2 @steveicarus Fix up parameter name part select
authored
386 const NetExpr*par_msb,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
387 const NetExpr*par_lsb,
388 unsigned expr_wid) const;
6a1235a @steveicarus Rework parameter indexed part select up.
authored
389 NetExpr*elaborate_expr_param_idx_up_(Design*des,
390 NetScope*scope,
391 const NetExpr*par,
142f661 @caryr Fix the compiler to keep the original file/line information.
caryr authored
392 NetScope*found_in,
6a1235a @steveicarus Rework parameter indexed part select up.
authored
393 const NetExpr*par_msb,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
394 const NetExpr*par_lsb,
395 bool need_const) const;
2b17366 @caryr Major rewrite of indexed part selects.
caryr authored
396 NetExpr*elaborate_expr_param_idx_do_(Design*des,
397 NetScope*scope,
398 const NetExpr*par,
142f661 @caryr Fix the compiler to keep the original file/line information.
caryr authored
399 NetScope*found_in,
2b17366 @caryr Major rewrite of indexed part selects.
caryr authored
400 const NetExpr*par_msb,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
401 const NetExpr*par_lsb,
402 bool need_const) const;
c02b3b8 Reorganize signal part select handling, and add support for
steve authored
403 NetExpr*elaborate_expr_net(Design*des,
91d84e7 Major rework of array handling. Memories are replaced with the
steve authored
404 NetScope*scope,
405 NetNet*net,
406 NetScope*found,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
407 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
408 unsigned flags) const;
91d84e7 Major rework of array handling. Memories are replaced with the
steve authored
409 NetExpr*elaborate_expr_net_word_(Design*des,
410 NetScope*scope,
411 NetNet*net,
412 NetScope*found,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
413 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
414 unsigned flags) const;
c02b3b8 Reorganize signal part select handling, and add support for
steve authored
415 NetExpr*elaborate_expr_net_part_(Design*des,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
416 NetScope*scope,
417 NetESignal*net,
418 NetScope*found,
419 unsigned expr_wid) const;
c02b3b8 Reorganize signal part select handling, and add support for
steve authored
420 NetExpr*elaborate_expr_net_idx_up_(Design*des,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
421 NetScope*scope,
422 NetESignal*net,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
423 NetScope*found,
424 bool need_const) const;
c02b3b8 Reorganize signal part select handling, and add support for
steve authored
425 NetExpr*elaborate_expr_net_idx_do_(Design*des,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
426 NetScope*scope,
427 NetESignal*net,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
428 NetScope*found,
429 bool need_const) const;
c02b3b8 Reorganize signal part select handling, and add support for
steve authored
430 NetExpr*elaborate_expr_net_bit_(Design*des,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
431 NetScope*scope,
432 NetESignal*net,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
433 NetScope*found,
434 bool need_const) const;
3fb7a05 Introduce verilog to CVS.
steve authored
435
91a755d Add support for memory words in l-value of
steve authored
436 private:
4a8be3d Implement bi-directional part selects.
steve authored
437 NetNet* elaborate_lnet_common_(Design*des, NetScope*scope,
438 bool bidirectional_flag) const;
439
9e94afe Use PartSelect/PV and VP to handle part selects through ports.
steve authored
440 bool eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
dfb7bf5 @steveicarus Handle part selects of nets that fall of the ends of the identifier.
authored
441 long&midx, long&lidx) const;
3fb7a05 Introduce verilog to CVS.
steve authored
442 };
443
14f229d @steveicarus Parse support for dynamic arrays.
authored
444 class PENew : public PExpr {
445
446 public:
447 explicit PENew (PExpr*s);
448 ~PENew();
449
450 virtual void dump(ostream&) const;
d0e6b24 @steveicarus Support the new[] operator for arrays
authored
451 virtual unsigned test_width(Design*des, NetScope*scope,
452 width_mode_t&mode);
453 virtual NetExpr*elaborate_expr(Design*des, NetScope*,
454 unsigned expr_wid,
455 unsigned flags) const;
14f229d @steveicarus Parse support for dynamic arrays.
authored
456
457 private:
458 PExpr*size_;
459 };
460
3fb7a05 Introduce verilog to CVS.
steve authored
461 class PENumber : public PExpr {
462
463 public:
b1fd927 Named events really should be expressed with PEIdent
steve authored
464 explicit PENumber(verinum*vp);
465 ~PENumber();
3fb7a05 Introduce verilog to CVS.
steve authored
466
b1fd927 Named events really should be expressed with PEIdent
steve authored
467 const verinum& value() const;
3fb7a05 Introduce verilog to CVS.
steve authored
468
469 virtual void dump(ostream&) const;
c339dc4 Remove last bits of relax_width methods, and use test_width
steve authored
470 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
471 width_mode_t&mode);
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
472
6733f76 Detect missing indices to memories (PR#421)
steve authored
473 virtual NetEConst*elaborate_expr(Design*des, NetScope*,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
474 unsigned expr_wid, unsigned) const;
8f2d679 Unify elaboration of l-values for all proceedural assignments,
steve authored
475 virtual NetAssign_* elaborate_lval(Design*des,
476 NetScope*scope,
477 bool is_force) const;
3d646aa Constant expressions are not l-values for task ports.
steve authored
478
8fd42fb Build errors in picky GCC compilers.
steve authored
479 virtual verinum* eval_const(Design*des, NetScope*sc) const;
3fb7a05 Introduce verilog to CVS.
steve authored
480
d27f260 Check net ranges in declarations.
steve authored
481 virtual bool is_the_same(const PExpr*that) const;
482
3fb7a05 Introduce verilog to CVS.
steve authored
483 private:
484 verinum*const value_;
485 };
486
03aebd7 Support elaborate_net for PEString objects.
steve authored
487 /*
488 * This represents a string constant in an expression.
489 *
490 * The s parameter to the PEString constructor is a C string that this
491 * class instance will take for its own. The caller should not delete
492 * the string, the destructor will do it.
493 */
3fb7a05 Introduce verilog to CVS.
steve authored
494 class PEString : public PExpr {
495
496 public:
03aebd7 Support elaborate_net for PEString objects.
steve authored
497 explicit PEString(char*s);
b1fd927 Named events really should be expressed with PEIdent
steve authored
498 ~PEString();
3fb7a05 Introduce verilog to CVS.
steve authored
499
b1fd927 Named events really should be expressed with PEIdent
steve authored
500 string value() const;
3fb7a05 Introduce verilog to CVS.
steve authored
501 virtual void dump(ostream&) const;
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
502
34b5a31 Add test_width methods for PETernary and PEString.
steve authored
503 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
504 width_mode_t&mode);
34b5a31 Add test_width methods for PETernary and PEString.
steve authored
505
6733f76 Detect missing indices to memories (PR#421)
steve authored
506 virtual NetEConst*elaborate_expr(Design*des, NetScope*,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
507 unsigned expr_wid, unsigned) const;
8fd42fb Build errors in picky GCC compilers.
steve authored
508 verinum* eval_const(Design*, NetScope*) const;
3fb7a05 Introduce verilog to CVS.
steve authored
509
510 private:
03aebd7 Support elaborate_net for PEString objects.
steve authored
511 char*text_;
3fb7a05 Introduce verilog to CVS.
steve authored
512 };
513
514 class PEUnary : public PExpr {
515
516 public:
056a3f7 Allow unary operators in constant expressions.
steve authored
517 explicit PEUnary(char op, PExpr*ex);
518 ~PEUnary();
3fb7a05 Introduce verilog to CVS.
steve authored
519
520 virtual void dump(ostream&out) const;
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
521
f955937 @martinwhitaker Fix for pr2924354.
martinwhitaker authored
522 virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
523
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
524 virtual bool has_aa_term(Design*des, NetScope*scope) const;
525
30e6cfc @steveicarus Real valued nets are signed, and pform unary expression have width.
authored
526 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
527 width_mode_t&mode);
30e6cfc @steveicarus Real valued nets are signed, and pform unary expression have width.
authored
528
5cf7355 Precalculate unary - if possible.
steve authored
529 virtual NetExpr*elaborate_expr(Design*des, NetScope*,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
530 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
531 unsigned flags) const;
8fd42fb Build errors in picky GCC compilers.
steve authored
532 virtual verinum* eval_const(Design*des, NetScope*sc) const;
3fb7a05 Introduce verilog to CVS.
steve authored
533
f8e346f @steveicarus Implement increment/decrement statements.
authored
534 public:
535 inline char get_op() const { return op_; }
536 inline PExpr*get_expr() const { return expr_; }
537
3fb7a05 Introduce verilog to CVS.
steve authored
538 private:
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
539 NetExpr* elaborate_expr_bits_(NetExpr*operand, unsigned expr_wid) const;
55b8ff4 @steveicarus Pad the subexpression of unary not.
authored
540
541 private:
3fb7a05 Introduce verilog to CVS.
steve authored
542 char op_;
543 PExpr*expr_;
544 };
545
546 class PEBinary : public PExpr {
547
548 public:
9572ddd Support more real arithmetic in delay constants.
steve authored
549 explicit PEBinary(char op, PExpr*l, PExpr*r);
550 ~PEBinary();
3fb7a05 Introduce verilog to CVS.
steve authored
551
552 virtual void dump(ostream&out) const;
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
553
f955937 @martinwhitaker Fix for pr2924354.
martinwhitaker authored
554 virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
555
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
556 virtual bool has_aa_term(Design*des, NetScope*scope) const;
557
c339dc4 Remove last bits of relax_width methods, and use test_width
steve authored
558 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
559 width_mode_t&mode);
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
560
a12a6d9 @steveicarus Fix left shift of unsized constants in sef-determined context.
authored
561 virtual NetExpr*elaborate_expr(Design*des, NetScope*,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
562 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
563 unsigned flags) const;
8fd42fb Build errors in picky GCC compilers.
steve authored
564 virtual verinum* eval_const(Design*des, NetScope*sc) const;
3fb7a05 Introduce verilog to CVS.
steve authored
565
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
566 protected:
3fb7a05 Introduce verilog to CVS.
steve authored
567 char op_;
568 PExpr*left_;
569 PExpr*right_;
e1bbbe5 Include subtraction in LPM_ADD_SUB device.
steve authored
570
d1ce6d2 @steveicarus Fix the signed-ness calculations of +- in parameter expressions.
authored
571 NetExpr*elaborate_expr_base_(Design*, NetExpr*lp, NetExpr*rp,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
572 unsigned expr_wid) const;
d1ce6d2 @steveicarus Fix the signed-ness calculations of +- in parameter expressions.
authored
573 NetExpr*elaborate_eval_expr_base_(Design*, NetExpr*lp, NetExpr*rp,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
574 unsigned expr_wid) const;
71a506a Binary and unary operators in parameter expressions.
steve authored
575
b89ab1f @martinwhitaker Cleanup after parameter expression rework.
martinwhitaker authored
576 NetExpr*elaborate_expr_base_bits_(Design*, NetExpr*lp, NetExpr*rp,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
577 unsigned expr_wid) const;
d1ce6d2 @steveicarus Fix the signed-ness calculations of +- in parameter expressions.
authored
578 NetExpr*elaborate_expr_base_div_(Design*, NetExpr*lp, NetExpr*rp,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
579 unsigned expr_wid) const;
d1ce6d2 @steveicarus Fix the signed-ness calculations of +- in parameter expressions.
authored
580 NetExpr*elaborate_expr_base_mult_(Design*, NetExpr*lp, NetExpr*rp,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
581 unsigned expr_wid) const;
d1ce6d2 @steveicarus Fix the signed-ness calculations of +- in parameter expressions.
authored
582 NetExpr*elaborate_expr_base_add_(Design*, NetExpr*lp, NetExpr*rp,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
583 unsigned expr_wid) const;
e18eb32 @steveicarus Process shift by constant amounts early in expression elaboration.
authored
584
3fb7a05 Introduce verilog to CVS.
steve authored
585 };
586
587 /*
47d6503 @ldoolitt Spelling fixes
ldoolitt authored
588 * Here are a few specialized classes for handling specific binary
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
589 * operators.
590 */
591 class PEBComp : public PEBinary {
592
593 public:
594 explicit PEBComp(char op, PExpr*l, PExpr*r);
595 ~PEBComp();
596
c339dc4 Remove last bits of relax_width methods, and use test_width
steve authored
597 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
598 width_mode_t&mode);
ea057a7 @steveicarus Elaborate logical and/or to account for special properties.
authored
599
600 NetExpr* elaborate_expr(Design*des, NetScope*scope,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
601 unsigned expr_wid, unsigned flags) const;
c4098cf @steveicarus Account for unsized arguments to comparisons.
authored
602
603 private:
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
604 unsigned l_width_;
605 unsigned r_width_;
ea057a7 @steveicarus Elaborate logical and/or to account for special properties.
authored
606 };
607
608 /*
609 * This derived class is for handling logical expressions: && and ||.
610 */
611 class PEBLogic : public PEBinary {
612
613 public:
614 explicit PEBLogic(char op, PExpr*l, PExpr*r);
615 ~PEBLogic();
616
617 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
618 width_mode_t&mode);
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
619
a12a6d9 @steveicarus Fix left shift of unsized constants in sef-determined context.
authored
620 NetExpr* elaborate_expr(Design*des, NetScope*scope,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
621 unsigned expr_wid, unsigned flags) const;
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
622 };
623
82143ed @steveicarus Rework shift and power PExpr nodes for their special needs.
authored
624 /*
625 * A couple of the binary operands have a special sub-expression rule
626 * where the expression width is carried entirely by the left
627 * expression, and the right operand is self-determined.
628 */
629 class PEBLeftWidth : public PEBinary {
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
630
631 public:
82143ed @steveicarus Rework shift and power PExpr nodes for their special needs.
authored
632 explicit PEBLeftWidth(char op, PExpr*l, PExpr*r);
633 ~PEBLeftWidth() =0;
634
635 virtual NetExpr*elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
636 unsigned expr_wid) const =0;
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
637
82143ed @steveicarus Rework shift and power PExpr nodes for their special needs.
authored
638 protected:
c339dc4 Remove last bits of relax_width methods, and use test_width
steve authored
639 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
640 width_mode_t&mode);
82143ed @steveicarus Rework shift and power PExpr nodes for their special needs.
authored
641
642 virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
643 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
644 unsigned flags) const;
82143ed @steveicarus Rework shift and power PExpr nodes for their special needs.
authored
645 };
646
647 class PEBPower : public PEBLeftWidth {
648
649 public:
650 explicit PEBPower(char op, PExpr*l, PExpr*r);
651 ~PEBPower();
652
653 NetExpr*elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
654 unsigned expr_wid) const;
82143ed @steveicarus Rework shift and power PExpr nodes for their special needs.
authored
655 };
656
657 class PEBShift : public PEBLeftWidth {
658
659 public:
660 explicit PEBShift(char op, PExpr*l, PExpr*r);
661 ~PEBShift();
662
663 NetExpr*elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
664 unsigned expr_wid) const;
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
665 };
666
667 /*
7c2cf8b Add support for the Ternary operator,
steve authored
668 * This class supports the ternary (?:) operator. The operator takes
669 * three expressions, the test, the true result and the false result.
670 */
671 class PETernary : public PExpr {
672
673 public:
a5921ce netlist support for ternary operator.
steve authored
674 explicit PETernary(PExpr*e, PExpr*t, PExpr*f);
7c2cf8b Add support for the Ternary operator,
steve authored
675 ~PETernary();
676
a5921ce netlist support for ternary operator.
steve authored
677 virtual void dump(ostream&out) const;
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
678
f955937 @martinwhitaker Fix for pr2924354.
martinwhitaker authored
679 virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
680
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
681 virtual bool has_aa_term(Design*des, NetScope*scope) const;
682
34b5a31 Add test_width methods for PETernary and PEString.
steve authored
683 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
684 width_mode_t&mode);
34b5a31 Add test_width methods for PETernary and PEString.
steve authored
685
65c3bc9 @steveicarus Short-circuit elaboration of ternary expressions.
authored
686 virtual NetExpr*elaborate_expr(Design*des, NetScope*,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
687 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
688 unsigned flags) const;
8fd42fb Build errors in picky GCC compilers.
steve authored
689 virtual verinum* eval_const(Design*des, NetScope*sc) const;
a5921ce netlist support for ternary operator.
steve authored
690
7c2cf8b Add support for the Ternary operator,
steve authored
691 private:
707a3eb @steveicarus Handle ternary expressions with mixed argument types.
authored
692 NetExpr* elab_and_eval_alternative_(Design*des, NetScope*scope,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
693 PExpr*expr, unsigned expr_wid,
694 unsigned flags) const;
707a3eb @steveicarus Handle ternary expressions with mixed argument types.
authored
695
696 private:
7c2cf8b Add support for the Ternary operator,
steve authored
697 PExpr*expr_;
698 PExpr*tru_;
699 PExpr*fal_;
700 };
701
bb38653 Parse system function calls.
steve authored
702 /*
fbe475e Add infrastructure for system functions, move
steve authored
703 * This class represents a parsed call to a function, including calls
b7c2bd4 Add the NetUserFunc netlist node.
steve authored
704 * to system functions. The parameters in the parms list are the
705 * expressions that are passed as input to the ports of the function.
bb38653 Parse system function calls.
steve authored
706 */
e0a988b Add functions up to elaboration (Ed Carter)
steve authored
707 class PECallFunction : public PExpr {
bb38653 Parse system function calls.
steve authored
708 public:
25a27f9 @steveicarus Parse contribution statements as far as pform.
authored
709 explicit PECallFunction(const pform_name_t&n, const vector<PExpr *> &parms);
47d6503 @ldoolitt Spelling fixes
ldoolitt authored
710 // Call of system function (name is not hierarchical)
25a27f9 @steveicarus Parse contribution statements as far as pform.
authored
711 explicit PECallFunction(perm_string n, const vector<PExpr *> &parms);
ddd36ec Rework the heirarchical identifier parse syntax and pform
steve authored
712 explicit PECallFunction(perm_string n);
25a27f9 @steveicarus Parse contribution statements as far as pform.
authored
713
714 // svector versions. Should be removed!
cced1e7 @steveicarus Remove some uses of the svector template.
authored
715 explicit PECallFunction(const pform_name_t&n, const list<PExpr *> &parms);
716 explicit PECallFunction(perm_string n, const list<PExpr *> &parms);
25a27f9 @steveicarus Parse contribution statements as far as pform.
authored
717
bb38653 Parse system function calls.
steve authored
718 ~PECallFunction();
e0a988b Add functions up to elaboration (Ed Carter)
steve authored
719
720 virtual void dump(ostream &) const;
2302693 Expression widths with unsized literals are pseudo-infinite width.
steve authored
721
f955937 @martinwhitaker Fix for pr2924354.
martinwhitaker authored
722 virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
723
0437715 Checks for illegal use of automatically allocated variables.
Martin Whitaker authored
724 virtual bool has_aa_term(Design*des, NetScope*scope) const;
725
726 virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
727 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
728 unsigned flags) const;
e0a988b Add functions up to elaboration (Ed Carter)
steve authored
729
d587499 @steveicarus test_width method for functions in expressions
authored
730 virtual unsigned test_width(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
731 width_mode_t&mode);
d587499 @steveicarus test_width method for functions in expressions
authored
732
bb38653 Parse system function calls.
steve authored
733 private:
ddd36ec Rework the heirarchical identifier parse syntax and pform
steve authored
734 pform_name_t path_;
25a27f9 @steveicarus Parse contribution statements as far as pform.
authored
735 vector<PExpr *> parms_;
bb38653 Parse system function calls.
steve authored
736
b7c2bd4 Add the NetUserFunc netlist node.
steve authored
737 bool check_call_matches_definition_(Design*des, NetScope*dscope) const;
738
2bef6b8 @steveicarus Detect and implement string.len() method, and string[index] expressions
authored
739
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
740 NetExpr* cast_to_width_(NetExpr*expr, unsigned wid) const;
14b2037 @martinwhitaker Fix for pr2922063.
martinwhitaker authored
741
14f229d @steveicarus Parse support for dynamic arrays.
authored
742 NetExpr*elaborate_expr_method_(Design*des, NetScope*scope,
743 unsigned expr_wid) const;
744 #if 0
745 NetExpr*elaborate_expr_string_method_(Design*des, NetScope*scope) const;
2bef6b8 @steveicarus Detect and implement string.len() method, and string[index] expressions
authored
746 NetExpr*elaborate_expr_enum_method_(Design*des, NetScope*scope,
747 unsigned expr_wid) const;
14f229d @steveicarus Parse support for dynamic arrays.
authored
748 #endif
2bef6b8 @steveicarus Detect and implement string.len() method, and string[index] expressions
authored
749
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
750 NetExpr* elaborate_sfunc_(Design*des, NetScope*scope,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
751 unsigned expr_wid,
752 unsigned flags) const;
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
753 NetExpr* elaborate_access_func_(Design*des, NetScope*scope, ivl_nature_t,
754 unsigned expr_wid) const;
d587499 @steveicarus test_width method for functions in expressions
authored
755 unsigned test_width_sfunc_(Design*des, NetScope*scope,
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
756 width_mode_t&mode);
14f229d @steveicarus Parse support for dynamic arrays.
authored
757 unsigned test_width_method_(Design*des, NetScope*scope,
758 width_mode_t&mode);
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
759 };
760
761 /*
557e331 @steveicarus Support SystemVerilog size cast.
authored
762 * Support the SystemVerilog cast to size.
763 */
764 class PECastSize : public PExpr {
765
766 public:
767 explicit PECastSize(unsigned expr_wid, PExpr*base);
768 ~PECastSize();
769
770 void dump(ostream &out) const;
771
772 virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
773 unsigned expr_wid,
774 unsigned flags) const;
775
776 virtual unsigned test_width(Design*des, NetScope*scope,
777 width_mode_t&mode);
778
779 private:
780 unsigned size_;
781 PExpr* base_;
782 };
783
784 /*
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
785 * This class is used for error recovery. All methods do nothing and return
786 * null or default values.
787 */
788 class PEVoid : public PExpr {
789
790 public:
791 explicit PEVoid();
792 ~PEVoid();
793
794 virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
795 unsigned expr_wid,
9306714 @martinwhitaker Rework of constant expression error reporting.
martinwhitaker authored
796 unsigned flags) const;
e0a988b Add functions up to elaboration (Ed Carter)
steve authored
797 };
798
3fb7a05 Introduce verilog to CVS.
steve authored
799 #endif
Something went wrong with that request. Please try again.