Better organize the NetESFunc return type guesses.
This commit is contained in:
parent
06d5c8135c
commit
6d94f2ea55
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: dup_expr.cc,v 1.11 2003/03/10 23:40:53 steve Exp $"
|
#ident "$Id: dup_expr.cc,v 1.12 2003/03/15 04:46:28 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -53,7 +53,7 @@ NetESelect* NetESelect::dup_expr() const
|
||||||
|
|
||||||
NetESFunc* NetESFunc::dup_expr() const
|
NetESFunc* NetESFunc::dup_expr() const
|
||||||
{
|
{
|
||||||
NetESFunc*tmp = new NetESFunc(name_, expr_width(), nparms());
|
NetESFunc*tmp = new NetESFunc(name_, type_, expr_width(), nparms());
|
||||||
assert(tmp);
|
assert(tmp);
|
||||||
for (unsigned idx = 0 ; idx < nparms() ; idx += 1) {
|
for (unsigned idx = 0 ; idx < nparms() ; idx += 1) {
|
||||||
assert(tmp->parm(idx));
|
assert(tmp->parm(idx));
|
||||||
|
|
@ -109,6 +109,9 @@ NetEVariable* NetEVariable::dup_expr() const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: dup_expr.cc,v $
|
* $Log: dup_expr.cc,v $
|
||||||
|
* Revision 1.12 2003/03/15 04:46:28 steve
|
||||||
|
* Better organize the NetESFunc return type guesses.
|
||||||
|
*
|
||||||
* Revision 1.11 2003/03/10 23:40:53 steve
|
* Revision 1.11 2003/03/10 23:40:53 steve
|
||||||
* Keep parameter constants for the ivl_target API.
|
* Keep parameter constants for the ivl_target API.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
49
elab_expr.cc
49
elab_expr.cc
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: elab_expr.cc,v 1.71 2003/03/10 23:40:53 steve Exp $"
|
#ident "$Id: elab_expr.cc,v 1.72 2003/03/15 04:46:28 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -28,6 +28,30 @@
|
||||||
# include "netmisc.h"
|
# include "netmisc.h"
|
||||||
# include "util.h"
|
# include "util.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This table describes all the return values of various system
|
||||||
|
* functions. This table is used to elaborate expressions that are
|
||||||
|
* system function calls.
|
||||||
|
*/
|
||||||
|
struct sfunc_return_type {
|
||||||
|
const char* name;
|
||||||
|
NetExpr::TYPE type;
|
||||||
|
unsigned wid;
|
||||||
|
int signed_flag;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct sfunc_return_type sfunc_table[] = {
|
||||||
|
{ "$realtime", NetExpr::ET_REAL, 0, 0 },
|
||||||
|
{ "$bitstoreal", NetExpr::ET_REAL, 0, 0 },
|
||||||
|
{ "$itor", NetExpr::ET_REAL, 0, 0 },
|
||||||
|
{ "$realtobits", NetExpr::ET_VECTOR, 64, 0 },
|
||||||
|
{ "$time", NetExpr::ET_VECTOR, 64, 0 },
|
||||||
|
{ "$stime", NetExpr::ET_VECTOR, 32, 0 },
|
||||||
|
{ "$simtime", NetExpr::ET_VECTOR, 64, 0 },
|
||||||
|
{ 0, NetExpr::ET_VECTOR, 32, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
NetExpr* PExpr::elaborate_expr(Design*des, NetScope*, bool) const
|
NetExpr* PExpr::elaborate_expr(Design*des, NetScope*, bool) const
|
||||||
{
|
{
|
||||||
cerr << get_line() << ": internal error: I do not know how to elaborate"
|
cerr << get_line() << ": internal error: I do not know how to elaborate"
|
||||||
|
|
@ -211,16 +235,15 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope) const
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned wid = 32;
|
/* Get the return type of the system function by looking it up
|
||||||
|
in the sfunc_table. */
|
||||||
|
unsigned sfunc_idx;
|
||||||
|
for (sfunc_idx = 0 ; sfunc_table[sfunc_idx].name ; sfunc_idx += 1)
|
||||||
|
if (strcmp(path_.peek_name(0), sfunc_table[sfunc_idx].name) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
if (strcmp(path_.peek_name(0), "$realtobits") == 0)
|
NetExpr::TYPE sfunc_type = sfunc_table[sfunc_idx].type;
|
||||||
wid = 64;
|
unsigned wid = sfunc_table[sfunc_idx].wid;
|
||||||
if (strcmp(path_.peek_name(0), "$simtime") == 0)
|
|
||||||
wid = 64;
|
|
||||||
if (strcmp(path_.peek_name(0), "$stime") == 0)
|
|
||||||
wid = 32;
|
|
||||||
if (strcmp(path_.peek_name(0), "$time") == 0)
|
|
||||||
wid = 64;
|
|
||||||
|
|
||||||
|
|
||||||
/* How many parameters are there? The Verilog language allows
|
/* How many parameters are there? The Verilog language allows
|
||||||
|
|
@ -235,7 +258,8 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope) const
|
||||||
if ((nparms == 1) && (parms_[0] == 0))
|
if ((nparms == 1) && (parms_[0] == 0))
|
||||||
nparms = 0;
|
nparms = 0;
|
||||||
|
|
||||||
NetESFunc*fun = new NetESFunc(path_.peek_name(0), wid, nparms);
|
NetESFunc*fun = new NetESFunc(path_.peek_name(0), sfunc_type,
|
||||||
|
wid, nparms);
|
||||||
|
|
||||||
/* Now run through the expected parameters. If we find that
|
/* Now run through the expected parameters. If we find that
|
||||||
there are missing parameters, print an error message.
|
there are missing parameters, print an error message.
|
||||||
|
|
@ -914,6 +938,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: elab_expr.cc,v $
|
* $Log: elab_expr.cc,v $
|
||||||
|
* Revision 1.72 2003/03/15 04:46:28 steve
|
||||||
|
* Better organize the NetESFunc return type guesses.
|
||||||
|
*
|
||||||
* Revision 1.71 2003/03/10 23:40:53 steve
|
* Revision 1.71 2003/03/10 23:40:53 steve
|
||||||
* Keep parameter constants for the ivl_target API.
|
* Keep parameter constants for the ivl_target API.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
15
net_expr.cc
15
net_expr.cc
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: net_expr.cc,v 1.14 2003/03/01 06:25:30 steve Exp $"
|
#ident "$Id: net_expr.cc,v 1.15 2003/03/15 04:46:29 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -350,8 +350,9 @@ bool NetESelect::set_width(unsigned w)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetESFunc::NetESFunc(const char*n, unsigned width, unsigned np)
|
NetESFunc::NetESFunc(const char*n, NetExpr::TYPE t,
|
||||||
: name_(0)
|
unsigned width, unsigned np)
|
||||||
|
: name_(0), type_(t)
|
||||||
{
|
{
|
||||||
name_ = lex_strings.add(n);
|
name_ = lex_strings.add(n);
|
||||||
expr_width(width);
|
expr_width(width);
|
||||||
|
|
@ -402,14 +403,14 @@ NetExpr* NetESFunc::parm(unsigned idx)
|
||||||
|
|
||||||
NetExpr::TYPE NetESFunc::expr_type() const
|
NetExpr::TYPE NetESFunc::expr_type() const
|
||||||
{
|
{
|
||||||
if (strcmp(name_,"$realtime") == 0)
|
return type_;
|
||||||
return ET_REAL;
|
|
||||||
|
|
||||||
return ET_VECTOR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: net_expr.cc,v $
|
* $Log: net_expr.cc,v $
|
||||||
|
* Revision 1.15 2003/03/15 04:46:29 steve
|
||||||
|
* Better organize the NetESFunc return type guesses.
|
||||||
|
*
|
||||||
* Revision 1.14 2003/03/01 06:25:30 steve
|
* Revision 1.14 2003/03/01 06:25:30 steve
|
||||||
* Add the lex_strings string handler, and put
|
* Add the lex_strings string handler, and put
|
||||||
* scope names and system task/function names
|
* scope names and system task/function names
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: netlist.h,v 1.280 2003/03/10 23:40:53 steve Exp $"
|
#ident "$Id: netlist.h,v 1.281 2003/03/15 04:46:29 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -2663,7 +2663,8 @@ class NetEScope : public NetExpr {
|
||||||
class NetESFunc : public NetExpr {
|
class NetESFunc : public NetExpr {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetESFunc(const char*name, unsigned width, unsigned nprms);
|
NetESFunc(const char*name, NetExpr::TYPE t,
|
||||||
|
unsigned width, unsigned nprms);
|
||||||
~NetESFunc();
|
~NetESFunc();
|
||||||
|
|
||||||
const char* name() const;
|
const char* name() const;
|
||||||
|
|
@ -2683,6 +2684,7 @@ class NetESFunc : public NetExpr {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char* name_;
|
const char* name_;
|
||||||
|
TYPE type_;
|
||||||
unsigned nparms_;
|
unsigned nparms_;
|
||||||
NetExpr**parms_;
|
NetExpr**parms_;
|
||||||
|
|
||||||
|
|
@ -3235,6 +3237,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: netlist.h,v $
|
* $Log: netlist.h,v $
|
||||||
|
* Revision 1.281 2003/03/15 04:46:29 steve
|
||||||
|
* Better organize the NetESFunc return type guesses.
|
||||||
|
*
|
||||||
* Revision 1.280 2003/03/10 23:40:53 steve
|
* Revision 1.280 2003/03/10 23:40:53 steve
|
||||||
* Keep parameter constants for the ivl_target API.
|
* Keep parameter constants for the ivl_target API.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue