From 444c83b19a9729b131f3506a57c04e1094d76dc2 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 1 Aug 1999 21:48:11 +0000 Subject: [PATCH] set width of procedural r-values when then l-value is a memory word. --- elaborate.cc | 7 ++++++- netlist.cc | 28 +++++++++++++++++++++++++++- netlist.h | 32 ++++++++++++++++---------------- 3 files changed, 49 insertions(+), 18 deletions(-) diff --git a/elaborate.cc b/elaborate.cc index 5da67712b..21c6d9fa6 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: elaborate.cc,v 1.64 1999/08/01 21:18:55 steve Exp $" +#ident "$Id: elaborate.cc,v 1.65 1999/08/01 21:48:11 steve Exp $" #endif /* @@ -1163,6 +1163,7 @@ NetProc* PAssign::assign_to_memory_(NetMemory*mem, PExpr*ix, } assert(rv); + rv->set_width(mem->width()); NetExpr*idx = ix->elaborate_expr(des, path); assert(idx); @@ -2044,6 +2045,10 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.65 1999/08/01 21:48:11 steve + * set width of procedural r-values when then + * l-value is a memory word. + * * Revision 1.64 1999/08/01 21:18:55 steve * elaborate rise/fall/decay for continuous assign. * diff --git a/netlist.cc b/netlist.cc index 8cbfeff31..66ff9d225 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: netlist.cc,v 1.50 1999/07/31 19:14:47 steve Exp $" +#ident "$Id: netlist.cc,v 1.51 1999/08/01 21:48:11 steve Exp $" #endif # include @@ -841,6 +841,28 @@ NetEMemory::~NetEMemory() { } +NetMemory::NetMemory(const string&n, long w, long s, long e) +: name_(n), width_(w), idxh_(s), idxl_(e) +{ +} + +unsigned NetMemory::count() const +{ + if (idxh_ < idxl_) + return idxl_ - idxh_ + 1; + else + return idxh_ - idxl_ + 1; +} + +unsigned NetMemory::index_to_address(long idx) const +{ + if (idxh_ < idxl_) + return idx - idxh_; + else + return idx - idxl_; +} + + void NetMemory::set_attributes(const map&attr) { assert(attributes_.size() == 0); @@ -1530,6 +1552,10 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*)) /* * $Log: netlist.cc,v $ + * Revision 1.51 1999/08/01 21:48:11 steve + * set width of procedural r-values when then + * l-value is a memory word. + * * Revision 1.50 1999/07/31 19:14:47 steve * Add functions up to elaboration (Ed Carter) * diff --git a/netlist.h b/netlist.h index 7e3047dc2..c1019ed8e 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: netlist.h,v 1.53 1999/08/01 16:34:50 steve Exp $" +#ident "$Id: netlist.h,v 1.54 1999/08/01 21:48:11 steve Exp $" #endif /* @@ -283,30 +283,26 @@ class NetNet : public NetObj, public LineInfo { * This class represents the declared memory object. The parser * creates one of these for each declared memory in the elaborated * design. A reference to one of these is handled by the NetEMemory - * object, which is derived from NetExpr. + * object, which is derived from NetExpr. This is not a node because + * memory objects can only be accessed by behavioral code. */ class NetMemory { public: - NetMemory(const string&n, long w, long s, long e) - : name_(n), width_(w), idxh_(s), idxl_(e) { } + NetMemory(const string&n, long w, long s, long e); const string&name() const { return name_; } + + // This is the width (in bits) of a single memory position. unsigned width() const { return width_; } - unsigned count() const - { if (idxh_ < idxl_) - return idxl_ - idxh_ + 1; - else - return idxh_ - idxl_ + 1; - } + // This is the number of memory positions. + unsigned count() const; - unsigned index_to_address(long idx) const - { if (idxh_ < idxl_) - return idx - idxh_; - else - return idx - idxl_; - } + // This method returns a 0 based address of a memory entry as + // indexed by idx. The Verilog source may give index ranges + // that are not zero based. + unsigned index_to_address(long idx) const; void set_attributes(const map&a); @@ -1444,6 +1440,10 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.54 1999/08/01 21:48:11 steve + * set width of procedural r-values when then + * l-value is a memory word. + * * Revision 1.53 1999/08/01 16:34:50 steve * Parse and elaborate rise/fall/decay times * for gates, and handle the rules for partial