Restrict enum compatibility to the same scope
An enum data type declared in a module is not compatible between different
instances of the module. The type is unique in each hierarchical instance
scope. The type can for example depend on module parameters which would
result in conflicting definitions. This is defined in section 6.22 ("Type
compatibility") of the LRM (1800-2017).
At the moment enum compatibility is checked by comparing the enum_type_t.
But the enum_type_t is shared among the netenum_t that are created for each
module instance and gives the wrong result.
Since there is exactly one netenum_t created for each enum and each
instantiated scope use this to check if the data type of two enum type
signals is compatible.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
59b3e220ad
commit
fabff5ef5f
|
|
@ -186,8 +186,7 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
|
|||
netenum_t*use_enum = new netenum_t(enum_type->base_type,
|
||||
enum_type->signed_flag,
|
||||
enum_type->integer_flag, range,
|
||||
enum_type->names->size(),
|
||||
enum_type);
|
||||
enum_type->names->size());
|
||||
|
||||
use_enum->set_line(*enum_type);
|
||||
scope->add_enumeration_set(enum_type, use_enum);
|
||||
|
|
|
|||
10
netenum.cc
10
netenum.cc
|
|
@ -24,11 +24,9 @@
|
|||
using namespace std;
|
||||
|
||||
netenum_t::netenum_t(ivl_variable_type_t btype, bool signed_flag,
|
||||
bool integer_flag, const netrange_t &range, size_t name_count,
|
||||
enum_type_t*enum_type)
|
||||
: base_type_(btype), enum_type_(enum_type), signed_flag_(signed_flag),
|
||||
integer_flag_(integer_flag), range_(range),
|
||||
names_(name_count), bits_(name_count)
|
||||
bool integer_flag, const netrange_t &range, size_t name_count)
|
||||
: base_type_(btype), signed_flag_(signed_flag), integer_flag_(integer_flag),
|
||||
range_(range), names_(name_count), bits_(name_count)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -159,5 +157,5 @@ perm_string netenum_t::bits_at(size_t idx) const
|
|||
|
||||
bool netenum_t::matches(const netenum_t*other) const
|
||||
{
|
||||
return enum_type_ == other->enum_type_;
|
||||
return this == other;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,14 +29,12 @@
|
|||
|
||||
class NetScope;
|
||||
|
||||
struct enum_type_t;
|
||||
|
||||
class netenum_t : public LineInfo, public ivl_type_s {
|
||||
|
||||
public:
|
||||
explicit netenum_t(ivl_variable_type_t base_type, bool signed_flag,
|
||||
bool isint_flag, const netrange_t &range,
|
||||
size_t name_count, enum_type_t*enum_type);
|
||||
size_t name_count);
|
||||
~netenum_t();
|
||||
|
||||
virtual ivl_variable_type_t base_type() const;
|
||||
|
|
@ -74,7 +72,6 @@ class netenum_t : public LineInfo, public ivl_type_s {
|
|||
|
||||
private:
|
||||
ivl_variable_type_t base_type_;
|
||||
enum_type_t*enum_type_;
|
||||
bool signed_flag_;
|
||||
bool integer_flag_;
|
||||
netrange_t range_;
|
||||
|
|
|
|||
Loading…
Reference in New Issue