From 51b9191021190ccd205f4669b2881527b0faf5ef Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 22 Jan 2015 11:17:33 +0100 Subject: [PATCH] vhdlpp: Added VType::is_unbounded() method. --- vhdlpp/vtype.cc | 11 +++++++++++ vhdlpp/vtype.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/vhdlpp/vtype.cc b/vhdlpp/vtype.cc index a7f9233aa..652c9047e 100644 --- a/vhdlpp/vtype.cc +++ b/vhdlpp/vtype.cc @@ -148,6 +148,17 @@ void VTypeArray::show(ostream&out) const out << ""; } +bool VTypeArray::is_unbounded() const { + for(std::vector::const_iterator it = ranges_.begin(); + it != ranges_.end(); ++it) + { + if(it->is_box()) + return true; + } + + return etype_->is_unbounded(); +} + VTypeRange::VTypeRange(const VType*base, int64_t max_val, int64_t min_val) : base_(base) { diff --git a/vhdlpp/vtype.h b/vhdlpp/vtype.h index 0412acd66..9f761536a 100644 --- a/vhdlpp/vtype.h +++ b/vhdlpp/vtype.h @@ -85,6 +85,9 @@ class VType { // Determines if a type can be used in Verilog packed array. virtual bool can_be_packed() const { return false; } + // Returns true if the type has an undefined dimension. + virtual bool is_unbounded() const { return false; } + private: friend struct decl_t; // This virtual method is called to emit the declaration. This @@ -218,6 +221,8 @@ class VTypeArray : public VType { bool can_be_packed() const { return etype_->can_be_packed(); } + bool is_unbounded() const; + private: int emit_with_dims_(std::ostream&out, bool packed, perm_string name) const; @@ -320,6 +325,8 @@ class VTypeDef : public VType { int emit_def(std::ostream&out, perm_string name) const; bool can_be_packed() const { return type_->can_be_packed(); } + + bool is_unbounded() const { return type_->is_unbounded(); } private: int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const;