2010-11-03 04:16:42 +01:00
|
|
|
#ifndef __netenum_H
|
|
|
|
|
#define __netenum_H
|
|
|
|
|
/*
|
2011-09-01 23:29:40 +02:00
|
|
|
* Copyright (c) 2010-2011 Stephen Williams (steve@icarus.com)
|
2010-11-03 04:16:42 +01:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-08-29 03:41:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-11-03 04:16:42 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "ivl_target.h"
|
2012-07-14 03:41:41 +02:00
|
|
|
# include "nettypes.h"
|
2010-11-03 04:16:42 +01:00
|
|
|
# include "verinum.h"
|
|
|
|
|
# include "StringHeap.h"
|
2011-09-01 23:29:40 +02:00
|
|
|
# include "LineInfo.h"
|
2010-11-21 00:09:32 +01:00
|
|
|
# include <vector>
|
2010-11-03 04:16:42 +01:00
|
|
|
# include <map>
|
|
|
|
|
|
2010-11-21 00:09:32 +01:00
|
|
|
class NetScope;
|
|
|
|
|
|
2012-09-23 18:28:49 +02:00
|
|
|
class netenum_t : public LineInfo, public ivl_type_s {
|
2010-11-03 04:16:42 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit netenum_t(ivl_variable_type_t base_type, bool signed_flag,
|
2010-11-21 00:09:32 +01:00
|
|
|
long msb, long lsb, size_t name_count);
|
2010-11-03 04:16:42 +01:00
|
|
|
~netenum_t();
|
|
|
|
|
|
2010-11-07 18:58:00 +01:00
|
|
|
ivl_variable_type_t base_type() const;
|
2012-08-20 02:27:48 +02:00
|
|
|
long packed_width() const;
|
2012-09-30 00:13:45 +02:00
|
|
|
std::vector<netrange_t> slice_dimensions() const;
|
2012-09-16 02:16:05 +02:00
|
|
|
bool get_signed() const;
|
2010-11-07 18:58:00 +01:00
|
|
|
|
|
|
|
|
// The size() is the number of enumeration literals.
|
2010-11-06 03:49:28 +01:00
|
|
|
size_t size() const;
|
|
|
|
|
|
2010-11-21 00:09:32 +01:00
|
|
|
// Insert the name (and value) at the specific place in the
|
|
|
|
|
// enumeration. This must be done exactly once for each
|
|
|
|
|
// enumeration value.
|
|
|
|
|
bool insert_name(size_t idx, perm_string name, const verinum&val);
|
2010-11-03 04:16:42 +01:00
|
|
|
|
2013-04-15 03:03:21 +02:00
|
|
|
// Indicate that there will be no more names to insert.
|
|
|
|
|
void insert_name_close(void);
|
|
|
|
|
|
2010-11-03 04:16:42 +01:00
|
|
|
typedef std::map<perm_string,verinum>::const_iterator iterator;
|
|
|
|
|
iterator find_name(perm_string name) const;
|
|
|
|
|
iterator end_name() const;
|
2011-09-30 04:34:23 +02:00
|
|
|
perm_string find_value(const verinum&val) const;
|
2010-11-03 04:16:42 +01:00
|
|
|
|
2010-11-06 03:49:28 +01:00
|
|
|
// These methods roughly match the .first() and .last() methods.
|
|
|
|
|
iterator first_name() const;
|
|
|
|
|
iterator last_name() const;
|
|
|
|
|
|
2010-11-21 00:09:32 +01:00
|
|
|
perm_string name_at(size_t idx) const;
|
2013-04-15 03:03:21 +02:00
|
|
|
perm_string bits_at(size_t idx) const;
|
2010-11-21 00:09:32 +01:00
|
|
|
|
2010-11-03 04:16:42 +01:00
|
|
|
private:
|
|
|
|
|
ivl_variable_type_t base_type_;
|
|
|
|
|
bool signed_flag_;
|
|
|
|
|
long msb_, lsb_;
|
|
|
|
|
|
2010-11-06 03:49:28 +01:00
|
|
|
std::map<perm_string,verinum> names_map_;
|
2010-11-21 00:09:32 +01:00
|
|
|
std::vector<perm_string> names_;
|
|
|
|
|
std::vector<perm_string> bits_;
|
2010-11-03 04:16:42 +01:00
|
|
|
};
|
|
|
|
|
|
2010-11-07 18:58:00 +01:00
|
|
|
inline ivl_variable_type_t netenum_t::base_type() const
|
|
|
|
|
{ return base_type_; }
|
|
|
|
|
|
2010-11-06 03:49:28 +01:00
|
|
|
inline size_t netenum_t::size() const { return names_.size(); }
|
|
|
|
|
|
2010-11-03 04:16:42 +01:00
|
|
|
#endif
|