Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 646 lines (538 sloc) 13.773 kb
583868e Redesign Links to include the Nexus class that
steve authored
1 /*
8cbff6d @steveicarus Cleanup various style issues.
authored
2 * Copyright (c) 2000-2010 Stephen Williams (steve@icarus.com)
583868e Redesign Links to include the Nexus class that
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
f5aafc3 @arunpersaud updated FSF-address
arunpersaud authored
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
583868e Redesign Links to include the Nexus class that
steve authored
18 */
19
b825f8d Create a config.h.in file to hold all the config
steve authored
20 # include "config.h"
21
22 # include <iostream>
23
583868e Redesign Links to include the Nexus class that
steve authored
24 # include "netlist.h"
f56d763 Move strstream to ostringstream for compatibility.
steve authored
25 # include <sstream>
8ea3b6b @ldoolitt header includes for gcc-4.3 compatibility
ldoolitt authored
26 # include <cstring>
583868e Redesign Links to include the Nexus class that
steve authored
27 # include <string>
28 # include <typeinfo>
1993bf6 @caryr Remove malloc.h support and for C++ files use <c...> include files.
caryr authored
29 # include <cstdlib>
a4a7b0a @caryr Make ivl_alloc.h the last include so it doesn't effect any system inc…
caryr authored
30 # include "ivl_alloc.h"
b094bbd Add support for conbinational events by finding
steve authored
31
4db4a46 @steveicarus Speed up the connect(Nexus*,Link&) function somewhat.
authored
32 void Nexus::connect(Link&r)
b094bbd Add support for conbinational events by finding
steve authored
33 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
34 Nexus*r_nexus = r.next_? r.find_nexus_() : 0;
35 if (this == r_nexus)
b094bbd Add support for conbinational events by finding
steve authored
36 return;
37
d7ae1ed @caryr No need to have an if for a delete (found with cppcheck).
caryr authored
38 delete[] name_;
39 name_ = 0;
4db4a46 @steveicarus Speed up the connect(Nexus*,Link&) function somewhat.
authored
40
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
41 // Special case: This nexus is empty. Simply copy all the
42 // links of the other nexus to this one, and delete the old
43 // nexus.
44 if (list_ == 0) {
45 if (r.next_ == 0) {
46 list_ = &r;
47 r.next_ = &r;
48 r.nexus_ = this;
49 driven_ = NO_GUESS;
50 } else {
51 driven_ = r_nexus->driven_;
52 list_ = r_nexus->list_;
53 list_->nexus_ = this;
54 r_nexus->list_ = 0;
55 delete r_nexus;
56 }
57 return;
58 }
59
60 // Special case: The Link is unconnected. Put it at the end of
61 // the current list and move the list_ pointer and nexus_ back
62 // pointer to suit.
63 if (r.next_ == 0) {
4db4a46 @steveicarus Speed up the connect(Nexus*,Link&) function somewhat.
authored
64 if (r.get_dir() != Link::INPUT)
65 driven_ = NO_GUESS;
66
67 r.nexus_ = this;
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
68 r.next_ = list_->next_;
69 list_->next_ = &r;
70 list_->nexus_ = 0;
4db4a46 @steveicarus Speed up the connect(Nexus*,Link&) function somewhat.
authored
71 list_ = &r;
a2aff77 @steveicarus Avoid creating Nexus objects until they are really needed.
authored
72 return;
73 }
b094bbd Add support for conbinational events by finding
steve authored
74
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
75 if (r_nexus->driven_ != Vz)
4db4a46 @steveicarus Speed up the connect(Nexus*,Link&) function somewhat.
authored
76 driven_ = NO_GUESS;
77
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
78 // Splice the list of links from the "tmp" nexus to the end of
79 // this nexus. Adjust the nexus pointers as needed.
80 Link*save_first = list_->next_;
81 list_->next_ = r_nexus->list_->next_;
82 r_nexus->list_->next_ = save_first;
83 list_->nexus_ = 0;
84 list_ = r_nexus->list_;
85 list_->nexus_ = this;
b094bbd Add support for conbinational events by finding
steve authored
86
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
87 r_nexus->list_ = 0;
88 delete r_nexus;
b094bbd Add support for conbinational events by finding
steve authored
89 }
583868e Redesign Links to include the Nexus class that
steve authored
90
91 void connect(Link&l, Link&r)
92 {
93 assert(&l != &r);
a2aff77 @steveicarus Avoid creating Nexus objects until they are really needed.
authored
94 if (l.nexus_ != 0) {
d434dd7 Allow part selects of memory words in l-values.
steve authored
95 connect(l.nexus_, r);
a2aff77 @steveicarus Avoid creating Nexus objects until they are really needed.
authored
96 } else if (r.nexus_ != 0) {
97 connect(r.nexus_, l);
98 } else {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
99 Nexus*tmp = new Nexus(l);
4db4a46 @steveicarus Speed up the connect(Nexus*,Link&) function somewhat.
authored
100 tmp->connect(r);
a2aff77 @steveicarus Avoid creating Nexus objects until they are really needed.
authored
101 }
583868e Redesign Links to include the Nexus class that
steve authored
102 }
103
104 Link::Link()
79f8b8f @steveicarus Remove Link::strength_t and PGate::strength_t types.
authored
105 : dir_(PASSIVE), drive0_(IVL_DR_STRONG), drive1_(IVL_DR_STRONG),
5dfecb3 @steveicarus Remove useless Link instance number.
authored
106 next_(0), nexus_(0)
583868e Redesign Links to include the Nexus class that
steve authored
107 {
108 }
109
110 Link::~Link()
111 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
112 if (next_) {
113 Nexus*tmp = nexus();
114 tmp->unlink(this);
a2aff77 @steveicarus Avoid creating Nexus objects until they are really needed.
authored
115 if (tmp->list_ == 0)
116 delete tmp;
117 }
583868e Redesign Links to include the Nexus class that
steve authored
118 }
119
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
120 Nexus* Link::find_nexus_() const
121 {
122 assert(next_);
123 if (nexus_) return nexus_;
124 for (Link*cur = next_ ; cur != this ; cur = cur->next_) {
125 if (cur->nexus_) return cur->nexus_;
126 }
127 return 0;
128 }
129
583868e Redesign Links to include the Nexus class that
steve authored
130 Nexus* Link::nexus()
131 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
132 if (next_ == 0) {
133 assert(nexus_ == 0);
134 Nexus*tmp = new Nexus(*this);
135 return tmp;
4db4a46 @steveicarus Speed up the connect(Nexus*,Link&) function somewhat.
authored
136 }
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
137
138 return find_nexus_();
583868e Redesign Links to include the Nexus class that
steve authored
139 }
140
141 const Nexus* Link::nexus() const
142 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
143 if (next_ == 0) return 0;
144 return find_nexus_();
583868e Redesign Links to include the Nexus class that
steve authored
145 }
146
147 void Link::set_dir(DIR d)
148 {
149 dir_ = d;
150 }
151
152 Link::DIR Link::get_dir() const
153 {
154 return dir_;
155 }
156
f1f2806 @steveicarus Get delays of signed extended continuous assignments right.
authored
157 void Link::drivers_delays(NetExpr*rise, NetExpr*fall, NetExpr*decay)
158 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
159 find_nexus_()->drivers_delays(rise, fall, decay);
f1f2806 @steveicarus Get delays of signed extended continuous assignments right.
authored
160 }
161
79f8b8f @steveicarus Remove Link::strength_t and PGate::strength_t types.
authored
162 void Link::drivers_drive(ivl_drive_t drive0__, ivl_drive_t drive1__)
6051150 @steveicarus Continuous assign no longer uses elaborate_net.
authored
163 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
164 find_nexus_()->drivers_drive(drive0__, drive1__);
6051150 @steveicarus Continuous assign no longer uses elaborate_net.
authored
165 }
166
bf4e745 @steveicarus Account for output drive of LPM mux devices.
authored
167
79f8b8f @steveicarus Remove Link::strength_t and PGate::strength_t types.
authored
168 void Link::drive0(ivl_drive_t str)
583868e Redesign Links to include the Nexus class that
steve authored
169 {
170 drive0_ = str;
171 }
172
79f8b8f @steveicarus Remove Link::strength_t and PGate::strength_t types.
authored
173 void Link::drive1(ivl_drive_t str)
583868e Redesign Links to include the Nexus class that
steve authored
174 {
175 drive1_ = str;
176 }
177
79f8b8f @steveicarus Remove Link::strength_t and PGate::strength_t types.
authored
178 ivl_drive_t Link::drive0() const
583868e Redesign Links to include the Nexus class that
steve authored
179 {
180 return drive0_;
181 }
182
79f8b8f @steveicarus Remove Link::strength_t and PGate::strength_t types.
authored
183 ivl_drive_t Link::drive1() const
583868e Redesign Links to include the Nexus class that
steve authored
184 {
185 return drive1_;
186 }
187
b292a5f @steveicarus Create a branch object to be the argument to the access function.
authored
188 void Link::cur_link(NetPins*&net, unsigned &pin)
583868e Redesign Links to include the Nexus class that
steve authored
189 {
e4c9ad2 @steveicarus Remove redundant NetPins node pointer.
authored
190 net = get_obj();
191 pin = get_pin();
583868e Redesign Links to include the Nexus class that
steve authored
192 }
193
b292a5f @steveicarus Create a branch object to be the argument to the access function.
authored
194 void Link::cur_link(const NetPins*&net, unsigned &pin) const
583868e Redesign Links to include the Nexus class that
steve authored
195 {
e4c9ad2 @steveicarus Remove redundant NetPins node pointer.
authored
196 net = get_obj();
197 pin = get_pin();
583868e Redesign Links to include the Nexus class that
steve authored
198 }
199
200 void Link::unlink()
201 {
202 if (! is_linked())
203 return;
204
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
205 find_nexus_()->unlink(this);
583868e Redesign Links to include the Nexus class that
steve authored
206 }
207
208 bool Link::is_equal(const Link&that) const
209 {
fff2598 @steveicarus Fix broken definition of is_linked().
authored
210 return (get_obj() == that.get_obj()) && (get_pin() == that.get_pin());
583868e Redesign Links to include the Nexus class that
steve authored
211 }
212
213 bool Link::is_linked() const
214 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
215 if (next_ == 0)
216 return false;
217 if (next_ == this)
a2aff77 @steveicarus Avoid creating Nexus objects until they are really needed.
authored
218 return false;
583868e Redesign Links to include the Nexus class that
steve authored
219
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
220 return true;
583868e Redesign Links to include the Nexus class that
steve authored
221 }
222
223 bool Link::is_linked(const Link&that) const
224 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
225 if (next_ == 0)
a2aff77 @steveicarus Avoid creating Nexus objects until they are really needed.
authored
226 return false;
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
227 if (that.next_ == 0)
228 return false;
229
230 const Link*cur = next_;
231 while (cur != this) {
232 if (cur == &that) return true;
233 cur = cur->next_;
234 }
235
236 return false;
583868e Redesign Links to include the Nexus class that
steve authored
237 }
238
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
239 Nexus::Nexus(Link&that)
583868e Redesign Links to include the Nexus class that
steve authored
240 {
8876cda Get at gate information for ivl_target interface.
steve authored
241 name_ = 0;
58c2e12 Make link_drive_constant cache its results in
steve authored
242 driven_ = NO_GUESS;
6f69773 ivl_target updates, including more complete
steve authored
243 t_cookie_ = 0;
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
244
245 if (that.next_ == 0) {
246 list_ = &that;
247 that.next_ = &that;
248 that.nexus_ = this;
249 driven_ = NO_GUESS;
250
251 } else {
252 Nexus*tmp = that.find_nexus_();
253 list_ = tmp->list_;
254 list_->nexus_ = this;
255 driven_ = tmp->driven_;
256 name_ = tmp->name_;
257
258 tmp->list_ = 0;
259 tmp->name_ = 0;
260 delete tmp;
261 }
583868e Redesign Links to include the Nexus class that
steve authored
262 }
263
264 Nexus::~Nexus()
265 {
266 assert(list_ == 0);
8cbff6d @steveicarus Cleanup various style issues.
authored
267 delete[] name_;
583868e Redesign Links to include the Nexus class that
steve authored
268 }
269
abc4eb9 @steveicarus Do not cprop through ternaries if the selector is an l-value.
authored
270 bool Nexus::assign_lval() const
271 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
272 for (const Link*cur = first_nlink() ; cur ; cur = cur->next_nlink()) {
abc4eb9 @steveicarus Do not cprop through ternaries if the selector is an l-value.
authored
273
274 const NetPins*obj;
275 unsigned pin;
276 cur->cur_link(obj, pin);
277 const NetNet*net = dynamic_cast<const NetNet*> (obj);
278 if (net == 0)
279 continue;
280
498bfcd @steveicarus Trivial optimizer cleanup.
authored
281 if (net->peek_lref() > 0)
abc4eb9 @steveicarus Do not cprop through ternaries if the selector is an l-value.
authored
282 return true;
283 }
284
285 return false;
286 }
287
4cda5ae @steveicarus Clean up some optimizer formance around the fringes.
authored
288 void Nexus::count_io(unsigned&inp, unsigned&out) const
289 {
290 for (const Link*cur = first_nlink() ; cur ; cur = cur->next_nlink()) {
291 switch (cur->get_dir()) {
292 case Link::INPUT:
293 inp += 1;
294 break;
295 case Link::OUTPUT:
296 out += 1;
297 break;
4622f30 @steveicarus Remove dead init values from NetNet and Link objects.
authored
298 default:
299 break;
4cda5ae @steveicarus Clean up some optimizer formance around the fringes.
authored
300 }
301 }
302 }
303
893aae2 @steveicarus Add BUFZ to input ports when necessary.
authored
304 bool Nexus::drivers_present() const
305 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
306 for (const Link*cur = first_nlink() ; cur ; cur = cur->next_nlink()) {
893aae2 @steveicarus Add BUFZ to input ports when necessary.
authored
307 if (cur->get_dir() == Link::OUTPUT)
308 return true;
309
310 if (cur->get_dir() == Link::INPUT)
311 continue;
312
313 // Must be PASSIVE, so if it is some kind of net, see if
314 // it is the sort that might drive the nexus.
1ca8241 @steveicarus Merge branch 'master' into verilog-ams
authored
315 const NetPins*obj;
893aae2 @steveicarus Add BUFZ to input ports when necessary.
authored
316 unsigned pin;
317 cur->cur_link(obj, pin);
318 if (const NetNet*net = dynamic_cast<const NetNet*>(obj))
319 switch (net->type()) {
320 case NetNet::SUPPLY0:
321 case NetNet::SUPPLY1:
322 case NetNet::TRI0:
323 case NetNet::TRI1:
324 case NetNet::WAND:
325 case NetNet::WOR:
326 case NetNet::TRIAND:
327 case NetNet::TRIOR:
328 case NetNet::REG:
329 return true;
330 default:
331 break;
332 }
333 }
334
335 return false;
336 }
337
f1f2806 @steveicarus Get delays of signed extended continuous assignments right.
authored
338 void Nexus::drivers_delays(NetExpr*rise, NetExpr*fall, NetExpr*decay)
339 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
340 for (Link*cur = first_nlink() ; cur ; cur = cur->next_nlink()) {
f1f2806 @steveicarus Get delays of signed extended continuous assignments right.
authored
341 if (cur->get_dir() != Link::OUTPUT)
342 continue;
343
b292a5f @steveicarus Create a branch object to be the argument to the access function.
authored
344 NetObj*obj = dynamic_cast<NetObj*>(cur->get_obj());
345 if (obj == 0)
346 continue;
347
f1f2806 @steveicarus Get delays of signed extended continuous assignments right.
authored
348 obj->rise_time(rise);
349 obj->fall_time(fall);
350 obj->decay_time(decay);
351 }
352 }
353
79f8b8f @steveicarus Remove Link::strength_t and PGate::strength_t types.
authored
354 void Nexus::drivers_drive(ivl_drive_t drive0, ivl_drive_t drive1)
6051150 @steveicarus Continuous assign no longer uses elaborate_net.
authored
355 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
356 for (Link*cur = first_nlink() ; cur ; cur = cur->next_nlink()) {
6051150 @steveicarus Continuous assign no longer uses elaborate_net.
authored
357 if (cur->get_dir() != Link::OUTPUT)
358 continue;
359
360 cur->drive0(drive0);
361 cur->drive1(drive1);
362 }
363 }
364
583868e Redesign Links to include the Nexus class that
steve authored
365 void Nexus::unlink(Link*that)
366 {
d7ae1ed @caryr No need to have an if for a delete (found with cppcheck).
caryr authored
367 delete[] name_;
368 name_ = 0;
8876cda Get at gate information for ivl_target interface.
steve authored
369
583868e Redesign Links to include the Nexus class that
steve authored
370 assert(that);
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
371
372 // Special case: the Link is the only link in the nexus. In
373 // this case, the unlink is trivial. Also clear the Nexus
374 // pointers.
375 if (that->next_ == that) {
376 assert(that->nexus_ == this);
377 assert(list_ == that);
378 list_ = 0;
379 driven_ = NO_GUESS;
583868e Redesign Links to include the Nexus class that
steve authored
380 that->nexus_ = 0;
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
381 that->next_ = 0;
583868e Redesign Links to include the Nexus class that
steve authored
382 return;
383 }
384
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
385 // If the link I'm removing was a driver for this nexus, then
ec49f10 @steveicarus Revert bad merge from vhdl branch
authored
386 // cancel my guess of the driven value.
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
387 if (that->get_dir() != Link::INPUT)
388 driven_ = NO_GUESS;
389
390 // Look for the Link that points to "that". We know that there
391 // will be one because the list is a circle. When we find the
392 // prev pointer, then remove that from the list.
393 Link*prev = list_;
394 while (prev->next_ != that)
395 prev = prev->next_;
396
397 prev->next_ = that->next_;
398
399 // If "that" was the last item in the list, then change the
400 // list_ pointer to point to the new end of the list.
401 if (list_ == that) {
402 assert(that->nexus_ == this);
403 list_ = prev;
404 list_->nexus_ = this;
583868e Redesign Links to include the Nexus class that
steve authored
405 }
406
407 that->nexus_ = 0;
408 that->next_ = 0;
409 }
410
411 Link* Nexus::first_nlink()
412 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
413 if (list_) return list_->next_;
414 else return 0;
583868e Redesign Links to include the Nexus class that
steve authored
415 }
416
417 const Link* Nexus::first_nlink() const
418 {
782c55f @steveicarus Restructure Nexus lists of Links to handle large net lists.
authored
419 if (list_) return list_->next_;
420 else return 0;
583868e Redesign Links to include the Nexus class that
steve authored
421 }
422
534207b @steveicarus Optimized Nexus handling during code generation.
authored
423 /*
424 * The t_cookie can be set exactly once. This attaches an ivl_nexus_t
425 * object to the Nexus, and causes the Link list to be marked up for
426 * efficient use by the code generator. The change is to give all the
427 * links a valid nexus_ pointer. This breaks most of the other
428 * methods, but they are not used during code generation.
429 */
430 void Nexus::t_cookie(ivl_nexus_t val) const
431 {
432 assert(val && !t_cookie_);
6f69773 ivl_target updates, including more complete
steve authored
433 t_cookie_ = val;
534207b @steveicarus Optimized Nexus handling during code generation.
authored
434
435 for (Link*cur = list_->next_ ; cur->nexus_ == 0 ; cur = cur->next_)
436 cur->nexus_ = const_cast<Nexus*> (this);
6f69773 ivl_target updates, including more complete
steve authored
437 }
438
365cfed Update DFF support to new data flow.
steve authored
439 unsigned Nexus::vector_width() const
440 {
441 for (const Link*cur = first_nlink() ; cur ; cur = cur->next_nlink()) {
442 const NetNet*sig = dynamic_cast<const NetNet*>(cur->get_obj());
443 if (sig == 0)
444 continue;
445
446 return sig->vector_width();
447 }
448
449 return 0;
450 }
451
452 NetNet* Nexus::pick_any_net()
453 {
454 for (Link*cur = first_nlink() ; cur ; cur = cur->next_nlink()) {
4413dd3 Fix compile errors.
steve authored
455 NetNet*sig = dynamic_cast<NetNet*>(cur->get_obj());
365cfed Update DFF support to new data flow.
steve authored
456 if (sig != 0)
457 return sig;
458 }
459
460 return 0;
461 }
462
8876cda Get at gate information for ivl_target interface.
steve authored
463 const char* Nexus::name() const
583868e Redesign Links to include the Nexus class that
steve authored
464 {
8876cda Get at gate information for ivl_target interface.
steve authored
465 if (name_)
466 return name_;
467
583868e Redesign Links to include the Nexus class that
steve authored
468 const NetNet*sig = 0;
469 unsigned pin = 0;
470 for (const Link*cur = first_nlink()
471 ; cur ; cur = cur->next_nlink()) {
472
473 const NetNet*cursig = dynamic_cast<const NetNet*>(cur->get_obj());
474 if (cursig == 0)
475 continue;
476
477 if (sig == 0) {
478 sig = cursig;
479 pin = cur->get_pin();
480 continue;
481 }
482
483 if ((cursig->pin_count() == 1) && (sig->pin_count() > 1))
484 continue;
485
486 if ((cursig->pin_count() > 1) && (sig->pin_count() == 1)) {
487 sig = cursig;
488 pin = cur->get_pin();
489 continue;
490 }
491
492 if (cursig->local_flag() && !sig->local_flag())
493 continue;
494
495 if (cursig->name() < sig->name())
496 continue;
497
498 sig = cursig;
499 pin = cur->get_pin();
500 }
501
502 if (sig == 0) {
503 const Link*lnk = first_nlink();
b292a5f @steveicarus Create a branch object to be the argument to the access function.
authored
504 const NetObj*obj = dynamic_cast<const NetObj*>(lnk->get_obj());
583868e Redesign Links to include the Nexus class that
steve authored
505 pin = lnk->get_pin();
3abf51d @steveicarus Get rid of names attached to Links.
authored
506 cerr << "internal error: No signal for nexus of "
507 << obj->name() << " pin " << pin
508 << " type=" << typeid(*obj).name() << "?" << endl;
583868e Redesign Links to include the Nexus class that
steve authored
509
510 }
511 assert(sig);
f56d763 Move strstream to ostringstream for compatibility.
steve authored
512 ostringstream tmp;
c7d97f4 Properly evaluate scope path expressions.
steve authored
513 tmp << scope_path(sig->scope()) << "." << sig->name();
583868e Redesign Links to include the Nexus class that
steve authored
514 if (sig->pin_count() > 1)
515 tmp << "<" << pin << ">";
516
f56d763 Move strstream to ostringstream for compatibility.
steve authored
517 const string tmps = tmp.str();
518 name_ = new char[strlen(tmps.c_str()) + 1];
519 strcpy(name_, tmps.c_str());
8876cda Get at gate information for ivl_target interface.
steve authored
520 return name_;
583868e Redesign Links to include the Nexus class that
steve authored
521 }
522
b094bbd Add support for conbinational events by finding
steve authored
523
524 NexusSet::NexusSet()
525 {
526 items_ = 0;
527 nitems_ = 0;
528 }
529
530 NexusSet::~NexusSet()
531 {
532 if (nitems_ > 0) {
533 assert(items_ != 0);
f7e840c @caryr Fix another delete[]/free problem.
caryr authored
534 free(items_);
b094bbd Add support for conbinational events by finding
steve authored
535 } else {
536 assert(items_ == 0);
537 }
538 }
539
540 unsigned NexusSet::count() const
541 {
542 return nitems_;
543 }
544
545 void NexusSet::add(Nexus*that)
546 {
a2aff77 @steveicarus Avoid creating Nexus objects until they are really needed.
authored
547 assert(that);
b094bbd Add support for conbinational events by finding
steve authored
548 if (nitems_ == 0) {
549 assert(items_ == 0);
550 items_ = (Nexus**)malloc(sizeof(Nexus*));
551 items_[0] = that;
552 nitems_ = 1;
553 return;
554 }
555
556 unsigned ptr = bsearch_(that);
cf85c19 Simplify NexusSet set handling.
steve authored
557 if (ptr < nitems_) {
558 assert(items_[ptr] == that);
b094bbd Add support for conbinational events by finding
steve authored
559 return;
cf85c19 Simplify NexusSet set handling.
steve authored
560 }
b094bbd Add support for conbinational events by finding
steve authored
561
cf85c19 Simplify NexusSet set handling.
steve authored
562 assert(ptr == nitems_);
b094bbd Add support for conbinational events by finding
steve authored
563
cf85c19 Simplify NexusSet set handling.
steve authored
564 items_ = (Nexus**)realloc(items_, (nitems_+1) * sizeof(Nexus*));
b094bbd Add support for conbinational events by finding
steve authored
565 items_[ptr] = that;
566 nitems_ += 1;
567 }
568
569 void NexusSet::add(const NexusSet&that)
570 {
571 for (unsigned idx = 0 ; idx < that.nitems_ ; idx += 1)
572 add(that.items_[idx]);
573 }
574
2fad8d4 Detect temporaries in sequential block synthesis.
steve authored
575 void NexusSet::rem(Nexus*that)
576 {
a2aff77 @steveicarus Avoid creating Nexus objects until they are really needed.
authored
577 assert(that);
2fad8d4 Detect temporaries in sequential block synthesis.
steve authored
578 if (nitems_ == 0)
579 return;
580
581 unsigned ptr = bsearch_(that);
cf85c19 Simplify NexusSet set handling.
steve authored
582 if (ptr >= nitems_)
2fad8d4 Detect temporaries in sequential block synthesis.
steve authored
583 return;
584
585 if (nitems_ == 1) {
586 free(items_);
587 items_ = 0;
588 nitems_ = 0;
589 return;
590 }
591
592 for (unsigned idx = ptr ; idx < (nitems_-1) ; idx += 1)
593 items_[idx] = items_[idx+1];
594
595 items_ = (Nexus**)realloc(items_, (nitems_-1) * sizeof(Nexus*));
596 nitems_ -= 1;
597 }
598
599 void NexusSet::rem(const NexusSet&that)
600 {
601 for (unsigned idx = 0 ; idx < that.nitems_ ; idx += 1)
602 rem(that.items_[idx]);
603 }
604
9b6b081 Add structure for asynchronous logic synthesis.
steve authored
605 Nexus* NexusSet::operator[] (unsigned idx) const
b094bbd Add support for conbinational events by finding
steve authored
606 {
607 assert(idx < nitems_);
608 return items_[idx];
609 }
610
9b6b081 Add structure for asynchronous logic synthesis.
steve authored
611 unsigned NexusSet::bsearch_(Nexus*that) const
b094bbd Add support for conbinational events by finding
steve authored
612 {
613 for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) {
cf85c19 Simplify NexusSet set handling.
steve authored
614 if (items_[idx] == that)
615 return idx;
b094bbd Add support for conbinational events by finding
steve authored
616 }
617
618 return nitems_;
619 }
620
9b6b081 Add structure for asynchronous logic synthesis.
steve authored
621 bool NexusSet::contains(const NexusSet&that) const
622 {
623 for (unsigned idx = 0 ; idx < that.nitems_ ; idx += 1) {
624 unsigned where = bsearch_(that[idx]);
625 if (where == nitems_)
626 return false;
627 if (items_[where] != that[idx])
628 return false;
629 }
630
631 return true;
632 }
b094bbd Add support for conbinational events by finding
steve authored
633
3d4593d Synthesizer support for synchronous begin-end blocks.
steve authored
634 bool NexusSet::intersect(const NexusSet&that) const
635 {
636 for (unsigned idx = 0 ; idx < that.nitems_ ; idx += 1) {
637 unsigned where = bsearch_(that[idx]);
638 if (where == nitems_)
639 continue;
640 if (items_[where] == that[idx])
641 return true;
642 }
643
644 return false;
645 }
Something went wrong with that request. Please try again.