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:
parent
a45fa00479
commit
3362fbc0db
90
elab_expr.cc
90
elab_expr.cc
|
|
@ -1872,30 +1872,26 @@ unsigned PEIdent::test_width(Design*des, NetScope*scope, width_mode_t&mode)
|
|||
// (as evaluated earlier). Note that specparams aren't fully
|
||||
// supported yet, so this code is likely to need rework when
|
||||
// they are.
|
||||
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;
|
||||
if (value.type == IVL_VT_REAL) {
|
||||
expr_type_ = IVL_VT_REAL;
|
||||
expr_width_ = 1;
|
||||
min_width_ = 1;
|
||||
signed_flag_ = true;
|
||||
} else {
|
||||
verinum val (value.integer);
|
||||
expr_type_ = IVL_VT_BOOL;
|
||||
expr_width_ = val.len();
|
||||
min_width_ = expr_width_;
|
||||
signed_flag_ = true;
|
||||
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;
|
||||
if (value.type == IVL_VT_REAL) {
|
||||
expr_type_ = IVL_VT_REAL;
|
||||
expr_width_ = 1;
|
||||
min_width_ = 1;
|
||||
signed_flag_ = true;
|
||||
} else {
|
||||
verinum val (value.integer);
|
||||
expr_type_ = IVL_VT_BOOL;
|
||||
expr_width_ = val.len();
|
||||
min_width_ = expr_width_;
|
||||
signed_flag_ = true;
|
||||
|
||||
if (mode < LOSSLESS)
|
||||
mode = LOSSLESS;
|
||||
|
||||
}
|
||||
return expr_width_;
|
||||
if (mode < LOSSLESS) mode = LOSSLESS;
|
||||
}
|
||||
return expr_width_;
|
||||
}
|
||||
|
||||
// Not a net, and not a parameter? Give up on the type, but
|
||||
|
|
@ -2042,34 +2038,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;
|
||||
}
|
||||
|
||||
// Maybe this is a method attached to an enumeration name? If
|
||||
|
|
|
|||
67
elaborate.cc
67
elaborate.cc
|
|
@ -4278,48 +4278,47 @@ bool Module::elaborate(Design*des, NetScope*scope) const
|
|||
{
|
||||
bool result_flag = 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 ) {
|
||||
typedef map<perm_string,PExpr*>::const_iterator specparam_it_t;
|
||||
for (specparam_it_t cur = specparams.begin() ;
|
||||
cur != specparams.end() ; ++ cur ) {
|
||||
|
||||
NetExpr*val = elab_and_eval(des, scope, (*cur).second, -1,
|
||||
true);
|
||||
NetScope::spec_val_t value;
|
||||
NetExpr*val = elab_and_eval(des, scope, (*cur).second, -1, true);
|
||||
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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue