diff --git a/vhdlpp/expression_elaborate.cc b/vhdlpp/expression_elaborate.cc index 30ddd4e2f..4c64ff186 100644 --- a/vhdlpp/expression_elaborate.cc +++ b/vhdlpp/expression_elaborate.cc @@ -877,6 +877,12 @@ const VType* ExpFunc::fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*) c return new VTypeArray(element, width, 0, sign); } + if(name_ == "and_reduce" || name_ == "or_reduce") { + ivl_assert(*this, argv_.size() == 1); + const VType*element = &primitive_STDLOGIC; + return new VTypeArray(element, 0, 0, false); + } + // Other cases Subprogram*prog = def_; @@ -888,6 +894,7 @@ const VType* ExpFunc::fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*) c if(!prog) prog = library_find_subprogram(name_); + cerr << get_fileline() << ": sorry: VHDL function " << name_ << " not yet implemented" << endl; ivl_assert(*this, prog); return def_->peek_return_type(); diff --git a/vhdlpp/expression_emit.cc b/vhdlpp/expression_emit.cc index 98b0ebe5c..b0ccefc5e 100644 --- a/vhdlpp/expression_emit.cc +++ b/vhdlpp/expression_emit.cc @@ -647,6 +647,16 @@ int ExpFunc::emit(ostream&out, Entity*ent, ScopeBase*scope) errors += argv_[0]->emit(out, ent, scope); out << ")"; + } else if (name_ == "and_reduce" && argv_.size() == 1) { + out << "&("; + errors += argv_[0]->emit(out, ent, scope); + out << ")"; + + } else if (name_ == "or_reduce" && argv_.size() == 1) { + out << "|("; + errors += argv_[0]->emit(out, ent, scope); + out << ")"; + } else { // If this function has an elaborated definition, and if // that definition is in a package, then include the