Pull NetAssign_ creation out of constructors.
This commit is contained in:
parent
ac81f6a201
commit
115d24a292
83
elaborate.cc
83
elaborate.cc
|
|
@ -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: elaborate.cc,v 1.184 2000/09/02 20:54:20 steve Exp $"
|
#ident "$Id: elaborate.cc,v 1.185 2000/09/02 23:40:12 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -944,20 +944,26 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
|
||||||
|
|
||||||
/* Generate an assignment of the l-value to the temporary... */
|
/* Generate an assignment of the l-value to the temporary... */
|
||||||
n = des->local_symbol(path);
|
n = des->local_symbol(path);
|
||||||
NetAssign*a1 = new NetAssign(n, des, wid, rv);
|
NetAssign_*lv = new NetAssign_(n, wid);
|
||||||
a1->set_line(*this);
|
des->add_node(lv);
|
||||||
|
|
||||||
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
||||||
connect(a1->l_val(0)->pin(idx), tmp->pin(idx));
|
connect(lv->pin(idx), tmp->pin(idx));
|
||||||
|
|
||||||
|
NetAssign*a1 = new NetAssign(lv, rv);
|
||||||
|
a1->set_line(*this);
|
||||||
|
|
||||||
/* Generate an assignment of the temporary to the r-value... */
|
/* Generate an assignment of the temporary to the r-value... */
|
||||||
n = des->local_symbol(path);
|
n = des->local_symbol(path);
|
||||||
NetESignal*sig = new NetESignal(tmp);
|
NetESignal*sig = new NetESignal(tmp);
|
||||||
NetAssign*a2 = new NetAssign(n, des, wid, sig);
|
lv = new NetAssign_(n, wid);
|
||||||
a2->set_line(*this);
|
des->add_node(lv);
|
||||||
|
|
||||||
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
||||||
connect(a2->l_val(0)->pin(idx), reg->pin(idx));
|
connect(lv->pin(idx), reg->pin(idx));
|
||||||
|
|
||||||
|
NetAssign*a2 = new NetAssign(lv, sig);
|
||||||
|
a2->set_line(*this);
|
||||||
|
|
||||||
/* Generate the delay statement with the final
|
/* Generate the delay statement with the final
|
||||||
assignment attached to it. If this is an event delay,
|
assignment attached to it. If this is an event delay,
|
||||||
|
|
@ -1000,19 +1006,24 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
|
||||||
rv = pad_to_width(rv, wid);
|
rv = pad_to_width(rv, wid);
|
||||||
assert(rv->expr_width() >= wid);
|
assert(rv->expr_width() >= wid);
|
||||||
|
|
||||||
cur = new NetAssign(des->local_symbol(path), des, wid, rv);
|
NetAssign_*lv = new NetAssign_(des->local_symbol(path), wid);
|
||||||
|
des->add_node(lv);
|
||||||
|
cur = new NetAssign(lv, rv);
|
||||||
unsigned off = reg->sb_to_idx(lsb);
|
unsigned off = reg->sb_to_idx(lsb);
|
||||||
assert((off+wid) <= reg->pin_count());
|
assert((off+wid) <= reg->pin_count());
|
||||||
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
||||||
connect(cur->l_val(0)->pin(idx), reg->pin(idx+off));
|
connect(lv->pin(idx), reg->pin(idx+off));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
assert(msb == lsb);
|
assert(msb == lsb);
|
||||||
cur = new NetAssign(des->local_symbol(path), des,
|
NetAssign_*lv = new NetAssign_(des->local_symbol(path),
|
||||||
reg->pin_count(), mux, rv);
|
reg->pin_count());
|
||||||
|
lv->set_bmux(mux);
|
||||||
|
des->add_node(lv);
|
||||||
|
cur = new NetAssign(lv, rv);
|
||||||
for (unsigned idx = 0 ; idx < reg->pin_count() ; idx += 1)
|
for (unsigned idx = 0 ; idx < reg->pin_count() ; idx += 1)
|
||||||
connect(cur->l_val(0)->pin(idx), reg->pin(idx));
|
connect(lv->pin(idx), reg->pin(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1100,9 +1111,11 @@ NetProc* PAssignNB::elaborate(Design*des, const string&path) const
|
||||||
rv = pad_to_width(rv, wid);
|
rv = pad_to_width(rv, wid);
|
||||||
assert(wid <= rv->expr_width());
|
assert(wid <= rv->expr_width());
|
||||||
|
|
||||||
cur = new NetAssignNB(des->local_symbol(path), des, wid, rv);
|
NetAssign_*lv = new NetAssign_(des->local_symbol(path), wid);
|
||||||
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
||||||
connect(cur->l_val(0)->pin(idx), reg->pin(reg->sb_to_idx(idx+lsb)));
|
connect(lv->pin(idx), reg->pin(reg->sb_to_idx(idx+lsb)));
|
||||||
|
des->add_node(lv);
|
||||||
|
cur = new NetAssignNB(lv, rv);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
@ -1111,10 +1124,13 @@ NetProc* PAssignNB::elaborate(Design*des, const string&path) const
|
||||||
value goes. Create a NetAssignNB object that carries
|
value goes. Create a NetAssignNB object that carries
|
||||||
that mux expression, and connect it to the entire
|
that mux expression, and connect it to the entire
|
||||||
width of the lval. */
|
width of the lval. */
|
||||||
cur = new NetAssignNB(des->local_symbol(path), des,
|
NetAssign_*lv = new NetAssign_(des->local_symbol(path),
|
||||||
reg->pin_count(), mux, rv);
|
reg->pin_count());
|
||||||
|
lv->set_bmux(mux);
|
||||||
for (unsigned idx = 0 ; idx < reg->pin_count() ; idx += 1)
|
for (unsigned idx = 0 ; idx < reg->pin_count() ; idx += 1)
|
||||||
connect(cur->l_val(0)->pin(idx), reg->pin(idx));
|
connect(lv->pin(idx), reg->pin(idx));
|
||||||
|
des->add_node(lv);
|
||||||
|
cur = new NetAssignNB(lv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1439,9 +1455,11 @@ NetProc* PCallTask::elaborate_usr(Design*des, const string&path) const
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
NetExpr*rv = parms_[idx]->elaborate_expr(des, scope);
|
NetExpr*rv = parms_[idx]->elaborate_expr(des, scope);
|
||||||
NetAssign*pr = new NetAssign("@", des, port->pin_count(), rv);
|
NetAssign_*lv = new NetAssign_("@", port->pin_count());
|
||||||
|
des->add_node(lv);
|
||||||
for (unsigned pi = 0 ; pi < port->pin_count() ; pi += 1)
|
for (unsigned pi = 0 ; pi < port->pin_count() ; pi += 1)
|
||||||
connect(port->pin(pi), pr->l_val(0)->pin(pi));
|
connect(port->pin(pi), lv->pin(pi));
|
||||||
|
NetAssign*pr = new NetAssign(lv, rv);
|
||||||
block->append(pr);
|
block->append(pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1528,9 +1546,11 @@ NetProc* PCallTask::elaborate_usr(Design*des, const string&path) const
|
||||||
|
|
||||||
|
|
||||||
/* Generate the assignment statement. */
|
/* Generate the assignment statement. */
|
||||||
NetAssign*ass = new NetAssign("@", des, val->pin_count(), pexp);
|
NetAssign_*lv = new NetAssign_("@", val->pin_count());
|
||||||
|
des->add_node(lv);
|
||||||
for (unsigned pi = 0 ; pi < val->pin_count() ; pi += 1)
|
for (unsigned pi = 0 ; pi < val->pin_count() ; pi += 1)
|
||||||
connect(val->pin(pi), ass->l_val(0)->pin(pi));
|
connect(val->pin(pi), lv->pin(pi));
|
||||||
|
NetAssign*ass = new NetAssign(lv, pexp);
|
||||||
|
|
||||||
block->append(ass);
|
block->append(ass);
|
||||||
}
|
}
|
||||||
|
|
@ -2001,10 +2021,11 @@ NetProc* PForStatement::elaborate(Design*des, const string&path) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
assert(sig);
|
assert(sig);
|
||||||
NetAssign*init = new NetAssign("@for-assign", des, sig->pin_count(),
|
NetAssign_*lv = new NetAssign_("@for-assign", sig->pin_count());
|
||||||
expr1_->elaborate_expr(des, scope));
|
for (unsigned idx = 0 ; idx < lv->pin_count() ; idx += 1)
|
||||||
for (unsigned idx = 0 ; idx < init->l_val(0)->pin_count() ; idx += 1)
|
connect(lv->pin(idx), sig->pin(idx));
|
||||||
connect(init->l_val(0)->pin(idx), sig->pin(idx));
|
des->add_node(lv);
|
||||||
|
NetAssign*init = new NetAssign(lv, expr1_->elaborate_expr(des, scope));
|
||||||
|
|
||||||
top->append(init);
|
top->append(init);
|
||||||
|
|
||||||
|
|
@ -2024,10 +2045,11 @@ NetProc* PForStatement::elaborate(Design*des, const string&path) const
|
||||||
statement. Put this into the "body" block. */
|
statement. Put this into the "body" block. */
|
||||||
sig = des->find_signal(scope, id2->name());
|
sig = des->find_signal(scope, id2->name());
|
||||||
assert(sig);
|
assert(sig);
|
||||||
NetAssign*step = new NetAssign("@for-assign", des, sig->pin_count(),
|
lv = new NetAssign_("@for-assign", sig->pin_count());
|
||||||
expr2_->elaborate_expr(des, scope));
|
for (unsigned idx = 0 ; idx < lv->pin_count() ; idx += 1)
|
||||||
for (unsigned idx = 0 ; idx < step->l_val(0)->pin_count() ; idx += 1)
|
connect(lv->pin(idx), sig->pin(idx));
|
||||||
connect(step->l_val(0)->pin(idx), sig->pin(idx));
|
des->add_node(lv);
|
||||||
|
NetAssign*step = new NetAssign(lv, expr2_->elaborate_expr(des, scope));
|
||||||
|
|
||||||
body->append(step);
|
body->append(step);
|
||||||
|
|
||||||
|
|
@ -2378,6 +2400,9 @@ Design* elaborate(const map<string,Module*>&modules,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: elaborate.cc,v $
|
* $Log: elaborate.cc,v $
|
||||||
|
* Revision 1.185 2000/09/02 23:40:12 steve
|
||||||
|
* Pull NetAssign_ creation out of constructors.
|
||||||
|
*
|
||||||
* Revision 1.184 2000/09/02 20:54:20 steve
|
* Revision 1.184 2000/09/02 20:54:20 steve
|
||||||
* Rearrange NetAssign to make NetAssign_ separate.
|
* Rearrange NetAssign to make NetAssign_ separate.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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: net_assign.cc,v 1.1 2000/09/02 20:54:20 steve Exp $"
|
#ident "$Id: net_assign.cc,v 1.2 2000/09/02 23:40:13 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "netlist.h"
|
# include "netlist.h"
|
||||||
|
|
@ -92,54 +92,18 @@ const NetAssign_* NetAssignBase::l_val(unsigned idx) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NetAssign::NetAssign(const string&n, Design*des, unsigned w, NetExpr*rv)
|
NetAssign::NetAssign(NetAssign_*lv, NetExpr*rv)
|
||||||
: NetAssignBase(new NetAssign_(n, w), rv)
|
: NetAssignBase(lv, rv)
|
||||||
{
|
{
|
||||||
des->add_node(l_val(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
NetAssign::NetAssign(const string&n, Design*des, unsigned w,
|
|
||||||
NetExpr*mu, NetExpr*rv)
|
|
||||||
: NetAssignBase(new NetAssign_(n, w), rv)
|
|
||||||
{
|
|
||||||
des->add_node(l_val(0));
|
|
||||||
bool flag = rv->set_width(1);
|
|
||||||
if (flag == false) {
|
|
||||||
cerr << rv->get_line() << ": Expression bit width" <<
|
|
||||||
" conflicts with l-value bit width." << endl;
|
|
||||||
des->errors += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
l_val(0)->set_bmux(mu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NetAssign::~NetAssign()
|
NetAssign::~NetAssign()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w, NetExpr*rv)
|
NetAssignNB::NetAssignNB(NetAssign_*lv, NetExpr*rv)
|
||||||
: NetAssignBase(new NetAssign_(n, w), rv)
|
: NetAssignBase(lv, rv)
|
||||||
{
|
{
|
||||||
if (rval()->expr_width() < w) {
|
|
||||||
cerr << rval()->get_line() << ": Expression bit width (" <<
|
|
||||||
rval()->expr_width() << ") conflicts with l-value "
|
|
||||||
"bit width (" << w << ")." << endl;
|
|
||||||
des->errors += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w,
|
|
||||||
NetExpr*mu, NetExpr*rv)
|
|
||||||
: NetAssignBase(new NetAssign_(n, w), rv)
|
|
||||||
{
|
|
||||||
bool flag = rval()->set_width(1);
|
|
||||||
if (flag == false) {
|
|
||||||
cerr << rval()->get_line() << ": Expression bit width" <<
|
|
||||||
" conflicts with l-value bit width." << endl;
|
|
||||||
des->errors += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
l_val(0)->set_bmux(mu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NetAssignNB::~NetAssignNB()
|
NetAssignNB::~NetAssignNB()
|
||||||
|
|
@ -148,6 +112,9 @@ NetAssignNB::~NetAssignNB()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: net_assign.cc,v $
|
* $Log: net_assign.cc,v $
|
||||||
|
* Revision 1.2 2000/09/02 23:40:13 steve
|
||||||
|
* Pull NetAssign_ creation out of constructors.
|
||||||
|
*
|
||||||
* Revision 1.1 2000/09/02 20:54:20 steve
|
* Revision 1.1 2000/09/02 20:54:20 steve
|
||||||
* Rearrange NetAssign to make NetAssign_ separate.
|
* Rearrange NetAssign to make NetAssign_ separate.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
13
netlist.h
13
netlist.h
|
|
@ -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.159 2000/09/02 20:54:20 steve Exp $"
|
#ident "$Id: netlist.h,v 1.160 2000/09/02 23:40:13 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1178,9 +1178,7 @@ class NetAssignBase : public NetProc {
|
||||||
class NetAssign : public NetAssignBase {
|
class NetAssign : public NetAssignBase {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NetAssign(const string&, Design*des, unsigned w, NetExpr*rv);
|
explicit NetAssign(NetAssign_*lv, NetExpr*rv);
|
||||||
explicit NetAssign(const string&, Design*des, unsigned w,
|
|
||||||
NetExpr*mux, NetExpr*rv);
|
|
||||||
~NetAssign();
|
~NetAssign();
|
||||||
|
|
||||||
virtual bool emit_proc(struct target_t*) const;
|
virtual bool emit_proc(struct target_t*) const;
|
||||||
|
|
@ -1192,9 +1190,7 @@ class NetAssign : public NetAssignBase {
|
||||||
|
|
||||||
class NetAssignNB : public NetAssignBase {
|
class NetAssignNB : public NetAssignBase {
|
||||||
public:
|
public:
|
||||||
explicit NetAssignNB(const string&, Design*des, unsigned w, NetExpr*rv);
|
explicit NetAssignNB(NetAssign_*lv, NetExpr*rv);
|
||||||
explicit NetAssignNB(const string&, Design*des, unsigned w,
|
|
||||||
NetExpr*mux, NetExpr*rv);
|
|
||||||
~NetAssignNB();
|
~NetAssignNB();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2748,6 +2744,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: netlist.h,v $
|
* $Log: netlist.h,v $
|
||||||
|
* Revision 1.160 2000/09/02 23:40:13 steve
|
||||||
|
* Pull NetAssign_ creation out of constructors.
|
||||||
|
*
|
||||||
* Revision 1.159 2000/09/02 20:54:20 steve
|
* Revision 1.159 2000/09/02 20:54:20 steve
|
||||||
* Rearrange NetAssign to make NetAssign_ separate.
|
* Rearrange NetAssign to make NetAssign_ separate.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue