10 #include <QTextStream>
25 std::vector<Net*> inputNets;
41 for (Net* n : inputNets)
43 for (
const Endpoint* ep : n->get_sources())
45 Gate* inpGate = ep->get_gate();
46 if (inpGate->is_gnd_gate() || inpGate->is_vcc_gate())
48 u32 inpGateId = inpGate->get_id();
51 mPredecessorSet.insert(inpEntry);
75 int n = mPredecessorSet.size();
79 for (
const QPoint& source : mPredecessorPositions)
83 retval += (n - mPredecessorPositions.size()) * defaultDistance * 4;
89 retval +=
getId() / 1000000.;
95 int dx = abs(source.
x() + 1 - pos.
x());
96 int dy = abs(source.
y() - pos.
y()) - 1;
104 return 5 + 4 * (dx + dy);
122 wtse->setPredecessorIds(mGateMap);
127 wtsePred->mSuccessorSet.insert(wtse);
130 if (wtse->mPredecessorSet.isEmpty())
132 if (wtse->mSuccessorSet.isEmpty())
138 if (mIsolated.
size() > 1)
141 if (mStartpoint.
size() > 1)
144 mSideLength = sqrt(
size());
158 mGateMap.insert(g->get_id(), wtse);
162 mGateMap.insert(wtse->
getId(), wtse);
167 bool isEdge = pos.
x() == 0 || pos.
y() == 0;
168 if (!mIsolated.
isEmpty() && (isEdge || mWaiting.isEmpty()))
172 if (!mStartpoint.
isEmpty() && (isEdge || mWaiting.isEmpty()))
180 if (!mPlaced.contains(wtse))
182 mWaiting.insert(wtse, mPlacementRound);
187 if (!mWaiting.isEmpty())
189 double minDistance = 0;
193 double distance = it.key()->distance(pos, mSideLength) - 0.5 * (mPlacementRound - it.value());
194 if (jt == mWaiting.end() || distance < minDistance)
196 minDistance = distance;
200 Q_ASSERT(jt != mWaiting.end());
211 assert(!mPlaced.contains(wtse));
213 mPlaced.insert(wtse);
216 wtseSucc->mPredecessorPositions.
append(pos);
217 if (!mWaiting.contains(wtseSucc) && !mPlaced.contains(wtseSucc))
218 mWaiting.insert(wtseSucc, mPlacementRound);
226 xout <<
"WaitToBeSeatedList\n";
230 xout << wtse->
getId();
231 xout << (wtse->
isModule() ?
"MOD" :
"GAT");
242 xout.setFieldWidth(0);
245 xout <<
"------------------------\n";
const std::vector< Net * > & get_fan_in_nets() const
const std::vector< Gate * > & get_gates() const
const std::unordered_set< Net * > & get_input_nets() const
Gate * get_gate_by_id(const u32 gate_id) const
Module * get_module_by_id(u32 module_id) const
The Node class object represents a module or a gate.
bool isModule() const
isModule test wheter node is a module
u32 id() const
id getter for ID information
double distance(const QPoint &pos, double defaultDistance) const
WaitToBeSeatedEntry(Node::NodeType t=Node::Module, u32 id=0)
void add(WaitToBeSeatedEntry *wtse)
const WaitToBeSeatedEntry * doPlacement(const QPoint &pos, WaitToBeSeatedEntry *wtse)
const WaitToBeSeatedEntry * nextPlacement(const QPoint &pos)
bool placementDone() const
std::vector< T > to_vector(const Container< T, Args... > &container)
bool compareWaitToBeSeated(const WaitToBeSeatedEntry *a, const WaitToBeSeatedEntry *b)
void append(const T &value)
bool isEmpty() const const
const Key & key() const const
const T value(const Key &key, const T &defaultValue) const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
void setFieldWidth(int width)