Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 143 lines (117 sloc) 3.377 kB
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
1 /*
2 * Copyright (c) 2000 Stephen Williams (steve@icarus.com)
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 #if !defined(WINNT)
e6c0629 Add language support for Verilog-2001 attribute
steve authored
20 #ident "$Id: Attrib.cc,v 1.3 2002/05/23 03:08:50 steve Exp $"
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
21 #endif
22
b825f8d Create a config.h.in file to hold all the config
steve authored
23 # include "config.h"
24
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
25 # include "Attrib.h"
26 # include <assert.h>
27
28 Attrib::Attrib()
29 {
30 nlist_ = 0;
31 list_ = 0;
32 }
33
34 Attrib::~Attrib()
35 {
36 delete[] list_;
37 }
38
e6c0629 Add language support for Verilog-2001 attribute
steve authored
39 #if 0
40 void Attrib::copy_attributes(const map<string,verinum>&attr)
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
41 {
42 assert(list_ == 0);
43
44 nlist_ = attr.size();
45 list_ = new cell_[nlist_];
46
e6c0629 Add language support for Verilog-2001 attribute
steve authored
47 map<string,verinum>::const_iterator idx;
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
48 unsigned jdx;
49 for (idx = attr.begin(), jdx = 0 ; idx != attr.end() ; idx ++, jdx++) {
50 struct cell_*tmp = list_ + jdx;
51 tmp->key = (*idx).first;
52 tmp->val = (*idx).second;
53 }
54 }
e6c0629 Add language support for Verilog-2001 attribute
steve authored
55 #endif
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
56
e6c0629 Add language support for Verilog-2001 attribute
steve authored
57 const verinum& Attrib::attribute(const string&key) const
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
58 {
59 for (unsigned idx = 0 ; idx < nlist_ ; idx += 1) {
60
61 if (key == list_[idx].key)
62 return list_[idx].val;
63 }
64
e6c0629 Add language support for Verilog-2001 attribute
steve authored
65 static const verinum null;
66 return null;
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
67 }
68
e6c0629 Add language support for Verilog-2001 attribute
steve authored
69 void Attrib::attribute(const string&key, const verinum&value)
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
70 {
71 unsigned idx;
72
73 for (idx = 0 ; idx < nlist_ ; idx += 1) {
74 if (key == list_[idx].key) {
75 list_[idx].val = value;
76 return;
77 }
78 }
79
80 struct cell_*tmp = new struct cell_[nlist_+1];
81 for (idx = 0 ; idx < nlist_ ; idx += 1)
82 tmp[idx] = list_[idx];
83
84 tmp[nlist_].key = key;
85 tmp[nlist_].val = value;
86
87 nlist_ += 1;
88 delete[]list_;
89 list_ = tmp;
90 }
91
92 bool Attrib::has_compat_attributes(const Attrib&that) const
93 {
94 unsigned idx;
95
96 for (idx = 0 ; idx < that.nlist_ ; idx += 1) {
97
e6c0629 Add language support for Verilog-2001 attribute
steve authored
98 verinum tmp = attribute(that.list_[idx].key);
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
99 if (tmp != that.list_[idx].val)
100 return false;
101 }
102
103 return true;
104 }
105
106 unsigned Attrib::size() const
107 {
108 return nlist_;
109 }
110
111 string Attrib::key(unsigned idx) const
112 {
113 assert(idx < nlist_);
114 return list_[idx].key;
115 }
116
e6c0629 Add language support for Verilog-2001 attribute
steve authored
117 const verinum& Attrib::value(unsigned idx) const
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
118 {
119 assert(idx < nlist_);
120 return list_[idx].val;
121 }
122
123
124 /*
125 * $Log: Attrib.cc,v $
e6c0629 Add language support for Verilog-2001 attribute
steve authored
126 * Revision 1.3 2002/05/23 03:08:50 steve
127 * Add language support for Verilog-2001 attribute
128 * syntax. Hook this support into existing $attribute
129 * handling, and add number and void value types.
130 *
131 * Add to the ivl_target API new functions for access
132 * of complex attributes attached to gates.
133 *
b825f8d Create a config.h.in file to hold all the config
steve authored
134 * Revision 1.2 2001/07/25 03:10:48 steve
135 * Create a config.h.in file to hold all the config
136 * junk, and support gcc 3.0. (Stephan Boettcher)
137 *
4f63888 Add Attrib class for holding NetObj attributes.
steve authored
138 * Revision 1.1 2000/12/04 17:37:03 steve
139 * Add Attrib class for holding NetObj attributes.
140 *
141 */
142
Something went wrong with that request. Please try again.