Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 656 lines (526 sloc) 13.984 kB
5796524 Add ne_expr.cc
steve authored
1 /*
ec49f10 @steveicarus Revert bad merge from vhdl branch
authored
2 * Copyright (c) 2002-2010 Stephen Williams (steve@icarus.com)
5796524 Add ne_expr.cc
steve authored
3 *
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 */
19
928df5c include config.h to eliminate warnings.
steve authored
20 # include "config.h"
5796524 Add ne_expr.cc
steve authored
21 # include "netlist.h"
4c67de5 Add the lex_strings string handler, and put
steve authored
22 # include "compiler.h"
fe72d02 @caryr Major rework of the ternary operator elaboration code.
caryr authored
23 # include "netmisc.h"
28e0616 Use standard name for iostream.
steve authored
24 # include <iostream>
5796524 Add ne_expr.cc
steve authored
25
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
26 /*
27 * the grand default data type is a logic vector.
28 */
29 ivl_variable_type_t NetExpr::expr_type() const
46253ed Rework expression parsing and elaboration to
steve authored
30 {
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
31 return IVL_VT_LOGIC;
46253ed Rework expression parsing and elaboration to
steve authored
32 }
33
5b5a6b0 @steveicarus Test type correctness during elaboration.
authored
34 netenum_t*NetExpr::enumeration() const
35 {
36 return 0;
37 }
38
de94d09 No need to keep excess width from an
steve authored
39 /*
40 * Create an add/sub node from the two operands. Make a best guess of
e4ae832 Clean up spurious trailing white space.
steve authored
41 * the
de94d09 No need to keep excess width from an
steve authored
42 */
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored
43 NetEBAdd::NetEBAdd(char op__, NetExpr*l, NetExpr*r, bool lossless_flag)
44 : NetEBinary(op__, l, r)
de94d09 No need to keep excess width from an
steve authored
45 {
46 NetEConst* tmp;
47
48 /* Catch the special case that one of the operands is an
49 unsized constant number. If so, then we should set the
50 width of that number to the size of the other operand, plus
51 one. This expands the expression to account for the largest
52 possible result.
53
c7edace @steveicarus Unsized integers have minimum size
authored
54 Remember to handle the special case of an unsized constant,
55 which we define to be at least "integer_width" bits.
56
de94d09 No need to keep excess width from an
steve authored
57 The set_width applied to a constant value will only
58 truncate the constant so far as it can still hold its
59 logical value, so this is safe to do. */
60 if ( (tmp = dynamic_cast<NetEConst*>(r))
61 && (! tmp->has_width())
c7edace @steveicarus Unsized integers have minimum size
authored
62 && (tmp->expr_width() > l->expr_width() || integer_width > l->expr_width()) ) {
de94d09 No need to keep excess width from an
steve authored
63
a9497e9 @steveicarus Less agressive padding of unsized lossless addition.
authored
64 verinum tmp_v = trim_vnum(tmp->value());
65 unsigned target_width = l->expr_width();
66 if (target_width < tmp_v.len())
67 target_width = tmp_v.len();
68 if (lossless_flag)
69 target_width += 1;
c7edace @steveicarus Unsized integers have minimum size
authored
70 if (target_width < integer_width)
71 target_width = integer_width;
a9497e9 @steveicarus Less agressive padding of unsized lossless addition.
authored
72
de94d09 No need to keep excess width from an
steve authored
73 r->set_width(target_width);
74
75 /* Note: This constant value will not gain a defined
7c1401a Spelling patch.
steve authored
76 width from this. Make sure. */
de94d09 No need to keep excess width from an
steve authored
77 assert(! r->has_width() );
78
a9497e9 @steveicarus Less agressive padding of unsized lossless addition.
authored
79 expr_width(target_width);
80
de94d09 No need to keep excess width from an
steve authored
81 } else if ( (tmp = dynamic_cast<NetEConst*>(l))
82 && (! tmp->has_width())
c7edace @steveicarus Unsized integers have minimum size
authored
83 && (tmp->expr_width() > r->expr_width() || integer_width > r->expr_width()) ) {
de94d09 No need to keep excess width from an
steve authored
84
a9497e9 @steveicarus Less agressive padding of unsized lossless addition.
authored
85 verinum tmp_v = trim_vnum(tmp->value());
86 unsigned target_width = r->expr_width();
87 if (target_width < tmp_v.len())
88 target_width = tmp_v.len();
89 if (lossless_flag)
90 target_width += 1;
c7edace @steveicarus Unsized integers have minimum size
authored
91 if (target_width < integer_width)
92 target_width = integer_width;
a9497e9 @steveicarus Less agressive padding of unsized lossless addition.
authored
93
de94d09 No need to keep excess width from an
steve authored
94 l->set_width(target_width);
95
96 /* Note: This constant value will not gain a defined
7c1401a Spelling patch.
steve authored
97 width from this. Make sure. */
de94d09 No need to keep excess width from an
steve authored
98 assert(! l->has_width() );
99
a9497e9 @steveicarus Less agressive padding of unsized lossless addition.
authored
100 expr_width(target_width);
de94d09 No need to keep excess width from an
steve authored
101
a9497e9 @steveicarus Less agressive padding of unsized lossless addition.
authored
102 } else if (r->expr_width() > l->expr_width()) {
103 unsigned loss_pad = lossless_flag? 1 : 0;
104 expr_width(r->expr_width() + loss_pad);
de94d09 No need to keep excess width from an
steve authored
105
106 } else {
a9497e9 @steveicarus Less agressive padding of unsized lossless addition.
authored
107 unsigned loss_pad = lossless_flag? 1 : 0;
108 expr_width(l->expr_width() + loss_pad);
de94d09 No need to keep excess width from an
steve authored
109 }
a9497e9 @steveicarus Less agressive padding of unsized lossless addition.
authored
110
111 cast_signed(l->has_sign() && r->has_sign());
de94d09 No need to keep excess width from an
steve authored
112 }
113
114 NetEBAdd::~NetEBAdd()
115 {
116 }
117
118 NetEBAdd* NetEBAdd::dup_expr() const
119 {
120 NetEBAdd*result = new NetEBAdd(op_, left_->dup_expr(),
121 right_->dup_expr());
122 return result;
123 }
124
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
125 ivl_variable_type_t NetEBAdd::expr_type() const
46253ed Rework expression parsing and elaboration to
steve authored
126 {
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
127 if (left_->expr_type() == IVL_VT_REAL)
128 return IVL_VT_REAL;
46253ed Rework expression parsing and elaboration to
steve authored
129
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
130 if (right_->expr_type() == IVL_VT_REAL)
131 return IVL_VT_REAL;
46253ed Rework expression parsing and elaboration to
steve authored
132
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
133 return IVL_VT_LOGIC;
46253ed Rework expression parsing and elaboration to
steve authored
134 }
135
c602d94 Comparison operators do have defined width.
steve authored
136 /*
137 * Create a comparison operator with two sub-expressions.
138 *
139 * Handle the special case of an unsized constant on the left or right
140 * side by resizing the number to match the other
141 * expression. Otherwise, the netlist will have to allow the
142 * expressions to have different widths.
143 */
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored
144 NetEBComp::NetEBComp(char op__, NetExpr*l, NetExpr*r)
145 : NetEBinary(op__, l, r)
c602d94 Comparison operators do have defined width.
steve authored
146 {
7b4fda8 @steveicarus Process arguments to bitwise operator using singned/unsigned rules.
authored
147 // The output of compare is always unsigned.
148 cast_signed_base_(false);
149
c602d94 Comparison operators do have defined width.
steve authored
150 if (NetEConst*tmp = dynamic_cast<NetEConst*>(r)) do {
151
152 if (tmp->has_width())
153 break;
154
7e2848b Do not try to set constants to width 0.
steve authored
155 if (l->expr_width() == 0)
156 break;
157
c602d94 Comparison operators do have defined width.
steve authored
158 if (tmp->expr_width() == l->expr_width())
159 break;
160
161 tmp->set_width(l->expr_width());
162
163 } while (0);
164
165 if (NetEConst*tmp = dynamic_cast<NetEConst*>(l)) do {
166
167 if (tmp->has_width())
168 break;
169
7e2848b Do not try to set constants to width 0.
steve authored
170 if (r->expr_width() == 0)
171 break;
172
c602d94 Comparison operators do have defined width.
steve authored
173 if (tmp->expr_width() == r->expr_width())
174 break;
175
176 tmp->set_width(r->expr_width());
177
178 } while (0);
179
180
181 expr_width(1);
182 }
183
184 NetEBComp::~NetEBComp()
185 {
186 }
187
188 bool NetEBComp::has_width() const
189 {
190 return true;
191 }
192
9fd1657 Support bool expressions and compares handle them optimally.
steve authored
193 ivl_variable_type_t NetEBComp::expr_type() const
194 {
195 // Case compare always returns BOOL
196 if (op() == 'E' || op() == 'N')
197 return IVL_VT_BOOL;
198
199 if (left()->expr_type() == IVL_VT_LOGIC)
200 return IVL_VT_LOGIC;
201
202 if (right()->expr_type() == IVL_VT_LOGIC)
203 return IVL_VT_LOGIC;
204
205 return IVL_VT_BOOL;
206 }
207
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored
208 NetEBDiv::NetEBDiv(char op__, NetExpr*l, NetExpr*r)
209 : NetEBinary(op__, l, r)
46253ed Rework expression parsing and elaboration to
steve authored
210 {
211 unsigned w = l->expr_width();
212 if (r->expr_width() > w)
213 w = r->expr_width();
214
215 expr_width(w);
216 cast_signed(l->has_sign() && r->has_sign());
217 }
218
219 NetEBDiv::~NetEBDiv()
220 {
221 }
222
223 NetEBDiv* NetEBDiv::dup_expr() const
224 {
225 NetEBDiv*result = new NetEBDiv(op_, left_->dup_expr(),
226 right_->dup_expr());
227 return result;
228 }
229
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
230 ivl_variable_type_t NetEBDiv::expr_type() const
46253ed Rework expression parsing and elaboration to
steve authored
231 {
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
232 if (left_->expr_type() == IVL_VT_REAL)
233 return IVL_VT_REAL;
46253ed Rework expression parsing and elaboration to
steve authored
234
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
235 if (right_->expr_type() == IVL_VT_REAL)
236 return IVL_VT_REAL;
46253ed Rework expression parsing and elaboration to
steve authored
237
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
238 return IVL_VT_LOGIC;
46253ed Rework expression parsing and elaboration to
steve authored
239 }
240
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored
241 NetEBMinMax::NetEBMinMax(char op__, NetExpr*l, NetExpr*r)
242 : NetEBinary(op__, l, r)
d60df2d @steveicarus Implement abs/min/max operators for real values.
authored
243 {
244 expr_width( max(l->expr_width(), r->expr_width()) );
245 cast_signed(l->has_sign() || r->has_sign());
246 }
247
248 NetEBMinMax::~NetEBMinMax()
249 {
250 }
251
252 ivl_variable_type_t NetEBMinMax::expr_type() const
253 {
254 if (left_->expr_type() == IVL_VT_REAL)
255 return IVL_VT_REAL;
256 if (right_->expr_type() == IVL_VT_REAL)
257 return IVL_VT_REAL;
258
259 return IVL_VT_LOGIC;
260 }
261
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored
262 NetEBMult::NetEBMult(char op__, NetExpr*l, NetExpr*r)
263 : NetEBinary(op__, l, r)
46253ed Rework expression parsing and elaboration to
steve authored
264 {
e980004 @caryr Fix power operator width in self-determined context.
caryr authored
265 if (expr_type() == IVL_VT_REAL) {
873ed60 @steveicarus Multiply of real values has width of 1.
authored
266 expr_width(1);
bd71b7f @steveicarus Real valued multiply are always signed.
authored
267 cast_signed(true);
e980004 @caryr Fix power operator width in self-determined context.
caryr authored
268 } else {
269 expr_width(l->expr_width() + r->expr_width());
bd71b7f @steveicarus Real valued multiply are always signed.
authored
270 cast_signed(l->has_sign() && r->has_sign());
e980004 @caryr Fix power operator width in self-determined context.
caryr authored
271 }
46253ed Rework expression parsing and elaboration to
steve authored
272 }
273
274 NetEBMult::~NetEBMult()
275 {
276 }
277
278 NetEBMult* NetEBMult::dup_expr() const
279 {
280 NetEBMult*result = new NetEBMult(op_, left_->dup_expr(),
281 right_->dup_expr());
282 return result;
283 }
284
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
285 ivl_variable_type_t NetEBMult::expr_type() const
46253ed Rework expression parsing and elaboration to
steve authored
286 {
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
287 if (left_->expr_type() == IVL_VT_REAL)
288 return IVL_VT_REAL;
46253ed Rework expression parsing and elaboration to
steve authored
289
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
290 if (right_->expr_type() == IVL_VT_REAL)
291 return IVL_VT_REAL;
46253ed Rework expression parsing and elaboration to
steve authored
292
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
293 return IVL_VT_LOGIC;
46253ed Rework expression parsing and elaboration to
steve authored
294 }
295
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored
296 NetEBPow::NetEBPow(char op__, NetExpr*l, NetExpr*r)
297 : NetEBinary(op__, l, r)
49b65e8 Add support for power in constant expressions.
steve authored
298 {
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored
299 assert(op__ == 'p');
e980004 @caryr Fix power operator width in self-determined context.
caryr authored
300 /* You could need up to a * (2^b - 1) bits. */
301 expr_width(l->expr_width());
49b65e8 Add support for power in constant expressions.
steve authored
302 cast_signed(l->has_sign() || r->has_sign());
303 }
304
305 NetEBPow::~NetEBPow()
306 {
307 }
308
309 NetEBPow* NetEBPow::dup_expr() const
310 {
311 NetEBPow*result = new NetEBPow(op_, left_->dup_expr(),
312 right_->dup_expr());
313 result->set_line(*this);
314 return result;
315 }
316
317 ivl_variable_type_t NetEBPow::expr_type() const
318 {
319 if (right_->expr_type() == IVL_VT_REAL)
320 return IVL_VT_REAL;
321 if (left_->expr_type() == IVL_VT_REAL)
322 return IVL_VT_REAL;
323
324 return IVL_VT_LOGIC;
325 }
326
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored
327 NetEBShift::NetEBShift(char op__, NetExpr*l, NetExpr*r)
328 : NetEBinary(op__, l, r)
71a404a Add arithmetic shift operators.
steve authored
329 {
330 expr_width(l->expr_width());
331
332 // The >>> is signed if the left operand is signed.
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored
333 if (op__ == 'R') cast_signed(l->has_sign());
71a404a Add arithmetic shift operators.
steve authored
334 }
335
336 NetEBShift::~NetEBShift()
337 {
338 }
339
340 bool NetEBShift::has_width() const
341 {
342 return left_->has_width();
343 }
344
345 NetEBShift* NetEBShift::dup_expr() const
346 {
347 NetEBShift*result = new NetEBShift(op_, left_->dup_expr(),
348 right_->dup_expr());
349 return result;
350 }
351
8667b9a Put off evaluation of concatenation repeat expresions
steve authored
352 NetEConcat::NetEConcat(unsigned cnt, NetExpr* r)
353 : parms_(cnt), repeat_(r)
354 {
355 if (repeat_ == 0) {
356 repeat_calculated_ = true;
357 repeat_value_ = 1;
358 } else {
359 repeat_calculated_ = false;
360 }
361
362 expr_width(0);
363 }
364
365 NetEConcat::~NetEConcat()
366 {
367 for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
368 delete parms_[idx];
369 }
370
aa8869a Postpone parameter width check to evaluation.
steve authored
371 bool NetEConcat::has_width() const
372 {
373 return true;
374 }
375
8667b9a Put off evaluation of concatenation repeat expresions
steve authored
376 void NetEConcat::set(unsigned idx, NetExpr*e)
377 {
378 assert(idx < parms_.count());
379 assert(parms_[idx] == 0);
380 parms_[idx] = e;
381 expr_width( expr_width() + e->expr_width() );
382 }
383
384 NetEConcat* NetEConcat::dup_expr() const
385 {
a288b01 @steveicarus Fix concatenations losing track of its repeat values.
authored
386 NetEConcat*dup = new NetEConcat(parms_.count(), 0);
387 dup->set_line(*this);
8667b9a Put off evaluation of concatenation repeat expresions
steve authored
388 for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
389 if (parms_[idx]) {
390 NetExpr*tmp = parms_[idx]->dup_expr();
391 assert(tmp);
392 dup->parms_[idx] = tmp;
393 }
394
395
a288b01 @steveicarus Fix concatenations losing track of its repeat values.
authored
396 dup->repeat_ = repeat_? repeat_->dup_expr() : 0;
397 dup->repeat_value_ = repeat_value_;
398 dup->repeat_calculated_ = repeat_calculated_;
8667b9a Put off evaluation of concatenation repeat expresions
steve authored
399 dup->expr_width(expr_width());
a288b01 @steveicarus Fix concatenations losing track of its repeat values.
authored
400
8667b9a Put off evaluation of concatenation repeat expresions
steve authored
401 return dup;
402 }
403
404 unsigned NetEConcat::repeat()
405 {
406 if (repeat_calculated_)
407 return repeat_value_;
408
fe72d02 @caryr Major rework of the ternary operator elaboration code.
caryr authored
409 eval_expr(repeat_);
8667b9a Put off evaluation of concatenation repeat expresions
steve authored
410
411 NetEConst*repeat_const = dynamic_cast<NetEConst*>(repeat_);
412
413 /* This should not be possible, as it was checked earlier to
414 assure that this is a constant expression. */
415 if (repeat_const == 0) {
7975e14 @steveicarus LineInfo uses perm_string for path.
authored
416 cerr << get_fileline() << ": internal error: repeat expression "
8667b9a Put off evaluation of concatenation repeat expresions
steve authored
417 << "is not a compile time constant." << endl;
7975e14 @steveicarus LineInfo uses perm_string for path.
authored
418 cerr << get_fileline() << ": : Expression is: "
8667b9a Put off evaluation of concatenation repeat expresions
steve authored
419 << *repeat_ << endl;
420 repeat_calculated_ = true;
421 repeat_value_ = 1;
422 return 1;
423 }
424
425 repeat_calculated_ = true;
426 repeat_value_ = repeat_const->value().as_ulong();
427
428 delete repeat_;
429 repeat_ = 0;
430
431 return repeat_value_;
432 }
433
434 unsigned NetEConcat::repeat() const
435 {
436 assert(repeat_calculated_);
437 return repeat_value_;
438 }
439
5b5a6b0 @steveicarus Test type correctness during elaboration.
authored
440 NetEConstEnum::NetEConstEnum(NetScope*s, perm_string n, netenum_t*eset, const verinum&v)
cd6c6c7 @steveicarus Get the netenum_t base type data from the pform.
authored
441 : NetEConst(v), scope_(s), enum_set_(eset), name_(n)
a14fa03 @steveicarus Enum names in r-value expressions
authored
442 {
5e2c0e5 @steveicarus Better handling of width of enum literals in expressions.
authored
443 assert(has_width());
a14fa03 @steveicarus Enum names in r-value expressions
authored
444 }
445
446 NetEConstEnum::~NetEConstEnum()
447 {
448 }
449
5b5a6b0 @steveicarus Test type correctness during elaboration.
authored
450 netenum_t*NetEConstEnum::enumeration() const
a14fa03 @steveicarus Enum names in r-value expressions
authored
451 {
452 return enum_set_;
453 }
454
46253ed Rework expression parsing and elaboration to
steve authored
455 NetECReal::NetECReal(const verireal&val)
456 : value_(val)
457 {
30273a1 @steveicarus Real value constants have width 1
authored
458 expr_width(1);
6116078 @caryr Real constants are always signed.
caryr authored
459 cast_signed(true);
46253ed Rework expression parsing and elaboration to
steve authored
460 }
461
462 NetECReal::~NetECReal()
463 {
464 }
465
466 const verireal& NetECReal::value() const
467 {
468 return value_;
469 }
470
589422b Real constants have no defined vector width
steve authored
471 bool NetECReal::has_width() const
472 {
473 return false;
474 }
475
46253ed Rework expression parsing and elaboration to
steve authored
476 NetECReal* NetECReal::dup_expr() const
477 {
478 NetECReal*tmp = new NetECReal(value_);
479 tmp->set_line(*this);
480 return tmp;
481 }
482
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
483 ivl_variable_type_t NetECReal::expr_type() const
46253ed Rework expression parsing and elaboration to
steve authored
484 {
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
485 return IVL_VT_REAL;
46253ed Rework expression parsing and elaboration to
steve authored
486 }
487
1295058 parameter keys are per_strings.
steve authored
488 NetECRealParam::NetECRealParam(NetScope*s, perm_string n, const verireal&v)
5903f07 Support parameters in real expressions and
steve authored
489 : NetECReal(v), scope_(s), name_(n)
490 {
491 }
492
493 NetECRealParam::~NetECRealParam()
494 {
495 }
496
1295058 parameter keys are per_strings.
steve authored
497 perm_string NetECRealParam::name() const
5903f07 Support parameters in real expressions and
steve authored
498 {
499 return name_;
500 }
501
502 const NetScope* NetECRealParam::scope() const
503 {
504 return scope_;
505 }
506
507
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
508 NetEParam::NetEParam()
4350180 Redo the parameter vector support to allow
steve authored
509 : des_(0), scope_(0)
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
510 {
ec49f10 @steveicarus Revert bad merge from vhdl branch
authored
511 solving_ = false;
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
512 }
513
1295058 parameter keys are per_strings.
steve authored
514 NetEParam::NetEParam(Design*d, NetScope*s, perm_string n)
c76e88c @steveicarus Add support for explicit parameter types, including real.
authored
515 : des_(d), scope_(s), reference_(scope_->find_parameter(n))
516 {
d1ce6d2 @steveicarus Fix the signed-ness calculations of +- in parameter expressions.
authored
517 cast_signed_base_(reference_->second.signed_flag);
ec49f10 @steveicarus Revert bad merge from vhdl branch
authored
518 solving_ = false;
c76e88c @steveicarus Add support for explicit parameter types, including real.
authored
519 }
520
521 NetEParam::NetEParam(Design*d, NetScope*s, ref_t ref)
522 : des_(d), scope_(s), reference_(ref)
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
523 {
d1ce6d2 @steveicarus Fix the signed-ness calculations of +- in parameter expressions.
authored
524 cast_signed_base_(reference_->second.signed_flag);
ec49f10 @steveicarus Revert bad merge from vhdl branch
authored
525 solving_ = false;
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
526 }
527
528 NetEParam::~NetEParam()
529 {
530 }
531
532 bool NetEParam::has_width() const
533 {
534 return false;
535 }
536
c76e88c @steveicarus Add support for explicit parameter types, including real.
authored
537 ivl_variable_type_t NetEParam::expr_type() const
538 {
539 return (*reference_).second.type;
540 }
541
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
542 NetEParam* NetEParam::dup_expr() const
543 {
c76e88c @steveicarus Add support for explicit parameter types, including real.
authored
544 NetEParam*tmp = new NetEParam(des_, scope_, reference_);
ec49f10 @steveicarus Revert bad merge from vhdl branch
authored
545 tmp->solving(solving_);
5903f07 Support parameters in real expressions and
steve authored
546 tmp->set_line(*this);
547 return tmp;
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
548 }
549
ec49f10 @steveicarus Revert bad merge from vhdl branch
authored
550 void NetEParam::solving(bool arg)
551 {
552 solving_ = arg;
553 }
554
555 bool NetEParam::solving() const
556 {
557 return solving_;
558 }
559
5796524 Add ne_expr.cc
steve authored
560 NetESelect::NetESelect(NetExpr*exp, NetExpr*base, unsigned wid)
561 : expr_(exp), base_(base)
562 {
563 expr_width(wid);
564 }
565
566 NetESelect::~NetESelect()
567 {
568 delete expr_;
569 delete base_;
570 }
571
572 const NetExpr*NetESelect::sub_expr() const
573 {
574 return expr_;
575 }
576
577 const NetExpr*NetESelect::select() const
578 {
579 return base_;
580 }
581
582 bool NetESelect::has_width() const
583 {
584 return true;
585 }
586
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
587 NetESFunc::NetESFunc(const char*n, ivl_variable_type_t t,
6d94f2e Better organize the NetESFunc return type guesses.
steve authored
588 unsigned width, unsigned np)
589 : name_(0), type_(t)
04ada23 Support in various contexts the $realtime
steve authored
590 {
4c67de5 Add the lex_strings string handler, and put
steve authored
591 name_ = lex_strings.add(n);
04ada23 Support in various contexts the $realtime
steve authored
592 expr_width(width);
593 nparms_ = np;
594 parms_ = new NetExpr*[np];
595 for (unsigned idx = 0 ; idx < nparms_ ; idx += 1)
596 parms_[idx] = 0;
597 }
598
599 NetESFunc::~NetESFunc()
600 {
601 for (unsigned idx = 0 ; idx < nparms_ ; idx += 1)
602 if (parms_[idx]) delete parms_[idx];
603
604 delete[]parms_;
4c67de5 Add the lex_strings string handler, and put
steve authored
605 /* name_ string ls lex_strings allocated. */
04ada23 Support in various contexts the $realtime
steve authored
606 }
607
608 const char* NetESFunc::name() const
609 {
610 return name_;
611 }
612
613 unsigned NetESFunc::nparms() const
614 {
615 return nparms_;
616 }
617
618 void NetESFunc::parm(unsigned idx, NetExpr*v)
619 {
620 assert(idx < nparms_);
621 if (parms_[idx])
622 delete parms_[idx];
623 parms_[idx] = v;
624 }
625
626 const NetExpr* NetESFunc::parm(unsigned idx) const
627 {
628 assert(idx < nparms_);
629 return parms_[idx];
630 }
631
632 NetExpr* NetESFunc::parm(unsigned idx)
633 {
634 assert(idx < nparms_);
635 return parms_[idx];
636 }
637
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
638 ivl_variable_type_t NetESFunc::expr_type() const
04ada23 Support in various contexts the $realtime
steve authored
639 {
6d94f2e Better organize the NetESFunc return type guesses.
steve authored
640 return type_;
04ada23 Support in various contexts the $realtime
steve authored
641 }
9f04641 @steveicarus Detect and elaborate AMS access functions.
authored
642
eb240dd @steveicarus Bring discipline natures all the way to the ivl_target API.
authored
643 NetEAccess::NetEAccess(NetBranch*br, ivl_nature_t nat)
b292a5f @steveicarus Create a branch object to be the argument to the access function.
authored
644 : branch_(br), nature_(nat)
9f04641 @steveicarus Detect and elaborate AMS access functions.
authored
645 {
646 }
647
648 NetEAccess::~NetEAccess()
649 {
650 }
651
652 ivl_variable_type_t NetEAccess::expr_type() const
653 {
654 return IVL_VT_REAL;
655 }
Something went wrong with that request. Please try again.