Pass the integer type for enumerations to the IVL target stage
This commit is contained in:
parent
4f62a0d1f2
commit
c25538d750
|
|
@ -177,8 +177,10 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
|
||||||
rc_flag = eval_as_long(lsb, lsb_ex);
|
rc_flag = eval_as_long(lsb, lsb_ex);
|
||||||
assert(rc_flag);
|
assert(rc_flag);
|
||||||
|
|
||||||
netenum_t*use_enum = new netenum_t(enum_type->base_type, enum_type->signed_flag,
|
netenum_t*use_enum = new netenum_t(enum_type->base_type,
|
||||||
msb, lsb, enum_type->names->size());
|
enum_type->signed_flag,
|
||||||
|
enum_type->integer_flag, msb, lsb,
|
||||||
|
enum_type->names->size());
|
||||||
|
|
||||||
use_enum->set_line(enum_type->li);
|
use_enum->set_line(enum_type->li);
|
||||||
if (scope)
|
if (scope)
|
||||||
|
|
|
||||||
13
netenum.cc
13
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
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -24,9 +24,9 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
netenum_t::netenum_t(ivl_variable_type_t btype, bool signed_flag,
|
netenum_t::netenum_t(ivl_variable_type_t btype, bool signed_flag,
|
||||||
long msb, long lsb, size_t name_count)
|
bool integer_flag, long msb, long lsb, size_t name_count)
|
||||||
: base_type_(btype), signed_flag_(signed_flag), msb_(msb), lsb_(lsb),
|
: base_type_(btype), signed_flag_(signed_flag), integer_flag_(integer_flag),
|
||||||
names_(name_count), bits_(name_count)
|
msb_(msb), lsb_(lsb), names_(name_count), bits_(name_count)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,6 +39,11 @@ bool netenum_t::get_signed() const
|
||||||
return signed_flag_;
|
return signed_flag_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool netenum_t::get_isint() const
|
||||||
|
{
|
||||||
|
return integer_flag_;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enumerations are by definition always packed.
|
* Enumerations are by definition always packed.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ class netenum_t : public LineInfo, public ivl_type_s {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit netenum_t(ivl_variable_type_t base_type, bool signed_flag,
|
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();
|
~netenum_t();
|
||||||
|
|
||||||
virtual ivl_variable_type_t base_type() const;
|
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;
|
virtual long packed_width() const;
|
||||||
std::vector<netrange_t> slice_dimensions() const;
|
std::vector<netrange_t> slice_dimensions() const;
|
||||||
bool get_signed() const;
|
bool get_signed() const;
|
||||||
|
bool get_isint() const;
|
||||||
|
|
||||||
// The size() is the number of enumeration literals.
|
// The size() is the number of enumeration literals.
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
|
|
@ -68,6 +70,7 @@ class netenum_t : public LineInfo, public ivl_type_s {
|
||||||
private:
|
private:
|
||||||
ivl_variable_type_t base_type_;
|
ivl_variable_type_t base_type_;
|
||||||
bool signed_flag_;
|
bool signed_flag_;
|
||||||
|
bool integer_flag_;
|
||||||
long msb_, lsb_;
|
long msb_, lsb_;
|
||||||
|
|
||||||
std::map<perm_string,verinum> names_map_;
|
std::map<perm_string,verinum> names_map_;
|
||||||
|
|
|
||||||
6
parse.y
6
parse.y
|
|
@ -2296,6 +2296,7 @@ enum_data_type
|
||||||
enum_type->names .reset($3);
|
enum_type->names .reset($3);
|
||||||
enum_type->base_type = IVL_VT_BOOL;
|
enum_type->base_type = IVL_VT_BOOL;
|
||||||
enum_type->signed_flag = true;
|
enum_type->signed_flag = true;
|
||||||
|
enum_type->integer_flag = false;
|
||||||
enum_type->range.reset(make_range_from_width(32));
|
enum_type->range.reset(make_range_from_width(32));
|
||||||
$$ = enum_type;
|
$$ = enum_type;
|
||||||
}
|
}
|
||||||
|
|
@ -2305,6 +2306,7 @@ enum_data_type
|
||||||
enum_type->names .reset($5);
|
enum_type->names .reset($5);
|
||||||
enum_type->base_type = IVL_VT_BOOL;
|
enum_type->base_type = IVL_VT_BOOL;
|
||||||
enum_type->signed_flag = $3;
|
enum_type->signed_flag = $3;
|
||||||
|
enum_type->integer_flag = false;
|
||||||
enum_type->range.reset(make_range_from_width($2));
|
enum_type->range.reset(make_range_from_width($2));
|
||||||
$$ = enum_type;
|
$$ = enum_type;
|
||||||
}
|
}
|
||||||
|
|
@ -2314,6 +2316,7 @@ enum_data_type
|
||||||
enum_type->names .reset($5);
|
enum_type->names .reset($5);
|
||||||
enum_type->base_type = IVL_VT_LOGIC;
|
enum_type->base_type = IVL_VT_LOGIC;
|
||||||
enum_type->signed_flag = $3;
|
enum_type->signed_flag = $3;
|
||||||
|
enum_type->integer_flag = true;
|
||||||
enum_type->range.reset(make_range_from_width(integer_width));
|
enum_type->range.reset(make_range_from_width(integer_width));
|
||||||
$$ = enum_type;
|
$$ = enum_type;
|
||||||
}
|
}
|
||||||
|
|
@ -2323,6 +2326,7 @@ enum_data_type
|
||||||
enum_type->names .reset($6);
|
enum_type->names .reset($6);
|
||||||
enum_type->base_type = IVL_VT_LOGIC;
|
enum_type->base_type = IVL_VT_LOGIC;
|
||||||
enum_type->signed_flag = $3;
|
enum_type->signed_flag = $3;
|
||||||
|
enum_type->integer_flag = false;
|
||||||
enum_type->range.reset($4);
|
enum_type->range.reset($4);
|
||||||
$$ = enum_type;
|
$$ = enum_type;
|
||||||
}
|
}
|
||||||
|
|
@ -2332,6 +2336,7 @@ enum_data_type
|
||||||
enum_type->names .reset($6);
|
enum_type->names .reset($6);
|
||||||
enum_type->base_type = IVL_VT_LOGIC;
|
enum_type->base_type = IVL_VT_LOGIC;
|
||||||
enum_type->signed_flag = $3;
|
enum_type->signed_flag = $3;
|
||||||
|
enum_type->integer_flag = false;
|
||||||
enum_type->range.reset($4);
|
enum_type->range.reset($4);
|
||||||
$$ = enum_type;
|
$$ = enum_type;
|
||||||
}
|
}
|
||||||
|
|
@ -2341,6 +2346,7 @@ enum_data_type
|
||||||
enum_type->names .reset($6);
|
enum_type->names .reset($6);
|
||||||
enum_type->base_type = IVL_VT_BOOL;
|
enum_type->base_type = IVL_VT_BOOL;
|
||||||
enum_type->signed_flag = $3;
|
enum_type->signed_flag = $3;
|
||||||
|
enum_type->integer_flag = false;
|
||||||
enum_type->range.reset($4);
|
enum_type->range.reset($4);
|
||||||
$$ = enum_type;
|
$$ = enum_type;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
pform.cc
5
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);
|
assert(enum_type->range->size() == 1);
|
||||||
//XXXXcur->set_range(*enum_type->range, SR_NET);
|
//XXXXcur->set_range(*enum_type->range, SR_NET);
|
||||||
cur->set_data_type(enum_type);
|
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);
|
pform_bind_attributes(cur->attributes, attr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,7 @@ struct enum_type_t : public data_type_t {
|
||||||
|
|
||||||
ivl_variable_type_t base_type;
|
ivl_variable_type_t base_type;
|
||||||
bool signed_flag;
|
bool signed_flag;
|
||||||
|
bool integer_flag; // True if "integer" was used
|
||||||
std::auto_ptr< list<pform_range_t> > range;
|
std::auto_ptr< list<pform_range_t> > range;
|
||||||
std::auto_ptr< list<named_pexpr_t> > names;
|
std::auto_ptr< list<named_pexpr_t> > names;
|
||||||
LineInfo li;
|
LineInfo li;
|
||||||
|
|
|
||||||
|
|
@ -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)
|
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* 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<const netvector_t*> (net->net_type))
|
if (const netvector_t*vec = dynamic_cast<const netvector_t*> (net->net_type))
|
||||||
return vec->get_isint()? 1 : 0;
|
return vec->get_isint()? 1 : 0;
|
||||||
|
else if (const netenum_t*enm = dynamic_cast<const netenum_t*> (net->net_type))
|
||||||
|
return enm->get_isint()? 1 : 0;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue