Add non-const bit select in l-value of assignment.

This commit is contained in:
steve 1999-10-07 05:25:33 +00:00
parent 1d215998b2
commit f949f96df1
5 changed files with 205 additions and 105 deletions

View File

@ -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) #if !defined(WINNT)
#ident "$Id: design_dump.cc,v 1.47 1999/10/06 05:06:16 steve Exp $" #ident "$Id: design_dump.cc,v 1.48 1999/10/07 05:25:33 steve Exp $"
#endif #endif
/* /*
@ -129,16 +129,18 @@ void NetAddSub::dump_node(ostream&o, unsigned ind) const
void NetAssign::dump_node(ostream&o, unsigned ind) const void NetAssign::dump_node(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "Procedural assign (NetAssign): " << o << setw(ind) << "" << "Procedural assign (NetAssign): " << name();
*rval() << endl; if (bmux())
o << "[" << *bmux() << "]";
o << " = " << *rval() << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
} }
void NetAssignNB::dump_node(ostream&o, unsigned ind) const void NetAssignNB::dump_node(ostream&o, unsigned ind) const
{ {
if (bmux_) if (bmux())
o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): " o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): "
<< name() << "[" << *bmux_ << "] <= " << *rval() << endl; << name() << "[" << *bmux() << "] <= " << *rval() << endl;
else else
o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): " o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): "
<< name() << " <= " << *rval() << endl; << name() << " <= " << *rval() << endl;
@ -334,21 +336,26 @@ void NetAssign::dump(ostream&o, unsigned ind) const
{ {
o << setw(ind) << ""; o << setw(ind) << "";
const NetNet*sig; if (bmux()) {
unsigned msb, lsb; o << name() << "[" << *bmux() << "] = ";
find_lval_range(sig, msb, lsb); if (rise_time())
o << sig->name() << "[" << msb; o << "#" << rise_time() << " ";
if (pin_count() > 1) o << *rval() << ";" << endl;
o << ":" << lsb;
o << "] = " << *rval() << ";" << endl; } else {
o << name() << " = ";
if (rise_time())
o << "#" << rise_time() << " ";
o << *rval() << ";" << endl;
}
} }
void NetAssignNB::dump(ostream&o, unsigned ind) const void NetAssignNB::dump(ostream&o, unsigned ind) const
{ {
o << setw(ind) << ""; o << setw(ind) << "";
if (bmux_) { if (bmux()) {
o << name() << "[" << *bmux_ << "] <= "; o << name() << "[" << *bmux() << "] <= ";
if (rise_time()) if (rise_time())
o << "#" << rise_time() << " "; o << "#" << rise_time() << " ";
o << *rval() << ";" << endl; o << *rval() << ";" << endl;
@ -779,6 +786,9 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $Log: design_dump.cc,v $
* Revision 1.48 1999/10/07 05:25:33 steve
* Add non-const bit select in l-value of assignment.
*
* Revision 1.47 1999/10/06 05:06:16 steve * Revision 1.47 1999/10/06 05:06:16 steve
* Move the rvalue into NetAssign_ common code. * Move the rvalue into NetAssign_ common code.
* *

View File

@ -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) #if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.110 1999/10/06 00:39:00 steve Exp $" #ident "$Id: elaborate.cc,v 1.111 1999/10/07 05:25:33 steve Exp $"
#endif #endif
/* /*
@ -120,16 +120,16 @@ void PWire::elaborate(Design*des, const string&path) const
for (unsigned idx = 0 ; idx < msb_.count() ; idx += 1) { for (unsigned idx = 0 ; idx < msb_.count() ; idx += 1) {
verinum*mval = msb_[idx]->eval_const(des,path); verinum*mval = msb_[idx]->eval_const(des,path);
if (mval == 0) { if (mval == 0) {
cerr << msb_[idx]->get_line() << ": Unable to " cerr << msb_[idx]->get_line() << ": error: "
"evaluate constant expression ``" << "Unable to evaluate constant expression ``" <<
*msb_[idx] << "''." << endl; *msb_[idx] << "''." << endl;
des->errors += 1; des->errors += 1;
return; return;
} }
verinum*lval = lsb_[idx]->eval_const(des, path); verinum*lval = lsb_[idx]->eval_const(des, path);
if (mval == 0) { if (mval == 0) {
cerr << lsb_[idx]->get_line() << ": Unable to " cerr << lsb_[idx]->get_line() << ": error: "
"evaluate constant expression ``" << "Unable to evaluate constant expression ``" <<
*lsb_[idx] << "''." << endl; *lsb_[idx] << "''." << endl;
des->errors += 1; des->errors += 1;
return; return;
@ -145,7 +145,7 @@ void PWire::elaborate(Design*des, const string&path) const
value. If not, report an error. */ value. If not, report an error. */
for (unsigned idx = 1 ; idx < msb_.count() ; idx += 1) { for (unsigned idx = 1 ; idx < msb_.count() ; idx += 1) {
if ((mnum[idx] != mnum[0]) || (lnum[idx] != lnum[0])) { if ((mnum[idx] != mnum[0]) || (lnum[idx] != lnum[0])) {
cerr << get_line() << ": Inconsistent width, " cerr << get_line() << ": error: Inconsistent width, "
"[" << mnum[idx] << ":" << lnum[idx] << "]" "[" << mnum[idx] << ":" << lnum[idx] << "]"
" vs. [" << mnum[0] << ":" << lnum[0] << "]" " vs. [" << mnum[0] << ":" << lnum[0] << "]"
" for signal ``" << name_ << "''" << endl; " for signal ``" << name_ << "''" << endl;
@ -202,7 +202,8 @@ void PWire::elaborate(Design*des, const string&path) const
void PGate::elaborate(Design*des, const string&path) const void PGate::elaborate(Design*des, const string&path) const
{ {
cerr << "what kind of gate? " << typeid(*this).name() << endl; cerr << "internal error: what kind of gate? " <<
typeid(*this).name() << endl;
} }
/* /*
@ -231,8 +232,8 @@ void PGAssign::elaborate(Design*des, const string&path) const
NetNet*rval = pin(1)->elaborate_net(des, path, rise_time, NetNet*rval = pin(1)->elaborate_net(des, path, rise_time,
fall_time, decay_time); fall_time, decay_time);
if (rval == 0) { if (rval == 0) {
cerr << get_line() << ": Unable to elaborate r-value: " << cerr << get_line() << ": error: Unable to elaborate r-value: "
*pin(1) << endl; << *pin(1) << endl;
des->errors += 1; des->errors += 1;
return; return;
} }
@ -240,7 +241,7 @@ void PGAssign::elaborate(Design*des, const string&path) const
assert(lval && rval); assert(lval && rval);
if (lval->pin_count() != rval->pin_count()) { if (lval->pin_count() != rval->pin_count()) {
cerr << get_line() << ": lval width (" << cerr << get_line() << ": error: lval width (" <<
lval->pin_count() << ") != rval width (" << lval->pin_count() << ") != rval width (" <<
rval->pin_count() << ")." << endl; rval->pin_count() << ")." << endl;
delete lval; delete lval;
@ -273,15 +274,15 @@ void PGBuiltin::elaborate(Design*des, const string&path) const
verinum*lsb = lsb_->eval_const(des, path); verinum*lsb = lsb_->eval_const(des, path);
if (msb == 0) { if (msb == 0) {
cerr << get_line() << ": Unable to evaluate expression " cerr << get_line() << ": error: Unable to evaluate "
<< *msb_ << endl; "expression " << *msb_ << endl;
des->errors += 1; des->errors += 1;
return; return;
} }
if (lsb == 0) { if (lsb == 0) {
cerr << get_line() << ": Unable to evaluate expression " cerr << get_line() << ": error: Unable to evaluate "
<< *lsb_ << endl; "expression " << *lsb_ << endl;
des->errors += 1; des->errors += 1;
return; return;
} }
@ -391,8 +392,8 @@ void PGBuiltin::elaborate(Design*des, const string&path) const
connect(cur[gdx]->pin(idx), sig->pin(gdx)); connect(cur[gdx]->pin(idx), sig->pin(gdx));
else { else {
cerr << get_line() << ": Gate count of " << count << cerr << get_line() << ": error: Gate count of " <<
" does not match net width of " << count << " does not match net width of " <<
sig->pin_count() << " at pin " << idx << "." sig->pin_count() << " at pin " << idx << "."
<< endl; << endl;
des->errors += 1; des->errors += 1;
@ -436,7 +437,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
// method will return the port count. Detect that // method will return the port count. Detect that
// as an error. // as an error.
if (pidx == nexp) { if (pidx == nexp) {
cerr << get_line() << ": port ``" << cerr << get_line() << ": error: port ``" <<
pins_[idx].name << "'' is not a port of " pins_[idx].name << "'' is not a port of "
<< get_name() << "." << endl; << get_name() << "." << endl;
des->errors += 1; des->errors += 1;
@ -447,7 +448,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
// the (*exp) array will already have a pointer // the (*exp) array will already have a pointer
// value where I want to place this expression. // value where I want to place this expression.
if ((*exp)[pidx]) { if ((*exp)[pidx]) {
cerr << get_line() << ": port ``" << cerr << get_line() << ": error: port ``" <<
pins_[idx].name << "'' already bound." << pins_[idx].name << "'' already bound." <<
endl; endl;
des->errors += 1; des->errors += 1;
@ -464,7 +465,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
} else { } else {
if (pin_count() != rmod->port_count()) { if (pin_count() != rmod->port_count()) {
cerr << get_line() << ": Wrong number " cerr << get_line() << ": error: Wrong number "
"of parameters. Expecting " << rmod->port_count() << "of parameters. Expecting " << rmod->port_count() <<
", got " << pin_count() << "." ", got " << pin_count() << "."
<< endl; << endl;
@ -495,7 +496,8 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
continue; continue;
NetNet*sig = (*pins)[idx]->elaborate_net(des, path); NetNet*sig = (*pins)[idx]->elaborate_net(des, path);
if (sig == 0) { if (sig == 0) {
cerr << "Expression too complicated for elaboration." << endl; cerr << "internal error: Expression too complicated "
"for elaboration." << endl;
continue; continue;
} }
@ -518,9 +520,10 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
// Check that the parts have matching pin counts. If // Check that the parts have matching pin counts. If
// not, they are different widths. // not, they are different widths.
if (prts_pin_count != sig->pin_count()) { if (prts_pin_count != sig->pin_count()) {
cerr << get_line() << ": Port " << idx << " of " << type_ << cerr << get_line() << ": error: Port " << idx << " of "
" expects " << prts_pin_count << " pins, got " << << type_ << " expects " << prts_pin_count <<
sig->pin_count() << " from " << sig->name() << endl; " pins, got " << sig->pin_count() << " from "
<< sig->name() << endl;
des->errors += 1; des->errors += 1;
continue; continue;
} }
@ -563,8 +566,8 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, const string&path) const
NetNet*sig = pin(idx)->elaborate_net(des, path); NetNet*sig = pin(idx)->elaborate_net(des, path);
if (sig == 0) { if (sig == 0) {
cerr << "Expression too complicated for elaboration:" cerr << "internal error: Expression too complicated "
<< *pin(idx) << endl; "for elaboration:" << *pin(idx) << endl;
continue; continue;
} }
@ -620,7 +623,7 @@ void PGModule::elaborate(Design*des, const string&path) const
return; return;
} }
cerr << get_line() << ": Unknown module: " << type_ << endl; cerr << get_line() << ": error: Unknown module: " << type_ << endl;
} }
/* /*
@ -636,13 +639,13 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
NetNet*lsig = left_->elaborate_net(des, path), NetNet*lsig = left_->elaborate_net(des, path),
*rsig = right_->elaborate_net(des, path); *rsig = right_->elaborate_net(des, path);
if (lsig == 0) { if (lsig == 0) {
cerr << get_line() << ": Cannot elaborate "; cerr << get_line() << ": error: Cannot elaborate ";
left_->dump(cerr); left_->dump(cerr);
cerr << endl; cerr << endl;
return 0; return 0;
} }
if (rsig == 0) { if (rsig == 0) {
cerr << get_line() << ": Cannot elaborate "; cerr << get_line() << ": error: Cannot elaborate ";
right_->dump(cerr); right_->dump(cerr);
cerr << endl; cerr << endl;
return 0; return 0;
@ -781,7 +784,7 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
} }
default: default:
cerr << "Unhandled BINARY '" << op_ << "'" << endl; cerr << "internal eror: Unhandled BINARY '" << op_ << "'" << endl;
osig = 0; osig = 0;
} }
@ -807,7 +810,7 @@ NetNet* PEConcat::elaborate_net(Design*des, const string&path,
unsigned errors = 0; unsigned errors = 0;
if (repeat_) { if (repeat_) {
cerr << get_line() << ": Sorry, I do not know how to" cerr << get_line() << ": sorry: I do not know how to"
" elaborate repeat concatenation nets." << endl; " elaborate repeat concatenation nets." << endl;
return 0; return 0;
} }
@ -862,7 +865,7 @@ NetNet* PEConcat::elaborate_lnet(Design*des, const string&path) const
unsigned errors = 0; unsigned errors = 0;
if (repeat_) { if (repeat_) {
cerr << get_line() << ": Sorry, I do not know how to" cerr << get_line() << ": sorry: I do not know how to"
" elaborate repeat concatenation nets." << endl; " elaborate repeat concatenation nets." << endl;
return 0; return 0;
} }
@ -914,7 +917,7 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
NetNet*sig = des->find_signal(path, text_); NetNet*sig = des->find_signal(path, text_);
if (sig == 0) { if (sig == 0) {
if (des->find_memory(path+"."+text_)) { if (des->find_memory(path+"."+text_)) {
cerr << get_line() << ": Sorry, memories not supported" cerr << get_line() << ": sorry: memories not supported"
" in this context." << endl; " in this context." << endl;
return 0; return 0;
} }
@ -991,7 +994,7 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
if (sig == 0) { if (sig == 0) {
/* Don't allow memories here. Is it a memory? */ /* Don't allow memories here. Is it a memory? */
if (des->find_memory(path+"."+text_)) { if (des->find_memory(path+"."+text_)) {
cerr << get_line() << ": memories (" << text_ cerr << get_line() << ": error: memories (" << text_
<< ") cannot be l-values in continuous " << ") cannot be l-values in continuous "
<< "assignments." << endl; << "assignments." << endl;
return 0; return 0;
@ -1008,7 +1011,7 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
/* Don't allow registers as assign l-values. */ /* Don't allow registers as assign l-values. */
if (sig->type() == NetNet::REG) { if (sig->type() == NetNet::REG) {
cerr << get_line() << ": registers (" << sig->name() cerr << get_line() << ": error: registers (" << sig->name()
<< ") cannot be l-values in continuous" << ") cannot be l-values in continuous"
<< " assignments." << endl; << " assignments." << endl;
return 0; return 0;
@ -1259,7 +1262,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
break; break;
default: default:
cerr << "Unhandled UNARY '" << op_ << "'" << endl; cerr << "internal error: Unhandled UNARY '" << op_ << "'" << endl;
sig = 0; sig = 0;
} }
@ -1335,7 +1338,7 @@ NetExpr* PEUnary::elaborate_expr(Design*des, const string&path) const
NetProc* Statement::elaborate(Design*des, const string&path) const NetProc* Statement::elaborate(Design*des, const string&path) const
{ {
cerr << "elaborate: What kind of statement? " << cerr << "internal error: elaborate: What kind of statement? " <<
typeid(*this).name() << endl; typeid(*this).name() << endl;
NetProc*cur = new NetProc; NetProc*cur = new NetProc;
return cur; return cur;
@ -1402,8 +1405,9 @@ NetNet* PAssign_::elaborate_lval(Design*des, const string&path,
assert(reg); assert(reg);
if ((reg->type() != NetNet::REG) && (reg->type() != NetNet::INTEGER)) { if ((reg->type() != NetNet::REG) && (reg->type() != NetNet::INTEGER)) {
cerr << get_line() << ": " << *lval() << " is not a register." cerr << get_line() << ": error: " << *lval() <<
<< endl; " is not a register." << endl;
des->errors += 1;
return 0; return 0;
} }
@ -1422,8 +1426,9 @@ NetNet* PAssign_::elaborate_lval(Design*des, const string&path,
} }
verinum*vm = id->msb_->eval_const(des, path); verinum*vm = id->msb_->eval_const(des, path);
if (vl == 0) { if (vl == 0) {
cerr << id->msb_->get_line() << ": Expression must be" cerr << id->msb_->get_line() << ": error: "
" constant in this context: " << *id->msb_; "Expression must be constant in this context: "
<< *id->msb_;
des->errors += 1; des->errors += 1;
return 0; return 0;
} }
@ -1617,12 +1622,10 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
} else { } else {
assert(msb == lsb); assert(msb == lsb);
unsigned wid = 1; cur = new NetAssign(des->local_symbol(path), des,
cerr << get_line() << ": sorry: l-value bit select expression" reg->pin_count(), mux, rv);
" must be constant." << endl; for (unsigned idx = 0 ; idx < reg->pin_count() ; idx += 1)
delete reg; connect(cur->pin(idx), reg->pin(idx));
delete rv;
return 0;
} }
@ -1776,7 +1779,7 @@ NetProc* PCase::elaborate(Design*des, const string&path) const
{ {
NetExpr*expr = expr_->elaborate_expr(des, path); NetExpr*expr = expr_->elaborate_expr(des, path);
if (expr == 0) { if (expr == 0) {
cerr << get_line() << ": Unable to elaborate the case" cerr << get_line() << ": error: Unable to elaborate this case"
" expression." << endl; " expression." << endl;
return 0; return 0;
} }
@ -2499,7 +2502,7 @@ bool Module::elaborate(Design*des, const string&path, svector<PExpr*>*overrides_
NetProc*cur = (*st)->statement()->elaborate(des, path); NetProc*cur = (*st)->statement()->elaborate(des, path);
if (cur == 0) { if (cur == 0) {
cerr << (*st)->get_line() << ": Elaboration " cerr << (*st)->get_line() << ": error: Elaboration "
"failed for this process." << endl; "failed for this process." << endl;
result_flag = false; result_flag = false;
continue; continue;
@ -2553,6 +2556,9 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.111 1999/10/07 05:25:33 steve
* Add non-const bit select in l-value of assignment.
*
* Revision 1.110 1999/10/06 00:39:00 steve * Revision 1.110 1999/10/06 00:39:00 steve
* == and != connected to the wrong pins of the compare. * == and != connected to the wrong pins of the compare.
* *

View File

@ -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) #if !defined(WINNT)
#ident "$Id: netlist.cc,v 1.74 1999/10/06 05:06:16 steve Exp $" #ident "$Id: netlist.cc,v 1.75 1999/10/07 05:25:34 steve Exp $"
#endif #endif
# include <cassert> # include <cassert>
@ -382,7 +382,7 @@ NetObj::Link& NetAddSub::pin_Result(unsigned idx)
} }
NetAssign_::NetAssign_(const string&n, unsigned w) NetAssign_::NetAssign_(const string&n, unsigned w)
: NetNode(n, w), rval_(0) : NetNode(n, w), rval_(0), bmux_(0)
{ {
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1) for (unsigned idx = 0 ; idx < pin_count() ; idx += 1)
pin(idx).set_dir(NetObj::Link::OUTPUT); pin(idx).set_dir(NetObj::Link::OUTPUT);
@ -392,13 +392,21 @@ NetAssign_::NetAssign_(const string&n, unsigned w)
NetAssign_::~NetAssign_() NetAssign_::~NetAssign_()
{ {
if (rval_) delete rval_; if (rval_) delete rval_;
if (bmux_) delete bmux_;
} }
void NetAssign_::set_rval(NetExpr*r) void NetAssign_::set_rval(NetExpr*r)
{ {
assert(rval_ == 0);
rval_ = r; rval_ = r;
} }
void NetAssign_::set_bmux(NetExpr*r)
{
assert(bmux_ == 0);
bmux_ = r;
}
NetExpr* NetAssign_::rval() NetExpr* NetAssign_::rval()
{ {
return rval_; return rval_;
@ -409,18 +417,38 @@ const NetExpr* NetAssign_::rval() const
return rval_; return rval_;
} }
const NetExpr* NetAssign_::bmux() const
{
return bmux_;
}
NetAssign::NetAssign(const string&n, Design*des, unsigned w, NetExpr*rv) NetAssign::NetAssign(const string&n, Design*des, unsigned w, NetExpr*rv)
: NetAssign_(n, w) : NetAssign_(n, w)
{ {
set_rval(rv); set_rval(rv);
} }
NetAssign::NetAssign(const string&n, Design*des, unsigned w,
NetExpr*mu, NetExpr*rv)
: NetAssign_(n, w)
{
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;
}
set_rval(rv);
set_bmux(mu);
}
NetAssign::~NetAssign() NetAssign::~NetAssign()
{ {
} }
NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w, NetExpr*rv) NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w, NetExpr*rv)
: NetAssign_(n, w), bmux_(0) : NetAssign_(n, w)
{ {
if (rv->expr_width() < w) { if (rv->expr_width() < w) {
cerr << rv->get_line() << ": Expression bit width (" << cerr << rv->get_line() << ": Expression bit width (" <<
@ -434,7 +462,7 @@ NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w, NetExpr*rv)
NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w, NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w,
NetExpr*mu, NetExpr*rv) NetExpr*mu, NetExpr*rv)
: NetAssign_(n, w), bmux_(mu) : NetAssign_(n, w)
{ {
bool flag = rv->set_width(1); bool flag = rv->set_width(1);
if (flag == false) { if (flag == false) {
@ -444,11 +472,11 @@ NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w,
} }
set_rval(rv); set_rval(rv);
set_bmux(mu);
} }
NetAssignNB::~NetAssignNB() NetAssignNB::~NetAssignNB()
{ {
delete bmux_;
} }
@ -479,7 +507,7 @@ NetAssignMemNB::~NetAssignMemNB()
{ {
} }
#if 0
/* /*
* This method looks at the objects connected to me, and searches for * This method looks at the objects connected to me, and searches for
* a signal that I am fully connected to. Return that signal, and the * a signal that I am fully connected to. Return that signal, and the
@ -519,6 +547,7 @@ void NetAssign::find_lval_range(const NetNet*&net, unsigned&msb,
assert(0); // No suitable signals?? assert(0); // No suitable signals??
} }
#endif
NetBlock::~NetBlock() NetBlock::~NetBlock()
{ {
@ -1703,6 +1732,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
/* /*
* $Log: netlist.cc,v $ * $Log: netlist.cc,v $
* Revision 1.75 1999/10/07 05:25:34 steve
* Add non-const bit select in l-value of assignment.
*
* Revision 1.74 1999/10/06 05:06:16 steve * Revision 1.74 1999/10/06 05:06:16 steve
* Move the rvalue into NetAssign_ common code. * Move the rvalue into NetAssign_ common code.
* *

View File

@ -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) #if !defined(WINNT)
#ident "$Id: netlist.h,v 1.77 1999/10/06 05:06:16 steve Exp $" #ident "$Id: netlist.h,v 1.78 1999/10/07 05:25:34 steve Exp $"
#endif #endif
/* /*
@ -622,24 +622,30 @@ class NetAssign_ : public NetProc, public NetNode {
NetExpr*rval(); NetExpr*rval();
const NetExpr*rval() const; const NetExpr*rval() const;
// If this expression exists, then only a single bit is to be
// set from the rval, and the value of this expression selects
// the pin that gets the value.
const NetExpr*bmux() const;
protected: protected:
NetAssign_(const string&n, unsigned w); NetAssign_(const string&n, unsigned w);
virtual ~NetAssign_() =0; virtual ~NetAssign_() =0;
void set_rval(NetExpr*); void set_rval(NetExpr*);
void set_bmux(NetExpr*);
private: private:
NetExpr*rval_; NetExpr*rval_;
NetExpr*bmux_;
}; };
class NetAssign : public NetAssign_ { class NetAssign : public NetAssign_ {
public: public:
explicit NetAssign(const string&, Design*des, unsigned w, NetExpr*rv); explicit NetAssign(const string&, Design*des, unsigned w, NetExpr*rv);
explicit NetAssign(const string&, Design*des, unsigned w,
NetExpr*mux, NetExpr*rv);
~NetAssign(); ~NetAssign();
void find_lval_range(const NetNet*&net, unsigned&msb,
unsigned&lsb) const;
virtual bool emit_proc(ostream&, struct target_t*) const; virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void emit_node(ostream&, struct target_t*) const; virtual void emit_node(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const; virtual void dump(ostream&, unsigned ind) const;
@ -659,18 +665,12 @@ class NetAssignNB : public NetAssign_ {
~NetAssignNB(); ~NetAssignNB();
// If this expression exists, then only a single bit is to be
// set from the rval, and the value of this expression selects
// the pin that gets the value.
const NetExpr*bmux() const { return bmux_; }
virtual bool emit_proc(ostream&, struct target_t*) const; virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void emit_node(ostream&, struct target_t*) const; virtual void emit_node(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const; virtual void dump(ostream&, unsigned ind) const;
virtual void dump_node(ostream&, unsigned ind) const; virtual void dump_node(ostream&, unsigned ind) const;
private: private:
NetExpr* bmux_;
}; };
/* /*
@ -1711,6 +1711,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.78 1999/10/07 05:25:34 steve
* Add non-const bit select in l-value of assignment.
*
* Revision 1.77 1999/10/06 05:06:16 steve * Revision 1.77 1999/10/06 05:06:16 steve
* Move the rvalue into NetAssign_ common code. * Move the rvalue into NetAssign_ common code.
* *

View File

@ -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) #if !defined(WINNT)
#ident "$Id: t-vvm.cc,v 1.59 1999/10/06 01:28:18 steve Exp $" #ident "$Id: t-vvm.cc,v 1.60 1999/10/07 05:25:34 steve Exp $"
#endif #endif
# include <iostream> # include <iostream>
@ -1139,8 +1139,53 @@ void target_vvm::proc_assign(ostream&os, const NetAssign*net)
defn << " // " << net->get_line() << ": " << endl; defn << " // " << net->get_line() << ": " << endl;
/* Not only is the lvalue signal assigned to, send the bits to if (net->bmux()) {
all the other pins that are connected to this signal. */
string bval = emit_proc_rval(defn, 8, net->bmux());
defn << " switch (" << bval << ".as_unsigned()) {" << endl;
for (unsigned idx = 0 ; idx < net->pin_count() ; idx += 1) {
const NetObj*cur;
unsigned pin;
map<string,bool> written;
defn << " case " << idx << ":" << endl;
for (net->pin(idx).next_link(cur, pin)
; net->pin(idx) != cur->pin(pin)
; cur->pin(pin).next_link(cur, pin)) {
// Skip output only pins.
if (cur->pin(pin).get_dir() == NetObj::Link::OUTPUT)
continue;
// Skip signals, I'll hit them when I handle the
// NetESignal nodes.
if (dynamic_cast<const NetNet*>(cur))
continue;
// It is possible for a named device to show up
// several times in a link. This is the classic
// case with NetESignal objects, which are
// repeated for each expression that uses it.
if (written[cur->name()])
continue;
written[cur->name()] = true;
defn << " " << mangle(cur->name()) <<
".set(sim_, " << pin << ", " <<
rval << "[" << idx << "]);" << endl;
}
defn << " break;" << endl;
}
defn << " }" << endl;
} else {
/* Not only is the lvalue signal assigned to, send the
bits to all the other pins that are connected to this
signal. */
for (unsigned idx = 0 ; idx < net->pin_count() ; idx += 1) { for (unsigned idx = 0 ; idx < net->pin_count() ; idx += 1) {
const NetObj*cur; const NetObj*cur;
@ -1173,6 +1218,7 @@ void target_vvm::proc_assign(ostream&os, const NetAssign*net)
rval << "[" << idx << "]);" << endl; rval << "[" << idx << "]);" << endl;
} }
} }
}
} }
/* /*
@ -1678,6 +1724,9 @@ extern const struct target tgt_vvm = {
}; };
/* /*
* $Log: t-vvm.cc,v $ * $Log: t-vvm.cc,v $
* Revision 1.60 1999/10/07 05:25:34 steve
* Add non-const bit select in l-value of assignment.
*
* Revision 1.59 1999/10/06 01:28:18 steve * Revision 1.59 1999/10/06 01:28:18 steve
* The $finish task should work immediately. * The $finish task should work immediately.
* *