diff --git a/elab_net.cc b/elab_net.cc index 0d80e4903..af3394c17 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 */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: elab_net.cc,v 1.68 2001/06/15 04:14:18 steve Exp $" +#ident "$Id: elab_net.cc,v 1.69 2001/06/16 23:45:05 steve Exp $" #endif # include "PExpr.h" @@ -791,7 +791,7 @@ NetNet* PEBinary::elaborate_net_mul_(Design*des, const string&path, if (rsig == 0) return 0; unsigned rwidth = lwidth; - NetMult*mult = new NetMult(des->local_symbol(path), rwidth, + NetMult*mult = new NetMult(scope, des->local_symbol(path), rwidth, lsig->pin_count(), rsig->pin_count()); des->add_node(mult); @@ -1901,6 +1901,11 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path, /* * $Log: elab_net.cc,v $ + * Revision 1.69 2001/06/16 23:45:05 steve + * Add support for structural multiply in t-dll. + * Add code generators and vvp support for both + * structural and behavioral multiply. + * * Revision 1.68 2001/06/15 04:14:18 steve * Generate vvp code for GT and GE comparisons. * diff --git a/ivl_target.h b/ivl_target.h index fd984cf28..3b3a5ecc1 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.67 2001/06/16 02:41:41 steve Exp $" +#ident "$Id: ivl_target.h,v 1.68 2001/06/16 23:45:05 steve Exp $" #endif #ifdef __cplusplus @@ -205,9 +205,10 @@ typedef enum ivl_lpm_type_e { IVL_LPM_CMP_GE, IVL_LPM_CMP_GT, IVL_LPM_FF, + IVL_LPM_MULT, IVL_LPM_MUX, IVL_LPM_SUB, - IVL_LPM_RAM, + IVL_LPM_RAM } ivl_lpm_type_t; /* Processes are initial or always blocks with a statement. This is @@ -517,13 +518,13 @@ extern unsigned ivl_lpm_width(ivl_lpm_t net); extern ivl_nexus_t ivl_lpm_clk(ivl_lpm_t net); /* IVL_LPM_RAM */ extern ivl_nexus_t ivl_lpm_enable(ivl_lpm_t net); - /* IVL_LPM_ADD IVL_LPM_FF IVL_LPM_RAM IVL_LPM_SUB */ + /* IVL_LPM_ADD IVL_LPM_FF IVL_LPM_MULT IVL_LPM_RAM IVL_LPM_SUB */ extern ivl_nexus_t ivl_lpm_data(ivl_lpm_t net, unsigned idx); - /* IVL_LPM_ADD IVL_LPM_SUB */ + /* IVL_LPM_ADD IVL_LPM_MULT IVL_LPM_SUB */ extern ivl_nexus_t ivl_lpm_datab(ivl_lpm_t net, unsigned idx); /* IVL_LPM_MUX */ extern ivl_nexus_t ivl_lpm_data2(ivl_lpm_t net, unsigned sdx, unsigned idx); - /* IVL_LPM_ADD IVL_LPM_FF IVL_LPM_RAM IVL_LPM_SUB */ + /* IVL_LPM_ADD IVL_LPM_FF IVL_LPM_MULT IVL_LPM_RAM IVL_LPM_SUB */ extern ivl_nexus_t ivl_lpm_q(ivl_lpm_t net, unsigned idx); /* IVL_LPM_MUX IVL_LPM_RAM */ extern unsigned ivl_lpm_selects(ivl_lpm_t net); @@ -881,6 +882,11 @@ _END_DECL /* * $Log: ivl_target.h,v $ + * Revision 1.68 2001/06/16 23:45:05 steve + * Add support for structural multiply in t-dll. + * Add code generators and vvp support for both + * structural and behavioral multiply. + * * Revision 1.67 2001/06/16 02:41:41 steve * Generate code to support memory access in continuous * assignment statements. (Stephan Boettcher) diff --git a/netlist.cc b/netlist.cc index ef11c2204..2ab20d9fa 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.162 2001/06/15 04:14:18 steve Exp $" +#ident "$Id: netlist.cc,v 1.163 2001/06/16 23:45:05 steve Exp $" #endif # include @@ -1012,10 +1012,10 @@ const Link& NetDivide::pin_DataB(unsigned idx) const return pin(idx+width_r_+width_a_); } -NetMult::NetMult(const string&n, unsigned wr, unsigned wa, unsigned wb, - unsigned ws) -: NetNode(n, 2+wr+wa+wb+ws), width_r_(wr), width_a_(wa), width_b_(wb), - width_s_(ws) +NetMult::NetMult(NetScope*sc, const string&n, unsigned wr, + unsigned wa, unsigned wb, unsigned ws) +: NetNode(sc, n, 2+wr+wa+wb+ws), width_r_(wr), width_a_(wa), width_b_(wb), + width_s_(ws) { pin(0).set_dir(Link::INPUT); pin(0).set_name("Aclr", 0); pin(1).set_dir(Link::INPUT); pin(1).set_name("Clock", 0); @@ -2323,6 +2323,11 @@ const NetProc*NetTaskDef::proc() const /* * $Log: netlist.cc,v $ + * Revision 1.163 2001/06/16 23:45:05 steve + * Add support for structural multiply in t-dll. + * Add code generators and vvp support for both + * structural and behavioral multiply. + * * Revision 1.162 2001/06/15 04:14:18 steve * Generate vvp code for GT and GE comparisons. * diff --git a/netlist.h b/netlist.h index 510fa8f3f..cd68754d6 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.208 2001/06/15 04:14:18 steve Exp $" +#ident "$Id: netlist.h,v 1.209 2001/06/16 23:45:05 steve Exp $" #endif /* @@ -678,8 +678,8 @@ class NetMemory { class NetMult : public NetNode { public: - NetMult(const string&n, unsigned width, unsigned wa, unsigned wb, - unsigned width_s =0); + NetMult(NetScope*sc, const string&n, unsigned width, + unsigned wa, unsigned wb, unsigned width_s =0); ~NetMult(); // Get the width of the device bussed inputs. There are these @@ -2809,6 +2809,11 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.209 2001/06/16 23:45:05 steve + * Add support for structural multiply in t-dll. + * Add code generators and vvp support for both + * structural and behavioral multiply. + * * Revision 1.208 2001/06/15 04:14:18 steve * Generate vvp code for GT and GE comparisons. * diff --git a/t-dll-api.cc b/t-dll-api.cc index 81a5421e9..63b7fcc28 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.50 2001/06/16 02:41:41 steve Exp $" +#ident "$Id: t-dll-api.cc,v 1.51 2001/06/16 23:45:05 steve Exp $" #endif # include "t-dll.h" @@ -465,6 +465,7 @@ extern "C" ivl_nexus_t ivl_lpm_data(ivl_lpm_t net, unsigned idx) case IVL_LPM_ADD: case IVL_LPM_CMP_GE: case IVL_LPM_CMP_GT: + case IVL_LPM_MULT: case IVL_LPM_SUB: assert(idx < net->u_.arith.width); return net->u_.arith.a[idx]; @@ -491,6 +492,7 @@ extern "C" ivl_nexus_t ivl_lpm_datab(ivl_lpm_t net, unsigned idx) case IVL_LPM_ADD: case IVL_LPM_CMP_GE: case IVL_LPM_CMP_GT: + case IVL_LPM_MULT: case IVL_LPM_SUB: assert(idx < net->u_.arith.width); return net->u_.arith.b[idx]; @@ -527,6 +529,7 @@ extern "C" ivl_nexus_t ivl_lpm_q(ivl_lpm_t net, unsigned idx) switch (net->type) { case IVL_LPM_ADD: + case IVL_LPM_MULT: case IVL_LPM_SUB: assert(idx < net->u_.arith.width); return net->u_.arith.q[idx]; @@ -621,6 +624,7 @@ extern "C" unsigned ivl_lpm_width(ivl_lpm_t net) case IVL_LPM_ADD: case IVL_LPM_CMP_GE: case IVL_LPM_CMP_GT: + case IVL_LPM_MULT: case IVL_LPM_SUB: return net->u_.arith.width; default: @@ -1223,6 +1227,11 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net) /* * $Log: t-dll-api.cc,v $ + * Revision 1.51 2001/06/16 23:45:05 steve + * Add support for structural multiply in t-dll. + * Add code generators and vvp support for both + * structural and behavioral multiply. + * * Revision 1.50 2001/06/16 02:41:41 steve * Generate code to support memory access in continuous * assignment statements. (Stephan Boettcher) diff --git a/t-dll.cc b/t-dll.cc index 96286a84b..1e485c143 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.48 2001/06/16 02:41:42 steve Exp $" +#ident "$Id: t-dll.cc,v 1.49 2001/06/16 23:45:05 steve Exp $" #endif # include "compiler.h" @@ -837,9 +837,10 @@ void dll_target::lpm_ram_dq(const NetRamDq*net) const Nexus*nex; - // How do I find out if there is something - // connected to the clock input? - bool has_write_port = false; + // A write port is present only if something is connected to + // the clock input. + + bool has_write_port = net->pin_InClock().is_linked(); // Connect the write clock and write enable @@ -933,6 +934,64 @@ void dll_target::lpm_ram_dq(const NetRamDq*net) } } +void dll_target::lpm_mult(const NetMult*net) +{ + ivl_lpm_t obj = new struct ivl_lpm_s; + obj->type = IVL_LPM_MULT; + obj->name = strdup(net->name()); + assert(net->scope()); + obj->scope = find_scope(des_.root_, net->scope()); + assert(obj->scope); + + unsigned wid = net->width_r(); + + obj->u_.arith.width = wid; + + obj->u_.arith.q = new ivl_nexus_t[3 * obj->u_.arith.width]; + obj->u_.arith.a = obj->u_.arith.q + obj->u_.arith.width; + obj->u_.arith.b = obj->u_.arith.a + obj->u_.arith.width; + + for (unsigned idx = 0 ; idx < wid ; idx += 1) { + const Nexus*nex; + + nex = net->pin_Result(idx).nexus(); + assert(nex->t_cookie()); + + obj->u_.arith.q[idx] = (ivl_nexus_t) nex->t_cookie(); + nexus_lpm_add(obj->u_.arith.q[idx], obj, 0, + IVL_DR_STRONG, IVL_DR_STRONG); + + if (idx < net->width_a()) { + nex = net->pin_DataA(idx).nexus(); + assert(nex); + assert(nex->t_cookie()); + + obj->u_.arith.a[idx] = (ivl_nexus_t) nex->t_cookie(); + nexus_lpm_add(obj->u_.arith.a[idx], obj, 0, + IVL_DR_HiZ, IVL_DR_HiZ); + + } else { + obj->u_.arith.a[idx] = 0; + } + + + if (idx < net->width_b()) { + nex = net->pin_DataB(idx).nexus(); + assert(nex); + assert(nex->t_cookie()); + + obj->u_.arith.b[idx] = (ivl_nexus_t) nex->t_cookie(); + nexus_lpm_add(obj->u_.arith.b[idx], obj, 0, + IVL_DR_HiZ, IVL_DR_HiZ); + + } else { + obj->u_.arith.b[idx] = 0; + } + } + + scope_add_lpm(obj->scope, obj); +} + void dll_target::lpm_mux(const NetMux*net) { ivl_lpm_t obj = new struct ivl_lpm_s; @@ -1293,6 +1352,11 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj }; /* * $Log: t-dll.cc,v $ + * Revision 1.49 2001/06/16 23:45:05 steve + * Add support for structural multiply in t-dll. + * Add code generators and vvp support for both + * structural and behavioral multiply. + * * Revision 1.48 2001/06/16 02:41:42 steve * Generate code to support memory access in continuous * assignment statements. (Stephan Boettcher) diff --git a/t-dll.h b/t-dll.h index fe6b0d57b..9dce8d93f 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.48 2001/06/16 02:41:42 steve Exp $" +#ident "$Id: t-dll.h,v 1.49 2001/06/16 23:45:05 steve Exp $" #endif # include "target.h" @@ -64,6 +64,7 @@ struct dll_target : public target_t, public expr_scan_t { void lpm_add_sub(const NetAddSub*); void lpm_compare(const NetCompare*); void lpm_ff(const NetFF*); + void lpm_mult(const NetMult*); void lpm_mux(const NetMux*); void lpm_ram_dq(const NetRamDq*); void net_assign(const NetAssign_*); @@ -537,6 +538,11 @@ struct ivl_statement_s { /* * $Log: t-dll.h,v $ + * Revision 1.49 2001/06/16 23:45:05 steve + * Add support for structural multiply in t-dll. + * Add code generators and vvp support for both + * structural and behavioral multiply. + * * Revision 1.48 2001/06/16 02:41:42 steve * Generate code to support memory access in continuous * assignment statements. (Stephan Boettcher) diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 3583c464c..179f531c7 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.29 2001/05/24 04:20:10 steve Exp $" +#ident "$Id: eval_expr.c,v 1.30 2001/06/16 23:45:05 steve Exp $" #endif # include "vvp_priv.h" @@ -518,12 +518,12 @@ static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) struct vector_info lv; struct vector_info rv; - assert(ivl_expr_width(le) == wid); - assert(ivl_expr_width(re) == wid); - lv = draw_eval_expr_wid(le, wid); rv = draw_eval_expr_wid(re, wid); + assert(lv.wid == wid); + assert(rv.wid == wid); + switch (ivl_expr_opcode(exp)) { case '+': fprintf(vvp_out, " %%add %u, %u, %u;\n", lv.base, rv.base, wid); @@ -533,6 +533,10 @@ static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) fprintf(vvp_out, " %%sub %u, %u, %u;\n", lv.base, rv.base, wid); break; + case '*': + fprintf(vvp_out, " %%mul %u, %u, %u;\n", lv.base, rv.base, wid); + break; + case '%': fprintf(vvp_out, " %%mod %u, %u, %u;\n", lv.base, rv.base, wid); break; @@ -572,6 +576,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, unsigned wid) case '+': case '-': + case '*': case '%': rv = draw_binary_expr_arith(exp, wid); break; @@ -1043,6 +1048,11 @@ struct vector_info draw_eval_expr(ivl_expr_t exp) /* * $Log: eval_expr.c,v $ + * Revision 1.30 2001/06/16 23:45:05 steve + * Add support for structural multiply in t-dll. + * Add code generators and vvp support for both + * structural and behavioral multiply. + * * Revision 1.29 2001/05/24 04:20:10 steve * Add behavioral modulus. * diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 2a3fe95bc..4685cc506 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 */ #if !defined(WINNT) -#ident "$Id: vvp_scope.c,v 1.33 2001/06/16 02:41:42 steve Exp $" +#ident "$Id: vvp_scope.c,v 1.34 2001/06/16 23:45:05 steve Exp $" #endif # include "vvp_priv.h" @@ -118,6 +118,7 @@ static const char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr) case IVL_LPM_RAM: case IVL_LPM_ADD: case IVL_LPM_SUB: + case IVL_LPM_MULT: for (idx = 0 ; idx < ivl_lpm_width(lpm) ; idx += 1) if (ivl_lpm_q(lpm, idx) == nex) { sprintf(result, "L_%s[%u]", @@ -138,7 +139,10 @@ static const char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr) } + fprintf(stderr, "internal error: no input to nexus %s\n", + ivl_nexus_name(nex)); assert(0); + return "C"; } static const char* draw_net_input(ivl_nexus_t nex) @@ -706,6 +710,9 @@ static void draw_lpm_add(ivl_lpm_t net) case IVL_LPM_SUB: type = "sub"; break; + case IVL_LPM_MULT: + type = "mult"; + break; default: assert(0); } @@ -779,6 +786,7 @@ static void draw_lpm_in_scope(ivl_lpm_t net) case IVL_LPM_ADD: case IVL_LPM_SUB: + case IVL_LPM_MULT: draw_lpm_add(net); return; @@ -876,6 +884,11 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent) /* * $Log: vvp_scope.c,v $ + * Revision 1.34 2001/06/16 23:45:05 steve + * Add support for structural multiply in t-dll. + * Add code generators and vvp support for both + * structural and behavioral multiply. + * * Revision 1.33 2001/06/16 02:41:42 steve * Generate code to support memory access in continuous * assignment statements. (Stephan Boettcher) diff --git a/vvp/README.txt b/vvp/README.txt index 59b6da172..14678a924 100644 --- a/vvp/README.txt +++ b/vvp/README.txt @@ -1,7 +1,7 @@ /* * Copyright (c) 2001 Stephen Williams (steve@icarus.com) * - * $Id: README.txt,v 1.29 2001/06/15 04:07:57 steve Exp $ + * $Id: README.txt,v 1.30 2001/06/16 23:45:05 steve Exp $ */ VVP SIMULATION ENGINE @@ -423,6 +423,7 @@ create special statement types for the various arithmetic operators.