Support more real arithmetic in delay constants.

This commit is contained in:
steve 2001-11-06 06:11:55 +00:00
parent 1ff36dc892
commit 9572ddd7e8
7 changed files with 105 additions and 10 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: PExpr.cc,v 1.24 2001/07/25 03:10:48 steve Exp $"
#ident "$Id: PExpr.cc,v 1.25 2001/11/06 06:11:55 steve Exp $"
#endif
# include "config.h"
@ -65,6 +65,15 @@ NetNet* PExpr::elaborate_lnet(Design*des, const string&path) const
return 0;
}
PEBinary::PEBinary(char op, PExpr*l, PExpr*r)
: op_(op), left_(l), right_(r)
{
}
PEBinary::~PEBinary()
{
}
bool PEBinary::is_constant(Module*mod) const
{
return left_->is_constant(mod) && right_->is_constant(mod);
@ -255,6 +264,9 @@ bool PEUnary::is_constant(Module*m) const
/*
* $Log: PExpr.cc,v $
* Revision 1.25 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*
* Revision 1.24 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)

12
PExpr.h
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: PExpr.h,v 1.48 2001/01/14 23:04:55 steve Exp $"
#ident "$Id: PExpr.h,v 1.49 2001/11/06 06:11:55 steve Exp $"
#endif
# include <string>
@ -234,6 +234,7 @@ class PEIdent : public PExpr {
virtual bool is_constant(Module*) const;
verinum* eval_const(const Design*des, const string&path) const;
verireal*eval_rconst(const Design*des, const NetScope*sc) const;
string name() const;
@ -275,6 +276,7 @@ class PENumber : public PExpr {
virtual NetEConst*elaborate_expr(Design*des, NetScope*) const;
virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual verinum* eval_const(const Design*des, const string&path) const;
virtual verireal*eval_rconst(const Design*, const NetScope*) const;
virtual bool is_the_same(const PExpr*that) const;
virtual bool is_constant(Module*) const;
@ -328,8 +330,8 @@ class PEUnary : public PExpr {
class PEBinary : public PExpr {
public:
explicit PEBinary(char op, PExpr*l, PExpr*r)
: op_(op), left_(l), right_(r) { }
explicit PEBinary(char op, PExpr*l, PExpr*r);
~PEBinary();
virtual bool is_constant(Module*) const;
@ -344,6 +346,7 @@ class PEBinary : public PExpr {
virtual NetEBinary*elaborate_expr(Design*des, NetScope*) const;
virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual verinum* eval_const(const Design*des, const string&path) const;
virtual verireal*eval_rconst(const Design*des, const NetScope*sc) const;
private:
char op_;
@ -446,6 +449,9 @@ class PECallFunction : public PExpr {
/*
* $Log: PExpr.h,v $
* Revision 1.49 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*
* Revision 1.48 2001/01/14 23:04:55 steve
* Generalize the evaluation of floating point delays, and
* get it working with delay assignment statements.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: eval.cc,v 1.21 2001/07/25 03:10:49 steve Exp $"
#ident "$Id: eval.cc,v 1.22 2001/11/06 06:11:55 steve Exp $"
#endif
# include "config.h"
@ -42,7 +42,6 @@ verinum* PEBinary::eval_const(const Design*des, const string&path) const
delete l;
return 0;
}
verinum*res;
switch (op_) {
@ -198,6 +197,9 @@ verinum* PEUnary::eval_const(const Design*des, const string&path) const
/*
* $Log: eval.cc,v $
* Revision 1.22 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*
* Revision 1.21 2001/07/25 03:10:49 steve
* Create a config.h.in file to hold all the config
* junk, and support gcc 3.0. (Stephan Boettcher)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: eval_rconst.cc,v 1.2 2001/07/25 03:10:49 steve Exp $"
#ident "$Id: eval_rconst.cc,v 1.3 2001/11/06 06:11:55 steve Exp $"
#endif
# include "config.h"
@ -36,8 +36,54 @@ verireal* PEFNumber::eval_rconst(const Design*, const NetScope*) const
return res;
}
verireal* PENumber::eval_rconst(const Design*, const NetScope*) const
{
verireal*res = new verireal(value_->as_long());
return res;
}
verireal* PEBinary::eval_rconst(const Design*des, const NetScope*scope) const
{
verireal*lef = left_->eval_rconst(des, scope);
verireal*rig = right_->eval_rconst(des, scope);
verireal*res = 0;
switch (op_) {
case '*':
if (lef == 0)
break;
if (rig == 0)
break;
res = new verireal;
*res = (*lef) * (*rig);
break;
default:
break;
}
delete lef;
delete rig;
return res;
}
verireal* PEIdent::eval_rconst(const Design*des, const NetScope*scope) const
{
verinum* val = eval_const(des, scope->name());
if (val == 0)
return 0;
verireal*res = new verireal(val->as_long());
delete val;
return res;
}
/*
* $Log: eval_rconst.cc,v $
* Revision 1.3 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*
* Revision 1.2 2001/07/25 03:10:49 steve
* Create a config.h.in file to hold all the config
* junk, and support gcc 3.0. (Stephan Boettcher)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: verinum.cc,v 1.27 2001/07/25 03:10:50 steve Exp $"
#ident "$Id: verinum.cc,v 1.28 2001/11/06 06:11:55 steve Exp $"
#endif
# include "config.h"
@ -117,6 +117,8 @@ verinum::verinum(long that)
tmp /= 2;
}
nbits_ += 1;
bits_ = new V[nbits_];
for (unsigned idx = 0 ; idx < nbits_ ; idx += 1) {
bits_[idx] = (that & 1)? V1 : V0;
@ -768,6 +770,9 @@ verinum::V operator & (verinum::V l, verinum::V r)
/*
* $Log: verinum.cc,v $
* Revision 1.28 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*
* Revision 1.27 2001/07/25 03:10:50 steve
* Create a config.h.in file to hold all the config
* junk, and support gcc 3.0. (Stephan Boettcher)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: verireal.cc,v 1.5 2001/07/25 03:10:50 steve Exp $"
#ident "$Id: verireal.cc,v 1.6 2001/11/06 06:11:55 steve Exp $"
#endif
# include "config.h"
@ -88,6 +88,12 @@ verireal::verireal(const char*txt)
assert(*ptr == 0);
}
verireal::verireal(long val)
{
sign_ = val < 0;
mant_ = sign_? -val : +val;
exp10_ = 0;
}
verireal::~verireal()
{
@ -118,6 +124,15 @@ long verireal::as_long(int shift) const
return val;
}
verireal operator* (const verireal&l, const verireal&r)
{
verireal res;
res.sign_ = l.sign_ != r.sign_;
res.mant_ = l.mant_ * r.mant_;
res.exp10_= l.exp10_ + r.exp10_;
return res;
}
ostream& operator<< (ostream&out, const verireal&v)
{
out << (v.sign_? "-" : "+") << v.mant_ << "e" << v.exp10_;
@ -126,6 +141,9 @@ ostream& operator<< (ostream&out, const verireal&v)
/*
* $Log: verireal.cc,v $
* Revision 1.6 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*
* Revision 1.5 2001/07/25 03:10:50 steve
* Create a config.h.in file to hold all the config
* junk, and support gcc 3.0. (Stephan Boettcher)

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: verireal.h,v 1.4 2001/01/16 02:44:18 steve Exp $"
#ident "$Id: verireal.h,v 1.5 2001/11/06 06:11:55 steve Exp $"
#endif
#ifdef HAVE_IOSFWD
@ -38,10 +38,12 @@ class ostream;
class verireal {
friend ostream& operator<< (ostream&, const verireal&);
friend verireal operator* (const verireal&, const verireal&);
public:
explicit verireal();
explicit verireal(const char*text);
explicit verireal(long val);
~verireal();
/* Return the value of the floating point number as an
@ -59,9 +61,13 @@ class verireal {
};
extern ostream& operator<< (ostream&, const verireal&);
extern verireal operator* (const verireal&, const verireal&);
/*
* $Log: verireal.h,v $
* Revision 1.5 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*
* Revision 1.4 2001/01/16 02:44:18 steve
* Use the iosfwd header if available.
*