diff --git a/vhdlpp/vtype.cc b/vhdlpp/vtype.cc index 17001977f..ee43570e7 100644 --- a/vhdlpp/vtype.cc +++ b/vhdlpp/vtype.cc @@ -273,11 +273,9 @@ void VTypeArray::evaluate_ranges(ScopeBase*scope) { } } -VTypeRange::VTypeRange(const VType*base, int64_t max_val, int64_t min_val) -: base_(base) +VTypeRange::VTypeRange(const VType*base, int64_t end_val, int64_t start_val) +: base_(base), end_(end_val), start_(start_val) { - max_ = max_val; - min_ = min_val; } VTypeRange::~VTypeRange() diff --git a/vhdlpp/vtype.h b/vhdlpp/vtype.h index 5b00bc885..62b528240 100644 --- a/vhdlpp/vtype.h +++ b/vhdlpp/vtype.h @@ -275,10 +275,10 @@ class VTypeArray : public VType { class VTypeRange : public VType { public: - VTypeRange(const VType*base, int64_t max_val, int64_t min_val); + VTypeRange(const VType*base, int64_t end, int64_t start); ~VTypeRange(); - VType*clone() const { return new VTypeRange(base_->clone(), max_, min_); } + VType*clone() const { return new VTypeRange(base_->clone(), start_, end_); } // Get the type that is limited by the range. inline const VType* base_type() const { return base_; } @@ -289,7 +289,7 @@ class VTypeRange : public VType { private: const VType*base_; - int64_t max_, min_; + int64_t end_, start_; }; class VTypeEnum : public VType { diff --git a/vhdlpp/vtype_stream.cc b/vhdlpp/vtype_stream.cc index f625f190a..0ded586de 100644 --- a/vhdlpp/vtype_stream.cc +++ b/vhdlpp/vtype_stream.cc @@ -171,14 +171,16 @@ void VTypeRange::write_to_stream(ostream&fd) const // Detect some special cases that can be written as ieee or // standard types. if (const VTypePrimitive*tmp = dynamic_cast (base_)) { - if (min_==0 && max_==INT64_MAX && tmp->type()==VTypePrimitive::INTEGER) { + if (start_==0 && end_==INT64_MAX && tmp->type()==VTypePrimitive::INTEGER) { fd << "natural"; return; } } base_->write_to_stream(fd); - fd << " range " << min_ << " to " << max_; + fd << " range " << start_; + fd << (start_ < end_ ? " to " : " downto "); + fd << end_; } void VTypeRecord::write_to_stream(ostream&fd) const