Fix type handling of real-value system functions in nets

In nets, if system functions return a real value the function lookup
was getting the correct width, but was also setting the width to 0,
which confused down-stream net handling. Real-value system fuctions
have a width of 1. (1 real-valued scalar.)
This commit is contained in:
Stephen Williams 2008-01-08 18:54:55 -08:00
parent 36bbf6ef5a
commit 1f7957c612
5 changed files with 22 additions and 5 deletions

View File

@ -512,7 +512,8 @@ void NetUReduce::dump_node(ostream&o, unsigned ind) const
void NetSysFunc::dump_node(ostream&o, unsigned ind) const void NetSysFunc::dump_node(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << def_->name << "(...)" << endl; o << setw(ind) << "" << def_->name << "(...) -->"
<< data_type() << " width=" << vector_width() << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
dump_obj_attr(o, ind+4); dump_obj_attr(o, ind+4);
} }

View File

@ -1365,6 +1365,11 @@ NetNet* PECallFunction::elaborate_net_sfunc_(Design*des, NetScope*scope,
return 0; return 0;
} }
if (debug_elaborate) {
cerr << get_fileline() << ": debug: Net system function "
<< name << " returns " << def->type << endl;
}
NetSysFunc*net = new NetSysFunc(scope, scope->local_symbol(), NetSysFunc*net = new NetSysFunc(scope, scope->local_symbol(),
def, 1+parms_.count()); def, 1+parms_.count());
des->add_node(net); des->add_node(net);
@ -1373,6 +1378,7 @@ NetNet* PECallFunction::elaborate_net_sfunc_(Design*des, NetScope*scope,
NetNet*osig = new NetNet(scope, scope->local_symbol(), NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, def->wid); NetNet::WIRE, def->wid);
osig->local_flag(true); osig->local_flag(true);
osig->set_signed(def->type==IVL_VT_REAL? true : false);
osig->data_type(def->type); osig->data_type(def->type);
osig->set_line(*this); osig->set_line(*this);
@ -2170,7 +2176,9 @@ NetNet* PEFNumber::elaborate_net(Design*des, NetScope*scope,
NetNet*net = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, 1); NetNet*net = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, 1);
net->data_type(IVL_VT_REAL); net->data_type(IVL_VT_REAL);
net->set_signed(true);
net->local_flag(true); net->local_flag(true);
net->set_line(*this);
connect(net->pin(0), obj->pin(0)); connect(net->pin(0), obj->pin(0));
return net; return net;
@ -3158,7 +3166,9 @@ NetNet* PEUnary::elab_net_uminus_const_real_(Design*des, NetScope*scope,
NetNet*sig = new NetNet(scope, scope->local_symbol(), NetNet*sig = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, width); NetNet::WIRE, width);
sig->data_type(IVL_VT_REAL); sig->data_type(IVL_VT_REAL);
sig->set_signed(true);
sig->local_flag(true); sig->local_flag(true);
sig->set_line(*this);
NetLiteral*con = new NetLiteral(scope, scope->local_symbol(), -val); NetLiteral*con = new NetLiteral(scope, scope->local_symbol(), -val);

View File

@ -138,6 +138,11 @@ const char*NetSysFunc::func_name() const
return def_->name; return def_->name;
} }
ivl_variable_type_t NetSysFunc::data_type() const
{
return def_->type;
}
unsigned NetSysFunc::vector_width() const unsigned NetSysFunc::vector_width() const
{ {
return def_->wid; return def_->wid;

View File

@ -1047,6 +1047,7 @@ class NetSysFunc : public NetNode {
unsigned ports); unsigned ports);
~NetSysFunc(); ~NetSysFunc();
ivl_variable_type_t data_type() const;
unsigned vector_width() const; unsigned vector_width() const;
const char* func_name() const; const char* func_name() const;

View File

@ -33,9 +33,9 @@
*/ */
static const struct sfunc_return_type sfunc_table[] = { static const struct sfunc_return_type sfunc_table[] = {
{ "$realtime", IVL_VT_REAL, 0, 0 }, { "$realtime", IVL_VT_REAL, 1, 0 },
{ "$bitstoreal", IVL_VT_REAL, 0, 0 }, { "$bitstoreal", IVL_VT_REAL, 1, 0 },
{ "$itor", IVL_VT_REAL, 0, 0 }, { "$itor", IVL_VT_REAL, 1, 0 },
{ "$realtobits", IVL_VT_LOGIC, 64, 0 }, { "$realtobits", IVL_VT_LOGIC, 64, 0 },
{ "$time", IVL_VT_LOGIC, 64, 0 }, { "$time", IVL_VT_LOGIC, 64, 0 },
{ "$stime", IVL_VT_LOGIC, 32, 0 }, { "$stime", IVL_VT_LOGIC, 32, 0 },
@ -127,7 +127,7 @@ int load_sys_func_table(const char*path)
cell = new struct sfunc_return_type_cell; cell = new struct sfunc_return_type_cell;
cell->name = lex_strings.add(name); cell->name = lex_strings.add(name);
cell->type = IVL_VT_REAL; cell->type = IVL_VT_REAL;
cell->wid = 0; cell->wid = 1;
cell->signed_flag = true; cell->signed_flag = true;
cell->next = sfunc_stack; cell->next = sfunc_stack;
sfunc_stack = cell; sfunc_stack = cell;