1999-02-15 03:06:15 +01:00
|
|
|
/*
|
2004-02-18 18:11:54 +01:00
|
|
|
* Copyright (c) 1999-2004 Stephen Williams (steve@icarus.com)
|
1999-02-15 03:06:15 +01:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
2002-08-12 03:34:58 +02:00
|
|
|
#ifdef HAVE_CVS_IDENT
|
2006-01-03 06:22:14 +01:00
|
|
|
#ident "$Id: PGate.cc,v 1.18 2006/01/03 05:22:14 steve Exp $"
|
1999-02-15 03:06:15 +01:00
|
|
|
#endif
|
|
|
|
|
|
2001-07-25 05:10:48 +02:00
|
|
|
# include "config.h"
|
|
|
|
|
|
1999-02-15 03:06:15 +01:00
|
|
|
# include "PGate.h"
|
1999-08-01 18:34:50 +02:00
|
|
|
# include "PExpr.h"
|
1999-08-01 23:18:55 +02:00
|
|
|
# include "verinum.h"
|
1999-08-01 18:34:50 +02:00
|
|
|
# include <assert.h>
|
|
|
|
|
|
2004-02-18 18:11:54 +01:00
|
|
|
PGate::PGate(perm_string name,
|
1999-08-01 18:34:50 +02:00
|
|
|
svector<PExpr*>*pins,
|
|
|
|
|
const svector<PExpr*>*del)
|
|
|
|
|
: name_(name), pins_(pins)
|
|
|
|
|
{
|
1999-09-14 03:50:35 +02:00
|
|
|
if (del) delay_.set_delays(del);
|
2000-05-06 17:41:56 +02:00
|
|
|
str0_ = STRONG;
|
|
|
|
|
str1_ = STRONG;
|
1999-08-01 18:34:50 +02:00
|
|
|
}
|
|
|
|
|
|
2004-02-18 18:11:54 +01:00
|
|
|
PGate::PGate(perm_string name,
|
1999-08-01 18:34:50 +02:00
|
|
|
svector<PExpr*>*pins,
|
|
|
|
|
PExpr*del)
|
|
|
|
|
: name_(name), pins_(pins)
|
|
|
|
|
{
|
1999-09-14 03:50:35 +02:00
|
|
|
if (del) delay_.set_delay(del);
|
2000-05-06 17:41:56 +02:00
|
|
|
str0_ = STRONG;
|
|
|
|
|
str1_ = STRONG;
|
1999-08-01 18:34:50 +02:00
|
|
|
}
|
|
|
|
|
|
2004-02-18 18:11:54 +01:00
|
|
|
PGate::PGate(perm_string name, svector<PExpr*>*pins)
|
1999-08-01 18:34:50 +02:00
|
|
|
: name_(name), pins_(pins)
|
|
|
|
|
{
|
2000-05-06 17:41:56 +02:00
|
|
|
str0_ = STRONG;
|
|
|
|
|
str1_ = STRONG;
|
1999-08-01 18:34:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PGate::~PGate()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-06 17:41:56 +02:00
|
|
|
PGate::strength_t PGate::strength0() const
|
|
|
|
|
{
|
|
|
|
|
return str0_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PGate::strength0(PGate::strength_t s)
|
|
|
|
|
{
|
|
|
|
|
str0_ = s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PGate::strength_t PGate::strength1() const
|
|
|
|
|
{
|
|
|
|
|
return str1_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PGate::strength1(PGate::strength_t s)
|
|
|
|
|
{
|
|
|
|
|
str1_ = s;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 05:36:53 +01:00
|
|
|
void PGate::elaborate_scope(Design*, NetScope*) const
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-08-01 23:18:55 +02:00
|
|
|
/*
|
|
|
|
|
* This method is used during elaboration to calculate the
|
|
|
|
|
* rise/fall/decay times for the gate. These values were set in pform
|
|
|
|
|
* by the constructor, so here I evaluate the expression in the given
|
|
|
|
|
* design context and save the calculated delays into the output
|
|
|
|
|
* parameters. This method understands how to handle the different
|
|
|
|
|
* numbers of expressions.
|
|
|
|
|
*/
|
2006-01-02 06:33:19 +01:00
|
|
|
|
|
|
|
|
void PGate::eval_delays(Design*des, NetScope*scope,
|
|
|
|
|
NetExpr*&rise_expr,
|
|
|
|
|
NetExpr*&fall_expr,
|
2006-01-03 06:22:14 +01:00
|
|
|
NetExpr*&decay_expr,
|
|
|
|
|
bool as_net_flag) const
|
2006-01-02 06:33:19 +01:00
|
|
|
{
|
2006-01-03 06:22:14 +01:00
|
|
|
delay_.eval_delays(des, scope,
|
|
|
|
|
rise_expr, fall_expr, decay_expr,
|
|
|
|
|
as_net_flag);
|
2006-01-02 06:33:19 +01:00
|
|
|
}
|
|
|
|
|
|
2001-11-22 07:20:59 +01:00
|
|
|
void PGate::eval_delays(Design*des, NetScope*scope,
|
1999-08-01 23:18:55 +02:00
|
|
|
unsigned long&rise_time,
|
|
|
|
|
unsigned long&fall_time,
|
|
|
|
|
unsigned long&decay_time) const
|
1999-08-01 18:34:50 +02:00
|
|
|
{
|
2006-01-02 06:33:19 +01:00
|
|
|
NetExpr*rise_expr, *fall_expr, *decay_expr;
|
|
|
|
|
delay_.eval_delays(des, scope, rise_expr, fall_expr, decay_expr);
|
|
|
|
|
|
|
|
|
|
if (rise_expr == 0) {
|
|
|
|
|
rise_time = 0;
|
|
|
|
|
fall_time = 0;
|
|
|
|
|
decay_time = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NetEConst*tmp = dynamic_cast<NetEConst*> (rise_expr)) {
|
|
|
|
|
rise_time = tmp->value().as_ulong();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
cerr << get_line() << ": error: Delay expressions must be "
|
|
|
|
|
<< "constant here." << endl;
|
|
|
|
|
cerr << get_line() << ": : Cannot calculate "
|
|
|
|
|
<< *rise_expr << endl;
|
|
|
|
|
des->errors += 1;
|
|
|
|
|
rise_time = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NetEConst*tmp = dynamic_cast<NetEConst*> (fall_expr)) {
|
|
|
|
|
fall_time = tmp->value().as_ulong();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (fall_expr != rise_expr) {
|
|
|
|
|
cerr << get_line() << ": error: Delay expressions must be "
|
|
|
|
|
<< "constant here." << endl;
|
|
|
|
|
cerr << get_line() << ": : Cannot calculate "
|
|
|
|
|
<< *rise_expr << endl;
|
|
|
|
|
}
|
|
|
|
|
des->errors += 1;
|
|
|
|
|
fall_time = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NetEConst*tmp = dynamic_cast<NetEConst*> (decay_expr)) {
|
|
|
|
|
decay_time = tmp->value().as_ulong();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
cerr << get_line() << ": error: Delay expressions must be "
|
|
|
|
|
<< "constant here." << endl;
|
|
|
|
|
cerr << get_line() << ": : Cannot calculate "
|
|
|
|
|
<< *rise_expr << endl;
|
|
|
|
|
des->errors += 1;
|
|
|
|
|
decay_time = 0;
|
|
|
|
|
}
|
1999-08-01 18:34:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PGAssign::PGAssign(svector<PExpr*>*pins)
|
2004-02-18 18:11:54 +01:00
|
|
|
: PGate(perm_string(), pins)
|
1999-08-01 18:34:50 +02:00
|
|
|
{
|
|
|
|
|
assert(pins->count() == 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PGAssign::PGAssign(svector<PExpr*>*pins, svector<PExpr*>*dels)
|
2004-02-18 18:11:54 +01:00
|
|
|
: PGate(perm_string(), pins, dels)
|
1999-08-01 18:34:50 +02:00
|
|
|
{
|
|
|
|
|
assert(pins->count() == 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PGAssign::~PGAssign()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-18 18:11:54 +01:00
|
|
|
PGBuiltin::PGBuiltin(Type t, perm_string name,
|
1999-08-01 18:34:50 +02:00
|
|
|
svector<PExpr*>*pins,
|
|
|
|
|
svector<PExpr*>*del)
|
|
|
|
|
: PGate(name, pins, del), type_(t), msb_(0), lsb_(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-18 18:11:54 +01:00
|
|
|
PGBuiltin::PGBuiltin(Type t, perm_string name,
|
1999-08-01 18:34:50 +02:00
|
|
|
svector<PExpr*>*pins,
|
|
|
|
|
PExpr*del)
|
|
|
|
|
: PGate(name, pins, del), type_(t), msb_(0), lsb_(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PGBuiltin::~PGBuiltin()
|
|
|
|
|
{
|
|
|
|
|
}
|
1999-02-15 03:06:15 +01:00
|
|
|
|
|
|
|
|
void PGBuiltin::set_range(PExpr*msb, PExpr*lsb)
|
|
|
|
|
{
|
|
|
|
|
assert(msb_ == 0);
|
|
|
|
|
assert(lsb_ == 0);
|
|
|
|
|
|
|
|
|
|
msb_ = msb;
|
|
|
|
|
lsb_ = lsb;
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-18 18:11:54 +01:00
|
|
|
PGModule::PGModule(perm_string type, perm_string name, svector<PExpr*>*pins)
|
2001-10-21 02:42:47 +02:00
|
|
|
: PGate(name, pins), overrides_(0), pins_(0),
|
2000-02-18 06:15:02 +01:00
|
|
|
npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0)
|
|
|
|
|
{
|
2003-03-06 05:37:12 +01:00
|
|
|
type_ = type;
|
2000-02-18 06:15:02 +01:00
|
|
|
}
|
|
|
|
|
|
2004-02-18 18:11:54 +01:00
|
|
|
PGModule::PGModule(perm_string type, perm_string name,
|
2000-02-18 06:15:02 +01:00
|
|
|
named<PExpr*>*pins, unsigned npins)
|
2001-10-21 02:42:47 +02:00
|
|
|
: PGate(name, 0), overrides_(0), pins_(pins),
|
2000-02-18 06:15:02 +01:00
|
|
|
npins_(npins), parms_(0), nparms_(0), msb_(0), lsb_(0)
|
|
|
|
|
{
|
2003-03-06 05:37:12 +01:00
|
|
|
type_ = type;
|
2001-10-21 02:42:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PGModule::~PGModule()
|
|
|
|
|
{
|
2000-02-18 06:15:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PGModule::set_parameters(svector<PExpr*>*o)
|
|
|
|
|
{
|
|
|
|
|
assert(overrides_ == 0);
|
|
|
|
|
overrides_ = o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PGModule::set_parameters(named<PExpr*>*pa, unsigned npa)
|
|
|
|
|
{
|
|
|
|
|
assert(parms_ == 0);
|
|
|
|
|
assert(overrides_ == 0);
|
|
|
|
|
parms_ = pa;
|
|
|
|
|
nparms_ = npa;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PGModule::set_range(PExpr*msb, PExpr*lsb)
|
|
|
|
|
{
|
|
|
|
|
assert(msb_ == 0);
|
|
|
|
|
assert(lsb_ == 0);
|
|
|
|
|
|
|
|
|
|
msb_ = msb;
|
|
|
|
|
lsb_ = lsb;
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-18 18:11:54 +01:00
|
|
|
perm_string PGModule::get_type()
|
2001-10-19 03:55:32 +02:00
|
|
|
{
|
|
|
|
|
return type_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-02-15 03:06:15 +01:00
|
|
|
/*
|
|
|
|
|
* $Log: PGate.cc,v $
|
2006-01-03 06:22:14 +01:00
|
|
|
* Revision 1.18 2006/01/03 05:22:14 steve
|
|
|
|
|
* Handle complex net node delays.
|
|
|
|
|
*
|
2006-01-02 06:33:19 +01:00
|
|
|
* Revision 1.17 2006/01/02 05:33:19 steve
|
|
|
|
|
* Node delays can be more general expressions in structural contexts.
|
|
|
|
|
*
|
2004-02-18 18:11:54 +01:00
|
|
|
* Revision 1.16 2004/02/18 17:11:54 steve
|
|
|
|
|
* Use perm_strings for named langiage items.
|
|
|
|
|
*
|
2003-03-06 05:37:12 +01:00
|
|
|
* Revision 1.15 2003/03/06 04:37:12 steve
|
|
|
|
|
* lex_strings.add module names earlier.
|
|
|
|
|
*
|
2002-08-12 03:34:58 +02:00
|
|
|
* Revision 1.14 2002/08/12 01:34:58 steve
|
|
|
|
|
* conditional ident string using autoconfig.
|
|
|
|
|
*
|
2001-11-22 07:20:59 +01:00
|
|
|
* Revision 1.13 2001/11/22 06:20:59 steve
|
|
|
|
|
* Use NetScope instead of string for scope path.
|
|
|
|
|
*
|
2001-10-21 02:42:47 +02:00
|
|
|
* Revision 1.12 2001/10/21 00:42:47 steve
|
|
|
|
|
* Module types in pform are char* instead of string.
|
|
|
|
|
*
|
2001-10-19 03:55:32 +02:00
|
|
|
* Revision 1.11 2001/10/19 01:55:32 steve
|
|
|
|
|
* Method to get the type_ member
|
|
|
|
|
*
|
2001-07-25 05:10:48 +02:00
|
|
|
* Revision 1.10 2001/07/25 03:10:48 steve
|
|
|
|
|
* Create a config.h.in file to hold all the config
|
|
|
|
|
* junk, and support gcc 3.0. (Stephan Boettcher)
|
|
|
|
|
*
|
2000-05-06 17:41:56 +02:00
|
|
|
* Revision 1.9 2000/05/06 15:41:56 steve
|
|
|
|
|
* Carry assignment strength to pform.
|
|
|
|
|
*
|
2000-03-08 05:36:53 +01:00
|
|
|
* Revision 1.8 2000/03/08 04:36:53 steve
|
|
|
|
|
* Redesign the implementation of scopes and parameters.
|
|
|
|
|
* I now generate the scopes and notice the parameters
|
|
|
|
|
* in a separate pass over the pform. Once the scopes
|
|
|
|
|
* are generated, I can process overrides and evalutate
|
|
|
|
|
* paremeters before elaboration begins.
|
|
|
|
|
*
|
2000-02-23 03:56:53 +01:00
|
|
|
* Revision 1.7 2000/02/23 02:56:53 steve
|
|
|
|
|
* Macintosh compilers do not support ident.
|
|
|
|
|
*
|
2000-02-18 06:15:02 +01:00
|
|
|
* Revision 1.6 2000/02/18 05:15:02 steve
|
|
|
|
|
* Catch module instantiation arrays.
|
|
|
|
|
*
|
1999-09-14 03:50:35 +02:00
|
|
|
* Revision 1.5 1999/09/14 01:50:35 steve
|
|
|
|
|
* Handle gates without delays.
|
|
|
|
|
*
|
1999-09-04 21:11:45 +02:00
|
|
|
* Revision 1.4 1999/09/04 19:11:46 steve
|
|
|
|
|
* Add support for delayed non-blocking assignments.
|
|
|
|
|
*
|
1999-08-01 23:18:55 +02:00
|
|
|
* Revision 1.3 1999/08/01 21:18:55 steve
|
|
|
|
|
* elaborate rise/fall/decay for continuous assign.
|
|
|
|
|
*
|
1999-08-01 18:34:50 +02:00
|
|
|
* Revision 1.2 1999/08/01 16:34:50 steve
|
|
|
|
|
* Parse and elaborate rise/fall/decay times
|
|
|
|
|
* for gates, and handle the rules for partial
|
|
|
|
|
* lists of times.
|
|
|
|
|
*
|
1999-02-15 03:06:15 +01:00
|
|
|
* Revision 1.1 1999/02/15 02:06:15 steve
|
|
|
|
|
* Elaborate gate ranges.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|