2 * Copyright (c) 1999-2007 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
27 PGate::PGate(perm_string name
,
29 const svector
<PExpr
*>*del
)
30 : name_(name
), pins_(pins
)
32 if (del
) delay_
.set_delays(del
);
37 PGate::PGate(perm_string name
,
40 : name_(name
), pins_(pins
)
42 if (del
) delay_
.set_delay(del
);
47 PGate::PGate(perm_string name
, svector
<PExpr
*>*pins
)
48 : name_(name
), pins_(pins
)
58 PGate::strength_t
PGate::strength0() const
63 void PGate::strength0(PGate::strength_t s
)
68 PGate::strength_t
PGate::strength1() const
73 void PGate::strength1(PGate::strength_t s
)
78 void PGate::elaborate_scope(Design
*, NetScope
*) const
83 * This method is used during elaboration to calculate the
84 * rise/fall/decay times for the gate. These values were set in pform
85 * by the constructor, so here I evaluate the expression in the given
86 * design context and save the calculated delays into the output
87 * parameters. This method understands how to handle the different
88 * numbers of expressions.
91 void PGate::eval_delays(Design
*des
, NetScope
*scope
,
95 bool as_net_flag
) const
97 delay_
.eval_delays(des
, scope
,
98 rise_expr
, fall_expr
, decay_expr
,
102 void PGate::eval_delays(Design
*des
, NetScope
*scope
,
103 unsigned long&rise_time
,
104 unsigned long&fall_time
,
105 unsigned long&decay_time
) const
107 NetExpr
*rise_expr
, *fall_expr
, *decay_expr
;
108 delay_
.eval_delays(des
, scope
, rise_expr
, fall_expr
, decay_expr
);
110 if (rise_expr
== 0) {
116 if (NetEConst
*tmp
= dynamic_cast<NetEConst
*> (rise_expr
)) {
117 rise_time
= tmp
->value().as_ulong();
120 cerr
<< get_fileline() << ": error: Delay expressions must be "
121 << "constant here." << endl
;
122 cerr
<< get_fileline() << ": : Cannot calculate "
123 << *rise_expr
<< endl
;
128 if (NetEConst
*tmp
= dynamic_cast<NetEConst
*> (fall_expr
)) {
129 fall_time
= tmp
->value().as_ulong();
132 if (fall_expr
!= rise_expr
) {
133 cerr
<< get_fileline() << ": error: Delay expressions must be "
134 << "constant here." << endl
;
135 cerr
<< get_fileline() << ": : Cannot calculate "
136 << *rise_expr
<< endl
;
142 if (NetEConst
*tmp
= dynamic_cast<NetEConst
*> (decay_expr
)) {
143 decay_time
= tmp
->value().as_ulong();
146 cerr
<< get_fileline() << ": error: Delay expressions must be "
147 << "constant here." << endl
;
148 cerr
<< get_fileline() << ": : Cannot calculate "
149 << *rise_expr
<< endl
;
155 PGAssign::PGAssign(svector
<PExpr
*>*pins
)
156 : PGate(perm_string(), pins
)
158 assert(pins
->count() == 2);
161 PGAssign::PGAssign(svector
<PExpr
*>*pins
, svector
<PExpr
*>*dels
)
162 : PGate(perm_string(), pins
, dels
)
164 assert(pins
->count() == 2);
167 PGAssign::~PGAssign()
171 PGBuiltin::PGBuiltin(Type t
, perm_string name
,
172 svector
<PExpr
*>*pins
,
174 : PGate(name
, pins
, del
), type_(t
), msb_(0), lsb_(0)
178 PGBuiltin::PGBuiltin(Type t
, perm_string name
,
179 svector
<PExpr
*>*pins
,
181 : PGate(name
, pins
, del
), type_(t
), msb_(0), lsb_(0)
186 PGBuiltin::~PGBuiltin()
190 void PGBuiltin::set_range(PExpr
*msb
, PExpr
*lsb
)
199 PGModule::PGModule(perm_string type
, perm_string name
, svector
<PExpr
*>*pins
)
200 : PGate(name
, pins
), overrides_(0), pins_(0),
201 npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0)
206 PGModule::PGModule(perm_string type
, perm_string name
,
207 named
<PExpr
*>*pins
, unsigned npins
)
208 : PGate(name
, 0), overrides_(0), pins_(pins
),
209 npins_(npins
), parms_(0), nparms_(0), msb_(0), lsb_(0)
214 PGModule::~PGModule()
218 void PGModule::set_parameters(svector
<PExpr
*>*o
)
220 assert(overrides_
== 0);
224 void PGModule::set_parameters(named
<PExpr
*>*pa
, unsigned npa
)
227 assert(overrides_
== 0);
232 void PGModule::set_range(PExpr
*msb
, PExpr
*lsb
)
241 perm_string
PGModule::get_type()