Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 102 lines (81 sloc) 2.299 kB
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
1 /*
ae14a58 @caryr V0.8: Remove deprecated #ident and fix some other compile warnings
caryr authored
2 * Copyright (c) 2000-2010 Stephen Williams (steve@icarus.com)
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
3 *
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.
9 *
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.
14 *
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
18 */
19
b825f8d Create a config.h.in file to hold all the config
steve authored
20 # include "config.h"
21
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
22 # include "Attrib.h"
23 # include <assert.h>
24
25 Attrib::Attrib()
26 {
27 nlist_ = 0;
28 list_ = 0;
29 }
30
31 Attrib::~Attrib()
32 {
33 delete[] list_;
34 }
35
36
177b6ff Addtrbute keys are perm_strings.
steve authored
37 const verinum& Attrib::attribute(perm_string key) const
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
38 {
39 for (unsigned idx = 0 ; idx < nlist_ ; idx += 1) {
40
41 if (key == list_[idx].key)
42 return list_[idx].val;
43 }
44
e6c0629 Add language support for Verilog-2001 attribute
steve authored
45 static const verinum null;
46 return null;
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
47 }
48
177b6ff Addtrbute keys are perm_strings.
steve authored
49 void Attrib::attribute(perm_string key, const verinum&value)
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
50 {
51 unsigned idx;
52
53 for (idx = 0 ; idx < nlist_ ; idx += 1) {
54 if (key == list_[idx].key) {
55 list_[idx].val = value;
56 return;
57 }
58 }
59
60 struct cell_*tmp = new struct cell_[nlist_+1];
61 for (idx = 0 ; idx < nlist_ ; idx += 1)
62 tmp[idx] = list_[idx];
63
64 tmp[nlist_].key = key;
65 tmp[nlist_].val = value;
66
67 nlist_ += 1;
68 delete[]list_;
69 list_ = tmp;
70 }
71
72 bool Attrib::has_compat_attributes(const Attrib&that) const
73 {
74 unsigned idx;
75
76 for (idx = 0 ; idx < that.nlist_ ; idx += 1) {
77
e6c0629 Add language support for Verilog-2001 attribute
steve authored
78 verinum tmp = attribute(that.list_[idx].key);
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
79 if (tmp != that.list_[idx].val)
80 return false;
81 }
82
83 return true;
84 }
85
bfad382 Carry Verilog 2001 attributes with processes,
steve authored
86 unsigned Attrib::attr_cnt() const
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
87 {
88 return nlist_;
89 }
90
177b6ff Addtrbute keys are perm_strings.
steve authored
91 perm_string Attrib::attr_key(unsigned idx) const
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
92 {
93 assert(idx < nlist_);
177b6ff Addtrbute keys are perm_strings.
steve authored
94 return list_[idx].key;
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
95 }
96
bfad382 Carry Verilog 2001 attributes with processes,
steve authored
97 const verinum& Attrib::attr_value(unsigned idx) const
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
98 {
99 assert(idx < nlist_);
100 return list_[idx].val;
101 }
Something went wrong with that request. Please try again.