V0.9: Always process specparams since they can be used outside a specify block.

The -gno-specify flag should only control the delay and timing checks.
It should not also remove the specparams since they can be used outside
of a specify block.
This commit is contained in:
Cary R 2011-06-01 18:28:37 -07:00 committed by Stephen Williams
parent 9ac9f36e3c
commit a59b778d75
2 changed files with 61 additions and 65 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -2181,34 +2181,30 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
// A specparam? Look up the name to see if it is a
// specparam. If we find it, then turn it into a NetEConst
// value and return that. Of course, this does not apply if
// specify blocks are disabled.
if (gn_specify_blocks_flag) {
map<perm_string,NetScope::spec_val_t>::const_iterator specp;
perm_string key = peek_tail_name(path_);
if (path_.size() == 1
&& ((specp = scope->specparams.find(key)) != scope->specparams.end())) {
NetScope::spec_val_t value = (*specp).second;
NetExpr*tmp = 0;
switch (value.type) {
case IVL_VT_BOOL:
tmp = new NetEConst(verinum(value.integer));
break;
case IVL_VT_REAL:
tmp = new NetECReal(verireal(value.real_val));
break;
default:
break;
}
assert(tmp);
tmp->set_line(*this);
if (debug_elaborate)
cerr << get_fileline() << ": debug: " << path_
<< " is a specparam" << endl;
return tmp;
// value and return that.
map<perm_string,NetScope::spec_val_t>::const_iterator specp;
perm_string key = peek_tail_name(path_);
if (path_.size() == 1 &&
((specp = scope->specparams.find(key)) != scope->specparams.end())) {
NetScope::spec_val_t value = (*specp).second;
NetExpr*tmp = 0;
switch (value.type) {
case IVL_VT_BOOL:
tmp = new NetEConst(verinum(value.integer));
break;
case IVL_VT_REAL:
tmp = new NetECReal(verireal(value.real_val));
break;
default:
break;
}
assert(tmp);
tmp->set_line(*this);
if (debug_elaborate)
cerr << get_fileline() << ": debug: " << path_
<< " is a specparam" << endl;
return tmp;
}
if (error_implicit==false

View File

@ -4146,50 +4146,50 @@ bool Module::elaborate(Design*des, NetScope*scope) const
bool result_flag = true;
error_implicit = true;
if (gn_specify_blocks_flag) {
// Elaborate specparams
typedef map<perm_string,PExpr*>::const_iterator specparam_it_t;
for (specparam_it_t cur = specparams.begin()
; cur != specparams.end() ; cur ++ ) {
// Elaborate specparams
typedef map<perm_string,PExpr*>::const_iterator specparam_it_t;
for (specparam_it_t cur = specparams.begin() ;
cur != specparams.end() ; cur ++ ) {
probe_expr_width(des, scope, (*cur).second);
need_constant_expr = true;
NetExpr*val = elab_and_eval(des, scope, (*cur).second, -1);
need_constant_expr = false;
NetScope::spec_val_t value;
probe_expr_width(des, scope, (*cur).second);
need_constant_expr = true;
NetExpr*val = elab_and_eval(des, scope, (*cur).second, -1);
need_constant_expr = false;
NetScope::spec_val_t value;
if (NetECReal*val_cr = dynamic_cast<NetECReal*> (val)) {
if (NetECReal*val_cr = dynamic_cast<NetECReal*> (val)) {
value.type = IVL_VT_REAL;
value.real_val = val_cr->value().as_double();
value.type = IVL_VT_REAL;
value.real_val = val_cr->value().as_double();
if (debug_elaborate)
cerr << get_fileline() << ": debug: Elaborate "
<< "specparam " << (*cur).first
<< " value=" << value.real_val << endl;
} else if (NetEConst*val_c = dynamic_cast<NetEConst*> (val)) {
value.type = IVL_VT_BOOL;
value.integer = val_c->value().as_long();
if (debug_elaborate)
cerr << get_fileline() << ": debug: Elaborate "
<< "specparam " << (*cur).first
<< " value=" << value.integer << endl;
} else {
value.type = IVL_VT_NO_TYPE;
cerr << (*cur).second->get_fileline() << ": error: "
<< "specparam " << (*cur).first << " value"
<< " is not constant: " << *val << endl;
des->errors += 1;
if (debug_elaborate) {
cerr << get_fileline() << ": debug: Elaborate "
<< "specparam " << (*cur).first
<< " value=" << value.real_val << endl;
}
assert(val);
delete val;
scope->specparams[(*cur).first] = value;
} else if (NetEConst*val_c = dynamic_cast<NetEConst*> (val)) {
value.type = IVL_VT_BOOL;
value.integer = val_c->value().as_long();
if (debug_elaborate) {
cerr << get_fileline() << ": debug: Elaborate "
<< "specparam " << (*cur).first
<< " value=" << value.integer << endl;
}
} else {
value.type = IVL_VT_NO_TYPE;
cerr << (*cur).second->get_fileline() << ": error: "
<< "specparam " << (*cur).first << " value"
<< " is not constant: " << *val << endl;
des->errors += 1;
}
assert(val);
delete val;
scope->specparams[(*cur).first] = value;
}
// Elaborate within the generate blocks.