Move signal tables to the NetScope class.

This commit is contained in:
steve 2000-05-02 00:58:11 +00:00
parent b175e4aef7
commit 8d8f1e2401
14 changed files with 419 additions and 280 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: design_dump.cc,v 1.79 2000/04/28 21:00:29 steve Exp $"
#ident "$Id: design_dump.cc,v 1.80 2000/05/02 00:58:11 steve Exp $"
#endif
/*
@ -668,6 +668,15 @@ void NetScope::dump(ostream&o) const
<< "// " << cur->get_line() << endl;
}
// Dump the signals,
if (signals_) {
NetNet*cur = signals_->sig_next_;
do {
cur->dump_net(o, 4);
cur = cur->sig_next_;
} while (cur != signals_->sig_next_);
}
/* Dump any sub-scopes. */
for (NetScope*cur = sub_ ; cur ; cur = cur->sib_)
cur->dump(o);
@ -867,17 +876,6 @@ void Design::dump(ostream&o) const
o << "SCOPES:" << endl;
root_scope_->dump(o);
o << "ELABORATED SIGNALS:" << endl;
// Dump the signals,
if (signals_) {
NetNet*cur = signals_->sig_next_;
do {
cur->dump_net(o, 0);
cur = cur->sig_next_;
} while (cur != signals_->sig_next_);
}
o << "ELABORATED MEMORIES:" << endl;
{
map<string,NetMemory*>::const_iterator pp;
@ -926,6 +924,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
* Revision 1.80 2000/05/02 00:58:11 steve
* Move signal tables to the NetScope class.
*
* Revision 1.79 2000/04/28 21:00:29 steve
* Over agressive signal elimination in constant probadation.
*

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_expr.cc,v 1.21 2000/04/28 18:43:23 steve Exp $"
#ident "$Id: elab_expr.cc,v 1.22 2000/05/02 00:58:11 steve Exp $"
#endif
@ -286,7 +286,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const
assert(net->sb_to_idx(msv) >= net->sb_to_idx(lsv));
string tname = des->local_symbol(scope->name());
NetTmp*tsig = new NetTmp(tname, wid);
NetTmp*tsig = new NetTmp(scope, tname, wid);
// Connect the pins from the lsb up to the msb.
unsigned off = net->sb_to_idx(lsv);
@ -296,7 +296,6 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const
NetESignal*tmp = new NetESignal(tsig);
tmp->set_line(*this);
des->add_signal(tsig);
return tmp;
}
@ -318,12 +317,11 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const
}
string tname = des->local_symbol(scope->name());
NetTmp*tsig = new NetTmp(tname);
NetTmp*tsig = new NetTmp(scope, tname);
connect(tsig->pin(0), net->pin(idx));
NetESignal*tmp = new NetESignal(tsig);
tmp->set_line(*this);
des->add_signal(tsig);
return tmp;
}
@ -456,6 +454,9 @@ NetEUnary* PEUnary::elaborate_expr(Design*des, NetScope*scope) const
/*
* $Log: elab_expr.cc,v $
* Revision 1.22 2000/05/02 00:58:11 steve
* Move signal tables to the NetScope class.
*
* Revision 1.21 2000/04/28 18:43:23 steve
* integer division in expressions properly get width.
*

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.30 2000/04/28 21:00:29 steve Exp $"
#ident "$Id: elab_net.cc,v 1.31 2000/05/02 00:58:11 steve Exp $"
#endif
# include "PExpr.h"
@ -139,6 +139,7 @@ NetNet* PEBinary::elaborate_net_add_(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
NetNet*lsig = left_->elaborate_net(des, path, lwidth, 0, 0, 0),
*rsig = right_->elaborate_net(des, path, lwidth, 0, 0, 0);
if (lsig == 0) {
@ -178,7 +179,7 @@ NetNet* PEBinary::elaborate_net_add_(Design*des, const string&path,
rsig = pad_to_width(des, path, rsig, width);
// Make the adder as wide as the widest operand
osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE, owidth);
osig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE, owidth);
NetAddSub*adder = new NetAddSub(name, width);
// Connect the adder to the various parts.
@ -192,7 +193,6 @@ NetNet* PEBinary::elaborate_net_add_(Design*des, const string&path,
connect(osig->pin(width), adder->pin_Cout());
gate = adder;
des->add_signal(osig);
gate->rise_time(rise);
gate->fall_time(fall);
gate->decay_time(decay);
@ -223,6 +223,7 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
NetNet*lsig = left_->elaborate_net(des, path, width, 0, 0, 0),
*rsig = right_->elaborate_net(des, path, width, 0, 0, 0);
if (lsig == 0) {
@ -253,7 +254,7 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, const string&path,
assert(lsig->pin_count() == rsig->pin_count());
NetNet*osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
NetNet*osig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE,
lsig->pin_count());
osig->local_flag(true);
@ -318,8 +319,6 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, const string&path,
assert(0);
}
des->add_signal(osig);
if (NetTmp*tmp = dynamic_cast<NetTmp*>(lsig))
delete tmp;
if (NetTmp*tmp = dynamic_cast<NetTmp*>(rsig))
@ -340,6 +339,7 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
NetNet*lsig = left_->elaborate_net(des, path, 0, 0, 0, 0),
*rsig = right_->elaborate_net(des, path, 0, 0, 0, 0);
if (lsig == 0) {
@ -362,12 +362,11 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
if (lsig->pin_count() != rsig->pin_count()) {
NetConst*tmp = new NetConst(des->local_symbol(path), verinum::V0);
des->add_node(tmp);
zero = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
des->add_signal(zero);
zero = new NetNet(scope, des->local_symbol(path), NetNet::WIRE);
connect(tmp->pin(0), zero->pin(0));
}
NetNet*osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
NetNet*osig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE);
osig->local_flag(true);
NetNode*gate;
@ -431,11 +430,10 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
des->add_node(cmp);
// Attach a label to this intermediate wire
NetNet*tmp = new NetNet(0, des->local_symbol(path),
NetNet*tmp = new NetNet(scope, des->local_symbol(path),
NetNet::WIRE);
tmp->local_flag(true);
connect(cmp->pin(0), tmp->pin(0));
des->add_signal(tmp);
}
break;
@ -460,11 +458,10 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
connect(cmp->pin(0), gate->pin(idx+1));
des->add_node(cmp);
NetNet*tmp = new NetNet(0, des->local_symbol(path),
NetNet*tmp = new NetNet(scope, des->local_symbol(path),
NetNet::WIRE);
tmp->local_flag(true);
connect(cmp->pin(0), tmp->pin(0));
des->add_signal(tmp);
}
break;
@ -488,11 +485,10 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
connect(cmp->pin(0), gate->pin(idx+1));
des->add_node(cmp);
NetNet*tmp = new NetNet(0, des->local_symbol(path),
NetNet*tmp = new NetNet(scope, des->local_symbol(path),
NetNet::WIRE);
tmp->local_flag(true);
connect(cmp->pin(0), tmp->pin(0));
des->add_signal(tmp);
}
break;
@ -500,7 +496,6 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
assert(0);
}
des->add_signal(osig);
gate->rise_time(rise);
gate->fall_time(fall);
gate->decay_time(decay);
@ -518,6 +513,8 @@ NetNet* PEBinary::elaborate_net_div_(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
NetNet*lsig = left_->elaborate_net(des, path, 0, 0, 0, 0);
if (lsig == 0) return 0;
NetNet*rsig = right_->elaborate_net(des, path, 0, 0, 0, 0);
@ -537,10 +534,9 @@ NetNet* PEBinary::elaborate_net_div_(Design*des, const string&path,
connect(div->pin_DataB(idx), rsig->pin(idx));
if (lwidth == 0) lwidth = rwidth;
NetNet*osig = new NetNet(0, des->local_symbol(path),
NetNet*osig = new NetNet(scope, des->local_symbol(path),
NetNet::IMPLICIT, lwidth);
osig->local_flag(true);
des->add_signal(osig);
unsigned cnt = osig->pin_count();
if (cnt > rwidth) cnt = rwidth;
@ -566,6 +562,9 @@ NetNet* PEBinary::elaborate_net_log_(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
NetNet*lsig = left_->elaborate_net(des, path, 0, 0, 0, 0),
*rsig = right_->elaborate_net(des, path, 0, 0, 0, 0);
if (lsig == 0) {
@ -608,11 +607,10 @@ NetNet* PEBinary::elaborate_net_log_(Design*des, const string&path,
/* The reduced logical value is a new nexus, create a
temporary signal to represent it. */
NetNet*tmp = new NetTmp(des->local_symbol(path));
NetNet*tmp = new NetTmp(scope, des->local_symbol(path));
connect(gate->pin(1), tmp->pin(0));
des->add_node(gate_t);
des->add_signal(tmp);
} else {
connect(gate->pin(1), lsig->pin(0));
@ -628,21 +626,19 @@ NetNet* PEBinary::elaborate_net_log_(Design*des, const string&path,
/* The reduced logical value is a new nexus, create a
temporary signal to represent it. */
NetNet*tmp = new NetTmp(des->local_symbol(path));
NetNet*tmp = new NetTmp(scope, des->local_symbol(path));
connect(gate->pin(2), tmp->pin(0));
des->add_node(gate_t);
des->add_signal(tmp);
} else {
connect(gate->pin(2), rsig->pin(0));
}
// The output is the AND/OR of the two logic values.
NetNet*osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
NetNet*osig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE);
osig->local_flag(true);
connect(gate->pin(0), osig->pin(0));
des->add_signal(osig);
des->add_node(gate);
return osig;
}
@ -653,6 +649,9 @@ NetNet* PEBinary::elaborate_net_mul_(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
NetNet*lsig = left_->elaborate_net(des, path, 0, 0, 0, 0);
if (lsig == 0) return 0;
NetNet*rsig = right_->elaborate_net(des, path, 0, 0, 0, 0);
@ -670,10 +669,9 @@ NetNet* PEBinary::elaborate_net_mul_(Design*des, const string&path,
connect(mult->pin_DataB(idx), rsig->pin(idx));
if (lwidth == 0) lwidth = rwidth;
NetNet*osig = new NetNet(0, des->local_symbol(path),
NetNet*osig = new NetNet(scope, des->local_symbol(path),
NetNet::IMPLICIT, lwidth);
osig->local_flag(true);
des->add_signal(osig);
unsigned cnt = osig->pin_count();
if (cnt > rwidth) cnt = rwidth;
@ -699,6 +697,9 @@ NetNet* PEBinary::elaborate_net_shift_(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
NetNet*lsig = left_->elaborate_net(des, path, lwidth, 0, 0, 0);
if (lsig == 0) return 0;
@ -718,8 +719,8 @@ NetNet* PEBinary::elaborate_net_shift_(Design*des, const string&path,
/* Very special case, constant 0 shift. */
if (dist == 0) return lsig;
NetNet*osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
lsig->pin_count());
NetNet*osig = new NetNet(scope, des->local_symbol(path),
NetNet::WIRE, lsig->pin_count());
osig->local_flag(true);
NetConst*zero = new NetConst(des->local_symbol(path), verinum::V0);
@ -742,7 +743,6 @@ NetNet* PEBinary::elaborate_net_shift_(Design*des, const string&path,
connect(osig->pin(idx), zero->pin(0));
}
des->add_signal(osig);
return osig;
}
@ -760,7 +760,7 @@ NetNet* PEBinary::elaborate_net_shift_(Design*des, const string&path,
NetCLShift*gate = new NetCLShift(des->local_symbol(path),
lwidth, rsig->pin_count());
NetNet*osig = new NetNet(0, des->local_symbol(path),
NetNet*osig = new NetNet(scope, des->local_symbol(path),
NetNet::WIRE, lwidth);
osig->local_flag(true);
@ -774,9 +774,8 @@ NetNet* PEBinary::elaborate_net_shift_(Design*des, const string&path,
if (lsig->pin_count() < lwidth) {
NetConst*zero = new NetConst(des->local_symbol(path), verinum::V0);
NetTmp*tmp = new NetTmp(des->local_symbol(path));
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path));
des->add_node(zero);
des->add_signal(tmp);
connect(zero->pin(0), tmp->pin(0));
for (unsigned idx = lsig->pin_count() ; idx < lwidth ; idx += 1)
connect(zero->pin(0), gate->pin_Data(idx));
@ -793,7 +792,6 @@ NetNet* PEBinary::elaborate_net_shift_(Design*des, const string&path,
des->add_node(dir);
}
des->add_signal(osig);
des->add_node(gate);
return osig;
@ -809,6 +807,9 @@ NetNet* PEConcat::elaborate_net(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
svector<NetNet*>nets (parms_.count());
unsigned pins = 0;
unsigned errors = 0;
@ -827,7 +828,7 @@ NetNet* PEConcat::elaborate_net(Design*des, const string&path,
assert(parms_.count() == 1);
NetNet*obj = parms_[0]->elaborate_net(des, path, 0, rise,
fall, decay);
NetTmp*tmp = new NetTmp(des->local_symbol(path),
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path),
repeat * obj->pin_count());
for (unsigned idx = 0 ; idx < repeat ; idx += 1) {
@ -836,7 +837,6 @@ NetNet* PEConcat::elaborate_net(Design*des, const string&path,
connect(tmp->pin(base+pin), obj->pin(pin));
}
des->add_signal(tmp);
return tmp;
}
@ -864,7 +864,7 @@ NetNet* PEConcat::elaborate_net(Design*des, const string&path,
operands, and connect it up. Scan the operands of the
concat operator from least significant to most significant,
which is opposite from how they are given in the list. */
NetNet*osig = new NetNet(0, des->local_symbol(path),
NetNet*osig = new NetNet(scope, des->local_symbol(path),
NetNet::IMPLICIT, pins);
pins = 0;
for (unsigned idx = nets.count() ; idx > 0 ; idx -= 1) {
@ -876,7 +876,6 @@ NetNet* PEConcat::elaborate_net(Design*des, const string&path,
}
osig->local_flag(true);
des->add_signal(osig);
return osig;
}
@ -902,18 +901,16 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
const NetEConst*pc = dynamic_cast<const NetEConst*>(pe);
assert(pc);
verinum pvalue = pc->value();
sig = new NetNet(0, path+"."+text_, NetNet::IMPLICIT,
sig = new NetNet(scope, path+"."+text_, NetNet::IMPLICIT,
pc->expr_width());
NetConst*cp = new NetConst(des->local_symbol(path), pvalue);
des->add_node(cp);
des->add_signal(sig);
for (unsigned idx = 0; idx < sig->pin_count(); idx += 1)
connect(sig->pin(idx), cp->pin(idx));
} else {
sig = new NetNet(scope, path+"."+text_, NetNet::IMPLICIT, 1);
des->add_signal(sig);
if (warn_implicit)
cerr << get_line() << ": warning: implicit "
@ -950,9 +947,8 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
unsigned lidx = sig->sb_to_idx(lval->as_long());
if (midx >= lidx) {
NetTmp*tmp = new NetTmp(des->local_symbol(path),
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path),
midx-lidx+1);
des->add_signal(tmp);
if (tmp->pin_count() > sig->pin_count()) {
cerr << get_line() << ": bit select out of "
<< "range for " << sig->name() << endl;
@ -965,9 +961,8 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
sig = tmp;
} else {
NetTmp*tmp = new NetTmp(des->local_symbol(path),
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path),
lidx-midx+1);
des->add_signal(tmp);
assert(tmp->pin_count() <= sig->pin_count());
for (unsigned idx = lidx ; idx >= midx ; idx -= 1)
connect(tmp->pin(idx-midx), sig->pin(idx));
@ -992,8 +987,7 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
des->errors += 1;
idx = 0;
}
NetTmp*tmp = new NetTmp(des->local_symbol(path), 1);
des->add_signal(tmp);
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path), 1);
connect(tmp->pin(0), sig->pin(idx));
sig = tmp;
}
@ -1011,6 +1005,9 @@ NetNet* PEIdent::elaborate_net_ram_(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
if (msb_ == 0) {
cerr << get_line() << ": error: memory reference without"
" the required index expression." << endl;
@ -1030,8 +1027,8 @@ NetNet* PEIdent::elaborate_net_ram_(Design*des, const string&path,
for (unsigned idx = 0 ; idx < adr->pin_count() ; idx += 1)
connect(ram->pin_Address(idx), adr->pin(idx));
NetNet*osig = new NetTmp(des->local_symbol(mem->name()), ram->width());
des->add_signal(osig);
NetNet*osig = new NetTmp(scope, des->local_symbol(mem->name()),
ram->width());
for (unsigned idx = 0 ; idx < osig->pin_count() ; idx += 1)
connect(ram->pin_Q(idx), osig->pin(idx));
@ -1045,6 +1042,9 @@ NetNet* PEIdent::elaborate_net_ram_(Design*des, const string&path,
*/
NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
NetNet*sig = des->find_signal(path, text_);
if (sig == 0) {
/* Don't allow memories here. Is it a memory? */
@ -1056,8 +1056,7 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
}
/* Fine, create an implicit wire as an l-value. */
sig = new NetNet(0, path+"."+text_, NetNet::IMPLICIT, 1);
des->add_signal(sig);
sig = new NetNet(scope, path+"."+text_, NetNet::IMPLICIT, 1);
if (warn_implicit)
cerr << get_line() << ": warning: implicit "
@ -1087,9 +1086,8 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
unsigned lidx = sig->sb_to_idx(lval->as_long());
if (midx >= lidx) {
NetTmp*tmp = new NetTmp(des->local_symbol(path),
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path),
midx-lidx+1);
des->add_signal(tmp);
if (tmp->pin_count() > sig->pin_count()) {
cerr << get_line() << ": bit select out of "
<< "range for " << sig->name() << endl;
@ -1102,9 +1100,8 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
sig = tmp;
} else {
NetTmp*tmp = new NetTmp(des->local_symbol(path),
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path),
lidx-midx+1);
des->add_signal(tmp);
assert(tmp->pin_count() <= sig->pin_count());
for (unsigned idx = lidx ; idx >= midx ; idx -= 1)
connect(tmp->pin(idx-midx), sig->pin(idx));
@ -1129,8 +1126,7 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
des->errors += 1;
idx = 0;
}
NetTmp*tmp = new NetTmp(des->local_symbol(path), 1);
des->add_signal(tmp);
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path), 1);
connect(tmp->pin(0), sig->pin(idx));
sig = tmp;
}
@ -1147,11 +1143,14 @@ NetNet* PENumber::elaborate_net(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
/* If we are constrained by a l-value size, then just make a
number constant with the correct size and set as many bits
in that constant as make sense. Pad excess with zeros. */
if (lwidth > 0) {
NetNet*net = new NetNet(0, des->local_symbol(path),
NetNet*net = new NetNet(scope, des->local_symbol(path),
NetNet::IMPLICIT, lwidth);
net->local_flag(true);
@ -1165,7 +1164,6 @@ NetNet* PENumber::elaborate_net(Design*des, const string&path,
connect(net->pin(idx), tmp->pin(idx));
des->add_node(tmp);
des->add_signal(net);
return net;
}
@ -1173,7 +1171,7 @@ NetNet* PENumber::elaborate_net(Design*des, const string&path,
number. Generate a constant object of exactly the user
specified size. */
if (value_->has_len()) {
NetNet*net = new NetNet(0, des->local_symbol(path),
NetNet*net = new NetNet(scope, des->local_symbol(path),
NetNet::IMPLICIT, value_->len());
net->local_flag(true);
NetConst*tmp = new NetConst(des->local_symbol(path), *value_);
@ -1181,7 +1179,6 @@ NetNet* PENumber::elaborate_net(Design*des, const string&path,
connect(net->pin(idx), tmp->pin(idx));
des->add_node(tmp);
des->add_signal(net);
return net;
}
@ -1210,7 +1207,7 @@ NetNet* PENumber::elaborate_net(Design*des, const string&path,
for (unsigned idx = 0 ; idx < width ; idx += 1)
num.set(idx, value_->get(idx));
NetNet*net = new NetNet(0, des->local_symbol(path),
NetNet*net = new NetNet(scope, des->local_symbol(path),
NetNet::IMPLICIT, width);
net->local_flag(true);
NetConst*tmp = new NetConst(des->local_symbol(path), num);
@ -1218,7 +1215,6 @@ NetNet* PENumber::elaborate_net(Design*des, const string&path,
connect(net->pin(idx), tmp->pin(idx));
des->add_node(tmp);
des->add_signal(net);
return net;
}
@ -1233,6 +1229,9 @@ NetNet* PETernary::elaborate_net(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
NetNet* expr_sig = expr_->elaborate_net(des, path, 0, 0, 0, 0);
NetNet* tru_sig = tru_->elaborate_net(des, path, width, 0, 0, 0);
NetNet* fal_sig = fal_->elaborate_net(des, path, width, 0, 0, 0);
@ -1245,7 +1244,7 @@ NetNet* PETernary::elaborate_net(Design*des, const string&path,
assert(width == tru_sig->pin_count());
assert(expr_sig->pin_count() == 1);
NetNet*sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
NetNet*sig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE,
tru_sig->pin_count());
sig->local_flag(true);
@ -1258,7 +1257,6 @@ NetNet* PETernary::elaborate_net(Design*des, const string&path,
connect(mux->pin_Data(idx,1), tru_sig->pin(idx));
}
des->add_signal(sig);
des->add_node(mux);
return sig;
@ -1270,6 +1268,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
unsigned long fall,
unsigned long decay) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
NetNet* sub_sig = expr_->elaborate_net(des, path,
op_=='~'?width:0,
0, 0, 0);
@ -1283,7 +1284,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
NetLogic*gate;
switch (op_) {
case '~': // Bitwise NOT
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
sig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE,
sub_sig->pin_count());
sig->local_flag(true);
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1) {
@ -1296,12 +1297,11 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
gate->fall_time(fall);
gate->decay_time(decay);
}
des->add_signal(sig);
break;
case 'N': // Reduction NOR
case '!': // Reduction NOT
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
sig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE);
sig->local_flag(true);
gate = new NetLogic(des->local_symbol(path),
1+sub_sig->pin_count(),
@ -1310,7 +1310,6 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
connect(gate->pin(idx+1), sub_sig->pin(idx));
des->add_signal(sig);
des->add_node(gate);
gate->rise_time(rise);
gate->fall_time(fall);
@ -1318,7 +1317,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
break;
case '&': // Reduction AND
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
sig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE);
sig->local_flag(true);
gate = new NetLogic(des->local_symbol(path),
1+sub_sig->pin_count(),
@ -1327,7 +1326,6 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
connect(gate->pin(idx+1), sub_sig->pin(idx));
des->add_signal(sig);
des->add_node(gate);
gate->rise_time(rise);
gate->fall_time(fall);
@ -1335,7 +1333,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
break;
case '|': // Reduction OR
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
sig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE);
sig->local_flag(true);
gate = new NetLogic(des->local_symbol(path),
1+sub_sig->pin_count(),
@ -1344,7 +1342,6 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
connect(gate->pin(idx+1), sub_sig->pin(idx));
des->add_signal(sig);
des->add_node(gate);
gate->rise_time(rise);
gate->fall_time(fall);
@ -1352,7 +1349,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
break;
case '^': // Reduction XOR
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
sig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE);
sig->local_flag(true);
gate = new NetLogic(des->local_symbol(path),
1+sub_sig->pin_count(),
@ -1361,7 +1358,6 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
connect(gate->pin(idx+1), sub_sig->pin(idx));
des->add_signal(sig);
des->add_node(gate);
gate->rise_time(rise);
gate->fall_time(fall);
@ -1369,7 +1365,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
break;
case 'A': // Reduction NAND (~&)
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
sig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE);
sig->local_flag(true);
gate = new NetLogic(des->local_symbol(path),
1+sub_sig->pin_count(),
@ -1378,7 +1374,6 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
connect(gate->pin(idx+1), sub_sig->pin(idx));
des->add_signal(sig);
des->add_node(gate);
gate->rise_time(rise);
gate->fall_time(fall);
@ -1387,7 +1382,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
case 'X': // Reduction XNOR (~^)
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
sig = new NetNet(scope, des->local_symbol(path), NetNet::WIRE);
sig->local_flag(true);
gate = new NetLogic(des->local_symbol(path),
1+sub_sig->pin_count(),
@ -1396,7 +1391,6 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
connect(gate->pin(idx+1), sub_sig->pin(idx));
des->add_signal(sig);
des->add_node(gate);
gate->rise_time(rise);
gate->fall_time(fall);
@ -1416,6 +1410,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
/*
* $Log: elab_net.cc,v $
* Revision 1.31 2000/05/02 00:58:11 steve
* Move signal tables to the NetScope class.
*
* Revision 1.30 2000/04/28 21:00:29 steve
* Over agressive signal elimination in constant probadation.
*

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: elaborate.cc,v 1.165 2000/04/28 23:12:12 steve Exp $"
#ident "$Id: elaborate.cc,v 1.166 2000/05/02 00:58:11 steve Exp $"
#endif
/*
@ -164,7 +164,6 @@ void PWire::elaborate(Design*des, NetScope*scope) const
for (unsigned idx = 0 ; idx < wid ; idx += 1)
sig->set_ival(idx, iv);
des->add_signal(sig);
}
}
@ -692,6 +691,9 @@ void PGModule::elaborate_scope(Design*des, NetScope*sc) const
*/
NetNet* PEConcat::elaborate_lnet(Design*des, const string&path) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
svector<NetNet*>nets (parms_.count());
unsigned pins = 0;
unsigned errors = 0;
@ -725,7 +727,7 @@ NetNet* PEConcat::elaborate_lnet(Design*des, const string&path) const
operands, and connect it up. Scan the operands of the
concat operator from least significant to most significant,
which is opposite from how they are given in the list. */
NetNet*osig = new NetNet(0, des->local_symbol(path),
NetNet*osig = new NetNet(scope, des->local_symbol(path),
NetNet::IMPLICIT, pins);
pins = 0;
for (unsigned idx = nets.count() ; idx > 0 ; idx -= 1) {
@ -737,7 +739,6 @@ NetNet* PEConcat::elaborate_lnet(Design*des, const string&path) const
}
osig->local_flag(true);
des->add_signal(osig);
return osig;
}
@ -987,9 +988,8 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
return 0;
}
NetNet*tmp = new NetNet(0, n, NetNet::REG, wid);
NetNet*tmp = new NetNet(scope, n, NetNet::REG, wid);
tmp->set_line(*this);
des->add_signal(tmp);
/* Generate an assignment of the l-value to the temporary... */
n = des->local_symbol(path);
@ -1998,29 +1998,69 @@ NetProc* PForStatement::elaborate(Design*des, const string&path) const
}
/*
* Elaborating function definitions takes 2 passes. The first creates
* the NetFuncDef object and attaches the ports to it. The second pass
* (elaborate_2) elaborates the statement that is contained
* within. These passes are needed because the statement may invoke
* the function itself (or other functions) so can't be elaborated
* until all the functions are partially elaborated.
* (See the PTask::elaborate methods for basic common stuff.)
*
* In both cases, the scope parameter is the scope of the function. In
* other words, it is the scope that has the name of the function with
* the path of the containing module.
* The return value of a function is represented as a reg variable
* within the scope of the function that has the name of the
* function. So for example with the function:
*
* function [7:0] incr;
* input [7:0] in1;
* incr = in1 + 1;
* endfunction
*
* The scope of the function is <parent>.incr and there is a reg
* variable <parent>.incr.incr. The elaborate_1 method is called with
* the scope of the function, so the return reg is easily located.
*
* The function parameters are all inputs, except for the synthetic
* output parameter that is the return value. The return value goes
* into port 0, and the parameters are all the remaining ports.
*/
void PFunction::elaborate_1(Design*des, NetScope*scope) const
{
/* Translate the wires that are ports to NetNet pointers by
presuming that the name is already elaborated, and look it
up in the design. Then save that pointer for later use by
calls to the task. (Remember, the task itself does not need
these ports.) */
string fname = scope->basename();
svector<NetNet*>ports (ports_? ports_->count()+1 : 1);
ports[0] = des->find_signal(scope->name(), scope->name());
/* Get the reg for the return value. I know the name of the
reg variable, and I know that it is in this scope, so look
it up directly. */
ports[0] = scope->find_signal(scope->basename());
if (ports[0] == 0) {
cerr << get_line() << ": internal error: function scope "
<< scope->name() << " is missing return reg "
<< fname << "." << endl;
scope->dump(cerr);
des->errors += 1;
return;
}
for (unsigned idx = 0 ; idx < ports_->count() ; idx += 1) {
NetNet*tmp = des->find_signal(scope->name(),
(*ports_)[idx]->name());
/* Parse the port name into the task name and the reg
name. We know by design that the port name is given
as two components: <func>.<port>. */
string pname = (*ports_)[idx]->name();
string ppath = parse_first_name(pname);
if (ppath != scope->basename()) {
cerr << get_line() << ": internal error: function "
<< "port " << (*ports_)[idx]->name()
<< " has wrong name for function "
<< scope->name() << "." << endl;
des->errors += 1;
}
NetNet*tmp = scope->find_signal(pname);
if (tmp == 0) {
cerr << get_line() << ": internal error: function "
<< scope->name() << " is missing port "
<< pname << "." << endl;
scope->dump(cerr);
des->errors += 1;
}
ports[idx+1] = tmp;
}
@ -2106,22 +2146,63 @@ NetProc* PRepeat::elaborate(Design*des, const string&path) const
* it contains, and connecting its ports to NetNet objects. The
* netlist doesn't really need the array of parameters once elaboration
* is complete, but this is the best place to store them.
*
* The first elaboration pass finds the reg objects that match the
* port names, and creates the NetTaskDef object. The port names are
* in the form task.port.
*
* task foo;
* output blah;
* begin <body> end
* endtask
*
* So in the foo example, the PWire objects that represent the ports
* of the task will include a foo.blah for the blah port. This port is
* bound to a NetNet object by looking up the name.
*
* Elaboration pass 2 for the task definition causes the statement of
* the task to be elaborated and attached to the NetTaskDef object
* created in pass 1.
*
* NOTE: I am not sure why I bothered to prepend the task name to the
* port name when making the port list. It is not really useful, but
* that is what I did in pform_make_task_ports, so there it is.
*/
void PTask::elaborate_1(Design*des, const string&path) const
{
NetScope*scope = des->find_scope(path);
assert(scope);
/* Translate the wires that are ports to NetNet pointers by
presuming that the name is already elaborated, and look it
up in the design. Then save that pointer for later use by
calls to the task. (Remember, the task itself does not need
these ports.) */
svector<NetNet*>ports (ports_? ports_->count() : 0);
for (unsigned idx = 0 ; idx < ports.count() ; idx += 1) {
NetNet*tmp = des->find_signal(path, (*ports_)[idx]->name());
assert(tmp->scope() == scope);
/* Parse the port name into the task name and the reg
name. We know by design that the port name is given
as two components: <task>.<port>. */
string pname = (*ports_)[idx]->name();
string ppath = parse_first_name(pname);
assert(pname != "");
/* check that the current scope really does have the
name of the first component of the task port name. Do
this by looking up the task scope in the parent of
the current scope. */
if (scope->parent()->child(ppath) != scope) {
cerr << "internal error: task scope " << ppath
<< " not the same as scope " << scope->name()
<< "?!" << endl;
return;
}
NetNet*tmp = scope->find_signal(pname);
if (tmp == 0) {
cerr << get_line() << ": internal error: "
<< "Could not find port " << pname
<< " in scope " << scope->name() << endl;
scope->dump(cerr);
}
ports[idx] = tmp;
}
@ -2350,6 +2431,9 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
* Revision 1.166 2000/05/02 00:58:11 steve
* Move signal tables to the NetScope class.
*
* Revision 1.165 2000/04/28 23:12:12 steve
* Overly aggressive eliding of task calls.
*

16
emit.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: emit.cc,v 1.41 2000/04/23 03:45:24 steve Exp $"
#ident "$Id: emit.cc,v 1.42 2000/05/02 00:58:12 steve Exp $"
#endif
/*
@ -289,6 +289,14 @@ void NetScope::emit_scope(ostream&o, struct target_t*tgt) const
for (NetScope*cur = sub_ ; cur ; cur = cur->sib_)
cur->emit_scope(o, tgt);
if (signals_) {
NetNet*cur = signals_->sig_next_;
do {
tgt->signal(o, cur);
cur = cur->sig_next_;
} while (cur != signals_->sig_next_);
}
}
void NetWhile::emit_proc_recurse(ostream&o, struct target_t*tgt) const
@ -304,6 +312,7 @@ bool Design::emit(ostream&o, struct target_t*tgt) const
// enumerate the scopes
root_scope_->emit_scope(o, tgt);
#if 0
// emit signals
if (signals_) {
NetNet*cur = signals_->sig_next_;
@ -312,7 +321,7 @@ bool Design::emit(ostream&o, struct target_t*tgt) const
cur = cur->sig_next_;
} while (cur != signals_->sig_next_);
}
#endif
// emit memories
{
@ -431,6 +440,9 @@ bool emit(ostream&o, const Design*des, const char*type)
/*
* $Log: emit.cc,v $
* Revision 1.42 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.41 2000/04/23 03:45:24 steve
* Add support for the procedural release statement.
*

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.13 2000/04/28 18:43:23 steve Exp $"
#ident "$Id: expr_synth.cc,v 1.14 2000/05/02 00:58:12 steve Exp $"
#endif
# include "netlist.h"
@ -45,7 +45,7 @@ NetNet* NetEBAdd::synthesize(Design*des)
assert(lsig->pin_count() == rsig->pin_count());
unsigned width=lsig->pin_count();
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, width);
NetNet*osig = new NetNet(lsig->scope(), path, NetNet::IMPLICIT, width);
string oname = des->local_symbol(path);
NetAddSub *adder = new NetAddSub(oname, width);
@ -55,7 +55,6 @@ NetNet* NetEBAdd::synthesize(Design*des)
connect(osig->pin(idx), adder->pin_Result(idx));
}
des->add_node(adder);
des->add_signal(osig);
switch (op()) {
case '+':
@ -82,7 +81,8 @@ NetNet* NetEBBits::synthesize(Design*des)
NetNet*rsig = right_->synthesize(des);
assert(lsig->pin_count() == rsig->pin_count());
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, lsig->pin_count());
NetNet*osig = new NetNet(lsig->scope(), path, NetNet::IMPLICIT,
lsig->pin_count());
osig->local_flag(true);
for (unsigned idx = 0 ; idx < osig->pin_count() ; idx += 1) {
@ -116,7 +116,6 @@ NetNet* NetEBBits::synthesize(Design*des)
des->add_node(gate);
}
des->add_signal(osig);
return osig;
}
@ -130,7 +129,7 @@ NetNet* NetEBComp::synthesize(Design*des)
if (rsig->pin_count() > lsig->pin_count())
width = rsig->pin_count();
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, 1);
NetNet*osig = new NetNet(lsig->scope(), path, NetNet::IMPLICIT, 1);
osig->local_flag(true);
/* Handle the special case of a single bit equality
@ -211,10 +210,12 @@ NetNet* NetEBDiv::synthesize(Design*des)
NetNet* NetEConcat::synthesize(Design*des)
{
NetScope*scope = des->find_root_scope();
assert(scope);
assert(repeat_ == 1);
string path = des->local_symbol("SYNTH");
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, expr_width());
NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, expr_width());
osig->local_flag(true);
unsigned obit = 0;
@ -230,23 +231,24 @@ NetNet* NetEConcat::synthesize(Design*des)
delete tmp;
}
des->add_signal(osig);
return osig;
}
NetNet* NetEConst::synthesize(Design*des)
{
NetScope*scope = des->find_root_scope();
assert(scope);
string path = des->local_symbol("SYNTH");
unsigned width=expr_width();
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, width);
NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, width);
osig->local_flag(true);
NetConst*con = new NetConst(des->local_symbol(path), value());
for (unsigned idx = 0 ; idx < width; idx += 1)
connect(osig->pin(idx), con->pin(idx));
des->add_node(con);
des->add_signal(osig);
return osig;
}
@ -259,7 +261,8 @@ NetNet* NetEUBits::synthesize(Design*des)
string path = des->local_symbol("SYNTH");
NetNet*isig = expr_->synthesize(des);
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, isig->pin_count());
NetNet*osig = new NetNet(isig->scope(), path, NetNet::IMPLICIT,
isig->pin_count());
osig->local_flag(true);
for (unsigned idx = 0 ; idx < osig->pin_count() ; idx += 1) {
@ -279,7 +282,7 @@ NetNet* NetEUBits::synthesize(Design*des)
des->add_node(gate);
}
des->add_signal(osig);
return osig;
}
@ -294,7 +297,7 @@ NetNet* NetETernary::synthesize(Design *des)
assert(csig->pin_count() == 1);
assert(tsig->pin_count() == fsig->pin_count());
unsigned width=tsig->pin_count();
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, width);
NetNet*osig = new NetNet(csig->scope(), path, NetNet::IMPLICIT, width);
osig->local_flag(true);
string oname = des->local_symbol(path);
@ -306,7 +309,7 @@ NetNet* NetETernary::synthesize(Design *des)
}
des->add_node(mux);
connect(csig->pin(0), mux->pin_Sel(0));
des->add_signal(osig);
return osig;
}
@ -317,6 +320,9 @@ NetNet* NetESignal::synthesize(Design*des)
/*
* $Log: expr_synth.cc,v $
* Revision 1.14 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.13 2000/04/28 18:43:23 steve
* integer division in expressions properly get width.
*

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: functor.cc,v 1.17 2000/04/20 00:28:03 steve Exp $"
#ident "$Id: functor.cc,v 1.18 2000/05/02 00:58:12 steve Exp $"
#endif
# include "functor.h"
@ -78,22 +78,22 @@ void NetScope::run_functor(Design*des, functor_t*fun)
cur = cur->snext_;
fun->event(des, tmp);
}
}
void Design::functor(functor_t*fun)
{
// Scan the scopes
root_scope_->run_functor(this, fun);
// apply to signals
if (signals_) {
NetNet*cur = signals_->sig_next_;
do {
NetNet*tmp = cur->sig_next_;
fun->signal(this, cur);
fun->signal(des, cur);
cur = tmp;
} while (cur != signals_->sig_next_);
}
}
void Design::functor(functor_t*fun)
{
// Scan the scopes
root_scope_->run_functor(this, fun);
// apply to processes
procs_idx_ = procs_;
@ -217,6 +217,9 @@ int proc_match_t::event_wait(NetEvWait*)
/*
* $Log: functor.cc,v $
* Revision 1.18 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.17 2000/04/20 00:28:03 steve
* Catch some simple identity compareoptimizations.
*

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: net_design.cc,v 1.5 2000/04/28 16:50:53 steve Exp $"
#ident "$Id: net_design.cc,v 1.6 2000/05/02 00:58:12 steve Exp $"
#endif
/*
@ -44,7 +44,7 @@ static string parse_last_name(string&path)
}
Design:: Design()
: errors(0), root_scope_(0), signals_(0), nodes_(0), procs_(0), lcounter_(0)
: errors(0), root_scope_(0), nodes_(0), procs_(0), lcounter_(0)
{
}
@ -67,6 +67,11 @@ NetScope* Design::make_root_scope(const string&root)
return root_scope_;
}
NetScope* Design::find_root_scope()
{
assert(root_scope_);
return root_scope_;
}
/*
* This method locates a scope in the design, given its rooted
@ -260,69 +265,27 @@ string Design::get_flag(const string&key) const
return (*tmp).second;
}
void Design::add_signal(NetNet*net)
{
assert(net->design_ == 0);
if (signals_ == 0) {
net->sig_next_ = net;
net->sig_prev_ = net;
} else {
net->sig_next_ = signals_->sig_next_;
net->sig_prev_ = signals_;
net->sig_next_->sig_prev_ = net;
net->sig_prev_->sig_next_ = net;
}
signals_ = net;
net->design_ = this;
}
void Design::del_signal(NetNet*net)
{
assert(net->design_ == this);
if (signals_ == net)
signals_ = net->sig_prev_;
if (signals_ == net) {
signals_ = 0;
} else {
net->sig_prev_->sig_next_ = net->sig_next_;
net->sig_next_->sig_prev_ = net->sig_prev_;
}
net->design_ = 0;
}
/*
* This method looks for a string given a current context as a
* starting point.
*/
NetNet* Design::find_signal(const string&path, const string&name)
{
if (signals_ == 0)
return 0;
const NetScope*scope = find_scope(path);
NetScope*scope = find_scope(path);
if (scope == 0) {
cerr << "internal error: invalid scope: " << path << endl;
return 0;
}
assert(scope);
for (;;) {
string fulname = scope? (scope->name() + "." + name) : name;
NetNet*cur = signals_;
do {
if (cur->name() == fulname)
return cur;
cur = cur->sig_prev_;
} while (cur != signals_);
if (scope == 0)
return 0;
while (scope) {
if (NetNet*net = scope->find_signal(name))
return net;
scope = scope->parent();
}
return 0;
}
void Design::add_memory(NetMemory*mem)
@ -352,7 +315,7 @@ NetMemory* Design::find_memory(const string&path, const string&name)
return 0;
}
void Design::find_symbol(const NetScope*scope, const string&key,
void Design::find_symbol(NetScope*scope, const string&key,
NetNet*&sig, NetMemory*&mem)
{
sig = 0;
@ -362,18 +325,11 @@ void Design::find_symbol(const NetScope*scope, const string&key,
/* Form the full heirarchical name for lookups. */
string fulname = scope? (scope->name() + "." + key) : key;
/* Is this a signal? If so, we are done. */
if (signals_) {
NetNet*cur = signals_;
do {
if (cur->name() == fulname) {
sig = cur;
return;
}
cur = cur->sig_prev_;
} while (cur != signals_);
}
if (scope)
if (NetNet*cur = scope->find_signal(fulname)) {
sig = cur;
return;
}
/* Is this a memory? If so, we are again done. */
map<string,NetMemory*>::const_iterator cur
@ -530,18 +486,6 @@ void Design::clear_node_marks()
} while (cur != nodes_);
}
void Design::clear_signal_marks()
{
if (signals_ == 0)
return;
NetNet*cur = signals_;
do {
cur->set_mark(false);
cur = cur->sig_next_;
} while (cur != signals_);
}
NetNode* Design::find_node(bool (*func)(const NetNode*))
{
if (nodes_ == 0)
@ -558,24 +502,11 @@ NetNode* Design::find_node(bool (*func)(const NetNode*))
return 0;
}
NetNet* Design::find_signal(bool (*func)(const NetNet*))
{
if (signals_ == 0)
return 0;
NetNet*cur = signals_->sig_next_;
do {
if ((cur->test_mark() == false) && func(cur))
return cur;
cur = cur->sig_next_;
} while (cur != signals_->sig_next_);
return 0;
}
/*
* $Log: net_design.cc,v $
* Revision 1.6 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.5 2000/04/28 16:50:53 steve
* Catch memory word parameters to tasks.
*

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: net_scope.cc,v 1.4 2000/04/18 04:50:20 steve Exp $"
#ident "$Id: net_scope.cc,v 1.5 2000/05/02 00:58:12 steve Exp $"
#endif
# include "netlist.h"
@ -34,6 +34,7 @@
NetScope::NetScope(const string&n)
: type_(NetScope::MODULE), name_(n), up_(0), sib_(0), sub_(0)
{
signals_ = 0;
events_ = 0;
lcounter_ = 0;
}
@ -41,6 +42,7 @@ NetScope::NetScope(const string&n)
NetScope::NetScope(NetScope*up, const string&n, NetScope::TYPE t)
: type_(t), name_(n), up_(up), sib_(0), sub_(0)
{
signals_ = 0;
events_ = 0;
sib_ = up_->sub_;
up_->sub_ = this;
@ -89,6 +91,11 @@ NetScope::TYPE NetScope::type() const
return type_;
}
string NetScope::basename() const
{
return name_;
}
string NetScope::name() const
{
if (up_)
@ -134,6 +141,49 @@ NetEvent* NetScope::find_event(const string&name)
return 0;
}
void NetScope::add_signal(NetNet*net)
{
if (signals_ == 0) {
net->sig_next_ = net;
net->sig_prev_ = net;
} else {
net->sig_next_ = signals_->sig_next_;
net->sig_prev_ = signals_;
net->sig_next_->sig_prev_ = net;
net->sig_prev_->sig_next_ = net;
}
signals_ = net;
}
void NetScope::rem_signal(NetNet*net)
{
assert(net->scope_ == this);
if (signals_ == net)
signals_ = net->sig_prev_;
if (signals_ == net) {
signals_ = 0;
} else {
net->sig_prev_->sig_next_ = net->sig_next_;
net->sig_next_->sig_prev_ = net->sig_prev_;
}
}
NetNet* NetScope::find_signal(const string&key)
{
if (signals_ == 0)
return 0;
string fulname = name()+"."+key;
NetNet*cur = signals_;
do {
if (cur->name() == fulname)
return cur;
cur = cur->sig_prev_;
} while (cur != signals_);
return 0;
}
/*
* This method locates a child scope by name. The name is the simple
* name of the child, no heirarchy is searched.
@ -184,6 +234,9 @@ string NetScope::local_symbol()
/*
* $Log: net_scope.cc,v $
* Revision 1.5 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.4 2000/04/18 04:50:20 steve
* Clean up unneeded NetEvent objects.
*

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.119 2000/04/28 18:43:23 steve Exp $"
#ident "$Id: netlist.cc,v 1.120 2000/05/02 00:58:12 steve Exp $"
#endif
# include <cassert>
@ -369,35 +369,43 @@ NetNode::~NetNode()
}
NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins)
: NetObj(n, npins), sig_next_(0), sig_prev_(0), design_(0), scope_(s),
: NetObj(n, npins), sig_next_(0), sig_prev_(0), scope_(s),
type_(t), port_type_(NOT_A_PORT), msb_(npins-1), lsb_(0),
local_flag_(false), eref_count_(0)
{
assert(scope_);
ivalue_ = new verinum::V[npins];
for (unsigned idx = 0 ; idx < npins ; idx += 1) {
pin(idx).set_name("P", idx);
ivalue_[idx] = verinum::Vz;
}
scope_->add_signal(this);
}
NetNet::NetNet(NetScope*s, const string&n, Type t, long ms, long ls)
: NetObj(n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0),
sig_prev_(0), design_(0), scope_(s), type_(t),
sig_prev_(0), scope_(s), type_(t),
port_type_(NOT_A_PORT), msb_(ms), lsb_(ls), local_flag_(false),
eref_count_(0)
{
assert(scope_);
ivalue_ = new verinum::V[pin_count()];
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1) {
pin(idx).set_name("P", idx);
ivalue_[idx] = verinum::Vz;
}
scope_->add_signal(this);
}
NetNet::~NetNet()
{
assert(eref_count_ == 0);
if (design_)
design_->del_signal(this);
if (scope_)
scope_->rem_signal(this);
}
NetScope* NetNet::scope()
@ -434,8 +442,8 @@ unsigned NetNet::get_eref() const
return eref_count_;
}
NetTmp::NetTmp(const string&name, unsigned npins)
: NetNet(0, name, IMPLICIT, npins)
NetTmp::NetTmp(NetScope*s, const string&name, unsigned npins)
: NetNet(s, name, IMPLICIT, npins)
{
local_flag(true);
}
@ -2537,6 +2545,9 @@ bool NetUDP::sequ_glob_(string input, char output)
/*
* $Log: netlist.cc,v $
* Revision 1.120 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.119 2000/04/28 18:43:23 steve
* integer division in expressions properly get width.
*

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.132 2000/04/28 18:43:23 steve Exp $"
#ident "$Id: netlist.h,v 1.133 2000/05/02 00:58:12 steve Exp $"
#endif
/*
@ -215,14 +215,16 @@ class NetNode : public NetObj {
/*
* NetNet is a special kind of NetObj that doesn't really do anything,
* but carries the properties of the wire/reg/trireg. Thus, a set of
* pins connected together would also be connected to exactly one of
* these.
* but carries the properties of the wire/reg/trireg, including its
* name. A scaler wire is a NetNet with one pin, a vector a wider
* NetNet. NetNet objects also appear as side effects of synthesis or
* other abstractions.
*
* Note that a net of any sort has exactly one pin. The pins feature
* of the NetObj class is used to make a set of identical wires, in
* order to support ranges, or busses. When dealing with vectors,
* pin(0) is always the least significant bit.
* NetNet objects have a name and exist within a scope, so the
* constructor takes a pointer to the containing scope. The object
* automatically adds itself to the scope.
*
* NetNet objects are located by searching NetScope objects.
*/
class NetNet : public NetObj, public LineInfo {
@ -276,10 +278,9 @@ class NetNet : public NetObj, public LineInfo {
virtual void dump_net(ostream&, unsigned) const;
private:
// The Design class uses this for listing signals.
friend class Design;
// The NetScope class uses this for listing signals.
friend class NetScope;
NetNet*sig_next_, *sig_prev_;
Design*design_;
private:
NetScope*scope_;
@ -749,12 +750,14 @@ class NetEConst : public NetExpr {
/*
* The NetTmp object is a network that is only used momentarily by
* elaboration to carry links around. A completed netlist should not
* have any of these within. This is a kind of wire, so it is NetNet type.
* have any of these within. This is a kind of wire, so it is NetNet
* type. The constructor for this class also marks the NetNet as
* local, so that it is not likely to suppress a real symbol.
*/
class NetTmp : public NetNet {
public:
explicit NetTmp(const string&name, unsigned npins =1);
explicit NetTmp(NetScope*s, const string&name, unsigned npins =1);
};
@ -2253,6 +2256,17 @@ class NetScope {
void rem_event(NetEvent*);
NetEvent*find_event(const string&name);
/* These methods manage signals. The add_ and rem_signal
methods are used by the NetNet objects to make themselves
available to the scope, and the find_signal method can be
used to locate signals within a scope. */
void add_signal(NetNet*);
void rem_signal(NetNet*);
NetNet* find_signal(const string&name);
/* The parent and child() methods allow users of NetScope
objects to locate nearby scopes. */
NetScope* parent();
@ -2261,6 +2275,11 @@ class NetScope {
const NetScope* child(const string&name) const;
TYPE type() const;
/* The name of the scope is the fully qualified hierarchical
name, whereas the basename is just my name within my parent
scope. */
string basename() const;
string name() const;
void run_defparams(class Design*);
@ -2292,6 +2311,7 @@ class NetScope {
map<string,NetExpr*>localparams_;
NetEvent*events_;
NetNet *signals_;
NetScope*up_;
NetScope*sib_;
@ -2323,6 +2343,7 @@ class Design {
string get_flag(const string&key) const;
NetScope* make_root_scope(const string&name);
NetScope* find_root_scope();
/* look up a scope. If no starting scope is passed, then the
path name string is taken as an absolute scope
@ -2341,9 +2362,11 @@ class Design {
void run_defparams();
void evaluate_parameters();
// SIGNALS
void add_signal(NetNet*);
void del_signal(NetNet*);
/* This method locates a signal, starting at a given
scope. The name parameter may be partially hierarchical, so
this method, unlike the NetScope::find_signal method,
handles global name binding. */
NetNet*find_signal(const string&path, const string&name);
// Memories
@ -2352,7 +2375,7 @@ class Design {
/* This is a more general lookup that finds the named signal
or memory, whichever is first in the search path. */
void find_symbol(const NetScope*,const string&key,
void find_symbol(NetScope*,const string&key,
NetNet*&sig, NetMemory*&mem);
// Functions
@ -2381,9 +2404,6 @@ class Design {
void clear_node_marks();
NetNode*find_node(bool (*test)(const NetNode*));
void clear_signal_marks();
NetNet*find_signal(bool (*test)(const NetNet*));
// This is incremented by elaboration when an error is
// detected. It prevents code being emitted.
unsigned errors;
@ -2396,9 +2416,6 @@ class Design {
// tree and per-hop searches for me.
NetScope*root_scope_;
// List all the signals in the design.
NetNet*signals_;
map<string,NetMemory*> memories_;
// List the function definitions in the design.
@ -2468,6 +2485,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.133 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.132 2000/04/28 18:43:23 steve
* integer division in expressions properly get width.
*

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: pad_to_width.cc,v 1.4 2000/02/23 02:56:55 steve Exp $"
#ident "$Id: pad_to_width.cc,v 1.5 2000/05/02 00:58:12 steve Exp $"
#endif
# include "netlist.h"
@ -47,6 +47,9 @@ NetExpr*pad_to_width(NetExpr*expr, unsigned wid)
NetNet*pad_to_width(Design*des, const string&path, NetNet*net, unsigned wid)
{
NetScope*scope = des->find_scope(path);
assert(scope);
if (net->pin_count() >= wid)
return net;
@ -54,9 +57,9 @@ NetNet*pad_to_width(Design*des, const string&path, NetNet*net, unsigned wid)
NetConst*con = new NetConst(des->local_symbol(path), pad);
des->add_node(con);
NetNet*tmp = new NetNet(0, des->local_symbol(path), NetNet::WIRE, wid);
NetNet*tmp = new NetNet(scope, des->local_symbol(path),
NetNet::WIRE, wid);
tmp->local_flag(true);
des->add_signal(tmp);
for (unsigned idx = 0 ; idx < net->pin_count() ; idx += 1)
connect(tmp->pin(idx), net->pin(idx));
@ -68,6 +71,9 @@ NetNet*pad_to_width(Design*des, const string&path, NetNet*net, unsigned wid)
/*
* $Log: pad_to_width.cc,v $
* Revision 1.5 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.4 2000/02/23 02:56:55 steve
* Macintosh compilers do not support ident.
*

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-vvm.cc,v 1.141 2000/04/28 18:43:23 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.142 2000/05/02 00:58:12 steve Exp $"
#endif
# include <iostream>
@ -384,6 +384,9 @@ void vvm_proc_rval::expr_ufunc(const NetEUFunc*expr)
/* Scan the parameter expressions, and assign the values to
the parameter port register. */
for (unsigned idx = 0 ; idx < pcnt ; idx += 1) {
assert(expr->parm(idx));
assert(def->port(idx+1));
expr->parm(idx)->expr_scan(this);
string bname = mangle(def->port(idx+1)->name());
for (unsigned bit = 0 ;
@ -2689,6 +2692,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.142 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.141 2000/04/28 18:43:23 steve
* integer division in expressions properly get width.
*

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: xnfio.cc,v 1.12 2000/04/20 00:28:03 steve Exp $"
#ident "$Id: xnfio.cc,v 1.13 2000/05/02 00:58:12 steve Exp $"
#endif
# include "functor.h"
@ -139,10 +139,11 @@ static NetLogic* make_obuf(Design*des, NetNet*net)
// of the netlist, to create a ring without a signal. Detect
// this case and create a new signal.
if (count_signals(buf->pin(1)) == 0) {
NetNet*tmp = new NetNet(0, des->local_symbol("$"), NetNet::WIRE);
NetNet*tmp = new NetNet(net->scope(),
des->local_symbol("$"),
NetNet::WIRE);
tmp->local_flag(true);
connect(buf->pin(1), tmp->pin(0));
des->add_signal(tmp);
}
return buf;
@ -201,6 +202,9 @@ static void absorb_OFF(Design*des, NetLogic*buf)
static void make_ibuf(Design*des, NetNet*net)
{
NetScope*scope = net->scope();
assert(scope);
assert(net->pin_count() == 1);
// XXXX For now, require at least one input.
assert(count_inputs(net->pin(0)) > 0);
@ -245,9 +249,10 @@ static void make_ibuf(Design*des, NetNet*net)
// of the netlist, to create a ring without a signal. Detect
// this case and create a new signal.
if (count_signals(buf->pin(0)) == 0) {
NetNet*tmp = new NetNet(0, des->local_symbol("$"), NetNet::WIRE);
NetNet*tmp = new NetNet(scope,
des->local_symbol(scope->name()),
NetNet::WIRE);
connect(buf->pin(0), tmp->pin(0));
des->add_signal(tmp);
}
}
@ -351,6 +356,9 @@ void xnfio(Design*des)
/*
* $Log: xnfio.cc,v $
* Revision 1.13 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class.
*
* Revision 1.12 2000/04/20 00:28:03 steve
* Catch some simple identity compareoptimizations.
*