diff --git a/src/web/README.md b/src/web/README.md index 87e2124744c..75b33a19c64 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 715dd49c067..b6ed72f33d1 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}, @@ -4402,6 +4403,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, @@ -4454,14 +4468,14 @@ std::vector TileGenerator::saveImageLayerOrder( return entries; } -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 = {{}}, @@ -4488,6 +4502,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 4a2fecb21be..92da8959cd8 100644 --- a/src/web/src/tile_generator.h +++ b/src/web/src/tile_generator.h @@ -334,6 +334,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) @@ -914,7 +916,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); // Whether `layer`'s tiles read visible_layers and chiplet_hidden_layers: @@ -1326,6 +1328,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 d5f3b5600a7..6ded5706b8d 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; } @@ -712,10 +713,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", @@ -725,7 +727,8 @@ TEST_F(SaveImageTest, LayerCompositionOrderMatchesClientZIndex) "_access_points", "_regions", "_gcell_grid", - "_rudy"}; + "_rudy", + "_routing_congestion"}; EXPECT_EQ(namesOf(TileGenerator::saveImageLayerOrder(vis, tech_layers)), expected); } @@ -845,6 +848,78 @@ TEST_F(SaveImageTest, RudyHeatmapRendersInSavedImage) << "Enabling rudy heatmap should render additional heatmap pixels"; } +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(logger); + }); + + const std::string path_no_congestion = tempPng("no_routing_congestion"); + TileVisibility vis_off; + 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.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)); + 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