diff --git a/design_dump.cc b/design_dump.cc index f6bcbc50a..6c15cb3f1 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: design_dump.cc,v 1.115 2001/07/27 02:41:55 steve Exp $" +#ident "$Id: design_dump.cc,v 1.116 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -876,10 +876,10 @@ void NetESFunc::dump(ostream&o) const void NetESignal::dump(ostream&o) const { - o << name(); + o << name() << "[" << msi_<<":"<dump(o); o << "["; @@ -960,6 +960,11 @@ void Design::dump(ostream&o) const /* * $Log: design_dump.cc,v $ + * Revision 1.116 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.115 2001/07/27 02:41:55 steve * Fix binding of dangling function ports. do not elide them. * diff --git a/elab_expr.cc b/elab_expr.cc index 879bc8309..c04a2cbba 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: elab_expr.cc,v 1.40 2001/07/25 03:10:48 steve Exp $" +#ident "$Id: elab_expr.cc,v 1.41 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -448,15 +448,9 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const return 0; } - string tname = des->local_symbol(scope->name()); - NetTmp*tsig = new NetTmp(scope, tname, wid); - - // Connect the pins from the lsb up to the msb. - unsigned off = net->sb_to_idx(lsv); - for (unsigned idx = 0 ; idx < wid ; idx += 1) - connect(tsig->pin(idx), net->pin(idx+off)); - - NetESignal*tmp = new NetESignal(tsig); + NetESignal*tmp = new NetESignal(net, + net->sb_to_idx(msv), + net->sb_to_idx(lsv)); tmp->set_line(*this); return tmp; @@ -479,10 +473,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const return 0; } - string tname = des->local_symbol(scope->name()); - NetTmp*tsig = new NetTmp(scope, tname); - connect(tsig->pin(0), net->pin(idx)); - NetESignal*tmp = new NetESignal(tsig); + NetESignal*tmp = new NetESignal(net, idx, idx); tmp->set_line(*this); return tmp; @@ -495,7 +486,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const // device to mux the bit in the net. if (msb_) { NetExpr*ex = msb_->elaborate_expr(des, scope); - NetESubSignal*ss = new NetESubSignal(node, ex); + NetEBitSel*ss = new NetEBitSel(node, ex); ss->set_line(*this); return ss; } @@ -634,6 +625,11 @@ NetEUnary* PEUnary::elaborate_expr(Design*des, NetScope*scope) const /* * $Log: elab_expr.cc,v $ + * Revision 1.41 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.40 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) diff --git a/emit.cc b/emit.cc index 7a81b75d9..51bf2099c 100644 --- a/emit.cc +++ b/emit.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: emit.cc,v 1.60 2001/07/25 03:10:49 steve Exp $" +#ident "$Id: emit.cc,v 1.61 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -448,7 +448,7 @@ void NetESignal::expr_scan(struct expr_scan_t*tgt) const tgt->expr_signal(this); } -void NetESubSignal::expr_scan(struct expr_scan_t*tgt) const +void NetEBitSel::expr_scan(struct expr_scan_t*tgt) const { tgt->expr_subsignal(this); } @@ -476,6 +476,11 @@ bool emit(const Design*des, const char*type) /* * $Log: emit.cc,v $ + * Revision 1.61 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.60 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) diff --git a/ivl.def b/ivl.def index 910314f53..e6cd1b457 100644 --- a/ivl.def +++ b/ivl.def @@ -22,6 +22,7 @@ ivl_event_pos ivl_expr_type ivl_expr_bits ivl_expr_def +ivl_exor_lsi ivl_expr_memory ivl_expr_name ivl_expr_opcode diff --git a/ivl_target.h b/ivl_target.h index 4e4fee0bf..d72669ca5 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: ivl_target.h,v 1.74 2001/07/27 02:41:55 steve Exp $" +#ident "$Id: ivl_target.h,v 1.75 2001/07/27 04:51:44 steve Exp $" #endif #ifdef __cplusplus @@ -394,6 +394,8 @@ extern ivl_expr_type_t ivl_expr_type(ivl_expr_t net); extern const char* ivl_expr_bits(ivl_expr_t net); /* IVL_EX_UFUNC */ extern ivl_scope_t ivl_expr_def(ivl_expr_t net); + /* IVL_EX_SIGNAL */ +extern unsigned ivl_expr_lsi(ivl_expr_t net); /* IVL_EX_SIGNAL, IVL_EX_SFUNC, IVL_EX_MEMORY */ extern const char* ivl_expr_name(ivl_expr_t net); /* IVL_EX_BINARY IVL_EX_UNARY */ @@ -894,6 +896,11 @@ _END_DECL /* * $Log: ivl_target.h,v $ + * Revision 1.75 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.74 2001/07/27 02:41:55 steve * Fix binding of dangling function ports. do not elide them. * diff --git a/netlist.cc b/netlist.cc index 64b0ae792..9d191dffb 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) && !defined(macintosh) -#ident "$Id: netlist.cc,v 1.168 2001/07/25 03:10:49 steve Exp $" +#ident "$Id: netlist.cc,v 1.169 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -2178,6 +2178,18 @@ NetExpr* NetESFunc::parm(unsigned idx) NetESignal::NetESignal(NetNet*n) : NetExpr(n->pin_count()), net_(n) { + msi_ = n->pin_count() - 1; + lsi_ = 0; + net_->incr_eref(); + set_line(*n); +} + +NetESignal::NetESignal(NetNet*n, unsigned m, unsigned l) +: NetExpr(m - l + 1), net_(n) +{ + assert(m >= l); + msi_ = m; + lsi_ = l; net_->incr_eref(); set_line(*n); } @@ -2197,14 +2209,15 @@ bool NetESignal::has_sign() const return net_->get_signed(); } -unsigned NetESignal::pin_count() const +unsigned NetESignal::bit_count() const { - return net_->pin_count(); + return msi_ - lsi_ + 1; } -Link& NetESignal::pin(unsigned idx) +Link& NetESignal::bit(unsigned idx) { - return net_->pin(idx); + assert(idx <= (msi_ - lsi_)); + return net_->pin(idx + lsi_); } NetESignal* NetESignal::dup_expr() const @@ -2217,7 +2230,17 @@ const NetNet* NetESignal::sig() const return net_; } -NetESubSignal::NetESubSignal(NetESignal*sig, NetExpr*ex) +unsigned NetESignal::lsi() const +{ + return lsi_; +} + +unsigned NetESignal::msi() const +{ + return msi_; +} + +NetEBitSel::NetEBitSel(NetESignal*sig, NetExpr*ex) : sig_(sig), idx_(ex) { // This supports mux type indexing of an expression, so the @@ -2225,22 +2248,22 @@ NetESubSignal::NetESubSignal(NetESignal*sig, NetExpr*ex) expr_width(1); } -NetESubSignal::~NetESubSignal() +NetEBitSel::~NetEBitSel() { delete idx_; } -string NetESubSignal::name() const +string NetEBitSel::name() const { return sig_->name(); } -const NetNet* NetESubSignal::sig() const +const NetNet* NetEBitSel::sig() const { return sig_->sig(); } -NetESubSignal* NetESubSignal::dup_expr() const +NetEBitSel* NetEBitSel::dup_expr() const { assert(0); } @@ -2362,6 +2385,11 @@ const NetProc*NetTaskDef::proc() const /* * $Log: netlist.cc,v $ + * Revision 1.169 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.168 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) diff --git a/netlist.h b/netlist.h index 1b0e2c617..e31467177 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) && !defined(macintosh) -#ident "$Id: netlist.h,v 1.212 2001/07/22 00:17:49 steve Exp $" +#ident "$Id: netlist.h,v 1.213 2001/07/27 04:51:44 steve Exp $" #endif /* @@ -2450,12 +2450,16 @@ class NetEMemory : public NetExpr { * structural signal. * * A signal shows up as a node in the netlist so that structural - * activity can invoke the expression. + * activity can invoke the expression. This node also supports part + * select by indexing a range of the NetNet that is associated with + * it. The msi() is the mose significant index, and lsi() the least + * significant index. */ class NetESignal : public NetExpr { public: NetESignal(NetNet*n); + NetESignal(NetNet*n, unsigned msi, unsigned lsi); ~NetESignal(); // a NetESignal expression is signed if the NetNet that it @@ -2470,31 +2474,35 @@ class NetESignal : public NetExpr { // These methods actually reference the properties of the // NetNet object that I point to. - unsigned pin_count() const; - Link& pin(unsigned idx); + unsigned bit_count() const; + Link& bit(unsigned idx); const NetNet* sig() const; + unsigned msi() const; + unsigned lsi() const; virtual void expr_scan(struct expr_scan_t*) const; virtual void dump(ostream&) const; private: NetNet*net_; + unsigned msi_; + unsigned lsi_; }; /* - * An expression that takes a portion of a signal is represented as + * An expression that takes a bit of a signal is represented as * one of these. For example, ``foo[x+5]'' is a signal and x+5 is an * expression to select a single bit from that signal. I can't just * make a new NetESignal node connected to the single net because the * expression may vary during execution, so the structure is not known * at compile (elaboration) time. */ -class NetESubSignal : public NetExpr { +class NetEBitSel : public NetExpr { public: - NetESubSignal(NetESignal*sig, NetExpr*ex); - ~NetESubSignal(); + NetEBitSel(NetESignal*sig, NetExpr*ex); + ~NetEBitSel(); string name() const; const NetExpr*index() const { return idx_; } @@ -2503,7 +2511,7 @@ class NetESubSignal : public NetExpr { const NetNet* sig() const; - NetESubSignal* dup_expr() const; + NetEBitSel* dup_expr() const; virtual void expr_scan(struct expr_scan_t*) const; virtual void dump(ostream&) const; @@ -2816,6 +2824,11 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.213 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.212 2001/07/22 00:17:49 steve * Support the NetESubSignal expressions in vvp.tgt. * diff --git a/set_width.cc b/set_width.cc index e9115b70c..de76c8d9b 100644 --- a/set_width.cc +++ b/set_width.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: set_width.cc,v 1.18 2001/07/25 03:10:49 steve Exp $" +#ident "$Id: set_width.cc,v 1.19 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -289,13 +289,13 @@ bool NetESFunc::set_width(unsigned w) */ bool NetESignal::set_width(unsigned w) { - if (w != pin_count()) + if (w != bit_count()) return false; return true; } -bool NetESubSignal::set_width(unsigned w) +bool NetEBitSel::set_width(unsigned w) { if (w != 1) return false; return true; @@ -341,6 +341,11 @@ bool NetEUnary::set_width(unsigned w) /* * $Log: set_width.cc,v $ + * Revision 1.19 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.18 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) diff --git a/syn-rules.y b/syn-rules.y index c4bffda9c..5272152b0 100644 --- a/syn-rules.y +++ b/syn-rules.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: syn-rules.y,v 1.12 2001/07/25 03:10:49 steve Exp $" +#ident "$Id: syn-rules.y,v 1.13 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -154,7 +154,7 @@ static void make_DFF_CE(Design*des, NetProcTop*top, NetEvWait*wclk, asn->l_val(0)->pin_count()); for (unsigned idx = 0 ; idx < ff->width() ; idx += 1) { - connect(ff->pin_Data(idx), d->pin(idx)); + connect(ff->pin_Data(idx), d->bit(idx)); connect(ff->pin_Q(idx), asn->l_val(0)->pin(idx)); } @@ -191,7 +191,7 @@ static void make_RAM_CE(Design*des, NetProcTop*top, NetEvWait*wclk, connect(adr->pin(idx), ram->pin_Address(idx)); for (unsigned idx = 0 ; idx < ram->width() ; idx += 1) - connect(ram->pin_Data(idx), d->pin(idx)); + connect(ram->pin_Data(idx), d->bit(idx)); if (ce) connect(ram->pin_WE(), ce->pin(0)); @@ -217,7 +217,7 @@ static void make_initializer(Design*des, NetProcTop*top, NetAssignBase*asn) for (unsigned idx = 0 ; idx < asn->l_val(0)->pin_count() ; idx += 1) { - verinum::V bit = driven_value(rsig->pin(idx)); + verinum::V bit = driven_value(rsig->bit(idx)); Nexus*nex = asn->l_val(0)->pin(idx).nexus(); for (Link*cur = nex->first_nlink() diff --git a/t-dll-api.cc b/t-dll-api.cc index 93593a1fe..d33b63f43 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll-api.cc,v 1.59 2001/07/27 02:41:55 steve Exp $" +#ident "$Id: t-dll-api.cc,v 1.60 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -198,6 +198,20 @@ extern "C" ivl_scope_t ivl_expr_def(ivl_expr_t net) return 0; } +extern "C" unsigned ivl_expr_lsi(ivl_expr_t net) +{ + switch (net->type_) { + + case IVL_EX_SIGNAL: + return net->u_.signal_.lsi; + + default: + assert(0); + + } + return 0; +} + extern "C" const char* ivl_expr_name(ivl_expr_t net) { switch (net->type_) { @@ -206,7 +220,7 @@ extern "C" const char* ivl_expr_name(ivl_expr_t net) return net->u_.sfunc_.name_; case IVL_EX_SIGNAL: - return net->u_.subsig_.sig->name_; + return net->u_.signal_.sig->name_; case IVL_EX_MEMORY: return net->u_.memory_.mem_->name_; @@ -241,7 +255,7 @@ extern "C" ivl_expr_t ivl_expr_oper1(ivl_expr_t net) return net->u_.binary_.lef_; case IVL_EX_BITSEL: - return net->u_.subsig_.msb_; + return net->u_.bitsel_.bit; case IVL_EX_UNARY: return net->u_.unary_.sub_; @@ -352,7 +366,7 @@ extern "C" ivl_signal_t ivl_expr_signal(ivl_expr_t net) assert(net); switch (net->type_) { case IVL_EX_BITSEL: - return net->u_.subsig_.sig; + return net->u_.bitsel_.sig; default: assert(0); @@ -1280,6 +1294,11 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net) /* * $Log: t-dll-api.cc,v $ + * Revision 1.60 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.59 2001/07/27 02:41:55 steve * Fix binding of dangling function ports. do not elide them. * diff --git a/t-dll-expr.cc b/t-dll-expr.cc index 44537ff06..741132cdc 100644 --- a/t-dll-expr.cc +++ b/t-dll-expr.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) & !defined(macintosh) -#ident "$Id: t-dll-expr.cc,v 1.16 2001/07/25 03:10:49 steve Exp $" +#ident "$Id: t-dll-expr.cc,v 1.17 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -222,10 +222,12 @@ void dll_target::expr_signal(const NetESignal*net) expr_->type_ = IVL_EX_SIGNAL; expr_->width_= net->expr_width(); expr_->signed_ = net->has_sign()? 1 : 0; - expr_->u_.subsig_.sig = find_signal(des_.root_, net->sig()); + expr_->u_.signal_.sig = find_signal(des_.root_, net->sig()); + expr_->u_.signal_.lsi = net->lsi(); + expr_->u_.signal_.msi = net->msi(); } -void dll_target::expr_subsignal(const NetESubSignal*net) +void dll_target::expr_subsignal(const NetEBitSel*net) { assert(expr_ == 0); @@ -240,11 +242,11 @@ void dll_target::expr_subsignal(const NetESubSignal*net) expr->type_ = IVL_EX_BITSEL; expr->width_= net->expr_width(); expr->signed_ = net->has_sign()? 1 : 0; - expr->u_.subsig_.sig = find_signal(des_.root_, net->sig()); + expr->u_.bitsel_.sig = find_signal(des_.root_, net->sig()); net->index()->expr_scan(this); assert(expr_); - expr->u_.subsig_.msb_ = expr_; + expr->u_.bitsel_.bit = expr_; expr_ = expr; } @@ -296,6 +298,11 @@ void dll_target::expr_unary(const NetEUnary*net) /* * $Log: t-dll-expr.cc,v $ + * Revision 1.17 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.16 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) diff --git a/t-dll.h b/t-dll.h index 74bbd8d36..062427d4e 100644 --- a/t-dll.h +++ b/t-dll.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll.h,v 1.57 2001/07/27 02:41:56 steve Exp $" +#ident "$Id: t-dll.h,v 1.58 2001/07/27 04:51:44 steve Exp $" #endif # include "target.h" @@ -118,7 +118,7 @@ struct dll_target : public target_t, public expr_scan_t { void expr_const(const NetEConst*); void expr_scope(const NetEScope*); void expr_sfunc(const NetESFunc*); - void expr_subsignal(const NetESubSignal*); + void expr_subsignal(const NetEBitSel*); void expr_ternary(const NetETernary*); void expr_ufunc(const NetEUFunc*); void expr_unary(const NetEUnary*); @@ -162,6 +162,11 @@ struct ivl_expr_s { ivl_expr_t rig_; } binary_; + struct { + ivl_signal_t sig; + ivl_expr_t bit; + } bitsel_; + struct { unsigned rept :16; unsigned parms :16; @@ -176,6 +181,11 @@ struct ivl_expr_s { ivl_scope_t scope; } scope_; + struct { + ivl_signal_t sig; + unsigned lsi, msi; + } signal_; + struct { char*name_; ivl_expr_t *parm; @@ -186,12 +196,6 @@ struct ivl_expr_s { char*value_; } string_; - struct { - ivl_signal_t sig; - ivl_expr_t msb_; - ivl_expr_t lsb_; - } subsig_; - struct { ivl_expr_t cond; ivl_expr_t true_e; @@ -557,6 +561,11 @@ struct ivl_statement_s { /* * $Log: t-dll.h,v $ + * Revision 1.58 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.57 2001/07/27 02:41:56 steve * Fix binding of dangling function ports. do not elide them. * diff --git a/t-vvm.cc b/t-vvm.cc index bc8f2a746..50c1aa07b 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-vvm.cc,v 1.210 2001/07/25 03:10:50 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.211 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -347,7 +347,7 @@ class vvm_proc_rval : public expr_scan_t { virtual void expr_memory(const NetEMemory*mem); virtual void expr_sfunc(const NetESFunc*); virtual void expr_signal(const NetESignal*); - virtual void expr_subsignal(const NetESubSignal*sig); + virtual void expr_subsignal(const NetEBitSel*sig); virtual void expr_ternary(const NetETernary*); virtual void expr_unary(const NetEUnary*); virtual void expr_binary(const NetEBinary*); @@ -526,13 +526,13 @@ void vvm_proc_rval::expr_signal(const NetESignal*expr) const string tname = make_temp(); tgt_->defn << " vvm_bitset_t " << tname << "(" - << mangle(expr->name()) << ".bits, " - << expr->expr_width() << ");" << endl; + << mangle(expr->name()) << ".bits+" << expr->lsi() + << ", " << expr->expr_width() << ");" << endl; result = tname; } -void vvm_proc_rval::expr_subsignal(const NetESubSignal*sig) +void vvm_proc_rval::expr_subsignal(const NetEBitSel*sig) { string idx = make_temp(); string val = make_temp(); @@ -956,6 +956,7 @@ void vvm_parm_rval::expr_scope(const NetEScope*escope) void vvm_parm_rval::expr_signal(const NetESignal*expr) { + assert(expr->lsi() == 0); string res = string("&") + mangle(expr->name()) + ".base"; result = res; } @@ -2595,7 +2596,7 @@ void target_vvm::proc_assign(const NetAssign*net) if (const NetESignal*rs = dynamic_cast(net->rval())) { - if (net->lwidth() > rs->pin_count()) { + if (net->lwidth() > rs->bit_count()) { rval = emit_proc_rval(this, net->rval()); } else { @@ -2841,7 +2842,7 @@ void target_vvm::proc_assign_nb(const NetAssignNB*net) if (const NetESignal*rs = dynamic_cast(net->rval())) { - if (net->lwidth() > rs->pin_count()) { + if (net->lwidth() > rs->bit_count()) { rval = emit_proc_rval(this, net->rval()); } else { @@ -3644,6 +3645,11 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.211 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.210 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) diff --git a/target.cc b/target.cc index 03014cabb..0cfcef99d 100644 --- a/target.cc +++ b/target.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: target.cc,v 1.55 2001/07/25 03:10:50 steve Exp $" +#ident "$Id: target.cc,v 1.56 2001/07/27 04:51:44 steve Exp $" #endif # include "config.h" @@ -357,10 +357,10 @@ void expr_scan_t::expr_signal(const NetESignal*) "unhandled expr_signal." << endl; } -void expr_scan_t::expr_subsignal(const NetESubSignal*) +void expr_scan_t::expr_subsignal(const NetEBitSel*) { cerr << "expr_scan_t (" << typeid(*this).name() << "): " - "unhandled expr_subsignal." << endl; + "unhandled bit select expression." << endl; } void expr_scan_t::expr_ternary(const NetETernary*) @@ -389,6 +389,11 @@ void expr_scan_t::expr_binary(const NetEBinary*ex) /* * $Log: target.cc,v $ + * Revision 1.56 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.55 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) diff --git a/target.h b/target.h index 59080a019..9b6335e88 100644 --- a/target.h +++ b/target.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: target.h,v 1.52 2001/04/22 23:09:46 steve Exp $" +#ident "$Id: target.h,v 1.53 2001/07/27 04:51:44 steve Exp $" #endif # include "netlist.h" @@ -135,7 +135,7 @@ struct expr_scan_t { virtual void expr_scope(const NetEScope*); virtual void expr_sfunc(const NetESFunc*); virtual void expr_signal(const NetESignal*); - virtual void expr_subsignal(const NetESubSignal*); + virtual void expr_subsignal(const NetEBitSel*); virtual void expr_ternary(const NetETernary*); virtual void expr_ufunc(const NetEUFunc*); virtual void expr_unary(const NetEUnary*); @@ -163,6 +163,11 @@ extern const struct target *target_table[]; /* * $Log: target.h,v $ + * Revision 1.53 2001/07/27 04:51:44 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.52 2001/04/22 23:09:46 steve * More UDP consolidation from Stephan Boettcher. * diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 3628c6851..e6287beca 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: eval_expr.c,v 1.39 2001/07/27 02:41:56 steve Exp $" +#ident "$Id: eval_expr.c,v 1.40 2001/07/27 04:51:45 steve Exp $" #endif # include "vvp_priv.h" @@ -699,9 +699,16 @@ static struct vector_info draw_number_expr(ivl_expr_t exp, unsigned wid) return res; } +/* + * Evaluating a signal expression means loading the bits of the signal + * into the thread bits. Remember to account for the part select by + * offsetting the read from the lsi (least significant index) of the + * signal. + */ static struct vector_info draw_signal_expr(ivl_expr_t exp, unsigned wid) { unsigned idx; + unsigned lsi = ivl_expr_lsi(exp); unsigned swid = ivl_expr_width(exp); const char*name = ivl_expr_name(exp); struct vector_info res; @@ -714,7 +721,7 @@ static struct vector_info draw_signal_expr(ivl_expr_t exp, unsigned wid) for (idx = 0 ; idx < swid ; idx += 1) fprintf(vvp_out, " %%load %u, V_%s[%u];\n", - res.base+idx, vvp_mangle_id(name), idx); + res.base+idx, vvp_mangle_id(name), idx+lsi); /* Pad the signal value with zeros. */ if (swid < wid) @@ -1159,6 +1166,11 @@ struct vector_info draw_eval_expr(ivl_expr_t exp) /* * $Log: eval_expr.c,v $ + * Revision 1.40 2001/07/27 04:51:45 steve + * Handle part select expressions as variants of + * NetESignal/IVL_EX_SIGNAL objects, instead of + * creating new and useless temporary signals. + * * Revision 1.39 2001/07/27 02:41:56 steve * Fix binding of dangling function ports. do not elide them. *