2 * Copyright (c) 1999-2004 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)
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
20 #ident "$Id: PGate.cc,v 1.18 2006/01/03 05:22:14 steve Exp $"
30 PGate::PGate(perm_string name
,
32 const svector
<PExpr
*>*del
)
33 : name_(name
), pins_(pins
)
35 if (del
) delay_
.set_delays(del
);
40 PGate::PGate(perm_string name
,
43 : name_(name
), pins_(pins
)
45 if (del
) delay_
.set_delay(del
);
50 PGate::PGate(perm_string name
, svector
<PExpr
*>*pins
)
51 : name_(name
), pins_(pins
)
61 PGate::strength_t
PGate::strength0() const
66 void PGate::strength0(PGate::strength_t s
)
71 PGate::strength_t
PGate::strength1() const
76 void PGate::strength1(PGate::strength_t s
)
81 void PGate::elaborate_scope(Design
*, NetScope
*) const
86 * This method is used during elaboration to calculate the
87 * rise/fall/decay times for the gate. These values were set in pform
88 * by the constructor, so here I evaluate the expression in the given
89 * design context and save the calculated delays into the output
90 * parameters. This method understands how to handle the different
91 * numbers of expressions.
94 void PGate::eval_delays(Design
*des
, NetScope
*scope
,
98 bool as_net_flag
) const
100 delay_
.eval_delays(des
, scope
,
101 rise_expr
, fall_expr
, decay_expr
,
105 void PGate::eval_delays(Design
*des
, NetScope
*scope
,
106 unsigned long&rise_time
,
107 unsigned long&fall_time
,
108 unsigned long&decay_time
) const
110 NetExpr
*rise_expr
, *fall_expr
, *decay_expr
;
111 delay_
.eval_delays(des
, scope
, rise_expr
, fall_expr
, decay_expr
);
113 if (rise_expr
== 0) {
119 if (NetEConst
*tmp
= dynamic_cast<NetEConst
*> (rise_expr
)) {
120 rise_time
= tmp
->value().as_ulong();
123 cerr
<< get_line() << ": error: Delay expressions must be "
124 << "constant here." << endl
;
125 cerr
<< get_line() << ": : Cannot calculate "
126 << *rise_expr
<< endl
;
131 if (NetEConst
*tmp
= dynamic_cast<NetEConst
*> (fall_expr
)) {
132 fall_time
= tmp
->value().as_ulong();
135 if (fall_expr
!= rise_expr
) {
136 cerr
<< get_line() << ": error: Delay expressions must be "
137 << "constant here." << endl
;
138 cerr
<< get_line() << ": : Cannot calculate "
139 << *rise_expr
<< endl
;
145 if (NetEConst
*tmp
= dynamic_cast<NetEConst
*> (decay_expr
)) {
146 decay_time
= tmp
->value().as_ulong();
149 cerr
<< get_line() << ": error: Delay expressions must be "
150 << "constant here." << endl
;
151 cerr
<< get_line() << ": : Cannot calculate "
152 << *rise_expr
<< endl
;
158 PGAssign::PGAssign(svector
<PExpr
*>*pins
)
159 : PGate(perm_string(), pins
)
161 assert(pins
->count() == 2);
164 PGAssign::PGAssign(svector
<PExpr
*>*pins
, svector
<PExpr
*>*dels
)
165 : PGate(perm_string(), pins
, dels
)
167 assert(pins
->count() == 2);
170 PGAssign::~PGAssign()
174 PGBuiltin::PGBuiltin(Type t
, perm_string name
,
175 svector
<PExpr
*>*pins
,
177 : PGate(name
, pins
, del
), type_(t
), msb_(0), lsb_(0)
181 PGBuiltin::PGBuiltin(Type t
, perm_string name
,
182 svector
<PExpr
*>*pins
,
184 : PGate(name
, pins
, del
), type_(t
), msb_(0), lsb_(0)
189 PGBuiltin::~PGBuiltin()
193 void PGBuiltin::set_range(PExpr
*msb
, PExpr
*lsb
)
202 PGModule::PGModule(perm_string type
, perm_string name
, svector
<PExpr
*>*pins
)
203 : PGate(name
, pins
), overrides_(0), pins_(0),
204 npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0)
209 PGModule::PGModule(perm_string type
, perm_string name
,
210 named
<PExpr
*>*pins
, unsigned npins
)
211 : PGate(name
, 0), overrides_(0), pins_(pins
),
212 npins_(npins
), parms_(0), nparms_(0), msb_(0), lsb_(0)
217 PGModule::~PGModule()
221 void PGModule::set_parameters(svector
<PExpr
*>*o
)
223 assert(overrides_
== 0);
227 void PGModule::set_parameters(named
<PExpr
*>*pa
, unsigned npa
)
230 assert(overrides_
== 0);
235 void PGModule::set_range(PExpr
*msb
, PExpr
*lsb
)
244 perm_string
PGModule::get_type()
251 * Revision 1.18 2006/01/03 05:22:14 steve
252 * Handle complex net node delays.
254 * Revision 1.17 2006/01/02 05:33:19 steve
255 * Node delays can be more general expressions in structural contexts.
257 * Revision 1.16 2004/02/18 17:11:54 steve
258 * Use perm_strings for named langiage items.
260 * Revision 1.15 2003/03/06 04:37:12 steve
261 * lex_strings.add module names earlier.
263 * Revision 1.14 2002/08/12 01:34:58 steve
264 * conditional ident string using autoconfig.
266 * Revision 1.13 2001/11/22 06:20:59 steve
267 * Use NetScope instead of string for scope path.
269 * Revision 1.12 2001/10/21 00:42:47 steve
270 * Module types in pform are char* instead of string.
272 * Revision 1.11 2001/10/19 01:55:32 steve
273 * Method to get the type_ member
275 * Revision 1.10 2001/07/25 03:10:48 steve
276 * Create a config.h.in file to hold all the config
277 * junk, and support gcc 3.0. (Stephan Boettcher)
279 * Revision 1.9 2000/05/06 15:41:56 steve
280 * Carry assignment strength to pform.
282 * Revision 1.8 2000/03/08 04:36:53 steve
283 * Redesign the implementation of scopes and parameters.
284 * I now generate the scopes and notice the parameters
285 * in a separate pass over the pform. Once the scopes
286 * are generated, I can process overrides and evalutate
287 * paremeters before elaboration begins.
289 * Revision 1.7 2000/02/23 02:56:53 steve
290 * Macintosh compilers do not support ident.
292 * Revision 1.6 2000/02/18 05:15:02 steve
293 * Catch module instantiation arrays.
295 * Revision 1.5 1999/09/14 01:50:35 steve
296 * Handle gates without delays.
298 * Revision 1.4 1999/09/04 19:11:46 steve
299 * Add support for delayed non-blocking assignments.
301 * Revision 1.3 1999/08/01 21:18:55 steve
302 * elaborate rise/fall/decay for continuous assign.
304 * Revision 1.2 1999/08/01 16:34:50 steve
305 * Parse and elaborate rise/fall/decay times
306 * for gates, and handle the rules for partial
309 * Revision 1.1 1999/02/15 02:06:15 steve
310 * Elaborate gate ranges.