Generate vvp code for GT and GE comparisons.

This commit is contained in:
steve 2001-06-15 04:14:18 +00:00
parent e002b1c1c4
commit b3a5a0e5ab
10 changed files with 186 additions and 132 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: cprop.cc,v 1.27 2001/06/07 02:12:43 steve Exp $"
#ident "$Id: cprop.cc,v 1.28 2001/06/15 04:14:18 steve Exp $"
#endif
# include "netlist.h"
@ -228,7 +228,7 @@ void cprop_functor::lpm_compare_eq_(Design*des, NetCompare*obj)
if (top == obj->width())
return;
NetCompare*tmp = new NetCompare(obj->name(), top);
NetCompare*tmp = new NetCompare(obj->scope(), obj->name(), top);
connect(tmp->pin_AEB(), obj->pin_AEB());
for (unsigned idx = 0 ; idx < top ; idx += 1) {
connect(tmp->pin_DataA(idx), obj->pin_DataA(idx));
@ -937,6 +937,9 @@ void cprop(Design*des)
/*
* $Log: cprop.cc,v $
* Revision 1.28 2001/06/15 04:14:18 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.27 2001/06/07 02:12:43 steve
* Support structural addition.
*

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.67 2001/06/07 02:12:43 steve Exp $"
#ident "$Id: elab_net.cc,v 1.68 2001/06/15 04:14:18 steve Exp $"
#endif
# include "PExpr.h"
@ -398,7 +398,7 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
case 'L':
case 'G': {
NetCompare*cmp = new
NetCompare(des->local_symbol(path), dwidth);
NetCompare(scope, des->local_symbol(path), dwidth);
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1)
connect(cmp->pin_DataA(idx), lsig->pin(idx));
for (unsigned idx = lsig->pin_count(); idx < dwidth ; idx += 1)
@ -1901,6 +1901,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
/*
* $Log: elab_net.cc,v $
* Revision 1.68 2001/06/15 04:14:18 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.67 2001/06/07 02:12:43 steve
* Support structural addition.
*

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: expr_synth.cc,v 1.21 2001/06/07 02:12:43 steve Exp $"
#ident "$Id: expr_synth.cc,v 1.22 2001/06/15 04:14:18 steve Exp $"
#endif
# include "netlist.h"
@ -167,7 +167,7 @@ NetNet* NetEBComp::synthesize(Design*des)
}
NetCompare*dev = new NetCompare(des->local_symbol(path), width);
NetCompare*dev = new NetCompare(scope, des->local_symbol(path), width);
des->add_node(dev);
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1)
@ -447,6 +447,9 @@ NetNet* NetESignal::synthesize(Design*des)
/*
* $Log: expr_synth.cc,v $
* Revision 1.22 2001/06/15 04:14:18 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.21 2001/06/07 02:12:43 steve
* Support structural addition.
*

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.65 2001/06/07 03:09:37 steve Exp $"
#ident "$Id: ivl_target.h,v 1.66 2001/06/15 04:14:18 steve Exp $"
#endif
#ifdef __cplusplus
@ -202,6 +202,8 @@ typedef enum ivl_logic_e {
/* This is the type of an LPM object. */
typedef enum ivl_lpm_type_e {
IVL_LPM_ADD,
IVL_LPM_CMP_GE,
IVL_LPM_CMP_GT,
IVL_LPM_FF,
IVL_LPM_MUX,
IVL_LPM_SUB
@ -873,6 +875,9 @@ _END_DECL
/*
* $Log: ivl_target.h,v $
* Revision 1.66 2001/06/15 04:14:18 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.65 2001/06/07 03:09:37 steve
* support subtraction in tgt-vvp.
*

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: netlist.cc,v 1.161 2001/06/07 02:12:43 steve Exp $"
#ident "$Id: netlist.cc,v 1.162 2001/06/15 04:14:18 steve Exp $"
#endif
# include <cassert>
@ -810,8 +810,8 @@ const Link& NetCLShift::pin_Distance(unsigned idx) const
return pin(3+2*width_+idx);
}
NetCompare::NetCompare(const string&n, unsigned wi)
: NetNode(n, 8+2*wi), width_(wi)
NetCompare::NetCompare(NetScope*s, const string&n, unsigned wi)
: NetNode(s, n, 8+2*wi), width_(wi)
{
pin(0).set_dir(Link::INPUT); pin(0).set_name("Aclr");
pin(1).set_dir(Link::INPUT); pin(1).set_name("Clock");
@ -2323,6 +2323,9 @@ const NetProc*NetTaskDef::proc() const
/*
* $Log: netlist.cc,v $
* Revision 1.162 2001/06/15 04:14:18 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.161 2001/06/07 02:12:43 steve
* Support structural addition.
*

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: netlist.h,v 1.207 2001/06/07 02:12:43 steve Exp $"
#ident "$Id: netlist.h,v 1.208 2001/06/15 04:14:18 steve Exp $"
#endif
/*
@ -470,7 +470,7 @@ class NetCLShift : public NetNode {
class NetCompare : public NetNode {
public:
NetCompare(const string&n, unsigned width);
NetCompare(NetScope*scope, const string&n, unsigned width);
~NetCompare();
unsigned width() const;
@ -2809,6 +2809,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.208 2001/06/15 04:14:18 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.207 2001/06/07 02:12:43 steve
* Support structural addition.
*

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.48 2001/06/07 03:09:37 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.49 2001/06/15 04:14:19 steve Exp $"
#endif
# include "t-dll.h"
@ -450,6 +450,8 @@ extern "C" ivl_nexus_t ivl_lpm_data(ivl_lpm_t net, unsigned idx)
assert(net);
switch (net->type) {
case IVL_LPM_ADD:
case IVL_LPM_CMP_GE:
case IVL_LPM_CMP_GT:
case IVL_LPM_SUB:
assert(idx < net->u_.arith.width);
return net->u_.arith.a[idx];
@ -473,6 +475,8 @@ extern "C" ivl_nexus_t ivl_lpm_datab(ivl_lpm_t net, unsigned idx)
switch (net->type) {
case IVL_LPM_ADD:
case IVL_LPM_CMP_GE:
case IVL_LPM_CMP_GT:
case IVL_LPM_SUB:
assert(idx < net->u_.arith.width);
return net->u_.arith.b[idx];
@ -513,6 +517,11 @@ extern "C" ivl_nexus_t ivl_lpm_q(ivl_lpm_t net, unsigned idx)
assert(idx < net->u_.arith.width);
return net->u_.arith.q[idx];
case IVL_LPM_CMP_GE:
case IVL_LPM_CMP_GT:
assert(idx == 0);
return net->u_.arith.q[0];
case IVL_LPM_FF:
assert(idx < net->u_.ff.width);
if (net->u_.ff.width == 1)
@ -585,6 +594,8 @@ extern "C" unsigned ivl_lpm_width(ivl_lpm_t net)
case IVL_LPM_MUX:
return net->u_.mux.width;
case IVL_LPM_ADD:
case IVL_LPM_CMP_GE:
case IVL_LPM_CMP_GT:
case IVL_LPM_SUB:
return net->u_.arith.width;
default:
@ -1175,6 +1186,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/*
* $Log: t-dll-api.cc,v $
* Revision 1.49 2001/06/15 04:14:19 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.48 2001/06/07 03:09:37 steve
* support subtraction in tgt-vvp.
*

160
t-dll.cc
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.45 2001/06/07 04:20:10 steve Exp $"
#ident "$Id: t-dll.cc,v 1.46 2001/06/15 04:14:19 steve Exp $"
#endif
# include "compiler.h"
@ -673,6 +673,64 @@ void dll_target::lpm_add_sub(const NetAddSub*net)
scope_add_lpm(obj->scope, obj);
}
void dll_target::lpm_compare(const NetCompare*net)
{
ivl_lpm_t obj = new struct ivl_lpm_s;
obj->name = strdup(net->name());
assert(net->scope());
obj->scope = find_scope(des_.root_, net->scope());
assert(obj->scope);
obj->u_.arith.width = net->width();
obj->u_.arith.q = new ivl_nexus_t[1 + 2 * obj->u_.arith.width];
obj->u_.arith.a = obj->u_.arith.q + 1;
obj->u_.arith.b = obj->u_.arith.a + obj->u_.arith.width;
if (net->pin_AGEB().is_linked()) {
const Nexus*nex = net->pin_AGEB().nexus();
obj->type = IVL_LPM_CMP_GE;
assert(nex->t_cookie());
obj->u_.arith.q[0] = (ivl_nexus_t) nex->t_cookie();
nexus_lpm_add(obj->u_.arith.q[0], obj, 0,
IVL_DR_STRONG, IVL_DR_STRONG);
} else if (net->pin_AGB().is_linked()) {
const Nexus*nex = net->pin_AGB().nexus();
obj->type = IVL_LPM_CMP_GT;
assert(nex->t_cookie());
obj->u_.arith.q[0] = (ivl_nexus_t) nex->t_cookie();
nexus_lpm_add(obj->u_.arith.q[0], obj, 0,
IVL_DR_STRONG, IVL_DR_STRONG);
} else {
assert(0);
}
for (unsigned idx = 0 ; idx < net->width() ; idx += 1) {
const Nexus*nex;
nex = net->pin_DataA(idx).nexus();
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);
nex = net->pin_DataB(idx).nexus();
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);
}
scope_add_lpm(obj->scope, obj);
}
void dll_target::lpm_ff(const NetFF*net)
{
ivl_lpm_t obj = new struct ivl_lpm_s;
@ -1087,6 +1145,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
/*
* $Log: t-dll.cc,v $
* Revision 1.46 2001/06/15 04:14:19 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.45 2001/06/07 04:20:10 steve
* Account for carry out on add devices.
*
@ -1118,102 +1179,5 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
*
* Revision 1.36 2001/04/26 05:12:02 steve
* Implement simple MUXZ for ?: operators.
*
* Revision 1.35 2001/04/24 02:23:58 steve
* Support for UDP devices in VVP (Stephen Boettcher)
*
* Revision 1.34 2001/04/22 23:09:46 steve
* More UDP consolidation from Stephan Boettcher.
*
* Revision 1.33 2001/04/05 01:12:28 steve
* Get signed compares working correctly in vvp.
*
* Revision 1.32 2001/04/01 01:48:21 steve
* Redesign event information to support arbitrary edge combining.
*
* Revision 1.31 2001/03/30 06:10:15 steve
* Initialize the event_ list of new scopes.
*
* Revision 1.30 2001/03/28 06:07:39 steve
* Add the ivl_event_t to ivl_target, and use that to generate
* .event statements in vvp way ahead of the thread that uses it.
*
* Revision 1.29 2001/03/27 03:31:06 steve
* Support error code from target_t::end_design method.
*
* Revision 1.28 2001/03/20 01:44:14 steve
* Put processes in the proper scope.
*
* Revision 1.27 2001/01/15 22:08:32 steve
* Add missing NetLogic gate types to ::logic method.
*
* Revision 1.26 2001/01/15 00:47:02 steve
* Pass scope type information to the target module.
*
* Revision 1.25 2001/01/06 06:31:59 steve
* declaration initialization for time variables.
*
* Revision 1.24 2001/01/06 02:29:36 steve
* Support arrays of integers.
*
* Revision 1.23 2000/12/15 18:06:47 steve
* A dlerror implementatin that HP/UX might like.
*
* Revision 1.22 2000/12/15 05:45:25 steve
* Autoconfigure the dlopen functions.
*
* Revision 1.21 2000/12/14 23:23:07 steve
* Support more logic gate types.
*
* Revision 1.20 2000/12/05 06:29:33 steve
* Make signal attributes available to ivl_target API.
*
* Revision 1.19 2000/11/11 00:03:36 steve
* Add support for the t-dll backend grabing flip-flops.
*
* Revision 1.18 2000/11/09 22:19:34 steve
* Initialize scope when creating it.
*
* Revision 1.17 2000/10/31 17:49:02 steve
* Support time variables.
*
* Revision 1.16 2000/10/21 16:49:45 steve
* Reduce the target entry points to the target_design.
*
* Revision 1.15 2000/10/15 04:46:23 steve
* Scopes and processes are accessible randomly from
* the design, and signals and logic are accessible
* from scopes. Remove the target calls that are no
* longer needed.
*
* Add the ivl_nexus_ptr_t and the means to get at
* them from nexus objects.
*
* Give names to methods that manipulate the ivl_design_t
* type more consistent names.
*
* Revision 1.14 2000/10/13 03:39:27 steve
* Include constants in nexus targets.
*
* Revision 1.13 2000/10/08 04:01:55 steve
* Back pointers in the nexus objects into the devices
* that point to it.
*
* Collect threads into a list in the design.
*
* Revision 1.12 2000/10/07 19:45:43 steve
* Put logic devices into scopes.
*
* Revision 1.11 2000/10/06 23:46:51 steve
* ivl_target updates, including more complete
* handling of ivl_nexus_t objects. Much reduced
* dependencies on pointers to netlist objects.
*
* Revision 1.10 2000/10/05 05:03:01 steve
* xor and constant devices.
*
* Revision 1.9 2000/09/30 02:18:15 steve
* ivl_expr_t support for binary operators,
* Create a proper ivl_scope_t object.
*/

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.46 2001/06/07 02:12:43 steve Exp $"
#ident "$Id: t-dll.h,v 1.47 2001/06/15 04:14:19 steve Exp $"
#endif
# include "target.h"
@ -62,6 +62,7 @@ struct dll_target : public target_t, public expr_scan_t {
void logic(const NetLogic*);
void udp(const NetUDP*);
void lpm_add_sub(const NetAddSub*);
void lpm_compare(const NetCompare*);
void lpm_ff(const NetFF*);
void lpm_mux(const NetMux*);
void net_assign(const NetAssign_*);
@ -528,6 +529,9 @@ struct ivl_statement_s {
/*
* $Log: t-dll.h,v $
* Revision 1.47 2001/06/15 04:14:19 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.46 2001/06/07 02:12:43 steve
* Support structural addition.
*

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.31 2001/06/07 04:20:10 steve Exp $"
#ident "$Id: vvp_scope.c,v 1.32 2001/06/15 04:14:19 steve Exp $"
#endif
# include "vvp_priv.h"
@ -113,6 +113,7 @@ static const char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr)
ivl_lpm_name(lpm), idx);
return result;
}
break;
case IVL_LPM_ADD:
case IVL_LPM_SUB:
@ -123,6 +124,17 @@ static const char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr)
return result;
}
break;
case IVL_LPM_CMP_GE:
case IVL_LPM_CMP_GT:
if (ivl_lpm_q(lpm, 0) == nex) {
sprintf(result, "L_%s", ivl_lpm_name(lpm));
return result;
}
break;
}
assert(0);
@ -607,26 +619,10 @@ static void draw_event_in_scope(ivl_event_t obj)
}
}
static void draw_lpm_add(ivl_lpm_t net)
static void draw_lpm_arith_a_b_inputs(ivl_lpm_t net)
{
unsigned idx, width;
const char*type = "";
width = ivl_lpm_width(net);
switch (ivl_lpm_type(net)) {
case IVL_LPM_ADD:
type = "sum";
break;
case IVL_LPM_SUB:
type = "sub";
break;
default:
assert(0);
}
fprintf(vvp_out, "L_%s .arith/%s %u", ivl_lpm_name(net), type, width);
unsigned width = ivl_lpm_width(net);
unsigned idx;
for (idx = 0 ; idx < width ; idx += 1) {
ivl_nexus_t a = ivl_lpm_data(net, idx);
if (a) {
@ -646,6 +642,54 @@ static void draw_lpm_add(ivl_lpm_t net)
fprintf(vvp_out, ", C<0>");
}
}
}
static void draw_lpm_add(ivl_lpm_t net)
{
unsigned width;
const char*type = "";
width = ivl_lpm_width(net);
switch (ivl_lpm_type(net)) {
case IVL_LPM_ADD:
type = "sum";
break;
case IVL_LPM_SUB:
type = "sub";
break;
default:
assert(0);
}
fprintf(vvp_out, "L_%s .arith/%s %u", ivl_lpm_name(net), type, width);
draw_lpm_arith_a_b_inputs(net);
fprintf(vvp_out, ";\n");
}
static void draw_lpm_cmp(ivl_lpm_t net)
{
unsigned width;
const char*type = "";
width = ivl_lpm_width(net);
switch (ivl_lpm_type(net)) {
case IVL_LPM_CMP_GE:
type = "ge";
break;
case IVL_LPM_CMP_GT:
type = "gt";
break;
default:
assert(0);
}
fprintf(vvp_out, "L_%s .cmp/%s %u", ivl_lpm_name(net), type, width);
draw_lpm_arith_a_b_inputs(net);
fprintf(vvp_out, ";\n");
}
@ -685,6 +729,11 @@ static void draw_lpm_in_scope(ivl_lpm_t net)
draw_lpm_add(net);
return;
case IVL_LPM_CMP_GE:
case IVL_LPM_CMP_GT:
draw_lpm_cmp(net);
return;
case IVL_LPM_MUX:
draw_lpm_mux(net);
return;
@ -774,6 +823,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
/*
* $Log: vvp_scope.c,v $
* Revision 1.32 2001/06/15 04:14:19 steve
* Generate vvp code for GT and GE comparisons.
*
* Revision 1.31 2001/06/07 04:20:10 steve
* Account for carry out on add devices.
*