Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Better organize the NetESFunc return type guesses.

  • Loading branch information...
commit 6d94f2ea5537a13fefa7a4efdd849655fc81a9ec 1 parent 06d5c81
steve authored
Showing with 58 additions and 22 deletions.
  1. +5 −2 dup_expr.cc
  2. +38 −11 elab_expr.cc
  3. +8 −7 net_expr.cc
  4. +7 −2 netlist.h
View
7 dup_expr.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#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
# include "config.h"
@@ -53,7 +53,7 @@ NetESelect* NetESelect::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);
for (unsigned idx = 0 ; idx < nparms() ; idx += 1) {
assert(tmp->parm(idx));
@@ -109,6 +109,9 @@ NetEVariable* NetEVariable::dup_expr() const
/*
* $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
* Keep parameter constants for the ivl_target API.
*
View
49 elab_expr.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#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
# include "config.h"
@@ -28,6 +28,30 @@
# include "netmisc.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
{
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;
}
- 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)
- wid = 64;
- 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;
+ NetExpr::TYPE sfunc_type = sfunc_table[sfunc_idx].type;
+ unsigned wid = sfunc_table[sfunc_idx].wid;
/* 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))
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
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 $
+ * 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
* Keep parameter constants for the ivl_target API.
*
View
15 net_expr.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#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
# include "config.h"
@@ -350,8 +350,9 @@ bool NetESelect::set_width(unsigned w)
return false;
}
-NetESFunc::NetESFunc(const char*n, unsigned width, unsigned np)
-: name_(0)
+NetESFunc::NetESFunc(const char*n, NetExpr::TYPE t,
+ unsigned width, unsigned np)
+: name_(0), type_(t)
{
name_ = lex_strings.add(n);
expr_width(width);
@@ -402,14 +403,14 @@ NetExpr* NetESFunc::parm(unsigned idx)
NetExpr::TYPE NetESFunc::expr_type() const
{
- if (strcmp(name_,"$realtime") == 0)
- return ET_REAL;
-
- return ET_VECTOR;
+ return type_;
}
/*
* $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
* Add the lex_strings string handler, and put
* scope names and system task/function names
View
9 netlist.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#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
/*
@@ -2663,7 +2663,8 @@ class NetEScope : public NetExpr {
class NetESFunc : public NetExpr {
public:
- NetESFunc(const char*name, unsigned width, unsigned nprms);
+ NetESFunc(const char*name, NetExpr::TYPE t,
+ unsigned width, unsigned nprms);
~NetESFunc();
const char* name() const;
@@ -2683,6 +2684,7 @@ class NetESFunc : public NetExpr {
private:
const char* name_;
+ TYPE type_;
unsigned nparms_;
NetExpr**parms_;
@@ -3235,6 +3237,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $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
* Keep parameter constants for the ivl_target API.
*
Please sign in to comment.
Something went wrong with that request. Please try again.