Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 280 lines (242 sloc) 7.296 kB
4cfa3e4 Support the creation of scopes.
steve authored
1 /*
a6220fe @caryr Add support for passing variable indexed part select type information
caryr authored
2 * Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
4cfa3e4 Support the creation of scopes.
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
b825f8d Create a config.h.in file to hold all the config
steve authored
20 # include "config.h"
21
4cfa3e4 Support the creation of scopes.
steve authored
22 # include "netlist.h"
23 # include <cassert>
1993bf6 @caryr Remove malloc.h support and for C++ files use <c...> include files.
caryr authored
24 # include <cstdlib>
9f04641 @steveicarus Detect and elaborate AMS access functions.
authored
25 # include "ivl_assert.h"
26
27 NetEAccess* NetEAccess::dup_expr() const
28 {
b292a5f @steveicarus Create a branch object to be the argument to the access function.
authored
29 NetEAccess*tmp = new NetEAccess(branch_, nature_);
9f04641 @steveicarus Detect and elaborate AMS access functions.
authored
30 ivl_assert(*this, tmp);
31 tmp->set_line(*this);
32 return tmp;
33 }
4cfa3e4 Support the creation of scopes.
steve authored
34
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
35 NetEBinary* NetEBinary::dup_expr() const
36 {
37 ivl_assert(*this, 0);
38 return 0;
39 }
40
41 NetEBAdd* NetEBAdd::dup_expr() const
42 {
43 NetEBAdd*tmp = new NetEBAdd(op_, left_->dup_expr(), right_->dup_expr(),
44 expr_width(), has_sign());
45 ivl_assert(*this, tmp);
46 tmp->set_line(*this);
47 return tmp;
48 }
49
50 NetEBBits* NetEBBits::dup_expr() const
51 {
52 NetEBBits*tmp = new NetEBBits(op_, left_->dup_expr(), right_->dup_expr(),
53 expr_width(), has_sign());
54 ivl_assert(*this, tmp);
55 tmp->set_line(*this);
56 return tmp;
57 }
58
c602d94 Comparison operators do have defined width.
steve authored
59 NetEBComp* NetEBComp::dup_expr() const
60 {
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
61 NetEBComp*tmp = new NetEBComp(op_, left_->dup_expr(), right_->dup_expr());
62 ivl_assert(*this, tmp);
63 tmp->set_line(*this);
64 return tmp;
65 }
66
67 NetEBDiv* NetEBDiv::dup_expr() const
68 {
69 NetEBDiv*tmp = new NetEBDiv(op_, left_->dup_expr(), right_->dup_expr(),
70 expr_width(), has_sign());
71 ivl_assert(*this, tmp);
72 tmp->set_line(*this);
73 return tmp;
74 }
75
76 NetEBLogic* NetEBLogic::dup_expr() const
77 {
78 NetEBLogic*tmp = new NetEBLogic(op_, left_->dup_expr(), right_->dup_expr());
79 ivl_assert(*this, tmp);
70c5c9f @caryr Propagate file and line information in more places.
caryr authored
80 tmp->set_line(*this);
81 return tmp;
c602d94 Comparison operators do have defined width.
steve authored
82 }
83
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
84 NetEBMult* NetEBMult::dup_expr() const
85 {
86 NetEBMult*tmp = new NetEBMult(op_, left_->dup_expr(), right_->dup_expr(),
87 expr_width(), has_sign());
88 ivl_assert(*this, tmp);
89 tmp->set_line(*this);
90 return tmp;
91 }
92
93 NetEBPow* NetEBPow::dup_expr() const
94 {
95 NetEBPow*tmp = new NetEBPow(op_, left_->dup_expr(), right_->dup_expr(),
96 expr_width(), has_sign());
97 ivl_assert(*this, tmp);
98 tmp->set_line(*this);
99 return tmp;
100 }
101
102 NetEBShift* NetEBShift::dup_expr() const
103 {
104 NetEBShift*tmp = new NetEBShift(op_, left_->dup_expr(), right_->dup_expr(),
105 expr_width(), has_sign());
106 ivl_assert(*this, tmp);
107 tmp->set_line(*this);
108 return tmp;
109 }
110
111 NetEConcat* NetEConcat::dup_expr() const
112 {
113 NetEConcat*dup = new NetEConcat(parms_.count(), repeat_);
114 ivl_assert(*this, dup);
115 dup->set_line(*this);
116 for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
117 if (parms_[idx]) {
118 NetExpr*tmp = parms_[idx]->dup_expr();
119 ivl_assert(*this, tmp);
120 dup->parms_[idx] = tmp;
121 }
122
123 dup->expr_width(expr_width());
124
125 return dup;
126 }
127
1222153 Keep parameter constants for the ivl_target API.
steve authored
128 NetEConst* NetEConst::dup_expr() const
129 {
130 NetEConst*tmp = new NetEConst(value_);
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
131 ivl_assert(*this, tmp);
1222153 Keep parameter constants for the ivl_target API.
steve authored
132 tmp->set_line(*this);
133 return tmp;
134 }
135
a14fa03 @steveicarus Enum names in r-value expressions
authored
136 NetEConstEnum* NetEConstEnum::dup_expr() const
137 {
138 NetEConstEnum*tmp = new NetEConstEnum(scope_, name_, enum_set_, value());
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
139 ivl_assert(*this, tmp);
a14fa03 @steveicarus Enum names in r-value expressions
authored
140 tmp->set_line(*this);
141 return tmp;
142 }
143
1222153 Keep parameter constants for the ivl_target API.
steve authored
144 NetEConstParam* NetEConstParam::dup_expr() const
145 {
146 NetEConstParam*tmp = new NetEConstParam(scope_, name_, value());
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
147 ivl_assert(*this, tmp);
148 tmp->set_line(*this);
149 return tmp;
150 }
151
152 NetECReal* NetECReal::dup_expr() const
153 {
154 NetECReal*tmp = new NetECReal(value_);
155 ivl_assert(*this, tmp);
1222153 Keep parameter constants for the ivl_target API.
steve authored
156 tmp->set_line(*this);
157 return tmp;
158 }
159
5903f07 Support parameters in real expressions and
steve authored
160 NetECRealParam* NetECRealParam::dup_expr() const
161 {
162 NetECRealParam*tmp = new NetECRealParam(scope_, name_, value());
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
163 ivl_assert(*this, tmp);
5903f07 Support parameters in real expressions and
steve authored
164 tmp->set_line(*this);
165 return tmp;
166 }
167
f1cc9d8 Support event names as expressions elements.
steve authored
168 NetEEvent* NetEEvent::dup_expr() const
169 {
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
170 ivl_assert(*this, 0);
f1cc9d8 Support event names as expressions elements.
steve authored
171 return 0;
172 }
173
de215f1 @steveicarus Describe enum type to code generators
authored
174 NetENetenum* NetENetenum::dup_expr() const
175 {
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
176 ivl_assert(*this, 0);
de215f1 @steveicarus Describe enum type to code generators
authored
177 return 0;
178 }
179
4cfa3e4 Support the creation of scopes.
steve authored
180 NetEScope* NetEScope::dup_expr() const
181 {
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
182 ivl_assert(*this, 0);
4cfa3e4 Support the creation of scopes.
steve authored
183 return 0;
184 }
185
364ffc9 Add support for bit select of parameters.
steve authored
186 NetESelect* NetESelect::dup_expr() const
187 {
70c5c9f @caryr Propagate file and line information in more places.
caryr authored
188 NetESelect*tmp = new NetESelect(expr_->dup_expr(),
189 base_? base_->dup_expr() : 0,
a6220fe @caryr Add support for passing variable indexed part select type information
caryr authored
190 expr_width(), sel_type_);
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
191 ivl_assert(*this, tmp);
70c5c9f @caryr Propagate file and line information in more places.
caryr authored
192 tmp->set_line(*this);
193 return tmp;
364ffc9 Add support for bit select of parameters.
steve authored
194 }
195
fbe475e Add infrastructure for system functions, move
steve authored
196 NetESFunc* NetESFunc::dup_expr() const
197 {
6d94f2e Better organize the NetESFunc return type guesses.
steve authored
198 NetESFunc*tmp = new NetESFunc(name_, type_, expr_width(), nparms());
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
199 ivl_assert(*this, tmp);
b3529d8 Help system function signedness survive elaboration.
steve authored
200
201 tmp->cast_signed(has_sign());
cfed393 Port close cropping behavior from mcrgb
steve authored
202 for (unsigned idx = 0 ; idx < nparms() ; idx += 1) {
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
203 ivl_assert(*this, parm(idx));
c41fb50 @caryr Copy from the existing function when duping a system function.
caryr authored
204 tmp->parm(idx, parm(idx)->dup_expr());
cfed393 Port close cropping behavior from mcrgb
steve authored
205 }
b28f258 Import MCD support from Stephen Tell, and add
steve authored
206
70c5c9f @caryr Propagate file and line information in more places.
caryr authored
207 tmp->set_line(*this);
b28f258 Import MCD support from Stephen Tell, and add
steve authored
208 return tmp;
fbe475e Add infrastructure for system functions, move
steve authored
209 }
210
cfed393 Port close cropping behavior from mcrgb
steve authored
211 NetESignal* NetESignal::dup_expr() const
212 {
ef9ee52 @caryr NetESignal::dup_expr() was not passing the word_ information.
caryr authored
213 NetESignal*tmp = new NetESignal(net_, word_);
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
214 ivl_assert(*this, tmp);
cfed393 Port close cropping behavior from mcrgb
steve authored
215 tmp->expr_width(expr_width());
ef9ee52 @caryr NetESignal::dup_expr() was not passing the word_ information.
caryr authored
216 tmp->set_line(*this);
cfed393 Port close cropping behavior from mcrgb
steve authored
217 return tmp;
218 }
219
220 NetETernary* NetETernary::dup_expr() const
221 {
222 NetETernary*tmp = new NetETernary(cond_->dup_expr(),
223 true_val_->dup_expr(),
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
224 false_val_->dup_expr(),
225 expr_width(),
226 has_sign());
227 ivl_assert(*this, tmp);
70c5c9f @caryr Propagate file and line information in more places.
caryr authored
228 tmp->set_line(*this);
cfed393 Port close cropping behavior from mcrgb
steve authored
229 return tmp;
230 }
231
588931f Add dup_expr for user defined function calls.
steve authored
232 NetEUFunc* NetEUFunc::dup_expr() const
233 {
234 NetEUFunc*tmp;
235 svector<NetExpr*> tmp_parms (parms_.count());
236
237 for (unsigned idx = 0 ; idx < tmp_parms.count() ; idx += 1) {
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
238 ivl_assert(*this, parms_[idx]);
588931f Add dup_expr for user defined function calls.
steve authored
239 tmp_parms[idx] = parms_[idx]->dup_expr();
240 }
241
fac1cc5 @caryr Add user function synth and clean up expression code.
caryr authored
242 tmp = new NetEUFunc(scope_, func_, result_sig_->dup_expr(), tmp_parms);
588931f Add dup_expr for user defined function calls.
steve authored
243
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
244 ivl_assert(*this, tmp);
70c5c9f @caryr Propagate file and line information in more places.
caryr authored
245 tmp->set_line(*this);
588931f Add dup_expr for user defined function calls.
steve authored
246 return tmp;
247 }
248
403a1e9 @steveicarus Add a dup_expr method to NetEUBits.
authored
249 NetEUBits* NetEUBits::dup_expr() const
250 {
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
251 NetEUBits*tmp = new NetEUBits(op_, expr_->dup_expr(), expr_width(), has_sign());
252 ivl_assert(*this, tmp);
403a1e9 @steveicarus Add a dup_expr method to NetEUBits.
authored
253 tmp->set_line(*this);
254 return tmp;
255 }
256
cfed393 Port close cropping behavior from mcrgb
steve authored
257 NetEUnary* NetEUnary::dup_expr() const
258 {
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
259 NetEUnary*tmp = new NetEUnary(op_, expr_->dup_expr(), expr_width(), has_sign());
260 ivl_assert(*this, tmp);
70c5c9f @caryr Propagate file and line information in more places.
caryr authored
261 tmp->set_line(*this);
cfed393 Port close cropping behavior from mcrgb
steve authored
262 return tmp;
263 }
264
7fd669f NetEUReduce has its own dup_expr method.
steve authored
265 NetEUReduce* NetEUReduce::dup_expr() const
266 {
267 NetEUReduce*tmp = new NetEUReduce(op_, expr_->dup_expr());
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
268 ivl_assert(*this, tmp);
70c5c9f @caryr Propagate file and line information in more places.
caryr authored
269 tmp->set_line(*this);
7fd669f NetEUReduce has its own dup_expr method.
steve authored
270 return tmp;
271 }
21d15ce @caryr Fix the compiler and modpath scaling of real delays.
caryr authored
272
273 NetECast* NetECast::dup_expr() const
274 {
312b4da @martinwhitaker Expression width rework.
martinwhitaker authored
275 NetECast*tmp = new NetECast(op_, expr_->dup_expr(), expr_width(), has_sign());
276 ivl_assert(*this, tmp);
21d15ce @caryr Fix the compiler and modpath scaling of real delays.
caryr authored
277 tmp->set_line(*this);
278 return tmp;
279 }
Something went wrong with that request. Please try again.