diff --git a/elab_scope.cc b/elab_scope.cc index a16e1173f..d3977c25e 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -177,8 +177,10 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope, rc_flag = eval_as_long(lsb, lsb_ex); assert(rc_flag); - netenum_t*use_enum = new netenum_t(enum_type->base_type, enum_type->signed_flag, - msb, lsb, enum_type->names->size()); + netenum_t*use_enum = new netenum_t(enum_type->base_type, + enum_type->signed_flag, + enum_type->integer_flag, msb, lsb, + enum_type->names->size()); use_enum->set_line(enum_type->li); if (scope) diff --git a/netenum.cc b/netenum.cc index 1b8f4441b..4294e323b 100644 --- a/netenum.cc +++ b/netenum.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2010-2014 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -24,9 +24,9 @@ using namespace std; netenum_t::netenum_t(ivl_variable_type_t btype, bool signed_flag, - long msb, long lsb, size_t name_count) -: base_type_(btype), signed_flag_(signed_flag), msb_(msb), lsb_(lsb), - names_(name_count), bits_(name_count) + bool integer_flag, long msb, long lsb, size_t name_count) +: base_type_(btype), signed_flag_(signed_flag), integer_flag_(integer_flag), + msb_(msb), lsb_(lsb), names_(name_count), bits_(name_count) { } @@ -39,6 +39,11 @@ bool netenum_t::get_signed() const return signed_flag_; } +bool netenum_t::get_isint() const +{ + return integer_flag_; +} + /* * Enumerations are by definition always packed. */ diff --git a/netenum.h b/netenum.h index 8b43086cf..64c2aac6a 100644 --- a/netenum.h +++ b/netenum.h @@ -33,7 +33,8 @@ class netenum_t : public LineInfo, public ivl_type_s { public: explicit netenum_t(ivl_variable_type_t base_type, bool signed_flag, - long msb, long lsb, size_t name_count); + bool isint_flag, long msb, long lsb, + size_t name_count); ~netenum_t(); virtual ivl_variable_type_t base_type() const; @@ -41,6 +42,7 @@ class netenum_t : public LineInfo, public ivl_type_s { virtual long packed_width() const; std::vector slice_dimensions() const; bool get_signed() const; + bool get_isint() const; // The size() is the number of enumeration literals. size_t size() const; @@ -68,6 +70,7 @@ class netenum_t : public LineInfo, public ivl_type_s { private: ivl_variable_type_t base_type_; bool signed_flag_; + bool integer_flag_; long msb_, lsb_; std::map names_map_; diff --git a/parse.y b/parse.y index 89b27e0c5..319067817 100644 --- a/parse.y +++ b/parse.y @@ -2296,6 +2296,7 @@ enum_data_type enum_type->names .reset($3); enum_type->base_type = IVL_VT_BOOL; enum_type->signed_flag = true; + enum_type->integer_flag = false; enum_type->range.reset(make_range_from_width(32)); $$ = enum_type; } @@ -2305,6 +2306,7 @@ enum_data_type enum_type->names .reset($5); enum_type->base_type = IVL_VT_BOOL; enum_type->signed_flag = $3; + enum_type->integer_flag = false; enum_type->range.reset(make_range_from_width($2)); $$ = enum_type; } @@ -2314,6 +2316,7 @@ enum_data_type enum_type->names .reset($5); enum_type->base_type = IVL_VT_LOGIC; enum_type->signed_flag = $3; + enum_type->integer_flag = true; enum_type->range.reset(make_range_from_width(integer_width)); $$ = enum_type; } @@ -2323,6 +2326,7 @@ enum_data_type enum_type->names .reset($6); enum_type->base_type = IVL_VT_LOGIC; enum_type->signed_flag = $3; + enum_type->integer_flag = false; enum_type->range.reset($4); $$ = enum_type; } @@ -2332,6 +2336,7 @@ enum_data_type enum_type->names .reset($6); enum_type->base_type = IVL_VT_LOGIC; enum_type->signed_flag = $3; + enum_type->integer_flag = false; enum_type->range.reset($4); $$ = enum_type; } @@ -2341,6 +2346,7 @@ enum_data_type enum_type->names .reset($6); enum_type->base_type = IVL_VT_BOOL; enum_type->signed_flag = $3; + enum_type->integer_flag = false; enum_type->range.reset($4); $$ = enum_type; } diff --git a/pform.cc b/pform.cc index 30a1f4ed6..56dcd0349 100644 --- a/pform.cc +++ b/pform.cc @@ -3170,6 +3170,11 @@ static void pform_set_enum(const struct vlltype&li, enum_type_t*enum_type, assert(enum_type->range->size() == 1); //XXXXcur->set_range(*enum_type->range, SR_NET); cur->set_data_type(enum_type); + // If this is an integer enumeration switch the wire to an integer. + if (enum_type->integer_flag) { + bool res = cur->set_wire_type(NetNet::INTEGER); + assert(res); + } pform_bind_attributes(cur->attributes, attr, true); } diff --git a/pform_types.h b/pform_types.h index b36bb01e1..df3e1a00b 100644 --- a/pform_types.h +++ b/pform_types.h @@ -154,6 +154,7 @@ struct enum_type_t : public data_type_t { ivl_variable_type_t base_type; bool signed_flag; + bool integer_flag; // True if "integer" was used std::auto_ptr< list > range; std::auto_ptr< list > names; LineInfo li; diff --git a/t-dll-api.cc b/t-dll-api.cc index 31389cba5..5a77f26eb 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -2433,6 +2433,8 @@ extern "C" int ivl_signal_integer(ivl_signal_t net) { if (const netvector_t*vec = dynamic_cast (net->net_type)) return vec->get_isint()? 1 : 0; + else if (const netenum_t*enm = dynamic_cast (net->net_type)) + return enm->get_isint()? 1 : 0; else return 0; }