Add the ability to dump array words
[iverilog.git] / Attrib.cc
blob543768d2b2c01d0df15ddd0c06edf2884ae9c974
1 /*
2 * Copyright (c) 2000 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: Attrib.cc,v 1.6 2004/02/20 18:53:33 steve Exp $"
21 #endif
23 # include "config.h"
25 # include "Attrib.h"
26 # include <assert.h>
28 Attrib::Attrib()
30 nlist_ = 0;
31 list_ = 0;
34 Attrib::~Attrib()
36 delete[] list_;
40 const verinum& Attrib::attribute(perm_string key) const
42 for (unsigned idx = 0 ; idx < nlist_ ; idx += 1) {
44 if (key == list_[idx].key)
45 return list_[idx].val;
48 static const verinum null;
49 return null;
52 void Attrib::attribute(perm_string key, const verinum&value)
54 unsigned idx;
56 for (idx = 0 ; idx < nlist_ ; idx += 1) {
57 if (key == list_[idx].key) {
58 list_[idx].val = value;
59 return;
63 struct cell_*tmp = new struct cell_[nlist_+1];
64 for (idx = 0 ; idx < nlist_ ; idx += 1)
65 tmp[idx] = list_[idx];
67 tmp[nlist_].key = key;
68 tmp[nlist_].val = value;
70 nlist_ += 1;
71 delete[]list_;
72 list_ = tmp;
75 bool Attrib::has_compat_attributes(const Attrib&that) const
77 unsigned idx;
79 for (idx = 0 ; idx < that.nlist_ ; idx += 1) {
81 verinum tmp = attribute(that.list_[idx].key);
82 if (tmp != that.list_[idx].val)
83 return false;
86 return true;
89 unsigned Attrib::attr_cnt() const
91 return nlist_;
94 perm_string Attrib::attr_key(unsigned idx) const
96 assert(idx < nlist_);
97 return list_[idx].key;
100 const verinum& Attrib::attr_value(unsigned idx) const
102 assert(idx < nlist_);
103 return list_[idx].val;
108 * $Log: Attrib.cc,v $
109 * Revision 1.6 2004/02/20 18:53:33 steve
110 * Addtrbute keys are perm_strings.
112 * Revision 1.5 2002/08/12 01:34:58 steve
113 * conditional ident string using autoconfig.
115 * Revision 1.4 2002/05/26 01:39:02 steve
116 * Carry Verilog 2001 attributes with processes,
117 * all the way through to the ivl_target API.
119 * Divide signal reference counts between rval
120 * and lval references.
122 * Revision 1.3 2002/05/23 03:08:50 steve
123 * Add language support for Verilog-2001 attribute
124 * syntax. Hook this support into existing $attribute
125 * handling, and add number and void value types.
127 * Add to the ivl_target API new functions for access
128 * of complex attributes attached to gates.
130 * Revision 1.2 2001/07/25 03:10:48 steve
131 * Create a config.h.in file to hold all the config
132 * junk, and support gcc 3.0. (Stephan Boettcher)
134 * Revision 1.1 2000/12/04 17:37:03 steve
135 * Add Attrib class for holding NetObj attributes.