From a992f3ce7c6d83805bff69eaa74f111e22ecf4e3 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 10 Oct 2014 18:35:17 +0200 Subject: [PATCH] vhdlpp: Evaluation for 'left and 'right attributes. --- vhdlpp/expression_evaluate.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/vhdlpp/expression_evaluate.cc b/vhdlpp/expression_evaluate.cc index 56b631006..0bdb8bded 100644 --- a/vhdlpp/expression_evaluate.cc +++ b/vhdlpp/expression_evaluate.cc @@ -110,8 +110,32 @@ bool ExpAttribute::evaluate(ScopeBase*, int64_t&val) const return false; } -bool ExpAttribute::evaluate(Entity*, Architecture*arc, int64_t&val) const +bool ExpAttribute::evaluate(Entity*ent, Architecture*arc, int64_t&val) const { + if (name_ == "left" || name_ == "right") { + const VType*base_type = base_->peek_type(); + if (base_type == 0) + base_type = base_->probe_type(ent,arc); + + ivl_assert(*this, base_type); + + const VTypeArray*arr = dynamic_cast(base_type); + if (arr == 0) { + cerr << get_fileline() << ": error: " + << "Cannot apply the 'left attribute to non-array objects" + << endl; + return false; + } + + ivl_assert(*this, arr->dimensions() == 1); + if(name_ == "left") + arr->dimension(0).msb()->evaluate(ent, arc, val); + else + arr->dimension(0).lsb()->evaluate(ent, arc, val); + + return true; + } + return evaluate(arc, val); }