vhdlpp: 'image attribute.

This commit is contained in:
Maciej Suminski 2016-01-05 13:54:05 +01:00
parent dff1ad08b0
commit b711f16f05
2 changed files with 27 additions and 0 deletions

View File

@ -605,6 +605,9 @@ int ExpTypeAttribute::elaborate_expr(Entity*, ScopeBase*, const VType*)
const VType* ExpTypeAttribute::probe_type(Entity*, ScopeBase*) const
{
if(name_ == "image")
return &primitive_STRING;
return NULL;
}

View File

@ -376,6 +376,30 @@ int ExpTypeAttribute::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
// Special case: The image attribute
if (name_=="image") {
if(!args_ || args_->size() != 1) {
out << "/* Invalid 'image attribute */" << endl;
cerr << get_fileline() << ": error: 'image attribute takes "
<< "exactly one argument." << endl;
++errors;
} else {
out << "$sformatf(\"";
if(base_->type_match(&primitive_INTEGER))
out << "%0d";
else if(base_->type_match(&primitive_REAL))
out << "%f";
else if(base_->type_match(&primitive_CHARACTER))
out << "'%c'";
out << "\",";
args_->front()->emit(out, ent, scope);
out << ")";
}
return errors;
}
// Fallback
out << "$ivl_attribute(";
errors += base_->emit_def(out, empty_perm_string);