Add structural modulus support down to vvp.

This commit is contained in:
steve 2002-01-03 04:19:01 +00:00
parent 51ffeb7c06
commit dd79885f6d
13 changed files with 210 additions and 17 deletions

View File

@ -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.84 2001/12/31 04:23:59 steve Exp $"
#ident "$Id: elab_net.cc,v 1.85 2002/01/03 04:19:01 steve Exp $"
#endif
# include "config.h"
@ -654,9 +654,12 @@ NetNet* PEBinary::elaborate_net_mod_(Design*des, NetScope*scope,
NetNet*rsig = right_->elaborate_net(des, scope, 0, 0, 0, 0);
if (rsig == 0) return 0;
unsigned rwidth = lsig->pin_count();
if (rsig->pin_count() > rwidth)
rwidth = rsig->pin_count();
unsigned rwidth = lwidth;
if (rwidth == 0) {
rwidth = lsig->pin_count();
if (rsig->pin_count() > rwidth)
rwidth = rsig->pin_count();
}
NetModulo*mod = new NetModulo(scope, scope->local_hsymbol(), rwidth,
lsig->pin_count(),
rsig->pin_count());
@ -1974,6 +1977,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
/*
* $Log: elab_net.cc,v $
* Revision 1.85 2002/01/03 04:19:01 steve
* Add structural modulus support down to vvp.
*
* Revision 1.84 2001/12/31 04:23:59 steve
* Elaborate multiply nets with constant operands ad NetConst.
*

View File

@ -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.90 2001/12/15 02:13:17 steve Exp $"
#ident "$Id: ivl_target.h,v 1.91 2002/01/03 04:19:01 steve Exp $"
#endif
#ifdef __cplusplus
@ -210,6 +210,7 @@ typedef enum ivl_lpm_type_e {
IVL_LPM_CMP_NE = 11,
IVL_LPM_DIVIDE = 12,
IVL_LPM_FF = 3,
IVL_LPM_MOD = 13,
IVL_LPM_MULT = 4,
IVL_LPM_MUX = 5,
IVL_LPM_SHIFTL = 6,
@ -976,6 +977,9 @@ _END_DECL
/*
* $Log: ivl_target.h,v $
* Revision 1.91 2002/01/03 04:19:01 steve
* Add structural modulus support down to vvp.
*
* Revision 1.90 2001/12/15 02:13:17 steve
* The IVL_SIT_WIRE type does not exist, it is a
* synonym for IVL_SIT_TRI.

View File

@ -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.73 2001/12/06 03:11:00 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.74 2002/01/03 04:19:01 steve Exp $"
#endif
# include "config.h"
@ -564,6 +564,7 @@ extern "C" ivl_nexus_t ivl_lpm_data(ivl_lpm_t net, unsigned idx)
case IVL_LPM_CMP_GT:
case IVL_LPM_CMP_NE:
case IVL_LPM_DIVIDE:
case IVL_LPM_MOD:
case IVL_LPM_MULT:
case IVL_LPM_SUB:
assert(idx < net->u_.arith.width);
@ -599,6 +600,7 @@ extern "C" ivl_nexus_t ivl_lpm_datab(ivl_lpm_t net, unsigned idx)
case IVL_LPM_CMP_GT:
case IVL_LPM_CMP_NE:
case IVL_LPM_DIVIDE:
case IVL_LPM_MOD:
case IVL_LPM_MULT:
case IVL_LPM_SUB:
assert(idx < net->u_.arith.width);
@ -637,6 +639,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_DIVIDE:
case IVL_LPM_MOD:
case IVL_LPM_MULT:
case IVL_LPM_SUB:
assert(idx < net->u_.arith.width);
@ -756,6 +759,7 @@ extern "C" unsigned ivl_lpm_width(ivl_lpm_t net)
case IVL_LPM_CMP_GT:
case IVL_LPM_CMP_NE:
case IVL_LPM_DIVIDE:
case IVL_LPM_MOD:
case IVL_LPM_MULT:
case IVL_LPM_SUB:
return net->u_.arith.width;
@ -1446,6 +1450,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/*
* $Log: t-dll-api.cc,v $
* Revision 1.74 2002/01/03 04:19:01 steve
* Add structural modulus support down to vvp.
*
* Revision 1.73 2001/12/06 03:11:00 steve
* Add ivl_logic_delay function to ivl_target.
*

View File

@ -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.74 2001/12/18 05:34:02 steve Exp $"
#ident "$Id: t-dll.cc,v 1.75 2002/01/03 04:19:01 steve Exp $"
#endif
# include "config.h"
@ -1109,6 +1109,73 @@ void dll_target::lpm_divide(const NetDivide*net)
scope_add_lpm(obj->scope, obj);
}
void dll_target::lpm_modulo(const NetModulo*net)
{
ivl_lpm_t obj = new struct ivl_lpm_s;
obj->type = IVL_LPM_MOD;
obj->name = strdup(net->name());
assert(net->scope());
obj->scope = find_scope(des_, net->scope());
assert(obj->scope);
unsigned wid = net->width_r();
if (wid < net->width_a())
wid = net->width_a();
if (wid < net->width_b())
wid = net->width_b();
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;
if (idx < net->width_r()) {
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);
} else {
obj->u_.arith.q[idx] = 0;
}
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_ff(const NetFF*net)
{
ivl_lpm_t obj = new struct ivl_lpm_s;
@ -1723,6 +1790,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
/*
* $Log: t-dll.cc,v $
* Revision 1.75 2002/01/03 04:19:01 steve
* Add structural modulus support down to vvp.
*
* Revision 1.74 2001/12/18 05:34:02 steve
* Comments about MUX synthesis.
*

View File

@ -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.72 2001/12/06 03:11:01 steve Exp $"
#ident "$Id: t-dll.h,v 1.73 2002/01/03 04:19:01 steve Exp $"
#endif
# include "target.h"
@ -75,6 +75,7 @@ struct dll_target : public target_t, public expr_scan_t {
void lpm_compare(const NetCompare*);
void lpm_divide(const NetDivide*);
void lpm_ff(const NetFF*);
void lpm_modulo(const NetModulo*);
void lpm_mult(const NetMult*);
void lpm_mux(const NetMux*);
void lpm_ram_dq(const NetRamDq*);
@ -589,6 +590,9 @@ struct ivl_statement_s {
/*
* $Log: t-dll.h,v $
* Revision 1.73 2002/01/03 04:19:01 steve
* Add structural modulus support down to vvp.
*
* Revision 1.72 2001/12/06 03:11:01 steve
* Add ivl_logic_delay function to ivl_target.
*

View File

@ -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.60 2001/12/15 02:13:33 steve Exp $"
#ident "$Id: vvp_scope.c,v 1.61 2002/01/03 04:19:01 steve Exp $"
#endif
# include "vvp_priv.h"
@ -247,6 +247,7 @@ static const char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr)
case IVL_LPM_SUB:
case IVL_LPM_MULT:
case IVL_LPM_DIVIDE:
case IVL_LPM_MOD:
for (idx = 0 ; idx < ivl_lpm_width(lpm) ; idx += 1)
if (ivl_lpm_q(lpm, idx) == nex) {
sprintf(result, "L_%s[%u]",
@ -1003,6 +1004,9 @@ static void draw_lpm_add(ivl_lpm_t net)
case IVL_LPM_DIVIDE:
type = "div";
break;
case IVL_LPM_MOD:
type = "mod";
break;
default:
assert(0);
}
@ -1202,6 +1206,7 @@ static void draw_lpm_in_scope(ivl_lpm_t net)
case IVL_LPM_SUB:
case IVL_LPM_MULT:
case IVL_LPM_DIVIDE:
case IVL_LPM_MOD:
draw_lpm_add(net);
return;
@ -1321,6 +1326,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
/*
* $Log: vvp_scope.c,v $
* Revision 1.61 2002/01/03 04:19:01 steve
* Add structural modulus support down to vvp.
*
* Revision 1.60 2001/12/15 02:13:33 steve
* Support all 3 TRI net types.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: README.txt,v 1.38 2001/11/01 03:00:19 steve Exp $
* $Id: README.txt,v 1.39 2002/01/03 04:19:01 steve Exp $
*/
VVP SIMULATION ENGINE
@ -433,6 +433,7 @@ create special statement types for the various arithmetic operators.
<label> .arith/sum <wid>, <symbols_list>;
<label> .arith/mult <wid>, <symbols_list>;
<label> .arith/div <wid>, <symbols_list>;
<label> .arith/mod <wid>, <symbols_list>;
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

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: arith.cc,v 1.21 2001/12/06 03:31:24 steve Exp $"
#ident "$Id: arith.cc,v 1.22 2002/01/03 04:19:02 steve Exp $"
#endif
# include "arith.h"
@ -128,6 +128,47 @@ void vvp_arith_div::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
output_val_(base, push, a/b);
}
inline void vvp_arith_mod::wide(vvp_ipoint_t base, bool push)
{
assert(0);
}
void vvp_arith_mod::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
{
put(i, val);
vvp_ipoint_t base = ipoint_make(i,0);
if(wid_ > 8*sizeof(unsigned long)) {
wide(base, push);
return;
}
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 val = obj->ival;
if (val & 0xaa) {
output_x_(base, push);
return;
}
if (val & 0x01)
a += 1 << idx;
if (val & 0x04)
b += 1 << idx;
}
if (b == 0) {
output_x_(base, push);
return;
}
output_val_(base, push, a%b);
}
// Multiplication
void vvp_arith_mult::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
@ -508,6 +549,9 @@ void vvp_shiftr::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
/*
* $Log: arith.cc,v $
* Revision 1.22 2002/01/03 04:19:02 steve
* Add structural modulus support down to vvp.
*
* Revision 1.21 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: arith.h,v 1.11 2001/10/31 04:27:46 steve Exp $"
#ident "$Id: arith.h,v 1.12 2002/01/03 04:19:02 steve Exp $"
#endif
# include "functor.h"
@ -75,6 +75,15 @@ class vvp_arith_div : public vvp_arith_ {
void wide(vvp_ipoint_t base, bool push);
};
class vvp_arith_mod : public vvp_arith_ {
public:
explicit vvp_arith_mod(unsigned wid) : vvp_arith_(wid) {}
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
void wide(vvp_ipoint_t base, bool push);
};
class vvp_arith_sum : public vvp_wide_arith_ {
public:
@ -125,6 +134,9 @@ class vvp_shiftr : public vvp_arith_ {
/*
* $Log: arith.h,v $
* Revision 1.12 2002/01/03 04:19:02 steve
* Add structural modulus support down to vvp.
*
* Revision 1.11 2001/10/31 04:27:46 steve
* Rewrite the functor type to have fewer functor modes,
* and use objects to manage the different types.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.cc,v 1.117 2001/12/15 02:11:51 steve Exp $"
#ident "$Id: compile.cc,v 1.118 2002/01/03 04:19:02 steve Exp $"
#endif
# include "arith.h"
@ -679,6 +679,22 @@ void compile_arith_div(char*label, long wid,
make_arith(arith, label, wid, argc, argv);
}
void compile_arith_mod(char*label, long wid,
unsigned argc, struct symb_s*argv)
{
assert( wid > 0 );
if ((long)argc != 2*wid) {
fprintf(stderr, "%s; .arith has wrong number of symbols\n", label);
compile_errors += 1;
return;
}
vvp_arith_ *arith = new vvp_arith_mod(wid);
make_arith(arith, label, wid, argc, argv);
}
void compile_arith_mult(char*label, long wid,
unsigned argc, struct symb_s*argv)
{
@ -1350,6 +1366,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
/*
* $Log: compile.cc,v $
* Revision 1.118 2002/01/03 04:19:02 steve
* Add structural modulus support down to vvp.
*
* Revision 1.117 2001/12/15 02:11:51 steve
* Give tri0 and tri1 their proper strengths.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.h,v 1.39 2001/12/14 02:04:49 steve Exp $"
#ident "$Id: compile.h,v 1.40 2002/01/03 04:19:02 steve Exp $"
#endif
# include <stdio.h>
@ -97,6 +97,8 @@ extern void compile_force(char*label, struct symb_s signal,
*/
extern void compile_arith_div(char*label, long width,
unsigned argc, struct symb_s*argv);
extern void compile_arith_mod(char*label, long width,
unsigned argc, struct symb_s*argv);
extern void compile_arith_mult(char*label, long width,
unsigned argc, struct symb_s*argv);
extern void compile_arith_sum(char*label, long width,
@ -223,6 +225,9 @@ extern void compile_net(char*label, char*name,
/*
* $Log: compile.h,v $
* Revision 1.40 2002/01/03 04:19:02 steve
* Add structural modulus support down to vvp.
*
* Revision 1.39 2001/12/14 02:04:49 steve
* Support strength syntax on functors.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: lexor.lex,v 1.28 2001/11/01 03:00:19 steve Exp $"
#ident "$Id: lexor.lex,v 1.29 2002/01/03 04:19:02 steve Exp $"
#endif
# include "parse_misc.h"
@ -67,6 +67,7 @@
/* These are some keywords that are recognized. */
".arith/div" { return K_ARITH_DIV; }
".arith/mod" { return K_ARITH_MOD; }
".arith/mult" { return K_ARITH_MULT; }
".arith/sub" { return K_ARITH_SUB; }
".arith/sum" { return K_ARITH_SUM; }
@ -150,6 +151,9 @@ int yywrap()
/*
* $Log: lexor.lex,v $
* Revision 1.29 2002/01/03 04:19:02 steve
* Add structural modulus support down to vvp.
*
* Revision 1.28 2001/11/01 03:00:19 steve
* Add force/cassign/release/deassign support. (Stephan Boettcher)
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: parse.y,v 1.42 2001/12/14 02:04:49 steve Exp $"
#ident "$Id: parse.y,v 1.43 2002/01/03 04:19:02 steve Exp $"
#endif
# include "parse_misc.h"
@ -57,7 +57,8 @@ extern FILE*yyin;
};
%token K_ARITH_DIV K_ARITH_MULT K_ARITH_SUB K_ARITH_SUM K_CMP_GE K_CMP_GT
%token K_ARITH_DIV K_ARITH_MOD K_ARITH_MULT K_ARITH_SUB K_ARITH_SUM
%token K_CMP_GE K_CMP_GT
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S
%token K_RESOLV K_SCOPE K_SHIFTL K_SHIFTR K_THREAD
%token K_UDP K_UDP_C K_UDP_S
@ -182,6 +183,11 @@ statement
compile_arith_div($1, $3, obj.cnt, obj.vect);
}
| T_LABEL K_ARITH_MOD T_NUMBER ',' symbols ';'
{ struct symbv_s obj = $5;
compile_arith_mod($1, $3, obj.cnt, obj.vect);
}
| T_LABEL K_ARITH_MULT T_NUMBER ',' symbols ';'
{ struct symbv_s obj = $5;
compile_arith_mult($1, $3, obj.cnt, obj.vect);
@ -532,6 +538,9 @@ int compile_design(const char*path)
/*
* $Log: parse.y,v $
* Revision 1.43 2002/01/03 04:19:02 steve
* Add structural modulus support down to vvp.
*
* Revision 1.42 2001/12/14 02:04:49 steve
* Support strength syntax on functors.
*