2014-07-23 22:39:29 +02:00
|
|
|
#ifndef IVL_netenum_H
|
|
|
|
|
#define IVL_netenum_H
|
2010-11-03 04:16:42 +01:00
|
|
|
/*
|
2025-10-21 07:45:05 +02:00
|
|
|
* Copyright (c) 2010-2025 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:
|
2022-03-15 08:24:33 +01:00
|
|
|
explicit netenum_t(ivl_type_t base_type, size_t name_count,
|
|
|
|
|
bool integer_flag);
|
2025-10-21 07:45:05 +02:00
|
|
|
~netenum_t() override;
|
2010-11-03 04:16:42 +01:00
|
|
|
|
2025-10-21 07:45:05 +02:00
|
|
|
virtual ivl_variable_type_t base_type() const override;
|
|
|
|
|
virtual bool packed() const override;
|
|
|
|
|
virtual long packed_width() const override;
|
|
|
|
|
netranges_t slice_dimensions() const override;
|
|
|
|
|
bool get_signed() const override;
|
2014-11-01 02:07:46 +01:00
|
|
|
bool get_isint() 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
|
|
|
|
2014-11-04 23:55:40 +01:00
|
|
|
// Check if two enumerations have the same definition.
|
|
|
|
|
bool matches(const netenum_t*other) const;
|
|
|
|
|
|
2010-11-03 04:16:42 +01:00
|
|
|
private:
|
2022-03-15 08:24:33 +01:00
|
|
|
ivl_type_t base_type_;
|
2014-11-01 02:07:46 +01:00
|
|
|
bool integer_flag_;
|
2010-11-03 04:16:42 +01:00
|
|
|
|
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
|
2022-03-15 08:24:33 +01:00
|
|
|
{ return base_type_->base_type(); }
|
2010-11-07 18:58:00 +01:00
|
|
|
|
2010-11-06 03:49:28 +01:00
|
|
|
inline size_t netenum_t::size() const { return names_.size(); }
|
|
|
|
|
|
2014-07-23 22:39:29 +02:00
|
|
|
#endif /* IVL_netenum_H */
|