Skip to content

Commit 720c435

Browse files
committed
Merge branch 'master' of https://github.com/The-OpenROAD-Project/OpenROAD into grt_real_capacity
2 parents 70d13a5 + dd56d50 commit 720c435

18 files changed

+245
-60
lines changed

src/gui/src/heatMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void HeatMapDataSource::dumpToFile(const std::string& file)
9797

9898
const double dbu_to_micron = block_->getDbUnitsPerMicron();
9999

100-
csv << "x0,y0,x1,y1,value" << std::endl;
100+
csv << "x0,y0,x1,y1,value (" << getValueUnits() << ")" << '\n';
101101
for (const auto& map_col : map_) {
102102
for (const auto& map_value : map_col) {
103103
if (!map_value->has_value) {

src/mpl/src/SimulatedAnnealingCore.cpp

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -263,62 +263,68 @@ void SimulatedAnnealingCore<T>::calOutlinePenalty()
263263
template <class T>
264264
void SimulatedAnnealingCore<T>::calWirelength()
265265
{
266-
// Initialization
267-
wirelength_ = 0.0;
268266
if (core_weights_.wirelength <= 0.0) {
269267
return;
270268
}
271269

272-
// calculate the total net weight
273-
float tot_net_weight = 0.0;
274-
for (const auto& net : nets_) {
275-
tot_net_weight += net.weight;
276-
}
270+
wirelength_ = computeNetsWireLength(nets_);
277271

278-
if (tot_net_weight <= 0.0) {
279-
return;
272+
if (graphics_) {
273+
graphics_->setWirelengthPenalty({.name = "Wire Length",
274+
.weight = core_weights_.wirelength,
275+
.value = wirelength_,
276+
.normalization_factor = norm_wirelength_});
280277
}
278+
}
279+
280+
template <class T>
281+
float SimulatedAnnealingCore<T>::computeNetsWireLength(
282+
const std::vector<BundledNet>& nets) const
283+
{
284+
float nets_wire_length = 0.0;
285+
float nets_weight_sum = 0.0;
281286

282287
for (const auto& net : nets_) {
283-
T& source = macros_[net.terminals.first];
284-
T& target = macros_[net.terminals.second];
288+
nets_weight_sum += net.weight;
289+
}
285290

286-
if (target.isClusterOfUnplacedIOPins()) {
287-
computeWLForClusterOfUnplacedIOPins(source, target, net.weight);
288-
continue;
289-
}
291+
if (nets_weight_sum != 0.0) {
292+
for (const auto& net : nets) {
293+
const T& source = macros_[net.terminals.first];
294+
const T& target = macros_[net.terminals.second];
290295

291-
const float x1 = source.getPinX();
292-
const float y1 = source.getPinY();
293-
const float x2 = target.getPinX();
294-
const float y2 = target.getPinY();
295-
wirelength_ += net.weight * (std::abs(x2 - x1) + std::abs(y2 - y1));
296-
}
296+
if (target.isClusterOfUnplacedIOPins()) {
297+
nets_wire_length
298+
+= computeWLForClusterOfUnplacedIOPins(source, target, net.weight);
299+
} else {
300+
const float x1 = source.getPinX();
301+
const float y1 = source.getPinY();
302+
const float x2 = target.getPinX();
303+
const float y2 = target.getPinY();
297304

298-
// normalization
299-
wirelength_ = wirelength_ / tot_net_weight
300-
/ (outline_.getHeight() + outline_.getWidth());
305+
nets_wire_length
306+
+= net.weight * (std::abs(x2 - x1) + std::abs(y2 - y1));
307+
}
308+
}
301309

302-
if (graphics_) {
303-
graphics_->setWirelengthPenalty({"Wire Length",
304-
core_weights_.wirelength,
305-
wirelength_,
306-
norm_wirelength_});
310+
nets_wire_length = nets_wire_length / nets_weight_sum
311+
/ (outline_.getHeight() + outline_.getWidth());
307312
}
313+
314+
return nets_wire_length;
308315
}
309316

310317
template <class T>
311-
void SimulatedAnnealingCore<T>::computeWLForClusterOfUnplacedIOPins(
318+
double SimulatedAnnealingCore<T>::computeWLForClusterOfUnplacedIOPins(
312319
const T& macro,
313320
const T& unplaced_ios,
314-
const float net_weight)
321+
const float net_weight) const
315322
{
316323
// To generate maximum cost.
317324
const float max_dist = die_area_.getPerimeter() / 2;
318325

319326
if (isOutsideTheOutline(macro)) {
320-
wirelength_ += net_weight * max_dist;
321-
return;
327+
return net_weight * max_dist;
322328
}
323329

324330
const odb::Point macro_location(block_->micronsToDbu(macro.getPinX()),
@@ -341,7 +347,7 @@ void SimulatedAnnealingCore<T>::computeWLForClusterOfUnplacedIOPins(
341347
= computeDistToNearestRegion(macro_location, {constraint}, nullptr);
342348
}
343349

344-
wirelength_ += net_weight * block_->dbuToMicrons(smallest_distance);
350+
return net_weight * block_->dbuToMicrons(smallest_distance);
345351
}
346352

347353
// We consider the macro outside the outline based on the location of

src/mpl/src/SimulatedAnnealingCore.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ class SimulatedAnnealingCore
116116
virtual void calPenalty() = 0;
117117
void calOutlinePenalty();
118118
void calWirelength();
119-
void computeWLForClusterOfUnplacedIOPins(const T& macro,
120-
const T& unplaced_ios,
121-
float net_weight);
119+
float computeNetsWireLength(const std::vector<BundledNet>& nets) const;
120+
double computeWLForClusterOfUnplacedIOPins(const T& macro,
121+
const T& unplaced_ios,
122+
float net_weight) const;
122123
bool isOutsideTheOutline(const T& macro) const;
123124
void calGuidancePenalty();
124125
void calFencePenalty();

src/psm/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ set_pdnsim_source_settings
145145
[-bump_size size]
146146
[-bump_interval interval]
147147
[-strap_track_pitch pitch]
148+
[-external_resistance resistance]
148149
```
149150

150151
#### Options
@@ -154,7 +155,8 @@ set_pdnsim_source_settings
154155
| `-bump_dx`,`-bump_dy` | Set the bump pitch to decide the voltage source location. The default bump pitch is 140um. |
155156
| `-bump_size` | Set the bump size. The default bump size is 70um. |
156157
| `-bump_interval` | Set the bump population interval, this is used to depopulate the bump grid to emulate signals and other power connections. The default bump pitch is 3. |
157-
| `-strap_track_pitch` | Sets the track pitck to use for moduling voltage sources as straps. The default is 10x. |
158+
| `-strap_track_pitch` | Sets the track pitch to use for modeling voltage sources as straps. The default is 10x. |
159+
| `-external_resistance` | Set to model the resistance of the package or power network outside the chip/block. The default value is 0.0. |
158160

159161
### Insert Decap Cells
160162
The `insert_decap` command inserts decap cells in the areas with the highest

src/psm/include/psm/pdnsim.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class PDNSim : public odb::dbBlockCallBackObj
5656

5757
// Straps
5858
int strap_track_pitch = 10;
59+
60+
// Source resistance
61+
float resistance = 0.0; // Ohms
5962
};
6063

6164
using IRDropByPoint = std::map<odb::Point, double>;

src/psm/src/connection.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,23 @@ TermConnection::TermConnection(Node* node0, Node* node1)
204204
{
205205
}
206206

207-
Connection::Resistance TermConnection::getResistance(
208-
const ResistanceMap& res_map) const
207+
std::string TermConnection::describe() const
209208
{
210-
return kResistance;
209+
return "Terminal Connection";
211210
}
212211

213-
std::string TermConnection::describe() const
212+
/////////////////////////////
213+
214+
FixedResistanceConnection::FixedResistanceConnection(Node* node0,
215+
Node* node1,
216+
Resistance resistance)
217+
: Connection(node0, node1), res_(resistance)
214218
{
215-
return "Terminal Connection";
219+
}
220+
221+
std::string FixedResistanceConnection::describe() const
222+
{
223+
return "Fixed Resistance Connection";
216224
}
217225

218226
} // namespace psm

src/psm/src/connection.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ class TermConnection : public Connection
131131
public:
132132
TermConnection(Node* node0, Node* node1);
133133

134-
Resistance getResistance(const ResistanceMap& res_map) const override;
134+
Resistance getResistance(const ResistanceMap& res_map) const override
135+
{
136+
return kResistance;
137+
}
135138
bool isValid() const override { return true; }
136139

137140
void mergeWith(const Connection* other) override {}
@@ -142,4 +145,23 @@ class TermConnection : public Connection
142145
static constexpr Resistance kResistance = 0.001;
143146
};
144147

148+
class FixedResistanceConnection : public Connection
149+
{
150+
public:
151+
FixedResistanceConnection(Node* node0, Node* node1, Resistance resistance);
152+
153+
Resistance getResistance(const ResistanceMap& res_map) const override
154+
{
155+
return res_;
156+
};
157+
bool isValid() const override { return true; }
158+
159+
void mergeWith(const Connection* other) override {}
160+
161+
std::string describe() const override;
162+
163+
private:
164+
Resistance res_;
165+
};
166+
145167
} // namespace psm

src/psm/src/ir_solver.cpp

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,17 @@ Connection::ResistanceMap IRSolver::getResistanceMap(sta::Corner* corner) const
431431
}
432432

433433
Connection::ConnectionMap<Connection::Conductance>
434-
IRSolver::generateConductanceMap(sta::Corner* corner) const
434+
IRSolver::generateConductanceMap(
435+
sta::Corner* corner,
436+
const std::vector<std::unique_ptr<Connection>>& connections) const
435437
{
436438
const utl::DebugScopedTimer timer(
437439
logger_, utl::PSM, "timer", 1, "Generate conductance map: {}");
438440

439441
const Connection::ResistanceMap resistance = getResistanceMap(corner);
440442

441443
Connection::ConnectionMap<Connection::Conductance> conductance;
442-
for (const auto& conn : network_->getConnections()) {
444+
for (const auto& conn : connections) {
443445
const auto res = conn->getResistance(resistance);
444446
conductance[conn.get()] = 1.0 / res;
445447
}
@@ -985,7 +987,33 @@ void IRSolver::solve(sta::Corner* corner,
985987
voltages.clear();
986988
currents.clear();
987989

988-
const auto conductance = generateConductanceMap(corner);
990+
// Build source map
991+
std::vector<std::unique_ptr<SourceNode>> real_src_nodes;
992+
Voltage src_voltage
993+
= generateSourceNodes(source_type, source_file, corner, real_src_nodes);
994+
995+
std::vector<std::unique_ptr<SourceNode>> src_nodes;
996+
std::vector<std::unique_ptr<Connection>> src_conns;
997+
// If resistance is set, add connection from source nodes to new source and
998+
// connect
999+
if (generated_source_settings_.resistance > 0) {
1000+
src_nodes.reserve(real_src_nodes.size());
1001+
src_conns.reserve(real_src_nodes.size());
1002+
for (const auto& real_src_node : real_src_nodes) {
1003+
src_conns.push_back(std::make_unique<FixedResistanceConnection>(
1004+
real_src_node->getSource(),
1005+
real_src_node.get(),
1006+
generated_source_settings_.resistance));
1007+
src_nodes.push_back(std::make_unique<SourceNode>(real_src_node.get()));
1008+
}
1009+
} else {
1010+
src_nodes = std::move(real_src_nodes);
1011+
real_src_nodes.clear();
1012+
}
1013+
1014+
// Build conductance map
1015+
Connection::ConnectionMap<Connection::Conductance> conductance
1016+
= generateConductanceMap(corner, network_->getConnections());
9891017
debugPrint(logger_,
9901018
utl::PSM,
9911019
"stats",
@@ -997,23 +1025,34 @@ void IRSolver::solve(sta::Corner* corner,
9971025
dumpConductance(conductance, "cond");
9981026
}
9991027

1000-
const auto node_connections = getNodeConnectionMap(conductance);
1028+
std::map<Node*, Connection::ConnectionSet> node_connections
1029+
= getNodeConnectionMap(conductance);
10011030
Node::NodeSet all_nodes;
10021031
for (const auto& [node, conns] : node_connections) {
10031032
all_nodes.insert(node);
10041033
}
10051034

1006-
const Power total_power = buildNodeCurrentMap(corner, currents);
1035+
// Add source conductance
1036+
if (!src_conns.empty()) {
1037+
const auto src_conductance = generateConductanceMap(corner, src_conns);
1038+
for (const auto& [conn, cond] : src_conductance) {
1039+
conductance[conn] = cond;
1040+
}
1041+
for (const auto& [node, conns] : getNodeConnectionMap(src_conductance)) {
1042+
node_connections[node].insert(conns.begin(), conns.end());
1043+
}
1044+
}
10071045

1008-
// Build source map
1009-
std::vector<std::unique_ptr<SourceNode>> src_nodes;
1010-
Voltage src_voltage
1011-
= generateSourceNodes(source_type, source_file, corner, src_nodes);
1046+
const Power total_power = buildNodeCurrentMap(corner, currents);
10121047

10131048
// Solve
10141049
// create vector of nodes
10151050
std::map<Node*, std::size_t> node_index = assignNodeIDs(all_nodes);
10161051
const std::map<Node*, std::size_t> real_node_index = node_index;
1052+
for (const auto& [node, id] :
1053+
assignNodeIDs(real_src_nodes, node_index.size())) {
1054+
node_index[node] = id;
1055+
}
10171056
for (const auto& [node, id] : assignNodeIDs(src_nodes, node_index.size())) {
10181057
node_index[node] = id;
10191058
}
@@ -1052,6 +1091,7 @@ void IRSolver::solve(sta::Corner* corner,
10521091
if (logger_->debugCheck(utl::PSM, "dump", 1)) {
10531092
network_->dumpNodes(node_index);
10541093
dumpMatrix(g_matrix, "G");
1094+
dumpVector(j_vector, "J");
10551095
}
10561096
logger_->error(
10571097
utl::PSM,
@@ -1576,7 +1616,8 @@ Connection::ConnectionMap<IRSolver::Current> IRSolver::generateCurrentMap(
15761616
{
15771617
const auto& voltages = voltages_.at(corner);
15781618
Connection::ConnectionMap<IRSolver::Current> currents;
1579-
for (const auto& [connection, cond] : generateConductanceMap(corner)) {
1619+
for (const auto& [connection, cond] :
1620+
generateConductanceMap(corner, network_->getConnections())) {
15801621
if (connection->hasITermNode() || connection->hasBPinNode()) {
15811622
continue;
15821623
}

src/psm/src/ir_solver.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ class IRSolver
143143
sta::Corner* corner) const;
144144

145145
Connection::ConnectionMap<Connection::Conductance> generateConductanceMap(
146-
sta::Corner* corner) const;
146+
sta::Corner* corner,
147+
const std::vector<std::unique_ptr<Connection>>& connections) const;
147148
Voltage generateSourceNodes(
148149
GeneratedSourceType source_type,
149150
const std::string& source_file,

src/psm/src/pdnsim.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ void PDNSim::setGeneratedSourceSettings(const GeneratedSourceSettings& settings)
205205
if (settings.strap_track_pitch > 0) {
206206
generated_source_settings_.strap_track_pitch = settings.strap_track_pitch;
207207
}
208+
if (settings.resistance > 0) {
209+
generated_source_settings_.resistance = settings.resistance;
210+
}
208211
}
209212

210213
void PDNSim::clearSolvers()

0 commit comments

Comments
 (0)