Add support for structural multiply in t-dll.

Add code generators and vvp support for both
 structural and behavioral multiply.
This commit is contained in:
steve 2001-06-16 23:45:05 +00:00
parent 63a02d1c0a
commit 4b82d26f5e
19 changed files with 344 additions and 41 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "PExpr.h" # include "PExpr.h"
@ -791,7 +791,7 @@ NetNet* PEBinary::elaborate_net_mul_(Design*des, const string&path,
if (rsig == 0) return 0; if (rsig == 0) return 0;
unsigned rwidth = lwidth; 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(), lsig->pin_count(),
rsig->pin_count()); rsig->pin_count());
des->add_node(mult); des->add_node(mult);
@ -1901,6 +1901,11 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
/* /*
* $Log: elab_net.cc,v $ * $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 * Revision 1.68 2001/06/15 04:14:18 steve
* Generate vvp code for GT and GE comparisons. * Generate vvp code for GT and GE comparisons.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
#ifdef __cplusplus #ifdef __cplusplus
@ -205,9 +205,10 @@ typedef enum ivl_lpm_type_e {
IVL_LPM_CMP_GE, IVL_LPM_CMP_GE,
IVL_LPM_CMP_GT, IVL_LPM_CMP_GT,
IVL_LPM_FF, IVL_LPM_FF,
IVL_LPM_MULT,
IVL_LPM_MUX, IVL_LPM_MUX,
IVL_LPM_SUB, IVL_LPM_SUB,
IVL_LPM_RAM, IVL_LPM_RAM
} ivl_lpm_type_t; } ivl_lpm_type_t;
/* Processes are initial or always blocks with a statement. This is /* 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); extern ivl_nexus_t ivl_lpm_clk(ivl_lpm_t net);
/* IVL_LPM_RAM */ /* IVL_LPM_RAM */
extern ivl_nexus_t ivl_lpm_enable(ivl_lpm_t net); 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); 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); extern ivl_nexus_t ivl_lpm_datab(ivl_lpm_t net, unsigned idx);
/* IVL_LPM_MUX */ /* IVL_LPM_MUX */
extern ivl_nexus_t ivl_lpm_data2(ivl_lpm_t net, unsigned sdx, unsigned idx); 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); extern ivl_nexus_t ivl_lpm_q(ivl_lpm_t net, unsigned idx);
/* IVL_LPM_MUX IVL_LPM_RAM */ /* IVL_LPM_MUX IVL_LPM_RAM */
extern unsigned ivl_lpm_selects(ivl_lpm_t net); extern unsigned ivl_lpm_selects(ivl_lpm_t net);
@ -881,6 +882,11 @@ _END_DECL
/* /*
* $Log: ivl_target.h,v $ * $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 * Revision 1.67 2001/06/16 02:41:41 steve
* Generate code to support memory access in continuous * Generate code to support memory access in continuous
* assignment statements. (Stephan Boettcher) * assignment statements. (Stephan Boettcher)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include <cassert> # include <cassert>
@ -1012,9 +1012,9 @@ const Link& NetDivide::pin_DataB(unsigned idx) const
return pin(idx+width_r_+width_a_); return pin(idx+width_r_+width_a_);
} }
NetMult::NetMult(const string&n, unsigned wr, unsigned wa, unsigned wb, NetMult::NetMult(NetScope*sc, const string&n, unsigned wr,
unsigned ws) unsigned wa, unsigned wb, unsigned ws)
: NetNode(n, 2+wr+wa+wb+ws), width_r_(wr), width_a_(wa), width_b_(wb), : NetNode(sc, n, 2+wr+wa+wb+ws), width_r_(wr), width_a_(wa), width_b_(wb),
width_s_(ws) width_s_(ws)
{ {
pin(0).set_dir(Link::INPUT); pin(0).set_name("Aclr", 0); pin(0).set_dir(Link::INPUT); pin(0).set_name("Aclr", 0);
@ -2323,6 +2323,11 @@ const NetProc*NetTaskDef::proc() const
/* /*
* $Log: netlist.cc,v $ * $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 * Revision 1.162 2001/06/15 04:14:18 steve
* Generate vvp code for GT and GE comparisons. * Generate vvp code for GT and GE comparisons.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
/* /*
@ -678,8 +678,8 @@ class NetMemory {
class NetMult : public NetNode { class NetMult : public NetNode {
public: public:
NetMult(const string&n, unsigned width, unsigned wa, unsigned wb, NetMult(NetScope*sc, const string&n, unsigned width,
unsigned width_s =0); unsigned wa, unsigned wb, unsigned width_s =0);
~NetMult(); ~NetMult();
// Get the width of the device bussed inputs. There are these // 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 $ * $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 * Revision 1.208 2001/06/15 04:14:18 steve
* Generate vvp code for GT and GE comparisons. * Generate vvp code for GT and GE comparisons.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "t-dll.h" # 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_ADD:
case IVL_LPM_CMP_GE: case IVL_LPM_CMP_GE:
case IVL_LPM_CMP_GT: case IVL_LPM_CMP_GT:
case IVL_LPM_MULT:
case IVL_LPM_SUB: case IVL_LPM_SUB:
assert(idx < net->u_.arith.width); assert(idx < net->u_.arith.width);
return net->u_.arith.a[idx]; 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_ADD:
case IVL_LPM_CMP_GE: case IVL_LPM_CMP_GE:
case IVL_LPM_CMP_GT: case IVL_LPM_CMP_GT:
case IVL_LPM_MULT:
case IVL_LPM_SUB: case IVL_LPM_SUB:
assert(idx < net->u_.arith.width); assert(idx < net->u_.arith.width);
return net->u_.arith.b[idx]; 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) { switch (net->type) {
case IVL_LPM_ADD: case IVL_LPM_ADD:
case IVL_LPM_MULT:
case IVL_LPM_SUB: case IVL_LPM_SUB:
assert(idx < net->u_.arith.width); assert(idx < net->u_.arith.width);
return net->u_.arith.q[idx]; 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_ADD:
case IVL_LPM_CMP_GE: case IVL_LPM_CMP_GE:
case IVL_LPM_CMP_GT: case IVL_LPM_CMP_GT:
case IVL_LPM_MULT:
case IVL_LPM_SUB: case IVL_LPM_SUB:
return net->u_.arith.width; return net->u_.arith.width;
default: default:
@ -1223,6 +1227,11 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/* /*
* $Log: t-dll-api.cc,v $ * $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 * Revision 1.50 2001/06/16 02:41:41 steve
* Generate code to support memory access in continuous * Generate code to support memory access in continuous
* assignment statements. (Stephan Boettcher) * assignment statements. (Stephan Boettcher)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "compiler.h" # include "compiler.h"
@ -837,9 +837,10 @@ void dll_target::lpm_ram_dq(const NetRamDq*net)
const Nexus*nex; const Nexus*nex;
// How do I find out if there is something // A write port is present only if something is connected to
// connected to the clock input? // the clock input.
bool has_write_port = false;
bool has_write_port = net->pin_InClock().is_linked();
// Connect the write clock and write enable // 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) void dll_target::lpm_mux(const NetMux*net)
{ {
ivl_lpm_t obj = new struct ivl_lpm_s; 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 $ * $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 * Revision 1.48 2001/06/16 02:41:42 steve
* Generate code to support memory access in continuous * Generate code to support memory access in continuous
* assignment statements. (Stephan Boettcher) * assignment statements. (Stephan Boettcher)

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "target.h" # 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_add_sub(const NetAddSub*);
void lpm_compare(const NetCompare*); void lpm_compare(const NetCompare*);
void lpm_ff(const NetFF*); void lpm_ff(const NetFF*);
void lpm_mult(const NetMult*);
void lpm_mux(const NetMux*); void lpm_mux(const NetMux*);
void lpm_ram_dq(const NetRamDq*); void lpm_ram_dq(const NetRamDq*);
void net_assign(const NetAssign_*); void net_assign(const NetAssign_*);
@ -537,6 +538,11 @@ struct ivl_statement_s {
/* /*
* $Log: t-dll.h,v $ * $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 * Revision 1.48 2001/06/16 02:41:42 steve
* Generate code to support memory access in continuous * Generate code to support memory access in continuous
* assignment statements. (Stephan Boettcher) * assignment statements. (Stephan Boettcher)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #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 #endif
# include "vvp_priv.h" # 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 lv;
struct vector_info rv; struct vector_info rv;
assert(ivl_expr_width(le) == wid);
assert(ivl_expr_width(re) == wid);
lv = draw_eval_expr_wid(le, wid); lv = draw_eval_expr_wid(le, wid);
rv = draw_eval_expr_wid(re, wid); rv = draw_eval_expr_wid(re, wid);
assert(lv.wid == wid);
assert(rv.wid == wid);
switch (ivl_expr_opcode(exp)) { switch (ivl_expr_opcode(exp)) {
case '+': case '+':
fprintf(vvp_out, " %%add %u, %u, %u;\n", lv.base, rv.base, wid); 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); fprintf(vvp_out, " %%sub %u, %u, %u;\n", lv.base, rv.base, wid);
break; break;
case '*':
fprintf(vvp_out, " %%mul %u, %u, %u;\n", lv.base, rv.base, wid);
break;
case '%': case '%':
fprintf(vvp_out, " %%mod %u, %u, %u;\n", lv.base, rv.base, wid); fprintf(vvp_out, " %%mod %u, %u, %u;\n", lv.base, rv.base, wid);
break; break;
@ -572,6 +576,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, unsigned wid)
case '+': case '+':
case '-': case '-':
case '*':
case '%': case '%':
rv = draw_binary_expr_arith(exp, wid); rv = draw_binary_expr_arith(exp, wid);
break; break;
@ -1043,6 +1048,11 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
/* /*
* $Log: eval_expr.c,v $ * $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 * Revision 1.29 2001/05/24 04:20:10 steve
* Add behavioral modulus. * Add behavioral modulus.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #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 #endif
# include "vvp_priv.h" # 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_RAM:
case IVL_LPM_ADD: case IVL_LPM_ADD:
case IVL_LPM_SUB: case IVL_LPM_SUB:
case IVL_LPM_MULT:
for (idx = 0 ; idx < ivl_lpm_width(lpm) ; idx += 1) for (idx = 0 ; idx < ivl_lpm_width(lpm) ; idx += 1)
if (ivl_lpm_q(lpm, idx) == nex) { if (ivl_lpm_q(lpm, idx) == nex) {
sprintf(result, "L_%s[%u]", 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); assert(0);
return "C<z>";
} }
static const char* draw_net_input(ivl_nexus_t nex) 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: case IVL_LPM_SUB:
type = "sub"; type = "sub";
break; break;
case IVL_LPM_MULT:
type = "mult";
break;
default: default:
assert(0); assert(0);
} }
@ -779,6 +786,7 @@ static void draw_lpm_in_scope(ivl_lpm_t net)
case IVL_LPM_ADD: case IVL_LPM_ADD:
case IVL_LPM_SUB: case IVL_LPM_SUB:
case IVL_LPM_MULT:
draw_lpm_add(net); draw_lpm_add(net);
return; return;
@ -876,6 +884,11 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
/* /*
* $Log: vvp_scope.c,v $ * $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 * Revision 1.33 2001/06/16 02:41:42 steve
* Generate code to support memory access in continuous * Generate code to support memory access in continuous
* assignment statements. (Stephan Boettcher) * assignment statements. (Stephan Boettcher)

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com) * 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 VVP SIMULATION ENGINE
@ -423,6 +423,7 @@ create special statement types for the various arithmetic operators.
<label> .arith/sub <wid>, <symbols_list>; <label> .arith/sub <wid>, <symbols_list>;
<label> .arith/sum <wid>, <symbols_list>; <label> .arith/sum <wid>, <symbols_list>;
<label> .arith/mult <wid>, <symbols_list>;
Addition is represented by the .arith/sum statement. This creates an Addition is represented by the .arith/sum statement. This creates an
array of functors based at the label. The width of the array is given array of functors based at the label. The width of the array is given

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: arith.cc,v 1.4 2001/06/16 03:36:03 steve Exp $" #ident "$Id: arith.cc,v 1.5 2001/06/16 23:45:05 steve Exp $"
#endif #endif
# include "arith.h" # include "arith.h"
@ -48,6 +48,55 @@ void vvp_arith_::output_x_(bool push)
} }
} }
vvp_arith_mult::vvp_arith_mult(vvp_ipoint_t b, unsigned w)
: vvp_arith_(b, w)
{
}
void vvp_arith_mult::set(vvp_ipoint_t i, functor_t f, bool push)
{
assert(wid_ <= 8*sizeof(unsigned long));
unsigned long a = 0, b = 0;
for (unsigned idx = 0 ; idx < wid_ ; idx += 1) {
vvp_ipoint_t ptr = ipoint_index(base_,idx);
functor_t obj = functor_index(ptr);
unsigned ival = obj->ival;
if (ival & 0xaa) {
output_x_(push);
return;
}
if (ival & 0x01)
a += 1 << idx;
if (ival & 0x04)
b += 1 << idx;
}
unsigned long sum = a * b;
for (unsigned idx = 0 ; idx < wid_ ; idx += 1) {
vvp_ipoint_t ptr = ipoint_index(base_,idx);
functor_t obj = functor_index(ptr);
unsigned oval = sum & 1;
sum >>= 1;
if (obj->oval == oval)
continue;
obj->oval = oval;
if (push)
functor_propagate(ptr);
else
schedule_functor(ptr, 0);
}
}
vvp_arith_sum::vvp_arith_sum(vvp_ipoint_t b, unsigned w) vvp_arith_sum::vvp_arith_sum(vvp_ipoint_t b, unsigned w)
: vvp_arith_(b, w) : vvp_arith_(b, w)
{ {
@ -55,7 +104,7 @@ vvp_arith_sum::vvp_arith_sum(vvp_ipoint_t b, unsigned w)
void vvp_arith_sum::set(vvp_ipoint_t i, functor_t f, bool push) void vvp_arith_sum::set(vvp_ipoint_t i, functor_t f, bool push)
{ {
assert(wid_ <= sizeof(unsigned long)); assert(wid_ <= 8*sizeof(unsigned long));
unsigned long sum = 0; unsigned long sum = 0;
@ -108,7 +157,7 @@ vvp_arith_sub::vvp_arith_sub(vvp_ipoint_t b, unsigned w)
void vvp_arith_sub::set(vvp_ipoint_t i, functor_t f, bool push) void vvp_arith_sub::set(vvp_ipoint_t i, functor_t f, bool push)
{ {
assert(wid_ <= sizeof(unsigned long)); assert(wid_ <= 8*sizeof(unsigned long));
unsigned long sum = 0; unsigned long sum = 0;
@ -242,6 +291,11 @@ void vvp_cmp_gt::set(vvp_ipoint_t i, functor_t f, bool push)
/* /*
* $Log: arith.cc,v $ * $Log: arith.cc,v $
* Revision 1.5 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.4 2001/06/16 03:36:03 steve * Revision 1.4 2001/06/16 03:36:03 steve
* Relax width restriction for structural comparators. * Relax width restriction for structural comparators.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: arith.h,v 1.3 2001/06/15 04:07:58 steve Exp $" #ident "$Id: arith.h,v 1.4 2001/06/16 23:45:05 steve Exp $"
#endif #endif
# include "functor.h" # include "functor.h"
@ -47,6 +47,18 @@ class vvp_arith_ : public vvp_fobj_s {
* in cause the 4-input summation to be calculated, and output * in cause the 4-input summation to be calculated, and output
* functors that are affected cause propagations. * functors that are affected cause propagations.
*/ */
class vvp_arith_mult : public vvp_arith_ {
public:
explicit vvp_arith_mult(vvp_ipoint_t b, unsigned wid);
void set(vvp_ipoint_t i, functor_t f, bool push);
private: // not implemented
vvp_arith_mult(const vvp_arith_mult&);
vvp_arith_mult& operator= (const vvp_arith_mult&);
};
class vvp_arith_sum : public vvp_arith_ { class vvp_arith_sum : public vvp_arith_ {
public: public:
@ -96,6 +108,11 @@ class vvp_cmp_gt : public vvp_arith_ {
}; };
/* /*
* $Log: arith.h,v $ * $Log: arith.h,v $
* Revision 1.4 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.3 2001/06/15 04:07:58 steve * Revision 1.3 2001/06/15 04:07:58 steve
* Add .cmp statements for structural comparison. * Add .cmp statements for structural comparison.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: codes.h,v 1.27 2001/05/24 04:20:10 steve Exp $" #ident "$Id: codes.h,v 1.28 2001/06/16 23:45:05 steve Exp $"
#endif #endif
@ -63,6 +63,7 @@ extern bool of_LOAD(vthread_t thr, vvp_code_t code);
extern bool of_LOAD_MEM(vthread_t thr, vvp_code_t code); extern bool of_LOAD_MEM(vthread_t thr, vvp_code_t code);
extern bool of_MOD(vthread_t thr, vvp_code_t code); extern bool of_MOD(vthread_t thr, vvp_code_t code);
extern bool of_MOV(vthread_t thr, vvp_code_t code); extern bool of_MOV(vthread_t thr, vvp_code_t code);
extern bool of_MUL(vthread_t thr, vvp_code_t code);
extern bool of_NOOP(vthread_t thr, vvp_code_t code); extern bool of_NOOP(vthread_t thr, vvp_code_t code);
extern bool of_NORR(vthread_t thr, vvp_code_t code); extern bool of_NORR(vthread_t thr, vvp_code_t code);
extern bool of_OR(vthread_t thr, vvp_code_t code); extern bool of_OR(vthread_t thr, vvp_code_t code);
@ -128,6 +129,11 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
/* /*
* $Log: codes.h,v $ * $Log: codes.h,v $
* Revision 1.28 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.27 2001/05/24 04:20:10 steve * Revision 1.27 2001/05/24 04:20:10 steve
* Add behavioral modulus. * Add behavioral modulus.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: compile.cc,v 1.76 2001/06/15 04:07:58 steve Exp $" #ident "$Id: compile.cc,v 1.77 2001/06/16 23:45:05 steve Exp $"
#endif #endif
# include "arith.h" # include "arith.h"
@ -102,6 +102,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%load/m", of_LOAD_MEM,2, {OA_BIT1, OA_MEM_PTR, OA_NONE} }, { "%load/m", of_LOAD_MEM,2, {OA_BIT1, OA_MEM_PTR, OA_NONE} },
{ "%mod", of_MOD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%mod", of_MOD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%mul", of_MUL, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%noop", of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} }, { "%noop", of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} },
{ "%nor/r", of_NORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%nor/r", of_NORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%or", of_OR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%or", of_OR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
@ -433,6 +434,26 @@ static void connect_arith_inputs(vvp_ipoint_t fdx, long wid,
free(argv); free(argv);
} }
void compile_arith_mult(char*label, long wid,
unsigned argc, struct symb_s*argv)
{
assert( wid > 0 );
if (argc != 2*wid) {
fprintf(stderr, "%s; .arith has wrong number of symbols\n", label);
compile_errors += 1;
free(label);
return;
}
vvp_ipoint_t fdx = functor_allocate(wid);
define_functor_symbol(label, fdx);
vvp_arith_mult*arith = new vvp_arith_mult(fdx, wid);
connect_arith_inputs(fdx, wid, arith, argc, argv);
}
void compile_arith_sub(char*label, long wid, unsigned argc, struct symb_s*argv) void compile_arith_sub(char*label, long wid, unsigned argc, struct symb_s*argv)
{ {
assert( wid > 0 ); assert( wid > 0 );
@ -1380,6 +1401,11 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
/* /*
* $Log: compile.cc,v $ * $Log: compile.cc,v $
* Revision 1.77 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.76 2001/06/15 04:07:58 steve * Revision 1.76 2001/06/15 04:07:58 steve
* Add .cmp statements for structural comparison. * Add .cmp statements for structural comparison.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: compile.h,v 1.27 2001/06/15 04:07:58 steve Exp $" #ident "$Id: compile.h,v 1.28 2001/06/16 23:45:05 steve Exp $"
#endif #endif
# include <stdio.h> # include <stdio.h>
@ -73,6 +73,8 @@ extern void compile_resolver(char*label, char*type,
* This is called by the parser to make the various arithmetic and * This is called by the parser to make the various arithmetic and
* comparison functors. * comparison functors.
*/ */
extern void compile_arith_mult(char*label, long width,
unsigned argc, struct symb_s*argv);
extern void compile_arith_sum(char*label, long width, extern void compile_arith_sum(char*label, long width,
unsigned argc, struct symb_s*argv); unsigned argc, struct symb_s*argv);
extern void compile_arith_sub(char*label, long width, extern void compile_arith_sub(char*label, long width,
@ -196,6 +198,11 @@ extern void compile_net(char*label, char*name,
/* /*
* $Log: compile.h,v $ * $Log: compile.h,v $
* Revision 1.28 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.27 2001/06/15 04:07:58 steve * Revision 1.27 2001/06/15 04:07:58 steve
* Add .cmp statements for structural comparison. * Add .cmp statements for structural comparison.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: lexor.lex,v 1.21 2001/06/15 04:07:58 steve Exp $" #ident "$Id: lexor.lex,v 1.22 2001/06/16 23:45:05 steve Exp $"
#endif #endif
# include "parse_misc.h" # include "parse_misc.h"
@ -65,6 +65,7 @@
/* These are some keywords that are recognized. */ /* These are some keywords that are recognized. */
".arith/mult" { return K_ARITH_MULT; }
".arith/sub" { return K_ARITH_SUB; } ".arith/sub" { return K_ARITH_SUB; }
".arith/sum" { return K_ARITH_SUM; } ".arith/sum" { return K_ARITH_SUM; }
".cmp/ge" { return K_CMP_GE; } ".cmp/ge" { return K_CMP_GE; }
@ -144,6 +145,11 @@ int yywrap()
/* /*
* $Log: lexor.lex,v $ * $Log: lexor.lex,v $
* Revision 1.22 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.21 2001/06/15 04:07:58 steve * Revision 1.21 2001/06/15 04:07:58 steve
* Add .cmp statements for structural comparison. * Add .cmp statements for structural comparison.
* *

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com) * Copyright (c) 2001 Stephen Williams (steve@icarus.com)
* *
* $Id: opcodes.txt,v 1.22 2001/05/24 04:20:10 steve Exp $ * $Id: opcodes.txt,v 1.23 2001/06/16 23:45:05 steve Exp $
*/ */
@ -244,6 +244,14 @@ is one of the 4 constant bits, the effect is to replicate the value
into the destination vector. This is useful for filling a vector. into the destination vector. This is useful for filling a vector.
* %mul <bit-l>, <bit-r>, <wid>
This instruction multiplies the left vector by the right vector, the
vectors having the width <wid>. If any of the bits of either vector
are x or z, the result is x. Otherwise, the result is the arithmetic
product.
* %nor/r <dst>, <src>, <wid> * %nor/r <dst>, <src>, <wid>
The %nor/r instruction is a reduction nor. That is, the <src> is a The %nor/r instruction is a reduction nor. That is, the <src> is a

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: parse.y,v 1.31 2001/06/15 04:07:58 steve Exp $" #ident "$Id: parse.y,v 1.32 2001/06/16 23:45:05 steve Exp $"
#endif #endif
# include "parse_misc.h" # include "parse_misc.h"
@ -54,7 +54,7 @@ extern FILE*yyin;
}; };
%token K_ARITH_SUB K_ARITH_SUM K_CMP_GE K_CMP_GT %token K_ARITH_MULT K_ARITH_SUB K_ARITH_SUM K_CMP_GE K_CMP_GT
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S %token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S
%token K_RESOLV K_SCOPE K_THREAD %token K_RESOLV K_SCOPE K_THREAD
%token K_UDP K_UDP_C K_UDP_S %token K_UDP K_UDP_C K_UDP_S
@ -157,6 +157,11 @@ statement
/* Arithmetic statements generate functor arrays of a given width /* Arithmetic statements generate functor arrays of a given width
that take like size input vectors. */ that take like size input vectors. */
| T_LABEL K_ARITH_MULT T_NUMBER ',' symbols ';'
{ struct symbv_s obj = $5;
compile_arith_mult($1, $3, obj.cnt, obj.vect);
}
| T_LABEL K_ARITH_SUB T_NUMBER ',' symbols ';' | T_LABEL K_ARITH_SUB T_NUMBER ',' symbols ';'
{ struct symbv_s obj = $5; { struct symbv_s obj = $5;
compile_arith_sub($1, $3, obj.cnt, obj.vect); compile_arith_sub($1, $3, obj.cnt, obj.vect);
@ -469,6 +474,11 @@ int compile_design(const char*path)
/* /*
* $Log: parse.y,v $ * $Log: parse.y,v $
* Revision 1.32 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.31 2001/06/15 04:07:58 steve * Revision 1.31 2001/06/15 04:07:58 steve
* Add .cmp statements for structural comparison. * Add .cmp statements for structural comparison.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: vthread.cc,v 1.42 2001/05/30 03:02:35 steve Exp $" #ident "$Id: vthread.cc,v 1.43 2001/06/16 23:45:05 steve Exp $"
#endif #endif
# include "vthread.h" # include "vthread.h"
@ -820,6 +820,46 @@ bool of_MOV(vthread_t thr, vvp_code_t cp)
return true; return true;
} }
bool of_MUL(vthread_t thr, vvp_code_t cp)
{
assert(cp->bit_idx1 >= 4);
assert(cp->number <= 8*sizeof(unsigned long));
unsigned idx1 = cp->bit_idx1;
unsigned idx2 = cp->bit_idx2;
unsigned long lv = 0, rv = 0;
for (unsigned idx = 0 ; idx < cp->number ; idx += 1) {
unsigned lb = thr_get_bit(thr, idx1);
unsigned rb = thr_get_bit(thr, idx2);
if ((lb | rb) & 2)
goto x_out;
lv |= lb << idx;
rv |= rb << idx;
idx1 += 1;
if (idx2 >= 4)
idx2 += 1;
}
lv *= rv;
for (unsigned idx = 0 ; idx < cp->number ; idx += 1) {
thr_put_bit(thr, cp->bit_idx1+idx, (lv&1) ? 1 : 0);
lv >>= 1;
}
return true;
x_out:
for (unsigned idx = 0 ; idx < cp->number ; idx += 1)
thr_put_bit(thr, cp->bit_idx1+idx, 2);
return true;
}
bool of_NOOP(vthread_t thr, vvp_code_t cp) bool of_NOOP(vthread_t thr, vvp_code_t cp)
{ {
return true; return true;
@ -1047,6 +1087,11 @@ bool of_ZOMBIE(vthread_t thr, vvp_code_t)
/* /*
* $Log: vthread.cc,v $ * $Log: vthread.cc,v $
* Revision 1.43 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.42 2001/05/30 03:02:35 steve * Revision 1.42 2001/05/30 03:02:35 steve
* Propagate strength-values instead of drive strengths. * Propagate strength-values instead of drive strengths.
* *