vhdlpp: Added 'packed' property for VTypes.
It detetermines if a type can be used as the base type of a packed array.
This commit is contained in:
parent
feccae56bf
commit
8e9c25a23e
|
|
@ -343,11 +343,11 @@ static void import_ieee_use(ActiveScope*res, perm_string package, perm_string na
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const VTypePrimitive primitive_BOOLEAN(VTypePrimitive::BOOLEAN);
|
const VTypePrimitive primitive_BOOLEAN(VTypePrimitive::BOOLEAN, true);
|
||||||
const VTypePrimitive primitive_BIT(VTypePrimitive::BIT);
|
const VTypePrimitive primitive_BIT(VTypePrimitive::BIT, true);
|
||||||
const VTypePrimitive primitive_INTEGER(VTypePrimitive::INTEGER);
|
const VTypePrimitive primitive_INTEGER(VTypePrimitive::INTEGER);
|
||||||
const VTypePrimitive primitive_REAL(VTypePrimitive::REAL);
|
const VTypePrimitive primitive_REAL(VTypePrimitive::REAL);
|
||||||
const VTypePrimitive primitive_STDLOGIC(VTypePrimitive::STDLOGIC);
|
const VTypePrimitive primitive_STDLOGIC(VTypePrimitive::STDLOGIC, true);
|
||||||
const VTypePrimitive primitive_CHARACTER(VTypePrimitive::CHARACTER);
|
const VTypePrimitive primitive_CHARACTER(VTypePrimitive::CHARACTER);
|
||||||
|
|
||||||
const VTypeRange primitive_NATURAL(&primitive_INTEGER, INT64_MAX, 0);
|
const VTypeRange primitive_NATURAL(&primitive_INTEGER, INT64_MAX, 0);
|
||||||
|
|
@ -383,6 +383,15 @@ bool is_global_type(perm_string name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool can_be_packed(perm_string name)
|
||||||
|
{
|
||||||
|
if (name == "boolean") return true;
|
||||||
|
if (name == "bit") return true;
|
||||||
|
if (name == "std_logic") return true;
|
||||||
|
if (name == "bit_vector") return true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void library_set_work_path(const char*path)
|
void library_set_work_path(const char*path)
|
||||||
{
|
{
|
||||||
assert(library_work_path == 0);
|
assert(library_work_path == 0);
|
||||||
|
|
|
||||||
|
|
@ -67,4 +67,7 @@ extern void generate_global_types(ActiveScope*res);
|
||||||
|
|
||||||
extern bool is_global_type(perm_string type_name);
|
extern bool is_global_type(perm_string type_name);
|
||||||
|
|
||||||
|
// Returns true if a type can be used as the base type in Verilog packed array.
|
||||||
|
extern bool can_be_packed(perm_string type_name);
|
||||||
|
|
||||||
#endif /* IVL_parse_misc_H */
|
#endif /* IVL_parse_misc_H */
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ void VType::show(ostream&out) const
|
||||||
write_to_stream(out);
|
write_to_stream(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTypePrimitive::VTypePrimitive(VTypePrimitive::type_t tt)
|
VTypePrimitive::VTypePrimitive(VTypePrimitive::type_t tt, bool packed)
|
||||||
: type_(tt)
|
: type_(tt), packed_(packed)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,9 @@ class VType {
|
||||||
// all the types that it emits.
|
// all the types that it emits.
|
||||||
virtual int emit_typedef(std::ostream&out, typedef_context_t&ctx) const;
|
virtual int emit_typedef(std::ostream&out, typedef_context_t&ctx) const;
|
||||||
|
|
||||||
|
// Determines if a type can be used in Verilog packed array.
|
||||||
|
virtual bool can_be_packed() const { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class decl_t;
|
friend class decl_t;
|
||||||
// This virtual method is called to emit the declaration. This
|
// This virtual method is called to emit the declaration. This
|
||||||
|
|
@ -128,7 +131,7 @@ class VTypePrimitive : public VType {
|
||||||
enum type_t { BOOLEAN, BIT, INTEGER, REAL, STDLOGIC, CHARACTER };
|
enum type_t { BOOLEAN, BIT, INTEGER, REAL, STDLOGIC, CHARACTER };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VTypePrimitive(type_t);
|
VTypePrimitive(type_t tt, bool packed = false);
|
||||||
~VTypePrimitive();
|
~VTypePrimitive();
|
||||||
|
|
||||||
void write_to_stream(std::ostream&fd) const;
|
void write_to_stream(std::ostream&fd) const;
|
||||||
|
|
@ -139,8 +142,11 @@ class VTypePrimitive : public VType {
|
||||||
int emit_primitive_type(std::ostream&fd) const;
|
int emit_primitive_type(std::ostream&fd) const;
|
||||||
int emit_def(std::ostream&out) const;
|
int emit_def(std::ostream&out) const;
|
||||||
|
|
||||||
|
bool can_be_packed() const { return packed_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type_t type_;
|
type_t type_;
|
||||||
|
bool packed_;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const VTypePrimitive primitive_BOOLEAN;
|
extern const VTypePrimitive primitive_BOOLEAN;
|
||||||
|
|
@ -194,6 +200,8 @@ class VTypeArray : public VType {
|
||||||
int emit_def(std::ostream&out) const;
|
int emit_def(std::ostream&out) const;
|
||||||
int emit_typedef(std::ostream&out, typedef_context_t&ctx) const;
|
int emit_typedef(std::ostream&out, typedef_context_t&ctx) const;
|
||||||
|
|
||||||
|
bool can_be_packed() const { return etype_->can_be_packed(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const VType*etype_;
|
const VType*etype_;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue