Update support for LPM_MOD.

This commit is contained in:
steve 2005-03-12 06:43:35 +00:00
parent bae8507c90
commit ab1ca54df2
6 changed files with 101 additions and 123 deletions

View File

@ -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.153 2005/03/09 05:52:03 steve Exp $"
#ident "$Id: elab_net.cc,v 1.154 2005/03/12 06:43:35 steve Exp $"
#endif
# include "config.h"
@ -781,42 +781,32 @@ 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;
/* rwidth is result width. */
unsigned rwidth = lwidth;
if (rwidth == 0) {
rwidth = lsig->pin_count();
if (rsig->pin_count() > rwidth)
rwidth = rsig->pin_count();
rwidth = lsig->vector_width();
if (rsig->vector_width() > rwidth)
rwidth = rsig->vector_width();
lwidth = rwidth;
}
NetModulo*mod = new NetModulo(scope, scope->local_symbol(), rwidth,
lsig->pin_count(),
rsig->pin_count());
lsig->vector_width(),
rsig->vector_width());
des->add_node(mod);
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1)
connect(mod->pin_DataA(idx), lsig->pin(idx));
for (unsigned idx = 0 ; idx < rsig->pin_count() ; idx += 1)
connect(mod->pin_DataB(idx), rsig->pin(idx));
connect(mod->pin_DataA(), lsig->pin(0));
connect(mod->pin_DataB(), rsig->pin(0));
if (lwidth == 0) lwidth = rwidth;
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, lwidth);
NetNet::IMPLICIT, rwidth);
osig->local_flag(true);
unsigned cnt = osig->pin_count();
if (cnt > rwidth) cnt = rwidth;
for (unsigned idx = 0 ; idx < cnt ; idx += 1)
connect(mod->pin_Result(idx), osig->pin(idx));
/* If the lvalue is larger then the result, then pad the
output with constant 0. */
if (cnt < osig->pin_count()) {
NetConst*tmp = new NetConst(scope, scope->local_symbol(),
verinum::V0);
des->add_node(tmp);
for (unsigned idx = cnt ; idx < osig->pin_count() ; idx += 1)
connect(osig->pin(idx), tmp->pin(0));
}
connect(mod->pin_Result(), osig->pin(0));
return osig;
}
@ -2504,6 +2494,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
/*
* $Log: elab_net.cc,v $
* Revision 1.154 2005/03/12 06:43:35 steve
* Update support for LPM_MOD.
*
* Revision 1.153 2005/03/09 05:52:03 steve
* Handle case inequality in netlists.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: expr_synth.cc,v 1.64 2005/02/19 02:43:38 steve Exp $"
#ident "$Id: expr_synth.cc,v 1.65 2005/03/12 06:43:35 steve Exp $"
#endif
# include "config.h"
@ -384,16 +384,13 @@ NetNet* NetEBDiv::synthesize(Design*des)
case '%': {
NetModulo*div = new NetModulo(scope, scope->local_symbol(),
expr_width(),
lsig->pin_count(),
rsig->pin_count());
lsig->vector_width(),
rsig->vector_width());
des->add_node(div);
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1)
connect(div->pin_DataA(idx), lsig->pin(idx));
for (unsigned idx = 0 ; idx < rsig->pin_count() ; idx += 1)
connect(div->pin_DataB(idx), rsig->pin(idx));
for (unsigned idx = 0 ; idx < osig->pin_count() ; idx += 1)
connect(div->pin_Result(idx), osig->pin(idx));
connect(div->pin_DataA(), lsig->pin(0));
connect(div->pin_DataB(), rsig->pin(0));
connect(div->pin_Result(),osig->pin(0));
break;
}
@ -845,6 +842,9 @@ NetNet* NetESignal::synthesize(Design*des)
/*
* $Log: expr_synth.cc,v $
* Revision 1.65 2005/03/12 06:43:35 steve
* Update support for LPM_MOD.
*
* Revision 1.64 2005/02/19 02:43:38 steve
* Support shifts and divide.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2004 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2005 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: net_modulo.cc,v 1.7 2004/02/18 17:11:56 steve Exp $"
#ident "$Id: net_modulo.cc,v 1.8 2005/03/12 06:43:35 steve Exp $"
#endif
# include "config.h"
@ -30,25 +30,22 @@
# include "netlist.h"
# include "compiler.h"
/*
* 0 -- Result
* 1 -- DataA
* 2 -- DataB
*/
NetModulo::NetModulo(NetScope*s, perm_string n, unsigned wr,
unsigned wa, unsigned wb)
: NetNode(s, n, wr+wa+wb),
: NetNode(s, n, 3),
width_r_(wr), width_a_(wa), width_b_(wb)
{
unsigned p = 0;
for (unsigned idx = 0 ; idx < width_r_ ; idx += 1, p += 1) {
pin(p).set_dir(Link::OUTPUT);
pin(p).set_name(perm_string::literal("Result"), idx);
}
for (unsigned idx = 0 ; idx < width_a_ ; idx += 1, p += 1) {
pin(p).set_dir(Link::INPUT);
pin(p).set_name(perm_string::literal("DataA"), idx);
}
for (unsigned idx = 0 ; idx < width_b_ ; idx += 1, p += 1) {
pin(p).set_dir(Link::INPUT);
pin(p).set_name(perm_string::literal("DataB"), idx);
}
pin(0).set_dir(Link::OUTPUT);
pin(0).set_name(perm_string::literal("Result"), 0);
pin(0).set_dir(Link::INPUT);
pin(0).set_name(perm_string::literal("DataA"), 0);
pin(0).set_dir(Link::INPUT);
pin(0).set_name(perm_string::literal("DataB"), 0);
}
NetModulo::~NetModulo()
@ -70,44 +67,41 @@ unsigned NetModulo::width_b() const
return width_b_;
}
Link& NetModulo::pin_Result(unsigned idx)
Link& NetModulo::pin_Result()
{
assert(idx < width_r_);
return pin(idx);
return pin(0);
}
const Link& NetModulo::pin_Result(unsigned idx) const
const Link& NetModulo::pin_Result() const
{
assert(idx < width_r_);
return pin(idx);
return pin(0);
}
Link& NetModulo::pin_DataA(unsigned idx)
Link& NetModulo::pin_DataA()
{
assert(idx < width_a_);
return pin(idx+width_r_);
return pin(1);
}
const Link& NetModulo::pin_DataA(unsigned idx) const
const Link& NetModulo::pin_DataA() const
{
assert(idx < width_a_);
return pin(idx+width_r_);
return pin(1);
}
Link& NetModulo::pin_DataB(unsigned idx)
Link& NetModulo::pin_DataB()
{
assert(idx < width_b_);
return pin(idx+width_r_+width_a_);
return pin(2);
}
const Link& NetModulo::pin_DataB(unsigned idx) const
const Link& NetModulo::pin_DataB() const
{
assert(idx < width_b_);
return pin(idx+width_r_+width_a_);
return pin(2);
}
/*
* $Log: net_modulo.cc,v $
* Revision 1.8 2005/03/12 06:43:35 steve
* Update support for LPM_MOD.
*
* Revision 1.7 2004/02/18 17:11:56 steve
* Use perm_strings for named langiage items.
*

View File

@ -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.336 2005/03/09 05:52:04 steve Exp $"
#ident "$Id: netlist.h,v 1.337 2005/03/12 06:43:36 steve Exp $"
#endif
/*
@ -674,13 +674,13 @@ class NetModulo : public NetNode {
unsigned width_a() const;
unsigned width_b() const;
Link& pin_DataA(unsigned idx);
Link& pin_DataB(unsigned idx);
Link& pin_Result(unsigned idx);
Link& pin_DataA();
Link& pin_DataB();
Link& pin_Result();
const Link& pin_DataA(unsigned idx) const;
const Link& pin_DataB(unsigned idx) const;
const Link& pin_Result(unsigned idx) const;
const Link& pin_DataA() const;
const Link& pin_DataB() const;
const Link& pin_Result() const;
virtual void dump_node(ostream&, unsigned ind) const;
virtual bool emit_node(struct target_t*) const;
@ -3417,6 +3417,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.337 2005/03/12 06:43:36 steve
* Update support for LPM_MOD.
*
* Revision 1.336 2005/03/09 05:52:04 steve
* Handle case inequality in netlists.
*

View File

@ -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.143 2005/03/09 05:52:04 steve Exp $"
#ident "$Id: t-dll.cc,v 1.144 2005/03/12 06:43:36 steve Exp $"
#endif
# include "config.h"
@ -1388,62 +1388,30 @@ void dll_target::lpm_modulo(const NetModulo*net)
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;
#if 0
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;
obj->u_.arith.signed_flag = 0;
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
const Nexus*nex;
const Nexus*nex;
if (idx < net->width_r()) {
nex = net->pin_Result(idx).nexus();
assert(nex->t_cookie());
nex = net->pin_Result().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);
obj->u_.arith.q = (ivl_nexus_t) nex->t_cookie();
nexus_lpm_add(obj->u_.arith.q, obj, 0, IVL_DR_STRONG, IVL_DR_STRONG);
} else {
obj->u_.arith.q[idx] = 0;
}
nex = net->pin_DataA().nexus();
assert(nex->t_cookie());
if (idx < net->width_a()) {
nex = net->pin_DataA(idx).nexus();
assert(nex);
assert(nex->t_cookie());
obj->u_.arith.a = (ivl_nexus_t) nex->t_cookie();
nexus_lpm_add(obj->u_.arith.a, obj, 0, IVL_DR_HiZ, IVL_DR_HiZ);
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().nexus();
assert(nex->t_cookie());
} else {
obj->u_.arith.a[idx] = 0;
}
obj->u_.arith.b = (ivl_nexus_t) nex->t_cookie();
nexus_lpm_add(obj->u_.arith.b, obj, 0, IVL_DR_HiZ, IVL_DR_HiZ);
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;
}
}
#else
cerr << "XXXX: t-dll.cc: Forgot how to handle lpm_modulo." << endl;
#endif
scope_add_lpm(obj->scope, obj);
}
@ -2168,6 +2136,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
/*
* $Log: t-dll.cc,v $
* Revision 1.144 2005/03/12 06:43:36 steve
* Update support for LPM_MOD.
*
* Revision 1.143 2005/03/09 05:52:04 steve
* Handle case inequality in netlists.
*

View File

@ -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.115 2005/03/09 05:52:04 steve Exp $"
#ident "$Id: stub.c,v 1.116 2005/03/12 06:43:36 steve Exp $"
#endif
# include "config.h"
@ -377,6 +377,16 @@ static void show_lpm_concat(ivl_lpm_t net)
}
}
static void show_lpm_mod(ivl_lpm_t net)
{
unsigned width = ivl_lpm_width(net);
fprintf(out, " LPM_MOD %s: <width=%u>\n",
ivl_lpm_basename(net), width);
show_lpm_arithmetic_pins(net);
}
/*
* The LPM_MULT node has a Q output and two data inputs. The width of
* the Q output must be the width of the node itself.
@ -705,6 +715,10 @@ static void show_lpm(ivl_lpm_t net)
break;
}
case IVL_LPM_MOD:
show_lpm_mod(net);
break;
case IVL_LPM_MULT:
show_lpm_mult(net);
break;
@ -1171,6 +1185,9 @@ int target_design(ivl_design_t des)
/*
* $Log: stub.c,v $
* Revision 1.116 2005/03/12 06:43:36 steve
* Update support for LPM_MOD.
*
* Revision 1.115 2005/03/09 05:52:04 steve
* Handle case inequality in netlists.
*