Skip to content
Newer
Older
100644 168 lines (143 sloc) 4.79 KB
ec773fe @steveicarus Elaborate tran devices
authored May 19, 2008
1 /*
eb525b6 @caryr Fix some initialization problem found with cppcheck.
caryr authored Oct 9, 2010
2 * Copyright (c) 2008-2010 Stephen Williams (steve@icarus.com)
ec773fe @steveicarus Elaborate tran devices
authored May 20, 2008
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 Aug 28, 2012
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
ec773fe @steveicarus Elaborate tran devices
authored May 20, 2008
18 */
19
20 # include "config.h"
21
22 # include <iostream>
23
24 # include <typeinfo>
25 # include <cstdlib>
26 # include "compiler.h"
27 # include "netlist.h"
28 # include "netmisc.h"
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 1, 2008
29 # include "ivl_target_priv.h"
ec773fe @steveicarus Elaborate tran devices
authored May 20, 2008
30 # include "ivl_assert.h"
31
ca756f3 @steveicarus Bring switch information out to the ivl_target API.
authored May 23, 2008
32 static bool has_enable(ivl_switch_type_t tt)
33 {
34 switch (tt) {
35 case IVL_SW_TRANIF0:
36 case IVL_SW_TRANIF1:
37 case IVL_SW_RTRANIF0:
38 case IVL_SW_RTRANIF1:
39 return true;
40 default:
41 return false;
42 }
43 }
44
ba4137d @caryr Keep the width information for all the tran gates.
caryr authored Jan 2, 2012
45 NetTran::NetTran(NetScope*scope__, perm_string n, ivl_switch_type_t tt,
46 unsigned width)
47 : NetNode(scope__, n, has_enable(tt)? 3 : 2), type_(tt), wid_(width)
ec773fe @steveicarus Elaborate tran devices
authored May 20, 2008
48 {
3abf51d @steveicarus Get rid of names attached to Links.
authored Sep 10, 2008
49 pin(0).set_dir(Link::PASSIVE);
50 pin(1).set_dir(Link::PASSIVE);
ca756f3 @steveicarus Bring switch information out to the ivl_target API.
authored May 24, 2008
51 if (pin_count() == 3) {
3abf51d @steveicarus Get rid of names attached to Links.
authored Sep 11, 2008
52 pin(2).set_dir(Link::INPUT); // Enable
ec773fe @steveicarus Elaborate tran devices
authored May 20, 2008
53 }
eb525b6 @caryr Fix some initialization problem found with cppcheck.
caryr authored Oct 10, 2010
54 part_ = 0;
55 off_ = 0;
ec773fe @steveicarus Elaborate tran devices
authored May 20, 2008
56 }
57
3adcbb5 @ldoolitt Shadow reduction part 2
ldoolitt authored Oct 13, 2008
58 NetTran::NetTran(NetScope*scope__, perm_string n, unsigned wid, unsigned part, unsigned off)
59 : NetNode(scope__, n, 2), type_(IVL_SW_TRAN_VP), wid_(wid), part_(part), off_(off)
73e2b29 @steveicarus Replace the NetPartSelect:BI with NetTran(VP).
authored Jun 3, 2008
60 {
3abf51d @steveicarus Get rid of names attached to Links.
authored Sep 11, 2008
61 pin(0).set_dir(Link::PASSIVE);
62 pin(1).set_dir(Link::PASSIVE);
73e2b29 @steveicarus Replace the NetPartSelect:BI with NetTran(VP).
authored Jun 3, 2008
63 }
64
ec773fe @steveicarus Elaborate tran devices
authored May 20, 2008
65 NetTran::~NetTran()
66 {
67 }
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
68
73e2b29 @steveicarus Replace the NetPartSelect:BI with NetTran(VP).
authored Jun 3, 2008
69 unsigned NetTran::vector_width() const
70 {
71 return wid_;
72 }
73
74 unsigned NetTran::part_width() const
75 {
76 return part_;
77 }
78
79 unsigned NetTran::part_offset() const
80 {
81 return off_;
82 }
83
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
84 void join_island(NetPins*obj)
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
85 {
86 IslandBranch*branch = dynamic_cast<IslandBranch*> (obj);
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 3, 2008
87
88 // If this is not even a branch, then stop now.
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
89 if (branch == 0)
90 return;
91
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
92 // If this is a branch, but already given to an island, then
93 // stop.
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
94 if (branch->island_)
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
95 return;
96
97 list<NetObj*> uncommitted_neighbors;
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
98
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
99 // Look for neighboring objects that might already be in
100 // islands. If we find something, then join that island.
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
101 for (unsigned idx = 0 ; idx < obj->pin_count() ; idx += 1) {
102 Nexus*nex = obj->pin(idx).nexus();
103 for (Link*cur = nex->first_nlink() ; cur ; cur = cur->next_nlink()) {
104 unsigned pin;
b292a5f @steveicarus Create a branch object to be the argument to the access function.
authored Aug 4, 2008
105 NetPins*tmp_pins;
106 cur->cur_link(tmp_pins, pin);
107
108 NetObj*tmp = dynamic_cast<NetObj*> (tmp_pins);
109 if (tmp == 0)
110 continue;
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
111
112 // Skip self.
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
113 if (tmp == obj)
114 continue;
115
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
116 // If tmp is not a branch, then skip it.
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
117 IslandBranch*tmp_branch = dynamic_cast<IslandBranch*> (tmp);
118 if (tmp_branch == 0)
119 continue;
120
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
121 // If tmp is an uncommitted branch, then save
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
122 // it. When I finally choose an island for self,
d90ce68 @ldoolitt Spelling fixes
ldoolitt authored Jun 10, 2008
123 // these branches will be scanned so that they join
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
124 // this island as well.
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
125 if (tmp_branch->island_ == 0) {
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
126 uncommitted_neighbors.push_back(tmp);
127 continue;
128 }
129
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
130 ivl_assert(*obj, branch->island_==0 || branch->island_==tmp_branch->island_);
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
131
132 // We found an existing island to join. Join it
133 // now. Keep scanning in order to find more neighbors.
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
134 if (branch->island_ == 0) {
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
135 if (debug_elaborate)
136 cerr << obj->get_fileline() << ": debug: "
eed4ff7 @ldoolitt Spelling fixes
ldoolitt authored Jun 12, 2008
137 << "Join branch to existing island." << endl;
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
138 branch->island_ = tmp_branch->island_;
139 ivl_assert(*obj, branch->island_->discipline == tmp_branch->island_->discipline);
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
140
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
141 } else if (branch->island_ != tmp_branch->island_) {
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
142 cerr << obj->get_fileline() << ": internal error: "
143 << "Oops, Found 2 neighboring islands." << endl;
144 ivl_assert(*obj, 0);
145 }
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
146 }
147 }
148
eed4ff7 @ldoolitt Spelling fixes
ldoolitt authored Jun 12, 2008
149 // If after all that we did not find an island to join, then
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
150 // start the island not and join it.
0da27a2 @steveicarus Collect analog branches into islands.
authored Nov 9, 2008
151 if (branch->island_ == 0) {
152 branch->island_ = new ivl_island_s;
153 branch->island_->discipline = branch->discipline_;
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
154 if (debug_elaborate)
155 cerr << obj->get_fileline() << ": debug: "
156 << "Create new island for this branch" << endl;
157 }
158
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
159 // Now scan all the uncommitted neighbors I found. Calling
160 // join_island() on them will cause them to notice me in the
161 // process, and thus they will join my island. This process
162 // will recurse until all the connected branches join this island.
163 for (list<NetObj*>::iterator cur = uncommitted_neighbors.begin()
225ca1e @caryr Change iterators to use prefix ++ since it is more efficient.
caryr authored Oct 23, 2010
164 ; cur != uncommitted_neighbors.end() ; ++ cur ) {
db09f2f @steveicarus More cost effective and reliable island joining algorithm.
authored Jun 4, 2008
165 join_island(*cur);
166 }
df15a03 @steveicarus Collect NetTran devices into islands.
authored Jun 2, 2008
167 }
Something went wrong with that request. Please try again.