vhdlpp: Support for 'left & 'right attributes.

This commit is contained in:
Maciej Suminski 2014-10-08 10:05:04 +02:00
parent fddb3ec129
commit 1333bc54a2
2 changed files with 8 additions and 4 deletions

View File

@ -567,7 +567,7 @@ const VType* ExpAttribute::probe_type(Entity*ent, Architecture*arc) const
{
base_->probe_type(ent, arc);
if (name_ == "length") {
if (name_ == "length" || name_ == "left" || name_ == "right") {
return &primitive_INTEGER;
}

View File

@ -313,8 +313,8 @@ int ExpAttribute::emit(ostream&out, Entity*ent, Architecture*arc)
return errors;
}
/* Special Case: The length attribute can be calculated all
the down to a literal integer at compile time, and all it
/* Special Case: The length,left & right attributes can be calculated
all the down to a literal integer at compile time, and all it
needs is the type of the base expression. (The base
expression doesn't even need to be evaluated.) */
if (name_=="length") {
@ -322,9 +322,13 @@ int ExpAttribute::emit(ostream&out, Entity*ent, Architecture*arc)
errors += base_->emit(out, ent, arc);
out << ")";
return errors;
} else if (name_=="left" || name_=="right") {
out << "$" << name_ << "(";
errors += base_->emit(out, ent, arc);
out << ")";
return errors;
}
out << "$ivl_attribute(";
errors += base_->emit(out, ent, arc);
out << ", \"" << name_ << "\")";