Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 655 lines (525 sloc) 13.957 kb
5796524 Add ne_expr.cc
steve authored
1 /*
ec49f10 Stephen Williams 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 Cary R. 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 Stephen Williams 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 Larry Doolittle 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 Stephen Williams 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 Stephen Williams 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 Stephen Williams 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 Stephen Williams Unsized integers have minimum size
authored
70 if (target_width < integer_width)
71 target_width = integer_width;
a9497e9 Stephen Williams 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 Stephen Williams 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 Stephen Williams 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 Stephen Williams 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 Stephen Williams Unsized integers have minimum size
authored
91 if (target_width < integer_width)
92 target_width = integer_width;
a9497e9 Stephen Williams 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 Stephen Williams 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 Stephen Williams 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 Stephen Williams 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 Stephen Williams 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 Larry Doolittle 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 Stephen Williams 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 Larry Doolittle 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 Larry Doolittle Shadow reduction part 2
ldoolitt authored
241 NetEBMinMax::NetEBMinMax(char op__, NetExpr*l, NetExpr*r)
242 : NetEBinary(op__, l, r)
d60df2d Stephen Williams 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 Larry Doolittle 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 Cary R. Fix power operator width in self-determined context.
caryr authored
265 if (expr_type() == IVL_VT_REAL) {
873ed60 Stephen Williams Multiply of real values has width of 1.
authored
266 expr_width(1);
bd71b7f Stephen Williams Real valued multiply are always signed.
authored
267 cast_signed(true);
e980004 Cary R. Fix power operator width in self-determined context.
caryr authored
268 } else {
269 expr_width(l->expr_width() + r->expr_width());
bd71b7f Stephen Williams Real valued multiply are always signed.
authored
270 cast_signed(l->has_sign() && r->has_sign());
e980004 Cary R. 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 Larry Doolittle 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 Larry Doolittle Shadow reduction part 2
ldoolitt authored
299 assert(op__ == 'p');
e980004 Cary R. 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 Larry Doolittle 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 Larry Doolittle 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 Stephen Williams 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 Stephen Williams 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 Stephen Williams 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 Cary R. 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 Stephen Williams 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 Stephen Williams 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 Stephen Williams Test type correctness during elaboration.
authored
440 NetEConstEnum::NetEConstEnum(NetScope*s, perm_string n, netenum_t*eset, const verinum&v)
cd6c6c7 Stephen Williams Get the netenum_t base type data from the pform.
authored
441 : NetEConst(v), scope_(s), enum_set_(eset), name_(n)
a14fa03 Stephen Williams Enum names in r-value expressions
authored
442 {
443 }
444
445 NetEConstEnum::~NetEConstEnum()
446 {
447 }
448
5b5a6b0 Stephen Williams Test type correctness during elaboration.
authored
449 netenum_t*NetEConstEnum::enumeration() const
a14fa03 Stephen Williams Enum names in r-value expressions
authored
450 {
451 return enum_set_;
452 }
453
46253ed Rework expression parsing and elaboration to
steve authored
454 NetECReal::NetECReal(const verireal&val)
455 : value_(val)
456 {
30273a1 Stephen Williams Real value constants have width 1
authored
457 expr_width(1);
6116078 Cary R. Real constants are always signed.
caryr authored
458 cast_signed(true);
46253ed Rework expression parsing and elaboration to
steve authored
459 }
460
461 NetECReal::~NetECReal()
462 {
463 }
464
465 const verireal& NetECReal::value() const
466 {
467 return value_;
468 }
469
589422b Real constants have no defined vector width
steve authored
470 bool NetECReal::has_width() const
471 {
472 return false;
473 }
474
46253ed Rework expression parsing and elaboration to
steve authored
475 NetECReal* NetECReal::dup_expr() const
476 {
477 NetECReal*tmp = new NetECReal(value_);
478 tmp->set_line(*this);
479 return tmp;
480 }
481
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
482 ivl_variable_type_t NetECReal::expr_type() const
46253ed Rework expression parsing and elaboration to
steve authored
483 {
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
484 return IVL_VT_REAL;
46253ed Rework expression parsing and elaboration to
steve authored
485 }
486
1295058 parameter keys are per_strings.
steve authored
487 NetECRealParam::NetECRealParam(NetScope*s, perm_string n, const verireal&v)
5903f07 Support parameters in real expressions and
steve authored
488 : NetECReal(v), scope_(s), name_(n)
489 {
490 }
491
492 NetECRealParam::~NetECRealParam()
493 {
494 }
495
1295058 parameter keys are per_strings.
steve authored
496 perm_string NetECRealParam::name() const
5903f07 Support parameters in real expressions and
steve authored
497 {
498 return name_;
499 }
500
501 const NetScope* NetECRealParam::scope() const
502 {
503 return scope_;
504 }
505
506
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
507 NetEParam::NetEParam()
4350180 Redo the parameter vector support to allow
steve authored
508 : des_(0), scope_(0)
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
509 {
ec49f10 Stephen Williams Revert bad merge from vhdl branch
authored
510 solving_ = false;
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
511 }
512
1295058 parameter keys are per_strings.
steve authored
513 NetEParam::NetEParam(Design*d, NetScope*s, perm_string n)
c76e88c Stephen Williams Add support for explicit parameter types, including real.
authored
514 : des_(d), scope_(s), reference_(scope_->find_parameter(n))
515 {
d1ce6d2 Stephen Williams Fix the signed-ness calculations of +- in parameter expressions.
authored
516 cast_signed_base_(reference_->second.signed_flag);
ec49f10 Stephen Williams Revert bad merge from vhdl branch
authored
517 solving_ = false;
c76e88c Stephen Williams Add support for explicit parameter types, including real.
authored
518 }
519
520 NetEParam::NetEParam(Design*d, NetScope*s, ref_t ref)
521 : des_(d), scope_(s), reference_(ref)
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
522 {
d1ce6d2 Stephen Williams Fix the signed-ness calculations of +- in parameter expressions.
authored
523 cast_signed_base_(reference_->second.signed_flag);
ec49f10 Stephen Williams Revert bad merge from vhdl branch
authored
524 solving_ = false;
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
525 }
526
527 NetEParam::~NetEParam()
528 {
529 }
530
531 bool NetEParam::has_width() const
532 {
533 return false;
534 }
535
c76e88c Stephen Williams Add support for explicit parameter types, including real.
authored
536 ivl_variable_type_t NetEParam::expr_type() const
537 {
538 return (*reference_).second.type;
539 }
540
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
541 NetEParam* NetEParam::dup_expr() const
542 {
c76e88c Stephen Williams Add support for explicit parameter types, including real.
authored
543 NetEParam*tmp = new NetEParam(des_, scope_, reference_);
ec49f10 Stephen Williams Revert bad merge from vhdl branch
authored
544 tmp->solving(solving_);
5903f07 Support parameters in real expressions and
steve authored
545 tmp->set_line(*this);
546 return tmp;
7e1e44e Properly cast signedness of parameters with ranges.
steve authored
547 }
548
ec49f10 Stephen Williams Revert bad merge from vhdl branch
authored
549 void NetEParam::solving(bool arg)
550 {
551 solving_ = arg;
552 }
553
554 bool NetEParam::solving() const
555 {
556 return solving_;
557 }
558
5796524 Add ne_expr.cc
steve authored
559 NetESelect::NetESelect(NetExpr*exp, NetExpr*base, unsigned wid)
560 : expr_(exp), base_(base)
561 {
562 expr_width(wid);
563 }
564
565 NetESelect::~NetESelect()
566 {
567 delete expr_;
568 delete base_;
569 }
570
571 const NetExpr*NetESelect::sub_expr() const
572 {
573 return expr_;
574 }
575
576 const NetExpr*NetESelect::select() const
577 {
578 return base_;
579 }
580
581 bool NetESelect::has_width() const
582 {
583 return true;
584 }
585
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
586 NetESFunc::NetESFunc(const char*n, ivl_variable_type_t t,
6d94f2e Better organize the NetESFunc return type guesses.
steve authored
587 unsigned width, unsigned np)
588 : name_(0), type_(t)
04ada23 Support in various contexts the $realtime
steve authored
589 {
4c67de5 Add the lex_strings string handler, and put
steve authored
590 name_ = lex_strings.add(n);
04ada23 Support in various contexts the $realtime
steve authored
591 expr_width(width);
592 nparms_ = np;
593 parms_ = new NetExpr*[np];
594 for (unsigned idx = 0 ; idx < nparms_ ; idx += 1)
595 parms_[idx] = 0;
596 }
597
598 NetESFunc::~NetESFunc()
599 {
600 for (unsigned idx = 0 ; idx < nparms_ ; idx += 1)
601 if (parms_[idx]) delete parms_[idx];
602
603 delete[]parms_;
4c67de5 Add the lex_strings string handler, and put
steve authored
604 /* name_ string ls lex_strings allocated. */
04ada23 Support in various contexts the $realtime
steve authored
605 }
606
607 const char* NetESFunc::name() const
608 {
609 return name_;
610 }
611
612 unsigned NetESFunc::nparms() const
613 {
614 return nparms_;
615 }
616
617 void NetESFunc::parm(unsigned idx, NetExpr*v)
618 {
619 assert(idx < nparms_);
620 if (parms_[idx])
621 delete parms_[idx];
622 parms_[idx] = v;
623 }
624
625 const NetExpr* NetESFunc::parm(unsigned idx) const
626 {
627 assert(idx < nparms_);
628 return parms_[idx];
629 }
630
631 NetExpr* NetESFunc::parm(unsigned idx)
632 {
633 assert(idx < nparms_);
634 return parms_[idx];
635 }
636
b9799cf Remove NetVariable and ivl_variable_t structures.
steve authored
637 ivl_variable_type_t NetESFunc::expr_type() const
04ada23 Support in various contexts the $realtime
steve authored
638 {
6d94f2e Better organize the NetESFunc return type guesses.
steve authored
639 return type_;
04ada23 Support in various contexts the $realtime
steve authored
640 }
9f04641 Stephen Williams Detect and elaborate AMS access functions.
authored
641
eb240dd Stephen Williams Bring discipline natures all the way to the ivl_target API.
authored
642 NetEAccess::NetEAccess(NetBranch*br, ivl_nature_t nat)
b292a5f Stephen Williams Create a branch object to be the argument to the access function.
authored
643 : branch_(br), nature_(nat)
9f04641 Stephen Williams Detect and elaborate AMS access functions.
authored
644 {
645 }
646
647 NetEAccess::~NetEAccess()
648 {
649 }
650
651 ivl_variable_type_t NetEAccess::expr_type() const
652 {
653 return IVL_VT_REAL;
654 }
Something went wrong with that request. Please try again.