Skip to content

Commit 898fa93

Browse files
committed
Merge branch 'master' into drt_msg
2 parents a2cf268 + e30d385 commit 898fa93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+75267
-1855
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,8 @@ if(BUILD_MAN)
176176
install(DIRECTORY ${OPENROAD_HOME}/docs/cat DESTINATION ${OPENROAD_SHARE}/man)
177177
install(DIRECTORY ${OPENROAD_HOME}/docs/html DESTINATION ${OPENROAD_SHARE}/man)
178178
endif()
179+
180+
####################################################################
181+
# Add a configuration for ReleaseWithAsserts
182+
set(CMAKE_CXX_FLAGS_RELEASEWITHASSERTS "${CMAKE_CXX_FLAGS_RELEASE} -UNDEBUG" CACHE STRING "" FORCE)
183+
set(CMAKE_C_FLAGS_RELEASEWITHASSERTS "${CMAKE_C_FLAGS_RELEASE} -UNDEBUG" CACHE STRING "" FORCE)

src/dbSta/include/db_sta/dbNetwork.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ class dbNetwork : public ConcreteNetwork
291291
const Net* highestConnectedNet(Net* net) const override;
292292
bool isSpecial(Net* net);
293293
dbNet* flatNet(const Net* net) const;
294+
Net* getFlatNet(Net* net) const;
294295

295296
////////////////////////////////////////////////////////////////
296297
// Edit functions

src/dbSta/src/dbNetwork.cc

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,7 +2635,9 @@ void dbNetwork::staToDb(const Instance* instance,
26352635

26362636
dbNet* dbNetwork::staToDb(const Net* net) const
26372637
{
2638-
return reinterpret_cast<dbNet*>(const_cast<Net*>(net));
2638+
dbNet* db_net = reinterpret_cast<dbNet*>(const_cast<Net*>(net));
2639+
assert(!db_net || db_net->getObjectType() == odb::dbNetObj);
2640+
return db_net;
26392641
}
26402642

26412643
dbNet* dbNetwork::flatNet(const Net* net) const
@@ -2732,7 +2734,9 @@ void dbNetwork::staToDb(const Pin* pin,
27322734

27332735
dbBTerm* dbNetwork::staToDb(const Term* term) const
27342736
{
2735-
return reinterpret_cast<dbBTerm*>(const_cast<Term*>(term));
2737+
dbBTerm* bterm = reinterpret_cast<dbBTerm*>(const_cast<Term*>(term));
2738+
assert(!bterm || bterm->getObjectType() == odb::dbBTermObj);
2739+
return bterm;
27362740
}
27372741

27382742
void dbNetwork::staToDb(const Term* term,
@@ -2780,20 +2784,26 @@ void dbNetwork::staToDb(const Cell* cell,
27802784
dbMaster* dbNetwork::staToDb(const Cell* cell) const
27812785
{
27822786
const ConcreteCell* ccell = reinterpret_cast<const ConcreteCell*>(cell);
2783-
return reinterpret_cast<dbMaster*>(ccell->extCell());
2787+
auto master = reinterpret_cast<dbMaster*>(ccell->extCell());
2788+
assert(!master || master->getObjectType() == odb::dbMasterObj);
2789+
return master;
27842790
}
27852791

27862792
// called only on db cells.
27872793
dbMaster* dbNetwork::staToDb(const LibertyCell* cell) const
27882794
{
27892795
const ConcreteCell* ccell = cell;
2790-
return reinterpret_cast<dbMaster*>(ccell->extCell());
2796+
auto master = reinterpret_cast<dbMaster*>(ccell->extCell());
2797+
assert(!master || master->getObjectType() == odb::dbMasterObj);
2798+
return master;
27912799
}
27922800

27932801
dbMTerm* dbNetwork::staToDb(const Port* port) const
27942802
{
27952803
const ConcretePort* cport = reinterpret_cast<const ConcretePort*>(port);
2796-
return reinterpret_cast<dbMTerm*>(cport->extPort());
2804+
auto mterm = reinterpret_cast<dbMTerm*>(cport->extPort());
2805+
assert(!mterm || mterm->getObjectType() == odb::dbMTermObj);
2806+
return mterm;
27972807
}
27982808

27992809
dbBTerm* dbNetwork::isTopPort(const Port* port) const
@@ -2841,7 +2851,9 @@ void dbNetwork::staToDb(const Port* port,
28412851

28422852
dbMTerm* dbNetwork::staToDb(const LibertyPort* port) const
28432853
{
2844-
return reinterpret_cast<dbMTerm*>(port->extPort());
2854+
auto mterm = reinterpret_cast<dbMTerm*>(port->extPort());
2855+
assert(!mterm || mterm->getObjectType() == odb::dbMTermObj);
2856+
return mterm;
28452857
}
28462858

28472859
void dbNetwork::staToDb(PortDirection* dir,
@@ -4159,4 +4171,19 @@ void dbNetwork::AxiomCheck()
41594171
}
41604172
}
41614173

4174+
Net* dbNetwork::getFlatNet(Net* net) const
4175+
{
4176+
if (!net) {
4177+
return nullptr;
4178+
}
4179+
// Convert net to a flat net, if not already
4180+
dbNet* db_net;
4181+
dbModNet* db_mod_net;
4182+
staToDb(net, db_net, db_mod_net);
4183+
if (db_mod_net) {
4184+
db_net = findRelatedDbNet(db_mod_net);
4185+
}
4186+
return dbToSta(db_net);
4187+
}
4188+
41624189
} // namespace sta

src/gpl/test/macro03.ok

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,13 @@ Iteration | Overflow | HPWL (um) | HPWL(%) | Penalty | Group
103103
438 | 0.0993 | 7.432882e+09 | | 7.49e-08 |
104104
---------------------------------------------------------------
105105
[INFO GPL-1001] Global placement finished at iteration 438
106-
[INFO GPL-1003] Routability mode iteration count: 0
107106
[INFO GPL-1002] Placed Cell Area 431269.9937
108107
[INFO GPL-1003] Available Free Area 2022140.5120
109108
[INFO GPL-1004] Minimum Feasible Density 0.2200 (cell_area / free_area)
110109
[INFO GPL-1006] Suggested Target Densities:
111110
[INFO GPL-1007] - For 90% usage of free space: 0.2370
112111
[INFO GPL-1008] - For 80% usage of free space: 0.2666
113112
[INFO GPL-1009] - For 50% usage of free space: 0.4265
114-
[INFO GPL-1011] Original area (um^2): 431269.99
115-
[INFO GPL-1012] Total routability artificial inflation: 0.00 (+0.00%)
116-
[INFO GPL-1013] Total timing-driven delta area: 0.00 (+0.00%)
117113
[INFO GPL-1014] Final placement area: 431269.99 (+0.00%)
118114
No differences found.
119115
final hpwl: 8738338844

src/grt/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ cc_library(
4242
srcs = [
4343
"src/fastroute/src/FastRoute.cpp",
4444
"src/fastroute/src/FastRouteRenderer.cpp",
45+
"src/fastroute/src/graph2d.cpp",
4546
"src/fastroute/src/RSMT.cpp",
4647
"src/fastroute/src/RipUp.cpp",
4748
"src/fastroute/src/maze.cpp",
@@ -53,6 +54,7 @@ cc_library(
5354
"src/fastroute/include/AbstractMakeWireParasitics.h",
5455
"src/fastroute/include/FastRoute.h",
5556
"src/fastroute/include/FastRouteRenderer.h",
57+
"src/fastroute/include/Graph2D.h",
5658
],
5759
includes = [
5860
"src/fastroute/include",

src/grt/src/fastroute/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_library(FastRoute4.1
99
src/maze3D.cpp
1010
src/route.cpp
1111
src/utility.cpp
12+
src/graph2d.cpp
1213
)
1314

1415
target_compile_options(FastRoute4.1

src/grt/src/fastroute/include/DataType.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ struct TreeNode
153153
int stackAlias;
154154
};
155155

156+
struct GPoint3D
157+
{
158+
int16_t x = 0;
159+
int16_t y = 0;
160+
int16_t layer = 0;
161+
};
162+
156163
struct Route
157164
{
158165
RouteType type; // type of route: LRoute, ZRoute, MazeRoute
@@ -171,9 +178,7 @@ struct Route
171178

172179
// valid for MazeRoute: a list of grids (n=routelen+1) the route
173180
// passes, (x1, y1) is the first one, but (x2, y2) is the lastone
174-
std::vector<int16_t> gridsX;
175-
std::vector<int16_t> gridsY;
176-
std::vector<int16_t> gridsL;
181+
std::vector<GPoint3D> grids;
177182

178183
// valid for MazeRoute: the number of edges in the route
179184
int routelen;
@@ -189,6 +194,7 @@ struct TreeEdge
189194
int n1, n1a;
190195
int n2, n2a;
191196
Route route;
197+
void convertToMazerouteNet(const TreeNode& p1, const TreeNode& p2);
192198
};
193199

194200
struct StTree

src/grt/src/fastroute/include/FastRoute.h

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "AbstractMakeWireParasitics.h"
1818
#include "DataType.h"
19+
#include "Graph2D.h"
1920
#include "grt/GRoute.h"
2021
#include "odb/geom.h"
2122
#include "stt/SteinerTreeBuilder.h"
@@ -250,7 +251,6 @@ class FastRouteCore
250251
const CostParams& cost_params,
251252
float& slack_th);
252253
void convertToMazeroute();
253-
void updateCongestionHistory(int up_type, bool stop_decreasing, int& max_adj);
254254
int getOverflow2D(int* maxOverflow);
255255
int getOverflow2Dmaze(int* maxOverflow, int* tUsage);
256256
int getOverflow3D();
@@ -259,9 +259,6 @@ class FastRouteCore
259259
int& posY,
260260
int dir,
261261
int& radius);
262-
void str_accu(int rnd);
263-
void InitLastUsage(int upType);
264-
void InitEstUsage();
265262
void SaveLastRouteLen();
266263
void checkAndFixEmbeddedTree(const int net_id);
267264
bool areEdgesOverlapping(const int net_id,
@@ -274,8 +271,7 @@ class FastRouteCore
274271
void routeLShape(const TreeNode& startpoint,
275272
const TreeNode& endpoint,
276273
std::vector<std::pair<short, short>>& blocked_positions,
277-
std::vector<short>& new_route_x,
278-
std::vector<short>& new_route_y);
274+
std::vector<GPoint3D>& new_route);
279275
void convertToMazerouteNet(const int netID);
280276
void setupHeap(const int netID,
281277
const int edgeID,
@@ -349,9 +345,7 @@ class FastRouteCore
349345
int n2,
350346
std::vector<TreeEdge>& treeedges,
351347
int edge_n1n2,
352-
std::vector<int>& gridsX_n1n2,
353-
std::vector<int>& gridsY_n1n2,
354-
std::vector<int>& gridsL_n1n2);
348+
std::vector<GPoint3D>& grids_n1n2);
355349
void updateRouteType13D(int netID,
356350
std::vector<TreeNode>& treenodes,
357351
int n1,
@@ -500,7 +494,7 @@ class FastRouteCore
500494
*/
501495
bool checkRoute2DTree(int netID);
502496
void removeLoops();
503-
void netedgeOrderDec(int netID);
497+
void netedgeOrderDec(int netID, std::vector<OrderNetEdge>& net_eo);
504498
void printTree2D(int netID);
505499
void printEdge2D(int netID, int edgeID);
506500
void printEdge3D(int netID, int edgeID);
@@ -603,19 +597,17 @@ class FastRouteCore
603597

604598
std::vector<FrNet*> nets_;
605599
std::unordered_map<odb::dbNet*, int> db_net_id_map_; // db net -> net id
606-
std::vector<OrderNetEdge> net_eo_;
607-
std::vector<std::vector<int>>
608-
gxs_; // the copy of xs for nets, used for second FLUTE
609-
std::vector<std::vector<int>>
610-
gys_; // the copy of xs for nets, used for second FLUTE
611-
std::vector<std::vector<int>>
612-
gs_; // the copy of vertical sequence for nets, used for second FLUTE
600+
// the copy of xs for nets, used for second FLUTE
601+
std::vector<std::vector<int>> gxs_;
602+
// the copy of xs for nets, used for second FLUTE
603+
std::vector<std::vector<int>> gys_;
604+
// the copy of vertical sequence for nets, used for second FLUTE
605+
std::vector<std::vector<int>> gs_;
613606
std::vector<std::vector<Segment>> seglist_; // indexed by netID, segID
614607
std::vector<OrderNetPin> tree_order_pv_;
615608
std::vector<OrderTree> tree_order_cong_;
616609

617-
multi_array<Edge, 2> v_edges_; // The way it is indexed is (Y, X)
618-
multi_array<Edge, 2> h_edges_; // The way it is indexed is (Y, X)
610+
Graph2D graph2d_;
619611
multi_array<Edge3D, 3> h_edges_3D_; // The way it is indexed is (Layer, Y, X)
620612
multi_array<Edge3D, 3> v_edges_3D_; // The way it is indexed is (Layer, Y, X)
621613
multi_array<int, 2> corr_edge_;
@@ -642,8 +634,6 @@ class FastRouteCore
642634
std::unordered_map<Tile, interval_set<int>, boost::hash<Tile>>
643635
horizontal_blocked_intervals_;
644636

645-
std::set<std::pair<int, int>> h_used_ggrid_;
646-
std::set<std::pair<int, int>> v_used_ggrid_;
647637
std::vector<int> net_ids_;
648638

649639
// Maze 3D variables
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
// Copyright (c) 2019-2025, The OpenROAD Authors
3+
4+
#pragma once
5+
6+
#include <boost/multi_array.hpp>
7+
#include <cstdint>
8+
#include <functional>
9+
#include <set>
10+
#include <utility>
11+
#include <vector>
12+
13+
#include "DataType.h"
14+
15+
namespace grt {
16+
17+
using boost::multi_array;
18+
19+
class Graph2D
20+
{
21+
public:
22+
struct Interval
23+
{
24+
const int lo;
25+
const int hi;
26+
};
27+
28+
void init(int x_grid, int y_grid, int h_capacity, int v_capacity);
29+
void InitEstUsage();
30+
void InitLastUsage(int upType);
31+
void clear();
32+
void clearUsed();
33+
bool hasEdges() const;
34+
35+
uint16_t getUsageH(int x, int y) const;
36+
uint16_t getUsageV(int x, int y) const;
37+
int16_t getLastUsageH(int x, int y) const;
38+
int16_t getLastUsageV(int x, int y) const;
39+
double getEstUsageH(int x, int y) const;
40+
double getEstUsageV(int x, int y) const;
41+
uint16_t getUsageRedH(int x, int y) const;
42+
uint16_t getUsageRedV(int x, int y) const;
43+
double getEstUsageRedH(int x, int y) const;
44+
double getEstUsageRedV(int x, int y) const;
45+
int getOverflowH(int x, int y) const;
46+
int getOverflowV(int x, int y) const;
47+
uint16_t getCapH(int x, int y) const;
48+
uint16_t getCapV(int x, int y) const;
49+
50+
const std::set<std::pair<int, int>>& getUsedGridsH() const;
51+
const std::set<std::pair<int, int>>& getUsedGridsV() const;
52+
53+
void addCapH(int x, int y, int cap);
54+
void addCapV(int x, int y, int cap);
55+
void addEstUsageH(const Interval& xi, int y, double usage);
56+
void addEstUsageH(int x, int y, double usage);
57+
void addEstUsageToUsage();
58+
void addEstUsageV(int x, const Interval& yi, double usage);
59+
void addEstUsageV(int x, int y, double usage);
60+
void addRedH(int x, int y, int red);
61+
void addRedV(int x, int y, int red);
62+
void addUsageH(const Interval& xi, int y, int used);
63+
void addUsageH(int x, int y, int used);
64+
void addUsageV(int x, const Interval& yi, int used);
65+
void addUsageV(int x, int y, int used);
66+
67+
void updateCongestionHistory(int up_type,
68+
int ahth,
69+
bool stop_decreasing,
70+
int& max_adj);
71+
void str_accu(int rnd);
72+
73+
private:
74+
void foreachEdge(const std::function<void(Edge&)>& func);
75+
76+
multi_array<Edge, 2> v_edges_; // The way it is indexed is (X, Y)
77+
multi_array<Edge, 2> h_edges_; // The way it is indexed is (X, Y)
78+
79+
std::set<std::pair<int, int>> h_used_ggrid_;
80+
std::set<std::pair<int, int>> v_used_ggrid_;
81+
};
82+
83+
} // namespace grt

0 commit comments

Comments
 (0)