Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
23 changes: 21 additions & 2 deletions src/web/src/tile_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -4402,6 +4403,19 @@ void TileGenerator::drawRudyLayer(std::vector<unsigned char>& image,
}
}

void TileGenerator::drawRoutingCongestionLayer(
std::vector<unsigned char>& 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<PaintLayer> TileGenerator::saveImageLayerOrder(
const TileVisibility& vis,
Expand Down Expand Up @@ -4454,14 +4468,14 @@ std::vector<PaintLayer> TileGenerator::saveImageLayerOrder(
return entries;
}

const std::array<TileGenerator::PseudoLayerDef, 6>&
const std::array<TileGenerator::PseudoLayerDef, 7>&
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<PseudoLayerDef, 6> defs = {{
static const std::array<PseudoLayerDef, 7> defs = {{
{.name = "_access_points",
.shown_by = {{"access_points"}},
.layers_by = {{}},
Expand All @@ -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"}},
Expand Down
9 changes: 8 additions & 1 deletion src/web/src/tile_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<PseudoLayerDef, 6>& pseudoLayerDefs();
static const std::array<PseudoLayerDef, 7>& pseudoLayerDefs();
static bool anyGroupOn(const std::vector<std::vector<const char*>>& groups,
const TileVisibility& vis);
// Whether `layer`'s tiles read visible_layers and chiplet_hidden_layers:
Expand Down Expand Up @@ -1326,6 +1328,11 @@ class TileGenerator
const TileFrame& frame,
const TileVisibility& vis,
const TextSink& emit) const;
void drawRoutingCongestionLayer(std::vector<unsigned char>& image,
odb::dbBlock* block,
const TileFrame& frame,
const TileVisibility& vis,
const TextSink& emit) const;
void drawInstLabelsLayer(std::vector<unsigned char>& image,
odb::dbBlock* block,
const TileFrame& frame,
Expand Down
79 changes: 77 additions & 2 deletions src/web/test/cpp/TestSaveImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<std::string> expected = {"_instances",
"_pins",
"_mfg_grid",
Expand All @@ -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);
}
Expand Down Expand Up @@ -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<TestRoutingCongestionHeatMap>(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<PaintLayer> tech_layers
Expand Down
Loading