Fix repeated use of disabled const functions.
If constant functions are exited by a return/disable, fix the leaked "disable" flag that causes blocks in the next try at the function to not work. There are also a lot of debug messages added to help find this and similar problems.
This commit is contained in:
parent
bcaa6accec
commit
af304fea65
14
elab_sig.cc
14
elab_sig.cc
|
|
@ -964,6 +964,10 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
|
||||||
vector<netrange_t> plist, nlist;
|
vector<netrange_t> plist, nlist;
|
||||||
/* If they exist get the port definition MSB and LSB */
|
/* If they exist get the port definition MSB and LSB */
|
||||||
if (port_set_ && !port_.empty()) {
|
if (port_set_ && !port_.empty()) {
|
||||||
|
if (debug_elaborate) {
|
||||||
|
cerr << get_fileline() << ": PWire::elaborate_sig: "
|
||||||
|
<< "Evaluate ranges for port " << basename() << endl;
|
||||||
|
}
|
||||||
bad_range |= evaluate_ranges(des, scope, plist, port_);
|
bad_range |= evaluate_ranges(des, scope, plist, port_);
|
||||||
nlist = plist;
|
nlist = plist;
|
||||||
/* An implicit port can have a range so note that here. */
|
/* An implicit port can have a range so note that here. */
|
||||||
|
|
@ -974,10 +978,20 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
|
||||||
/* If they exist get the net/etc. definition MSB and LSB */
|
/* If they exist get the net/etc. definition MSB and LSB */
|
||||||
if (net_set_ && !net_.empty() && !bad_range) {
|
if (net_set_ && !net_.empty() && !bad_range) {
|
||||||
nlist.clear();
|
nlist.clear();
|
||||||
|
if (debug_elaborate) {
|
||||||
|
cerr << get_fileline() << ": PWire::elaborate_sig: "
|
||||||
|
<< "Evaluate ranges for net " << basename() << endl;
|
||||||
|
}
|
||||||
bad_range |= evaluate_ranges(des, scope, nlist, net_);
|
bad_range |= evaluate_ranges(des, scope, nlist, net_);
|
||||||
}
|
}
|
||||||
assert(net_set_ || net_.empty());
|
assert(net_set_ || net_.empty());
|
||||||
|
|
||||||
|
if (debug_elaborate) {
|
||||||
|
cerr << get_fileline() << ": PWire::elaborate_sig: "
|
||||||
|
<< "Calculated ranges for " << basename()
|
||||||
|
<< ". Now check for consistency." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we find errors here, then give up on this signal. */
|
/* If we find errors here, then give up on this signal. */
|
||||||
if (bad_range)
|
if (bad_range)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ NetExpr* NetFuncDef::evaluate_function(const LineInfo&loc, const std::vector<Net
|
||||||
map<perm_string,LocalVar>context_map;
|
map<perm_string,LocalVar>context_map;
|
||||||
|
|
||||||
if (debug_eval_tree) {
|
if (debug_eval_tree) {
|
||||||
cerr << loc.get_fileline() << ": debug: "
|
cerr << loc.get_fileline() << ": NetFuncDef::evaluate_function: "
|
||||||
<< "Evaluate function " << scope_->basename() << endl;
|
<< "Evaluate function " << scope_->basename() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ NetExpr* NetFuncDef::evaluate_function(const LineInfo&loc, const std::vector<Net
|
||||||
input_var.value = fix_assign_value(ports_[idx], args[idx]);
|
input_var.value = fix_assign_value(ports_[idx], args[idx]);
|
||||||
|
|
||||||
if (debug_eval_tree) {
|
if (debug_eval_tree) {
|
||||||
cerr << loc.get_fileline() << ": debug: "
|
cerr << loc.get_fileline() << ": NetFuncDef::evaluate_function: "
|
||||||
<< " input " << aname << " = " << *args[idx] << endl;
|
<< " input " << aname << " = " << *args[idx] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -123,9 +123,32 @@ NetExpr* NetFuncDef::evaluate_function(const LineInfo&loc, const std::vector<Net
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (disable) {
|
||||||
|
if (debug_eval_tree)
|
||||||
|
cerr << loc.get_fileline() << ": NetFuncDef::evaluate_function: "
|
||||||
|
<< "disable of " << scope_path(disable)
|
||||||
|
<< " trapped in function " << scope_path(scope_)
|
||||||
|
<< "." << endl;
|
||||||
|
ivl_assert(loc, disable==scope_);
|
||||||
|
disable = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Done.
|
// Done.
|
||||||
if (flag)
|
if (flag) {
|
||||||
|
if (debug_eval_tree) {
|
||||||
|
cerr << loc.get_fileline() << ": NetFuncDef::evaluate_function: "
|
||||||
|
<< "Evalutated to ";
|
||||||
|
if (res) cerr << *res;
|
||||||
|
else cerr << "<nil>";
|
||||||
|
cerr << endl;
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug_eval_tree) {
|
||||||
|
cerr << loc.get_fileline() << ": NetFuncDef::evaluate_function: "
|
||||||
|
<< "Evaluation failed." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
delete res;
|
delete res;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -256,9 +279,8 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc,
|
||||||
delete old_lval;
|
delete old_lval;
|
||||||
|
|
||||||
if (debug_eval_tree) {
|
if (debug_eval_tree) {
|
||||||
cerr << get_fileline() << ": debug: "
|
cerr << get_fileline() << ": NetAssign::evaluate_function: "
|
||||||
<< "NetAssign::evaluate_function: " << lval->name()
|
<< lval->name() << " = " << *rval_result << endl;
|
||||||
<< " = " << *rval_result << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr->second.nwords > 0)
|
if (ptr->second.nwords > 0)
|
||||||
|
|
@ -326,6 +348,11 @@ bool NetBlock::evaluate_function(const LineInfo&loc,
|
||||||
|
|
||||||
if (disable == subscope_) disable = 0;
|
if (disable == subscope_) disable = 0;
|
||||||
|
|
||||||
|
if (debug_eval_tree) {
|
||||||
|
cerr << get_fileline() << ": NetBlock::evaluate_function: "
|
||||||
|
<< "flag=" << (flag?"true":"false") << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -448,8 +475,13 @@ bool NetCondit::evaluate_function(const LineInfo&loc,
|
||||||
map<perm_string,LocalVar>&context_map) const
|
map<perm_string,LocalVar>&context_map) const
|
||||||
{
|
{
|
||||||
NetExpr*cond = expr_->evaluate_function(loc, context_map);
|
NetExpr*cond = expr_->evaluate_function(loc, context_map);
|
||||||
if (cond == 0)
|
if (cond == 0) {
|
||||||
|
if (debug_eval_tree) {
|
||||||
|
cerr << get_fileline() << ": NetCondit::evaluate_function: "
|
||||||
|
<< "Unable to evaluate condition (" << *expr_ <<")" << endl;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
|
NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
|
||||||
ivl_assert(loc, cond_const);
|
ivl_assert(loc, cond_const);
|
||||||
|
|
@ -457,18 +489,32 @@ bool NetCondit::evaluate_function(const LineInfo&loc,
|
||||||
long val = cond_const->value().as_long();
|
long val = cond_const->value().as_long();
|
||||||
delete cond;
|
delete cond;
|
||||||
|
|
||||||
|
bool flag;
|
||||||
|
|
||||||
if (val)
|
if (val)
|
||||||
// The condition is true, so evaluate the if clause
|
// The condition is true, so evaluate the if clause
|
||||||
return (if_ == 0) || if_->evaluate_function(loc, context_map);
|
flag = (if_ == 0) || if_->evaluate_function(loc, context_map);
|
||||||
else
|
else
|
||||||
// The condition is false, so evaluate the else clause
|
// The condition is false, so evaluate the else clause
|
||||||
return (else_ == 0) || else_->evaluate_function(loc, context_map);
|
flag = (else_ == 0) || else_->evaluate_function(loc, context_map);
|
||||||
|
|
||||||
|
if (debug_eval_tree) {
|
||||||
|
cerr << get_fileline() << ": NetCondit::evaluate_function: "
|
||||||
|
<< "Finished, flag=" << (flag?"true":"false") << endl;
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetDisable::evaluate_function(const LineInfo&,
|
bool NetDisable::evaluate_function(const LineInfo&,
|
||||||
map<perm_string,LocalVar>&) const
|
map<perm_string,LocalVar>&) const
|
||||||
{
|
{
|
||||||
disable = target_;
|
disable = target_;
|
||||||
|
|
||||||
|
if (debug_eval_tree) {
|
||||||
|
cerr << get_fileline() << ": NetDisable::evaluate_function: "
|
||||||
|
<< "disable " << scope_path(disable) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -541,7 +587,7 @@ bool NetWhile::evaluate_function(const LineInfo&loc,
|
||||||
bool flag = true;
|
bool flag = true;
|
||||||
|
|
||||||
if (debug_eval_tree) {
|
if (debug_eval_tree) {
|
||||||
cerr << get_fileline() << ": debug: NetWhile::evaluate_function: "
|
cerr << get_fileline() << ": NetWhile::evaluate_function: "
|
||||||
<< "Start loop" << endl;
|
<< "Start loop" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -572,8 +618,8 @@ bool NetWhile::evaluate_function(const LineInfo&loc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug_eval_tree) {
|
if (debug_eval_tree) {
|
||||||
cerr << get_fileline() << ": debug: NetWhile::evaluate_function: "
|
cerr << get_fileline() << ": NetWhile::evaluate_function: "
|
||||||
<< "Done loop" << endl;
|
<< "Done loop, flag=" << (flag?"true":"false") << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return flag;
|
return flag;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue