Permalink
Browse files

Rework expression parsing and elaboration to

 accommodate real/realtime values and expressions.
  • Loading branch information...
1 parent 1a9ab8e commit 46253ed87370c9e2fe9896ac6b01a9cae2e3589a steve committed Jan 26, 2003
Showing with 1,546 additions and 749 deletions.
  1. +3 −3 Makefile.in
  2. +9 −1 Module.h
  3. +46 −0 PData.cc
  4. +63 −0 PData.h
  5. +5 −2 PWire.h
  6. +22 −1 design_dump.cc
  7. +11 −1 dup_expr.cc
  8. +23 −6 elab_expr.cc
  9. +19 −5 elab_lval.cc
  10. +21 −1 elab_scope.cc
  11. +18 −20 elaborate.cc
  12. +18 −1 emit.cc
  13. +13 −1 expr_synth.cc
  14. +54 −4 ivl_target.h
  15. +3 −2 lexor.lex
  16. +20 −3 net_assign.cc
  17. +29 −1 net_design.cc
  18. +109 −1 net_expr.cc
  19. +15 −1 net_nex_input.cc
  20. +23 −1 net_scope.cc
  21. +5 −41 netlist.cc
  22. +110 −1 netlist.h
  23. +9 −1 pad_to_width.cc
  24. +3 −5 parse.y
  25. +26 −1 pform.cc
  26. +10 −1 pform.h
  27. +13 −231 pform_dump.cc
  28. +62 −274 t-dll-api.cc
  29. +67 −3 t-dll-expr.cc
  30. +10 −1 t-dll-proc.cc
  31. +46 −2 t-dll.cc
  32. +32 −2 t-dll.h
  33. +24 −2 target.cc
  34. +11 −2 target.h
  35. +59 −5 tgt-stub/stub.c
  36. +2 −2 tgt-vvp/Makefile.in
  37. +137 −72 tgt-vvp/eval_expr.c
  38. +202 −0 tgt-vvp/eval_real.c
  39. +20 −33 tgt-vvp/vvp_priv.h
  40. +129 −11 tgt-vvp/vvp_process.c
  41. +22 −1 tgt-vvp/vvp_scope.c
  42. +11 −1 verireal.cc
  43. +6 −1 verireal.h
  44. +6 −1 vpi_user.h
View
@@ -16,7 +16,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
-#ident "$Id: Makefile.in,v 1.142 2003/01/18 23:56:06 steve Exp $"
+#ident "$Id: Makefile.in,v 1.143 2003/01/26 21:15:58 steve Exp $"
#
#
SHELL = /bin/sh
@@ -128,11 +128,11 @@ eval_tree.o expr_synth.o functor.o lexor.o lexor_keyword.o link_const.o \
load_module.o netlist.o netmisc.o net_assign.o \
net_design.o net_event.o net_expr.o net_force.o net_func.o \
net_link.o net_modulo.o net_nex_input.o net_nex_output.o \
-net_proc.o net_scope.o net_udp.o pad_to_width.o \
+net_proc.o net_scope.o net_udp.o net_variable.o pad_to_width.o \
parse.o parse_misc.o pform.o pform_dump.o \
set_width.o sync.o \
verinum.o verireal.o target.o targets.o \
-Attrib.o HName.o LineInfo.o Module.o PDelays.o PEvent.o \
+Attrib.o HName.o LineInfo.o Module.o PData.o PDelays.o PEvent.o \
PExpr.o PGate.o \
PTask.o PFunction.o PWire.o Statement.o StringHeap.o \
$(FF) $(TT)
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: Module.h,v 1.27 2002/08/19 02:39:16 steve Exp $"
+#ident "$Id: Module.h,v 1.28 2003/01/26 21:15:58 steve Exp $"
#endif
# include <list>
@@ -29,6 +29,7 @@
# include "named.h"
# include "LineInfo.h"
# include <string>
+class PData;
class PEvent;
class PExpr;
class PEIdent;
@@ -97,6 +98,9 @@ class Module : public LineInfo {
/* Keep a table of named events declared in the module. */
map<string,PEvent*>events;
+ /* Keep a table of datum variables declared in the module. */
+ map<string,PData*>datum;
+
/* These are the timescale for this module. The default is
set by the `timescale directive. */
int time_unit, time_precision;
@@ -151,6 +155,10 @@ class Module : public LineInfo {
/*
* $Log: Module.h,v $
+ * Revision 1.28 2003/01/26 21:15:58 steve
+ * Rework expression parsing and elaboration to
+ * accommodate real/realtime values and expressions.
+ *
* Revision 1.27 2002/08/19 02:39:16 steve
* Support parameters with defined ranges.
*
View
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003 Stephen Williams (steve@icarus.com)
+ *
+ * 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
+ */
+#ifdef HAVE_CVS_IDENT
+#ident "$Id: PData.cc,v 1.1 2003/01/26 21:15:58 steve Exp $"
+#endif
+
+# include "PData.h"
+
+PData::PData(const hname_t&h)
+: hname_(h)
+{
+}
+
+PData::~PData()
+{
+}
+
+const hname_t&PData::name() const
+{
+ return hname_;
+}
+
+/*
+ * $Log: PData.cc,v $
+ * Revision 1.1 2003/01/26 21:15:58 steve
+ * Rework expression parsing and elaboration to
+ * accommodate real/realtime values and expressions.
+ *
+ */
+
View
63 PData.h
@@ -0,0 +1,63 @@
+#ifndef __PData_H
+#define __PData_H
+/*
+ * Copyright (c) 2003 Stephen Williams (steve@icarus.com)
+ *
+ * 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
+ */
+#ifdef HAVE_CVS_IDENT
+#ident "$Id: PData.h,v 1.1 2003/01/26 21:15:58 steve Exp $"
+#endif
+
+# include "HName.h"
+# include "netlist.h"
+# include "LineInfo.h"
+
+/*
+ * The PData object represents declaration of atomic datum such as
+ * real and realtime variables. These are variables that cannot be bit
+ * or part selected, but can be used in expressions.
+ */
+
+class PData : public LineInfo {
+
+ public:
+ PData(const hname_t&hname);
+ ~PData();
+
+ // Return a hierarchical name.
+ const hname_t&name() const;
+
+ void elaborate_scope(Design*des, NetScope*scope) const;
+
+ map<string,PExpr*> attributes;
+
+ private:
+ hname_t hname_;
+
+ private:
+ PData(const PData&);
+ PData& operator= (const PData&);
+};
+
+/*
+ * $Log: PData.h,v $
+ * Revision 1.1 2003/01/26 21:15:58 steve
+ * Rework expression parsing and elaboration to
+ * accommodate real/realtime values and expressions.
+ *
+ */
+#endif
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: PWire.h,v 1.14 2002/08/12 01:34:58 steve Exp $"
+#ident "$Id: PWire.h,v 1.15 2003/01/26 21:15:58 steve Exp $"
#endif
# include "netlist.h"
@@ -53,7 +53,6 @@ class PWire : public LineInfo {
PWire(char*name, NetNet::Type t, NetNet::PortType pt);
// Return a hierarchical name.
- //const string name() const;
const hname_t&path() const;
NetNet::Type get_wire_type() const;
@@ -101,6 +100,10 @@ class PWire : public LineInfo {
/*
* $Log: PWire.h,v $
+ * Revision 1.15 2003/01/26 21:15:58 steve
+ * Rework expression parsing and elaboration to
+ * accommodate real/realtime values and expressions.
+ *
* Revision 1.14 2002/08/12 01:34:58 steve
* conditional ident string using autoconfig.
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: design_dump.cc,v 1.135 2002/10/23 01:47:17 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.136 2003/01/26 21:15:58 steve Exp $"
#endif
# include "config.h"
@@ -447,6 +447,8 @@ void NetAssign_::dump_lval(ostream&o) const
if (bmux_) o << *bmux_;
else o << "**oops**";
o << "]";
+ } else if (var_) {
+ o << "<real " << var_->basename() << ">";
} else {
o << "";
}
@@ -733,6 +735,11 @@ void NetScope::dump(ostream&o) const
}
}
+ for (NetVariable*cur = vars_ ; cur ; cur = cur->snext_) {
+ o << " real " << cur->basename() << " // "
+ << cur->get_line() << endl;
+ }
+
/* Dump the events in this scope. */
for (NetEvent*cur = events_ ; cur ; cur = cur->snext_) {
o << " event " << cur->name() << "; nprobe="
@@ -896,6 +903,11 @@ void NetEConst::dump(ostream&o) const
o << value_;
}
+void NetECReal::dump(ostream&o) const
+{
+ o << value_;
+}
+
void NetEScope::dump(ostream&o) const
{
o << "<scope=" << scope_->name() << ">";
@@ -975,6 +987,11 @@ void NetEUnary::dump(ostream&o) const
o << ")";
}
+void NetEVariable::dump(ostream&o) const
+{
+ o << var_->basename();
+}
+
void Design::dump(ostream&o) const
{
o << "DESIGN TIME PRECISION: 10e" << get_precision() << endl;
@@ -1004,6 +1021,10 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.136 2003/01/26 21:15:58 steve
+ * Rework expression parsing and elaboration to
+ * accommodate real/realtime values and expressions.
+ *
* Revision 1.135 2002/10/23 01:47:17 steve
* Fix synth2 handling of aset/aclr signals where
* flip-flops are split by begin-end blocks.
View
@@ -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.9 2002/11/09 00:25:27 steve Exp $"
+#ident "$Id: dup_expr.cc,v 1.10 2003/01/26 21:15:58 steve Exp $"
#endif
# include "config.h"
@@ -87,8 +87,18 @@ NetEUnary* NetEUnary::dup_expr() const
return tmp;
}
+NetEVariable* NetEVariable::dup_expr() const
+{
+ NetEVariable*tmp = new NetEVariable(var_);
+ return tmp;
+}
+
/*
* $Log: dup_expr.cc,v $
+ * Revision 1.10 2003/01/26 21:15:58 steve
+ * Rework expression parsing and elaboration to
+ * accommodate real/realtime values and expressions.
+ *
* Revision 1.9 2002/11/09 00:25:27 steve
* Add dup_expr for user defined function calls.
*
View
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2000 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 1999-2003 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -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.67 2002/12/21 00:55:57 steve Exp $"
+#ident "$Id: elab_expr.cc,v 1.68 2003/01/26 21:15:58 steve Exp $"
#endif
# include "config.h"
@@ -406,8 +406,9 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope, bool) const
NetExpr* PEFNumber::elaborate_expr(Design*des, NetScope*scope, bool) const
{
- long val = value_->as_long();
- return new NetEConst(verinum(val));
+ NetECReal*tmp = new NetECReal(*value_);
+ tmp->set_line(*this);
+ return tmp;
}
/*
@@ -721,6 +722,15 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
return node;
}
+ // If the identifier names a variable of some sort, then this
+ // is a variable reference.
+ if (NetVariable*var = des->find_variable(scope, path_)) {
+
+ NetEVariable*node = new NetEVariable(var);
+ node->set_line(*this);
+ return node;
+ }
+
// Finally, if this is a scope name, then return that. Look
// first to see if this is a name of a local scope. Failing
// that, search globally for a heirarchical name.
@@ -812,10 +822,13 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
case '-':
if (NetEConst*ipc = dynamic_cast<NetEConst*>(ip)) {
+ /* When taking the - of a number, turn it into a
+ signed expression and extend it one bit to
+ accommodate a possible sign bit. */
verinum val = ipc->value();
- verinum zero (verinum::V0, val.len(), val.has_len());
+ verinum zero (verinum::V0, val.len()+1, val.has_len());
val = zero - val;
- val.has_sign(ipc->has_sign());
+ val.has_sign(true);
tmp = new NetEConst(val);
delete ip;
} else {
@@ -887,6 +900,10 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
/*
* $Log: elab_expr.cc,v $
+ * Revision 1.68 2003/01/26 21:15:58 steve
+ * Rework expression parsing and elaboration to
+ * accommodate real/realtime values and expressions.
+ *
* Revision 1.67 2002/12/21 00:55:57 steve
* The $time system task returns the integer time
* scaled to the local units. Change the internal
Oops, something went wrong.

0 comments on commit 46253ed

Please sign in to comment.