A leading underscore is valid for macro substitutions.
[iverilog.git] / dup_expr.cc
blobf40dad8fff9874147c60caec71164a4c2997e365
1 /*
2 * Copyright (c) 1999-2002 Stephen Williams (steve@icarus.com)
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.
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.
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
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: dup_expr.cc,v 1.21 2006/11/04 06:10:13 steve Exp $"
21 #endif
23 # include "config.h"
25 # include "netlist.h"
26 # include <cassert>
28 NetEBComp* NetEBComp::dup_expr() const
30 NetEBComp*result = new NetEBComp(op_, left_->dup_expr(),
31 right_->dup_expr());
32 return result;
35 NetEConst* NetEConst::dup_expr() const
37 NetEConst*tmp = new NetEConst(value_);
38 tmp->set_line(*this);
39 return tmp;
42 NetEConstParam* NetEConstParam::dup_expr() const
44 NetEConstParam*tmp = new NetEConstParam(scope_, name_, value());
45 tmp->set_line(*this);
46 return tmp;
49 NetECRealParam* NetECRealParam::dup_expr() const
51 NetECRealParam*tmp = new NetECRealParam(scope_, name_, value());
52 tmp->set_line(*this);
53 return tmp;
56 NetEEvent* NetEEvent::dup_expr() const
58 assert(0);
59 return 0;
62 NetEScope* NetEScope::dup_expr() const
64 assert(0);
65 return 0;
68 NetESelect* NetESelect::dup_expr() const
70 return new NetESelect(expr_->dup_expr(),
71 base_? base_->dup_expr() : 0,
72 expr_width());
75 NetESFunc* NetESFunc::dup_expr() const
77 NetESFunc*tmp = new NetESFunc(name_, type_, expr_width(), nparms());
78 assert(tmp);
80 tmp->cast_signed(has_sign());
81 for (unsigned idx = 0 ; idx < nparms() ; idx += 1) {
82 assert(tmp->parm(idx));
83 tmp->parm(idx, tmp->parm(idx)->dup_expr());
86 return tmp;
89 NetESignal* NetESignal::dup_expr() const
91 NetESignal*tmp = new NetESignal(net_);
92 assert(tmp);
93 tmp->expr_width(expr_width());
94 return tmp;
97 NetETernary* NetETernary::dup_expr() const
99 NetETernary*tmp = new NetETernary(cond_->dup_expr(),
100 true_val_->dup_expr(),
101 false_val_->dup_expr());
102 return tmp;
105 NetEUFunc* NetEUFunc::dup_expr() const
107 NetEUFunc*tmp;
108 svector<NetExpr*> tmp_parms (parms_.count());
110 for (unsigned idx = 0 ; idx < tmp_parms.count() ; idx += 1) {
111 assert(parms_[idx]);
112 tmp_parms[idx] = parms_[idx]->dup_expr();
115 tmp = new NetEUFunc(func_, result_sig_->dup_expr(), tmp_parms);
117 assert(tmp);
118 return tmp;
121 NetEUnary* NetEUnary::dup_expr() const
123 NetEUnary*tmp = new NetEUnary(op_, expr_->dup_expr());
124 assert(tmp);
125 return tmp;
128 NetEUReduce* NetEUReduce::dup_expr() const
130 NetEUReduce*tmp = new NetEUReduce(op_, expr_->dup_expr());
131 assert(tmp);
132 return tmp;
136 * $Log: dup_expr.cc,v $
137 * Revision 1.21 2006/11/04 06:10:13 steve
138 * Handle dup of pad as well as normal select.
140 * Revision 1.20 2005/07/11 16:56:50 steve
141 * Remove NetVariable and ivl_variable_t structures.
143 * Revision 1.19 2004/12/11 02:31:25 steve
144 * Rework of internals to carry vectors through nexus instead
145 * of single bits. Make the ivl, tgt-vvp and vvp initial changes
146 * down this path.
148 * Revision 1.18 2004/06/17 16:06:18 steve
149 * Help system function signedness survive elaboration.
151 * Revision 1.17 2004/05/31 23:34:36 steve
152 * Rewire/generalize parsing an elaboration of
153 * function return values to allow for better
154 * speed and more type support.
156 * Revision 1.16 2003/10/31 02:47:11 steve
157 * NetEUReduce has its own dup_expr method.
159 * Revision 1.15 2003/05/30 02:55:32 steve
160 * Support parameters in real expressions and
161 * as real expressions, and fix multiply and
162 * divide with real results.
164 * Revision 1.14 2003/04/22 04:48:29 steve
165 * Support event names as expressions elements.
167 * Revision 1.13 2003/03/15 18:08:43 steve
168 * Comparison operators do have defined width.
170 * Revision 1.12 2003/03/15 04:46:28 steve
171 * Better organize the NetESFunc return type guesses.
173 * Revision 1.11 2003/03/10 23:40:53 steve
174 * Keep parameter constants for the ivl_target API.
176 * Revision 1.10 2003/01/26 21:15:58 steve
177 * Rework expression parsing and elaboration to
178 * accommodate real/realtime values and expressions.
180 * Revision 1.9 2002/11/09 00:25:27 steve
181 * Add dup_expr for user defined function calls.
183 * Revision 1.8 2002/08/12 01:34:58 steve
184 * conditional ident string using autoconfig.
186 * Revision 1.7 2002/01/28 00:52:41 steve
187 * Add support for bit select of parameters.
188 * This leads to a NetESelect node and the
189 * vvp code generator to support that.
191 * Revision 1.6 2001/11/19 01:54:14 steve
192 * Port close cropping behavior from mcrgb
193 * Move window array reset to libmc.
195 * Revision 1.5 2001/07/25 03:10:48 steve
196 * Create a config.h.in file to hold all the config
197 * junk, and support gcc 3.0. (Stephan Boettcher)
199 * Revision 1.4 2000/05/07 18:20:07 steve
200 * Import MCD support from Stephen Tell, and add
201 * system function parameter support to the IVL core.
203 * Revision 1.3 2000/05/04 03:37:58 steve
204 * Add infrastructure for system functions, move
205 * $time to that structure and add $random.