From ce589da58a3bf0aa81401ca7b9d043217d87bc92 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 22 Jul 2001 00:17:49 +0000 Subject: [PATCH] Support the NetESubSignal expressions in vvp.tgt. --- ivl.def | 1 + ivl_target.h | 11 +++++--- netlist.cc | 15 ++++++++++- netlist.h | 9 ++++++- t-dll-api.cc | 23 +++++++++++++++-- t-dll-expr.cc | 31 +++++++++++++++++++++-- t-dll.cc | 27 ++++++++++++++++++-- t-dll.h | 62 ++++++++------------------------------------- tgt-vvp/eval_expr.c | 30 +++++++++++++++++++++- 9 files changed, 145 insertions(+), 64 deletions(-) diff --git a/ivl.def b/ivl.def index 26137ab2e..910314f53 100644 --- a/ivl.def +++ b/ivl.def @@ -32,6 +32,7 @@ ivl_expr_parm ivl_expr_parms ivl_expr_repeat ivl_expr_scope +ivl_expr_signal ivl_expr_signed ivl_expr_string ivl_expr_uvalue diff --git a/ivl_target.h b/ivl_target.h index 6077d0e97..4f9d86c37 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.72 2001/07/19 04:55:06 steve Exp $" +#ident "$Id: ivl_target.h,v 1.73 2001/07/22 00:17:49 steve Exp $" #endif #ifdef __cplusplus @@ -158,6 +158,7 @@ typedef enum ivl_drive_e { /* This is the type of an ivl_expr_t object. */ typedef enum ivl_expr_type_e { IVL_EX_NONE = 0, + IVL_EX_BITSEL, IVL_EX_BINARY, IVL_EX_CONCAT, IVL_EX_MEMORY, @@ -166,7 +167,6 @@ typedef enum ivl_expr_type_e { IVL_EX_SFUNC, IVL_EX_SIGNAL, IVL_EX_STRING, - IVL_EX_SUBSIG, IVL_EX_TERNARY, IVL_EX_UFUNC, IVL_EX_ULONG, @@ -398,7 +398,7 @@ extern ivl_scope_t ivl_expr_def(ivl_expr_t net); extern const char* ivl_expr_name(ivl_expr_t net); /* IVL_EX_BINARY IVL_EX_UNARY */ extern char ivl_expr_opcode(ivl_expr_t net); - /* IVL_EX_BINARY IVL_EX_UNARY, IVL_EX_MEMORY IVL_EX_TERNARY */ + /* IVL_EX_BINARY IVL_EX_BITSEL IVL_EX_UNARY, IVL_EX_MEMORY IVL_EX_TERNARY */ extern ivl_expr_t ivl_expr_oper1(ivl_expr_t net); /* IVL_EX_BINARY IVL_EX_TERNARY */ extern ivl_expr_t ivl_expr_oper2(ivl_expr_t net); @@ -412,6 +412,8 @@ extern unsigned ivl_expr_parms(ivl_expr_t net); extern unsigned ivl_expr_repeat(ivl_expr_t net); /* IVL_EX_SCOPE */ extern ivl_scope_t ivl_expr_scope(ivl_expr_t net); + /* IVL_EX_BITSEL */ +extern ivl_signal_t ivl_expr_signal(ivl_expr_t net); /* any expression */ extern int ivl_expr_signed(ivl_expr_t net); /* IVL_EX_STRING */ @@ -892,6 +894,9 @@ _END_DECL /* * $Log: ivl_target.h,v $ + * Revision 1.73 2001/07/22 00:17:49 steve + * Support the NetESubSignal expressions in vvp.tgt. + * * Revision 1.72 2001/07/19 04:55:06 steve * Support calculated delays in vvp.tgt. * diff --git a/netlist.cc b/netlist.cc index e4f61a56b..619aa8976 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.166 2001/07/07 03:01:37 steve Exp $" +#ident "$Id: netlist.cc,v 1.167 2001/07/22 00:17:49 steve Exp $" #endif # include @@ -2208,6 +2208,11 @@ NetESignal* NetESignal::dup_expr() const assert(0); } +const NetNet* NetESignal::sig() const +{ + return net_; +} + NetESubSignal::NetESubSignal(NetESignal*sig, NetExpr*ex) : sig_(sig), idx_(ex) { @@ -2226,6 +2231,11 @@ string NetESubSignal::name() const return sig_->name(); } +const NetNet* NetESubSignal::sig() const +{ + return sig_->sig(); +} + NetESubSignal* NetESubSignal::dup_expr() const { assert(0); @@ -2348,6 +2358,9 @@ const NetProc*NetTaskDef::proc() const /* * $Log: netlist.cc,v $ + * Revision 1.167 2001/07/22 00:17:49 steve + * Support the NetESubSignal expressions in vvp.tgt. + * * Revision 1.166 2001/07/07 03:01:37 steve * Detect and make available to t-dll the right shift. * diff --git a/netlist.h b/netlist.h index 8aaf932d4..1b0e2c617 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.211 2001/07/04 22:59:25 steve Exp $" +#ident "$Id: netlist.h,v 1.212 2001/07/22 00:17:49 steve Exp $" #endif /* @@ -2473,6 +2473,8 @@ class NetESignal : public NetExpr { unsigned pin_count() const; Link& pin(unsigned idx); + const NetNet* sig() const; + virtual void expr_scan(struct expr_scan_t*) const; virtual void dump(ostream&) const; @@ -2499,6 +2501,8 @@ class NetESubSignal : public NetExpr { virtual bool set_width(unsigned); + const NetNet* sig() const; + NetESubSignal* dup_expr() const; virtual void expr_scan(struct expr_scan_t*) const; @@ -2812,6 +2816,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.212 2001/07/22 00:17:49 steve + * Support the NetESubSignal expressions in vvp.tgt. + * * Revision 1.211 2001/07/04 22:59:25 steve * handle left shifter in dll output. * diff --git a/t-dll-api.cc b/t-dll-api.cc index 28b8d711d..7aefbfddd 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.56 2001/07/19 04:55:06 steve Exp $" +#ident "$Id: t-dll-api.cc,v 1.57 2001/07/22 00:17:49 steve Exp $" #endif # include "t-dll.h" @@ -204,7 +204,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_.name_; + return net->u_.subsig_.sig->name_; case IVL_EX_MEMORY: return net->u_.memory_.mem_->name_; @@ -238,6 +238,9 @@ extern "C" ivl_expr_t ivl_expr_oper1(ivl_expr_t net) case IVL_EX_BINARY: return net->u_.binary_.lef_; + case IVL_EX_BITSEL: + return net->u_.subsig_.msb_; + case IVL_EX_UNARY: return net->u_.unary_.sub_; @@ -342,6 +345,19 @@ extern "C" ivl_scope_t ivl_expr_scope(ivl_expr_t net) return net->u_.scope_.scope; } +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; + + default: + assert(0); + return 0; + } +} + extern "C" int ivl_expr_signed(ivl_expr_t net) { assert(net); @@ -1262,6 +1278,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net) /* * $Log: t-dll-api.cc,v $ + * Revision 1.57 2001/07/22 00:17:49 steve + * Support the NetESubSignal expressions in vvp.tgt. + * * Revision 1.56 2001/07/19 04:55:06 steve * Support calculated delays in vvp.tgt. * diff --git a/t-dll-expr.cc b/t-dll-expr.cc index f93f63308..c4dc402c5 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.14 2001/07/07 20:20:10 steve Exp $" +#ident "$Id: t-dll-expr.cc,v 1.15 2001/07/22 00:17:49 steve Exp $" #endif # include "t-dll.h" @@ -218,7 +218,31 @@ 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_.name_ = strdup(net->name().c_str()); + expr_->u_.subsig_.sig = find_signal(des_.root_, net->sig()); +} + +void dll_target::expr_subsignal(const NetESubSignal*net) +{ + assert(expr_ == 0); + + ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); + assert(expr); + + if (net->sig()->lsb() != 0) { + cerr << net->get_line() << ": sorry: LSB for signal " + << "is not zero." << endl; + } + + 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()); + + net->index()->expr_scan(this); + assert(expr_); + expr->u_.subsig_.msb_ = expr_; + + expr_ = expr; } void dll_target::expr_ufunc(const NetEUFunc*net) @@ -268,6 +292,9 @@ void dll_target::expr_unary(const NetEUnary*net) /* * $Log: t-dll-expr.cc,v $ + * Revision 1.15 2001/07/22 00:17:49 steve + * Support the NetESubSignal expressions in vvp.tgt. + * * Revision 1.14 2001/07/07 20:20:10 steve * Pass parameters to system functions. * diff --git a/t-dll.cc b/t-dll.cc index a49b60f0f..89638f512 100644 --- a/t-dll.cc +++ b/t-dll.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.cc,v 1.54 2001/07/07 03:01:37 steve Exp $" +#ident "$Id: t-dll.cc,v 1.55 2001/07/22 00:17:49 steve Exp $" #endif # include "compiler.h" @@ -94,7 +94,7 @@ static struct dll_target dll_target_obj; * NetScope object. The search works by looking for the parent scope, * then scanning the parent scope for the NetScope object. */ -static ivl_scope_t find_scope(ivl_scope_t root, const NetScope*cur) +ivl_scope_t dll_target::find_scope(ivl_scope_t root, const NetScope*cur) { ivl_scope_t parent, tmp; @@ -118,6 +118,26 @@ ivl_scope_t dll_target::lookup_scope_(const NetScope*cur) return find_scope(des_.root_, cur); } +/* + * This is a convenience function to locate an ivl_signal_t object + * given the NetESignal that has the signal name. + */ +ivl_signal_t dll_target::find_signal(ivl_scope_t root, const NetNet*net) +{ + ivl_scope_t scope = find_scope(root, net->scope()); + assert(scope); + + const char*nname = net->name(); + + for (unsigned idx = 0 ; idx < scope->nsigs_ ; idx += 1) { + if (strcmp(scope->sigs_[idx]->name_, nname) == 0) + return scope->sigs_[idx]; + } + + assert(0); + return 0; +} + /* * This function locates an ivl_memory_t object that matches the * NetMemory object. The search works by looking for the parent scope, @@ -1460,6 +1480,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj }; /* * $Log: t-dll.cc,v $ + * Revision 1.55 2001/07/22 00:17:49 steve + * Support the NetESubSignal expressions in vvp.tgt. + * * Revision 1.54 2001/07/07 03:01:37 steve * Detect and make available to t-dll the right shift. * diff --git a/t-dll.h b/t-dll.h index c97f92ff1..4dc4225cd 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.55 2001/07/19 04:55:06 steve Exp $" +#ident "$Id: t-dll.h,v 1.56 2001/07/22 00:17:50 steve Exp $" #endif # include "target.h" @@ -118,6 +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_ternary(const NetETernary*); void expr_ufunc(const NetEUFunc*); void expr_unary(const NetEUnary*); @@ -125,6 +126,10 @@ struct dll_target : public target_t, public expr_scan_t { ivl_scope_t lookup_scope_(const NetScope*scope); ivl_memory_t lookup_memory_(const NetMemory*mem); + + private: + static ivl_scope_t find_scope(ivl_scope_t root, const NetScope*cur); + static ivl_signal_t find_signal(ivl_scope_t root, const NetNet*net); }; /* @@ -182,7 +187,7 @@ struct ivl_expr_s { } string_; struct { - char*name_; + ivl_signal_t sig; ivl_expr_t msb_; ivl_expr_t lsb_; } subsig_; @@ -552,6 +557,9 @@ struct ivl_statement_s { /* * $Log: t-dll.h,v $ + * Revision 1.56 2001/07/22 00:17:50 steve + * Support the NetESubSignal expressions in vvp.tgt. + * * Revision 1.55 2001/07/19 04:55:06 steve * Support calculated delays in vvp.tgt. * @@ -588,55 +596,5 @@ struct ivl_statement_s { * * Revision 1.45 2001/05/20 15:09:39 steve * Mingw32 support (Venkat Iyer) - * - * Revision 1.44 2001/05/17 04:37:02 steve - * Behavioral ternary operators for vvp. - * - * Revision 1.43 2001/05/08 23:59:33 steve - * Add ivl and vvp.tgt support for memories in - * expressions and l-values. (Stephan Boettcher) - * - * Revision 1.42 2001/05/06 17:48:20 steve - * Support memory objects. (Stephan Boettcher) - * - * Revision 1.41 2001/04/29 23:17:38 steve - * Carry drive strengths in the ivl_nexus_ptr_t, and - * handle constant devices in targets.' - * - * Revision 1.40 2001/04/26 05:12:02 steve - * Implement simple MUXZ for ?: operators. - * - * Revision 1.39 2001/04/22 23:09:46 steve - * More UDP consolidation from Stephan Boettcher. - * - * Revision 1.38 2001/04/15 02:58:11 steve - * vvp support for <= with internal delay. - * - * Revision 1.37 2001/04/07 19:26:32 steve - * Add the disable statemnent. - * - * Revision 1.36 2001/04/06 02:28:02 steve - * Generate vvp code for functions with ports. - * - * Revision 1.35 2001/04/05 03:20:58 steve - * Generate vvp code for the repeat statement. - * - * Revision 1.34 2001/04/04 04:50:35 steve - * Support forever loops in the tgt-vvp target. - * - * Revision 1.33 2001/04/03 04:50:37 steve - * Support non-blocking assignments. - * - * Revision 1.32 2001/04/02 02:28:12 steve - * Generate code for task calls. - * - * Revision 1.31 2001/04/02 00:28:35 steve - * Support the scope expression node. - * - * Revision 1.30 2001/04/01 06:52:28 steve - * support the NetWhile statement. - * - * Revision 1.29 2001/04/01 01:48:21 steve - * Redesign event information to support arbitrary edge combining. */ #endif diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 1acd60d2c..868f22538 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.36 2001/07/09 15:38:35 steve Exp $" +#ident "$Id: eval_expr.c,v 1.37 2001/07/22 00:17:50 steve Exp $" #endif # include "vvp_priv.h" @@ -553,6 +553,27 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, unsigned wid) return rv; } +static struct vector_info draw_bitsel_expr(ivl_expr_t exp, unsigned wid) +{ + struct vector_info res; + ivl_signal_t sig = ivl_expr_signal(exp); + ivl_expr_t sel = ivl_expr_oper1(exp); + + /* Evaluate the bit select expression and save the result into + index register 0. */ + res = draw_eval_expr(sel); + fprintf(vvp_out, " %%ix/get 0, %u,%u;\n", res.base, res.wid); + clr_vector(res); + + res.base = allocate_vector(wid); + res.wid = wid; + + fprintf(vvp_out, " %%load/x %u, V_%s, 0;\n", res.base, + vvp_mangle_id(ivl_signal_name(sig))); + + return res; +} + static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid) { unsigned idx, off; @@ -1082,6 +1103,10 @@ struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned wid) res = draw_binary_expr(exp, wid); break; + case IVL_EX_BITSEL: + res = draw_bitsel_expr(exp, wid); + break; + case IVL_EX_CONCAT: res = draw_concat_expr(exp, wid); break; @@ -1125,6 +1150,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp) /* * $Log: eval_expr.c,v $ + * Revision 1.37 2001/07/22 00:17:50 steve + * Support the NetESubSignal expressions in vvp.tgt. + * * Revision 1.36 2001/07/09 15:38:35 steve * Properly step through wide inputs. (Stephan Boettcher) *