diff --git a/vhdlpp/expression_elaborate.cc b/vhdlpp/expression_elaborate.cc index 917a6c28a..dcea7f470 100644 --- a/vhdlpp/expression_elaborate.cc +++ b/vhdlpp/expression_elaborate.cc @@ -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; } diff --git a/vhdlpp/expression_emit.cc b/vhdlpp/expression_emit.cc index 78f299b3a..a84122c02 100644 --- a/vhdlpp/expression_emit.cc +++ b/vhdlpp/expression_emit.cc @@ -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_ << "\")";