From 739a1839ed354dce699a6942c31896f61084b231 Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 24 May 2005 01:44:27 +0000 Subject: [PATCH] Do sign extension of structuran nets. --- design_dump.cc | 13 ++++++++++++- elab_net.cc | 18 ++++++++++++++---- elaborate.cc | 17 +++++++++++++---- emit.cc | 10 +++++++++- functor.cc | 14 +++++++++++++- functor.h | 7 ++++++- ivl_target.h | 11 ++++++++++- netlist.cc | 23 ++++++++++++++++++++++- netlist.h | 28 +++++++++++++++++++++++++++- netmisc.h | 7 ++++++- pad_to_width.cc | 28 +++++++++++++++++++++++++++- t-dll-api.cc | 10 +++++++++- t-dll.cc | 33 ++++++++++++++++++++++++++++++++- t-dll.h | 8 ++++++-- target.cc | 12 +++++++++++- target.h | 6 +++++- tgt-stub/stub.c | 29 ++++++++++++++++++++++++++++- tgt-vvp/vvp_scope.c | 18 +++++++++++++++++- 18 files changed, 267 insertions(+), 25 deletions(-) diff --git a/design_dump.cc b/design_dump.cc index 0669991bc..a28a87042 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: design_dump.cc,v 1.159 2005/05/17 20:56:55 steve Exp $" +#ident "$Id: design_dump.cc,v 1.160 2005/05/24 01:44:27 steve Exp $" #endif # include "config.h" @@ -388,6 +388,14 @@ void NetReplicate::dump_node(ostream&o, unsigned ind) const dump_obj_attr(o, ind+4); } +void NetSignExtend::dump_node(ostream&o, unsigned ind) const +{ + o << setw(ind) << "" << "NetSignExtend: " + << name() << " output width=" << width_ << endl; + dump_node_pins(o, ind+4); + dump_obj_attr(o, ind+4); +} + void NetUReduce::dump_node(ostream&o, unsigned ind) const { o << setw(ind) << "" << "reduction logic: "; @@ -1143,6 +1151,9 @@ void Design::dump(ostream&o) const /* * $Log: design_dump.cc,v $ + * Revision 1.160 2005/05/24 01:44:27 steve + * Do sign extension of structuran nets. + * * Revision 1.159 2005/05/17 20:56:55 steve * Parameters cannot have their width changed. * diff --git a/elab_net.cc b/elab_net.cc index 21d327808..befe21ddf 100644 --- a/elab_net.cc +++ b/elab_net.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elab_net.cc,v 1.164 2005/05/19 03:51:38 steve Exp $" +#ident "$Id: elab_net.cc,v 1.165 2005/05/24 01:44:27 steve Exp $" #endif # include "config.h" @@ -901,20 +901,27 @@ NetNet* PEBinary::elaborate_net_mul_(Design*des, NetScope*scope, NetNet*rsig = right_->elaborate_net(des, scope, lwidth, 0, 0, 0); if (rsig == 0) return 0; + // The mult is signed if both its operands are signed. + bool arith_is_signed = lsig->get_signed() && rsig->get_signed(); + unsigned rwidth = lwidth; if (rwidth == 0) { - rwidth = lsig->pin_count() + rsig->pin_count(); + rwidth = lsig->vector_width() + rsig->vector_width(); lwidth = rwidth; } + if (arith_is_signed) { + lsig = pad_to_width_signed(des, lsig, rwidth); + rsig = pad_to_width_signed(des, rsig, rwidth); + } + NetMult*mult = new NetMult(scope, scope->local_symbol(), rwidth, lsig->vector_width(), rsig->vector_width()); mult->set_line(*this); des->add_node(mult); - // The mult is signed if both its operands are signed. - mult->set_signed( lsig->get_signed() && rsig->get_signed() ); + mult->set_signed( arith_is_signed ); connect(mult->pin_DataA(), lsig->pin(0)); connect(mult->pin_DataB(), rsig->pin(0)); @@ -2461,6 +2468,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope, /* * $Log: elab_net.cc,v $ + * Revision 1.165 2005/05/24 01:44:27 steve + * Do sign extension of structuran nets. + * * Revision 1.164 2005/05/19 03:51:38 steve * Make sure comparison widths match. * diff --git a/elaborate.cc b/elaborate.cc index bb9758687..59a895821 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elaborate.cc,v 1.323 2005/05/17 20:56:55 steve Exp $" +#ident "$Id: elaborate.cc,v 1.324 2005/05/24 01:44:27 steve Exp $" #endif # include "config.h" @@ -157,9 +157,15 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const it to the desired width. */ if (cnt < lval->vector_width()) { if (lval->get_signed() && rid->get_signed()) { - cerr << get_line() << ": internal error: " - << "Forgot how to sign-extend r-value " - << "to l-value." << endl; + + unsigned use_width = lval->vector_width(); + + if (debug_elaborate) + cerr << get_line() << ": debug: PGassign " + << "Generate sign-extend node." << endl; + + rid = pad_to_width_signed(des, rid, use_width); + } else { if (debug_elaborate) @@ -2965,6 +2971,9 @@ Design* elaborate(listroots) /* * $Log: elaborate.cc,v $ + * Revision 1.324 2005/05/24 01:44:27 steve + * Do sign extension of structuran nets. + * * Revision 1.323 2005/05/17 20:56:55 steve * Parameters cannot have their width changed. * diff --git a/emit.cc b/emit.cc index cf83012a3..d2197af6f 100644 --- a/emit.cc +++ b/emit.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: emit.cc,v 1.83 2005/02/08 00:12:36 steve Exp $" +#ident "$Id: emit.cc,v 1.84 2005/05/24 01:44:27 steve Exp $" #endif # include "config.h" @@ -131,6 +131,11 @@ bool NetReplicate::emit_node(struct target_t*tgt) const return tgt->replicate(this); } +bool NetSignExtend::emit_node(struct target_t*tgt) const +{ + return tgt->sign_extend(this); +} + bool NetUReduce::emit_node(struct target_t*tgt) const { return tgt->ureduce(this); @@ -523,6 +528,9 @@ int emit(const Design*des, const char*type) /* * $Log: emit.cc,v $ + * Revision 1.84 2005/05/24 01:44:27 steve + * Do sign extension of structuran nets. + * * Revision 1.83 2005/02/08 00:12:36 steve * Add the NetRepeat node, and code generator support. * diff --git a/functor.cc b/functor.cc index a37d6f270..542292262 100644 --- a/functor.cc +++ b/functor.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: functor.cc,v 1.33 2005/02/03 04:56:20 steve Exp $" +#ident "$Id: functor.cc,v 1.34 2005/05/24 01:44:27 steve Exp $" #endif # include "config.h" @@ -79,6 +79,10 @@ void functor_t::lpm_mux(class Design*, class NetMux*) { } +void functor_t::sign_extend(class Design*, class NetSignExtend*) +{ +} + void functor_t::lpm_ureduce(class Design*, class NetUReduce*) { } @@ -210,6 +214,11 @@ void NetMux::functor_node(Design*des, functor_t*fun) fun->lpm_mux(des, this); } +void NetSignExtend::functor_node(Design*des, functor_t*fun) +{ + fun->sign_extend(des, this); +} + void NetUReduce::functor_node(Design*des, functor_t*fun) { fun->lpm_ureduce(des, this); @@ -276,6 +285,9 @@ int proc_match_t::event_wait(NetEvWait*) /* * $Log: functor.cc,v $ + * Revision 1.34 2005/05/24 01:44:27 steve + * Do sign extension of structuran nets. + * * Revision 1.33 2005/02/03 04:56:20 steve * laborate reduction gates into LPM_RED_ nodes. * diff --git a/functor.h b/functor.h index fcf66e1c7..2b7f4873f 100644 --- a/functor.h +++ b/functor.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: functor.h,v 1.21 2005/02/03 04:56:20 steve Exp $" +#ident "$Id: functor.h,v 1.22 2005/05/24 01:44:27 steve Exp $" #endif /* @@ -80,6 +80,8 @@ struct functor_t { /* This method is called for each unary reduction gate. */ virtual void lpm_ureduce(class Design*des, class NetUReduce*); + + virtual void sign_extend(class Design*des, class NetSignExtend*); }; struct proc_match_t { @@ -95,6 +97,9 @@ struct proc_match_t { /* * $Log: functor.h,v $ + * Revision 1.22 2005/05/24 01:44:27 steve + * Do sign extension of structuran nets. + * * Revision 1.21 2005/02/03 04:56:20 steve * laborate reduction gates into LPM_RED_ nodes. * diff --git a/ivl_target.h b/ivl_target.h index df548d1ef..867ae035b 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: ivl_target.h,v 1.154 2005/05/08 23:44:08 steve Exp $" +#ident "$Id: ivl_target.h,v 1.155 2005/05/24 01:44:28 steve Exp $" #endif #ifdef __cplusplus @@ -247,6 +247,7 @@ typedef enum ivl_lpm_type_e { IVL_LPM_REPEAT = 26, IVL_LPM_SHIFTL = 6, IVL_LPM_SHIFTR = 7, + IVL_LPM_SIGN_EXT=27, IVL_LPM_SUB = 8, IVL_LPM_RAM = 9, IVL_LPM_UFUNC = 14 @@ -933,6 +934,11 @@ extern const char* ivl_udp_name(ivl_udp_t net); * repeated to get the desired width. The ivl core assures that the * input vector is exactly ivl_lpm_width() / ivl_lpm_size() bits. * + * - Sign Exend (IVL_LPM_SIGN_EXT) + * This node takes a single input and generates a single output. The + * input must be signed, and the output will be a vector sign extended + * to the desired width. The ivl_lpm_width() value is the output + * width, the input will be whatever it wants to be. * - Shifts (IVL_LPM_SHIFTL/SHIFTR) * This node takes two inputs, a vector and a shift distance. The * ivl_lpm_data(0) nexus is the vector input, and the ivl_lpm_data(1) @@ -1658,6 +1664,9 @@ _END_DECL /* * $Log: ivl_target.h,v $ + * Revision 1.155 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.154 2005/05/08 23:44:08 steve * Add support for variable part select. * diff --git a/netlist.cc b/netlist.cc index 95e8db924..cf0c1ff9f 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netlist.cc,v 1.243 2005/05/08 23:44:08 steve Exp $" +#ident "$Id: netlist.cc,v 1.244 2005/05/24 01:44:28 steve Exp $" #endif # include "config.h" @@ -1474,6 +1474,24 @@ const Link& NetRamDq::pin_Q() const return pin(5); } +NetSignExtend::NetSignExtend(NetScope*s, perm_string n, unsigned w) +: NetNode(s, n, 2), width_(w) +{ + pin(0).set_dir(Link::OUTPUT); + pin(1).set_dir(Link::INPUT); + pin(0).set_name(perm_string::literal("O"), 0); + pin(1).set_name(perm_string::literal("I"), 0); +} + +NetSignExtend::~NetSignExtend() +{ +} + +unsigned NetSignExtend::width() const +{ + return width_; +} + NetBUFZ::NetBUFZ(NetScope*s, perm_string n, unsigned w) : NetNode(s, n, 2), width_(w) { @@ -2185,6 +2203,9 @@ const NetProc*NetTaskDef::proc() const /* * $Log: netlist.cc,v $ + * Revision 1.244 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.243 2005/05/08 23:44:08 steve * Add support for variable part select. * diff --git a/netlist.h b/netlist.h index c0a07ff10..d0042a3a1 100644 --- a/netlist.h +++ b/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.343 2005/05/17 20:56:55 steve Exp $" +#ident "$Id: netlist.h,v 1.344 2005/05/24 01:44:28 steve Exp $" #endif /* @@ -1364,6 +1364,29 @@ class NetLogic : public NetNode { unsigned width_; }; +/* + * This class represents a structural sign extension. The pin-0 is a + * vector of the input pin-1 sign-extended. The input is taken to be + * signed. This generally matches a hardware implementation of + * replicating the top bit enough times to create the desired output + * width. + */ +class NetSignExtend : public NetNode { + + public: + explicit NetSignExtend(NetScope*s, perm_string n, unsigned wid); + ~NetSignExtend(); + + unsigned width() const; + + virtual void dump_node(ostream&, unsigned ind) const; + virtual bool emit_node(struct target_t*) const; + virtual void functor_node(Design*, functor_t*); + + private: + unsigned width_; +}; + /* * This class represents *reduction* logic operators. Certain boolean * logic operators have reduction forms which take in a vector and @@ -3444,6 +3467,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.344 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.343 2005/05/17 20:56:55 steve * Parameters cannot have their width changed. * diff --git a/netmisc.h b/netmisc.h index 6c96ddc62..706d85855 100644 --- a/netmisc.h +++ b/netmisc.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netmisc.h,v 1.21 2005/04/24 23:44:02 steve Exp $" +#ident "$Id: netmisc.h,v 1.22 2005/05/24 01:44:28 steve Exp $" #endif # include "netlist.h" @@ -50,6 +50,8 @@ extern NetScope* symbol_search(Design*des, NetScope*start, hname_t path, extern NetExpr*pad_to_width(NetExpr*expr, unsigned wid); extern NetNet*pad_to_width(Design*des, NetNet*n, unsigned w); +extern NetNet*pad_to_width_signed(Design*des, NetNet*n, unsigned w); + /* * This function transforms an expression by cropping the high bits * off with a part select. The result has the width w passed in. This @@ -99,6 +101,9 @@ extern NetExpr* elab_and_eval(Design*des, NetScope*scope, const PExpr*pe); /* * $Log: netmisc.h,v $ + * Revision 1.22 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.21 2005/04/24 23:44:02 steve * Update DFF support to new data flow. * diff --git a/pad_to_width.cc b/pad_to_width.cc index 2bc2cbf9e..ba54bc371 100644 --- a/pad_to_width.cc +++ b/pad_to_width.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pad_to_width.cc,v 1.17 2005/04/24 23:44:02 steve Exp $" +#ident "$Id: pad_to_width.cc,v 1.18 2005/05/24 01:44:28 steve Exp $" #endif # include "config.h" @@ -110,6 +110,29 @@ NetNet*pad_to_width(Design*des, NetNet*net, unsigned wid) return tmp; } +NetNet*pad_to_width_signed(Design*des, NetNet*net, unsigned wid) +{ + NetScope*scope = net->scope(); + + if (net->vector_width() >= wid) + return net; + + NetSignExtend*se + = new NetSignExtend(scope, scope->local_symbol(), wid); + se->set_line(*net); + des->add_node(se); + + NetNet*tmp = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, wid); + tmp->set_line(*net); + tmp->local_flag(true); + tmp->set_signed(true); + + connect(tmp->pin(0), se->pin(0)); + connect(se->pin(1), net->pin(0)); + + return tmp; +} + NetNet*crop_to_width(Design*des, NetNet*net, unsigned wid) { NetScope*scope = net->scope(); @@ -132,6 +155,9 @@ NetNet*crop_to_width(Design*des, NetNet*net, unsigned wid) /* * $Log: pad_to_width.cc,v $ + * Revision 1.18 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.17 2005/04/24 23:44:02 steve * Update DFF support to new data flow. * diff --git a/t-dll-api.cc b/t-dll-api.cc index 5b8059bf8..e0bad4f63 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: t-dll-api.cc,v 1.126 2005/05/08 23:44:08 steve Exp $" +#ident "$Id: t-dll-api.cc,v 1.127 2005/05/24 01:44:28 steve Exp $" #endif # include "config.h" @@ -803,6 +803,7 @@ extern "C" ivl_nexus_t ivl_lpm_data(ivl_lpm_t net, unsigned idx) case IVL_LPM_RE_NAND: case IVL_LPM_RE_NOR: case IVL_LPM_RE_XNOR: + case IVL_LPM_SIGN_EXT: assert(idx == 0); return net->u_.reduce.a; @@ -982,6 +983,7 @@ extern "C" ivl_nexus_t ivl_lpm_q(ivl_lpm_t net, unsigned idx) case IVL_LPM_RE_NAND: case IVL_LPM_RE_NOR: case IVL_LPM_RE_XNOR: + case IVL_LPM_SIGN_EXT: assert(idx == 0); return net->u_.reduce.q; @@ -1078,6 +1080,8 @@ extern "C" int ivl_lpm_signed(ivl_lpm_t net) case IVL_LPM_SHIFTL: case IVL_LPM_SHIFTR: return net->u_.shift.signed_flag; + case IVL_LPM_SIGN_EXT: // Sign extend is always signed. + return 1; case IVL_LPM_UFUNC: return 0; case IVL_LPM_CONCAT: // Concatenations are always unsigned @@ -1140,6 +1144,7 @@ extern "C" unsigned ivl_lpm_width(ivl_lpm_t net) case IVL_LPM_RE_NAND: case IVL_LPM_RE_NOR: case IVL_LPM_RE_XNOR: + case IVL_LPM_SIGN_EXT: return net->u_.reduce.width; case IVL_LPM_SHIFTL: case IVL_LPM_SHIFTR: @@ -2035,6 +2040,9 @@ extern "C" ivl_variable_type_t ivl_variable_type(ivl_variable_t net) /* * $Log: t-dll-api.cc,v $ + * Revision 1.127 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.126 2005/05/08 23:44:08 steve * Add support for variable part select. * diff --git a/t-dll.cc b/t-dll.cc index 44aa304e0..43686ac4b 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: t-dll.cc,v 1.149 2005/05/08 23:44:08 steve Exp $" +#ident "$Id: t-dll.cc,v 1.150 2005/05/24 01:44:28 steve Exp $" #endif # include "config.h" @@ -904,6 +904,34 @@ void dll_target::logic(const NetLogic*net) scope_add_logic(scope, obj); } +bool dll_target::sign_extend(const NetSignExtend*net) +{ + struct ivl_lpm_s*obj = new struct ivl_lpm_s; + obj->type = IVL_LPM_SIGN_EXT; + obj->u_.reduce.width = net->width(); + obj->name = net->name(); + obj->scope = find_scope(des_, net->scope()); + assert(obj->scope); + + const Nexus*nex; + + nex = net->pin(0).nexus(); + assert(nex->t_cookie()); + + obj->u_.reduce.q = (ivl_nexus_t) nex->t_cookie(); + nexus_lpm_add(obj->u_.reduce.q, obj, 0, IVL_DR_STRONG, IVL_DR_STRONG); + + nex = net->pin(1).nexus(); + assert(nex->t_cookie()); + + obj->u_.reduce.a = (ivl_nexus_t) nex->t_cookie(); + nexus_lpm_add(obj->u_.reduce.a, obj, 1, IVL_DR_HiZ, IVL_DR_HiZ); + + scope_add_lpm(obj->scope, obj); + + return true; +} + bool dll_target::ureduce(const NetUReduce*net) { struct ivl_lpm_s*obj = new struct ivl_lpm_s; @@ -2080,6 +2108,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj }; /* * $Log: t-dll.cc,v $ + * Revision 1.150 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.149 2005/05/08 23:44:08 steve * Add support for variable part select. * diff --git a/t-dll.h b/t-dll.h index 5d528de4d..848ebf199 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: t-dll.h,v 1.125 2005/05/08 23:44:08 steve Exp $" +#ident "$Id: t-dll.h,v 1.126 2005/05/24 01:44:28 steve Exp $" #endif # include "target.h" @@ -90,6 +90,7 @@ struct dll_target : public target_t, public expr_scan_t { bool net_function(const NetUserFunc*); bool net_const(const NetConst*); void net_probe(const NetEvProbe*); + bool sign_extend(const NetSignExtend*); bool process(const NetProcTop*); void scope(const NetScope*); @@ -347,7 +348,7 @@ struct ivl_lpm_s { ivl_nexus_t q, a, s; } part; - // IVL_LPM_RE_* and IVL_LPM_REPEAT use this. + // IVL_LPM_RE_* and IVL_LPM_SIGN_EXT use this. struct ivl_lpm_reduce_s { unsigned width; ivl_nexus_t q, a; @@ -685,6 +686,9 @@ struct ivl_variable_s { /* * $Log: t-dll.h,v $ + * Revision 1.126 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.125 2005/05/08 23:44:08 steve * Add support for variable part select. * diff --git a/target.cc b/target.cc index 6557a30dc..130d7a58b 100644 --- a/target.cc +++ b/target.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: target.cc,v 1.74 2005/02/08 00:12:36 steve Exp $" +#ident "$Id: target.cc,v 1.75 2005/05/24 01:44:28 steve Exp $" #endif # include "config.h" @@ -194,6 +194,13 @@ void target_t::net_probe(const NetEvProbe*net) net->dump_node(cerr, 4); } +bool target_t::sign_extend(const NetSignExtend*net) +{ + cerr << "target (" << typeid(*this).name() << "): " + "Unhandled NetSignExtend node." << endl; + return false; +} + bool target_t::process(const NetProcTop*top) { return top->statement()->emit_proc(this); @@ -429,6 +436,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex) /* * $Log: target.cc,v $ + * Revision 1.75 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.74 2005/02/08 00:12:36 steve * Add the NetRepeat node, and code generator support. * diff --git a/target.h b/target.h index 867487e36..a31ab96aa 100644 --- a/target.h +++ b/target.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: target.h,v 1.71 2005/02/08 00:12:36 steve Exp $" +#ident "$Id: target.h,v 1.72 2005/05/24 01:44:28 steve Exp $" #endif # include "netlist.h" @@ -99,6 +99,7 @@ struct target_t { virtual bool net_const(const NetConst*); virtual bool net_function(const NetUserFunc*); virtual void net_probe(const NetEvProbe*); + virtual bool sign_extend(const NetSignExtend*); /* Output a process (called for each process). It is up to the target to recurse if desired. */ @@ -172,6 +173,9 @@ extern const struct target *target_table[]; /* * $Log: target.h,v $ + * Revision 1.72 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.71 2005/02/08 00:12:36 steve * Add the NetRepeat node, and code generator support. * diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 779060cfc..41bcfb035 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: stub.c,v 1.125 2005/05/18 03:46:01 steve Exp $" +#ident "$Id: stub.c,v 1.126 2005/05/24 01:44:28 steve Exp $" #endif # include "config.h" @@ -739,6 +739,26 @@ static void show_lpm_shift(ivl_lpm_t net, const char*shift_dir) ivl_nexus_name(nex), width_of_nexus(nex)); } +static void show_lpm_sign_ext(ivl_lpm_t net) +{ + unsigned width = ivl_lpm_width(net); + ivl_nexus_t nex_q = ivl_lpm_q(net,0); + ivl_nexus_t nex_a = ivl_lpm_data(net,0); + + fprintf(out, " LPM_SIGN_EXT %s: \n", + ivl_lpm_basename(net), width); + + fprintf(out, " Q: %s\n", ivl_nexus_name(nex_q)); + fprintf(out, " D: %s \n", + ivl_nexus_name(nex_a), width_of_nexus(nex_a)); + + if (width != width_of_nexus(nex_q)) { + fprintf(out, " ERROR: Width of Q is %u, expecting %u\n", + width_of_nexus(nex_q), width); + stub_errors += 1; + } +} + static void show_lpm_sub(ivl_lpm_t net) { unsigned width = ivl_lpm_width(net); @@ -830,6 +850,10 @@ static void show_lpm(ivl_lpm_t net) show_lpm_shift(net, "L"); break; + case IVL_LPM_SIGN_EXT: + show_lpm_sign_ext(net); + break; + case IVL_LPM_SHIFTR: show_lpm_shift(net, "R"); break; @@ -1383,6 +1407,9 @@ int target_design(ivl_design_t des) /* * $Log: stub.c,v $ + * Revision 1.126 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.125 2005/05/18 03:46:01 steve * Fixup structural GT comparators. * diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 077d6c4ab..121c67369 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vvp_scope.c,v 1.127 2005/05/08 23:44:08 steve Exp $" +#ident "$Id: vvp_scope.c,v 1.128 2005/05/24 01:44:28 steve Exp $" #endif # include "vvp_priv.h" @@ -567,6 +567,7 @@ static const char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr) case IVL_LPM_RE_XNOR: case IVL_LPM_SHIFTL: case IVL_LPM_SHIFTR: + case IVL_LPM_SIGN_EXT: case IVL_LPM_SUB: case IVL_LPM_MULT: case IVL_LPM_MUX: @@ -1742,6 +1743,14 @@ static void draw_lpm_repeat(ivl_lpm_t net) fprintf(vvp_out, ";\n"); } +static void draw_lpm_sign_ext(ivl_lpm_t net) +{ + fprintf(vvp_out, "L_%p .extend/s %u, ", net, + ivl_lpm_width(net)); + draw_input_from_net(ivl_lpm_data(net,0)); + fprintf(vvp_out, ";\n"); +} + static void draw_lpm_in_scope(ivl_lpm_t net) { switch (ivl_lpm_type(net)) { @@ -1815,6 +1824,10 @@ static void draw_lpm_in_scope(ivl_lpm_t net) draw_lpm_shiftl(net); return; + case IVL_LPM_SIGN_EXT: + draw_lpm_sign_ext(net); + return; + case IVL_LPM_UFUNC: draw_lpm_ufunc(net); return; @@ -1942,6 +1955,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent) /* * $Log: vvp_scope.c,v $ + * Revision 1.128 2005/05/24 01:44:28 steve + * Do sign extension of structuran nets. + * * Revision 1.127 2005/05/08 23:44:08 steve * Add support for variable part select. *