From 95dc15cc084f172a81da7d48ae0f807120c43cf6 Mon Sep 17 00:00:00 2001 From: Mike Inouye Date: Thu, 29 Oct 2026 00:21:21 +0000 Subject: [PATCH 1/4] web: add grt heatmap Signed-off-by: Mike Inouye --- src/web/README.md | 4 ++ src/web/src/tile_generator.cpp | 23 +++++++- src/web/src/tile_generator.h | 9 ++- src/web/test/cpp/TestSaveImage.cpp | 90 +++++++++++++++++++++++++++++- 4 files changed, 121 insertions(+), 5 deletions(-) diff --git a/src/web/README.md b/src/web/README.md index acfb3c30586..9031d792c6f 100644 --- a/src/web/README.md +++ b/src/web/README.md @@ -180,6 +180,7 @@ field and the value is `true` or `false`. | `rows` | false | Row outlines | | `tracks_pref` | false | Preferred-direction tracks | | `rudy` | false | Estimated congestion (RUDY) heatmap overlay | +| `routing_congestion` | false | Global routing congestion heatmap overlay | #### Examples @@ -206,6 +207,9 @@ save_image -web -display_option {routing false} \ # Save with RUDY congestion heatmap overlay save_image -web -display_option {rudy true} layout_rudy.png + +# Save with global routing congestion heatmap overlay +save_image -web -display_option {routing_congestion true} layout_congestion.png ``` ### Save Animated GIF diff --git a/src/web/src/tile_generator.cpp b/src/web/src/tile_generator.cpp index 01233b89883..8a02873c20d 100644 --- a/src/web/src/tile_generator.cpp +++ b/src/web/src/tile_generator.cpp @@ -1124,6 +1124,7 @@ const BoolField kBoolFields[] = { {"mfg_grid", &TileVisibility::mfg_grid, false}, {"gcell_grid", &TileVisibility::gcell_grid, false}, {"rudy", &TileVisibility::rudy, false}, + {"routing_congestion", &TileVisibility::routing_congestion, false}, {"inst_names", &TileVisibility::inst_names, true}, {"inst_pins", &TileVisibility::inst_pins, true}, {"inst_pin_names", &TileVisibility::inst_pin_names, false}, @@ -4225,6 +4226,19 @@ void TileGenerator::drawRudyLayer(std::vector& image, } } +void TileGenerator::drawRoutingCongestionLayer( + std::vector& image, + odb::dbBlock* /*block*/, + const TileFrame& frame, + const TileVisibility& /*vis*/, + const TextSink& /*emit*/) const +{ + auto routing = getHeatMapSource("Routing"); + if (routing) { + drawHeatMap(image, *routing, frame); + } +} + /* static */ std::vector TileGenerator::saveImageLayerOrder( const TileVisibility& vis, @@ -4274,14 +4288,14 @@ std::vector TileGenerator::saveImageLayerOrder( return names; } -const std::array& +const std::array& TileGenerator::pseudoLayerDefs() { // z_index follows the GUI's paint order (renderThread.cpp:1201-1298), where // the manufacturing grid goes down before the routing layers, the instance // names right after them, and access points, regions and the gcell grid on // top. - static const std::array defs = {{ + static const std::array defs = {{ {.name = "_access_points", .shown_by = {{"access_points"}}, .layers_by = {{}}, @@ -4308,6 +4322,11 @@ TileGenerator::pseudoLayerDefs() .layers_by = {}, .painter = &TileGenerator::drawRudyLayer, .z_index = 1003}, + {.name = "_routing_congestion", + .shown_by = {{"routing_congestion"}}, + .layers_by = {}, + .painter = &TileGenerator::drawRoutingCongestionLayer, + .z_index = 1004}, {.name = kInstLabelsLayer, .shown_by = {{"inst_names"}, {"inst_pins", "inst_pin_names"}}, .layers_by = {{"inst_pins", "inst_pin_names"}}, diff --git a/src/web/src/tile_generator.h b/src/web/src/tile_generator.h index 93fa1d2a0cb..4ac5dff7435 100644 --- a/src/web/src/tile_generator.h +++ b/src/web/src/tile_generator.h @@ -324,6 +324,8 @@ struct TileVisibility bool mfg_grid = false; // manufacturing-grid dots, off by default (Qt parity) bool gcell_grid = false; // GCell grid lines, off by default (Qt parity) bool rudy = false; // RUDY congestion heatmap, off by default + bool routing_congestion + = false; // Routing congestion heatmap, off by default // Shapes — other per-layer geometry (not routing sub-types) bool blockages = true; // master obstructions (LEF OBS) @@ -860,7 +862,7 @@ class TileGenerator // Whether this design gives the overlay anything to draw; null is always. bool (TileGenerator::*present)() const = nullptr; }; - static const std::array& pseudoLayerDefs(); + static const std::array& pseudoLayerDefs(); static bool anyGroupOn(const std::vector>& groups, const TileVisibility& vis); @@ -1266,6 +1268,11 @@ class TileGenerator const TileFrame& frame, const TileVisibility& vis, const TextSink& emit) const; + void drawRoutingCongestionLayer(std::vector& image, + odb::dbBlock* block, + const TileFrame& frame, + const TileVisibility& vis, + const TextSink& emit) const; void drawInstLabelsLayer(std::vector& image, odb::dbBlock* block, const TileFrame& frame, diff --git a/src/web/test/cpp/TestSaveImage.cpp b/src/web/test/cpp/TestSaveImage.cpp index dd0db4c4972..b52009844c1 100644 --- a/src/web/test/cpp/TestSaveImage.cpp +++ b/src/web/test/cpp/TestSaveImage.cpp @@ -159,6 +159,7 @@ class SaveImageTest : public tst::Nangate45Fixture vis.access_points = false; vis.gcell_grid = false; vis.rudy = false; + vis.routing_congestion = false; vis.inst_names = false; return vis; } @@ -692,10 +693,11 @@ TEST_F(SaveImageTest, LayerCompositionOrderMatchesClientZIndex) vis.regions = true; vis.gcell_grid = true; vis.rudy = true; + vis.routing_congestion = true; // zIndex on screen: _instances 0, _pins 1, _mfg_grid 2, tech layers 3.., then // _inst_labels 999, _access_points 1000, _regions 1001, _gcell_grid 1002, - // _rudy 1003. + // _rudy 1003, _routing_congestion 1004. const std::vector expected = {"_instances", "_pins", "_mfg_grid", @@ -705,7 +707,8 @@ TEST_F(SaveImageTest, LayerCompositionOrderMatchesClientZIndex) "_access_points", "_regions", "_gcell_grid", - "_rudy"}; + "_rudy", + "_routing_congestion"}; EXPECT_EQ(TileGenerator::saveImageLayerOrder(vis, tech_layers), expected); } @@ -823,6 +826,89 @@ TEST_F(SaveImageTest, RudyHeatmapRendersInSavedImage) << "Enabling rudy heatmap should render additional heatmap pixels"; } +TEST_F(SaveImageTest, ParseFromJsonRoutingCongestionOption) +{ + TileVisibility vis; + EXPECT_FALSE(vis.routing_congestion); + auto json_obj + = boost::json::parse("{\"routing_congestion\":true}").as_object(); + vis.parseFromJson(json_obj); + EXPECT_TRUE(vis.routing_congestion); +} + +class TestRoutingCongestionHeatMap : public web::HeatMapDataSource +{ + public: + explicit TestRoutingCongestionHeatMap(utl::Logger* logger) + : web::HeatMapDataSource(logger, + "Routing Congestion", + "Routing", + "RoutingCongestion") + { + } + + odb::Rect getBounds() const override + { + return getBlock() ? getBlock()->getDieArea() + : odb::Rect(0, 0, 100000, 100000); + } + + protected: + bool populateMap() override + { + addToMap(odb::Rect(20000, 20000, 80000, 80000), 10.0); + return true; + } + + void combineMapData(bool /*base_has_value*/, + double& base, + double new_data, + double /*data_area*/, + double /*intersection_area*/, + double /*rect_area*/) override + { + base = new_data; + } +}; + +TEST_F(SaveImageTest, RoutingCongestionHeatmapRendersInSavedImage) +{ + auto logger = getLogger(); + web::registerHeatMapSource("Routing Congestion", + "Routing", + "RoutingCongestion", + [logger]() { + return std::make_shared< + TestRoutingCongestionHeatMap>(logger); + }); + + const std::string path_no_congestion = tempPng("no_routing_congestion"); + TileVisibility vis_off; + vis_off.routing_congestion = false; + tile_gen_->saveImage( + path_no_congestion, odb::Rect(0, 0, 0, 0), 512, 0, vis_off); + + const std::string path_congestion = tempPng("with_routing_congestion"); + TileVisibility vis_on; + vis_on.routing_congestion = true; + tile_gen_->saveImage(path_congestion, odb::Rect(0, 0, 0, 0), 512, 0, vis_on); + + ASSERT_TRUE(std::filesystem::exists(path_no_congestion)); + ASSERT_TRUE(std::filesystem::exists(path_congestion)); + + unsigned w1 = 0, h1 = 0; + auto pixels_no_congestion = decodePngFile(path_no_congestion, w1, h1); + unsigned w2 = 0, h2 = 0; + auto pixels_congestion = decodePngFile(path_congestion, w2, h2); + + EXPECT_EQ(w1, 512u); + EXPECT_EQ(w2, 512u); + EXPECT_GT(countNonTransparentPixels(pixels_congestion), + countNonTransparentPixels(pixels_no_congestion)) + << "Enabling routing_congestion heatmap should render additional " + "heatmap pixels"; +} + TEST_F(SaveImageTest, LayerCompositionOrderHonorsTechLayerVisibility) { const std::vector tech_layers = {"metal1", "metal2", "metal3"}; From 47c1f3ba51901c3383b8ea8755ba87b742d610c3 Mon Sep 17 00:00:00 2001 From: Mike Inouye Date: Thu, 29 Oct 2026 00:25:52 +0000 Subject: [PATCH 2/4] clang-format Signed-off-by: Mike Inouye --- src/web/test/cpp/TestSaveImage.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/web/test/cpp/TestSaveImage.cpp b/src/web/test/cpp/TestSaveImage.cpp index b52009844c1..094765a93e5 100644 --- a/src/web/test/cpp/TestSaveImage.cpp +++ b/src/web/test/cpp/TestSaveImage.cpp @@ -874,13 +874,10 @@ class TestRoutingCongestionHeatMap : public web::HeatMapDataSource TEST_F(SaveImageTest, RoutingCongestionHeatmapRendersInSavedImage) { auto logger = getLogger(); - web::registerHeatMapSource("Routing Congestion", - "Routing", - "RoutingCongestion", - [logger]() { - return std::make_shared< - TestRoutingCongestionHeatMap>(logger); - }); + web::registerHeatMapSource( + "Routing Congestion", "Routing", "RoutingCongestion", [logger]() { + return std::make_shared(logger); + }); const std::string path_no_congestion = tempPng("no_routing_congestion"); TileVisibility vis_off; From b2d4d4c992e813a6948ee0b2f29d3944f3ec2706 Mon Sep 17 00:00:00 2001 From: Mike Inouye Date: Thu, 29 Oct 2026 18:47:42 +0000 Subject: [PATCH 3/4] address reviewer feedback Signed-off-by: Mike Inouye --- src/web/test/cpp/TestSaveImage.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/web/test/cpp/TestSaveImage.cpp b/src/web/test/cpp/TestSaveImage.cpp index 094765a93e5..8a538a49456 100644 --- a/src/web/test/cpp/TestSaveImage.cpp +++ b/src/web/test/cpp/TestSaveImage.cpp @@ -826,16 +826,6 @@ TEST_F(SaveImageTest, RudyHeatmapRendersInSavedImage) << "Enabling rudy heatmap should render additional heatmap pixels"; } -TEST_F(SaveImageTest, ParseFromJsonRoutingCongestionOption) -{ - TileVisibility vis; - EXPECT_FALSE(vis.routing_congestion); - auto json_obj - = boost::json::parse("{\"routing_congestion\":true}").as_object(); - vis.parseFromJson(json_obj); - EXPECT_TRUE(vis.routing_congestion); -} - class TestRoutingCongestionHeatMap : public web::HeatMapDataSource { public: @@ -881,13 +871,15 @@ TEST_F(SaveImageTest, RoutingCongestionHeatmapRendersInSavedImage) const std::string path_no_congestion = tempPng("no_routing_congestion"); TileVisibility vis_off; - vis_off.routing_congestion = false; + EXPECT_FALSE(vis_off.routing_congestion); tile_gen_->saveImage( path_no_congestion, odb::Rect(0, 0, 0, 0), 512, 0, vis_off); const std::string path_congestion = tempPng("with_routing_congestion"); TileVisibility vis_on; - vis_on.routing_congestion = true; + vis_on.parseFromJson( + boost::json::parse("{\"routing_congestion\":true}").as_object()); + EXPECT_TRUE(vis_on.routing_congestion); tile_gen_->saveImage(path_congestion, odb::Rect(0, 0, 0, 0), 512, 0, vis_on); ASSERT_TRUE(std::filesystem::exists(path_no_congestion)); From ff3d52a74113837f495abae2aa778dc57030a6a2 Mon Sep 17 00:00:00 2001 From: Mike Inouye Date: Tue, 10 Nov 2026 00:48:12 +0000 Subject: [PATCH 4/4] Trigger CI Signed-off-by: Mike Inouye