TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
wirelength.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Wirelength and airwire metrics: weighted half-perimeter wirelength (HPWL) and crossings between the
4// minimum-spanning-tree airwires of different signal nets (doc 04 §3 E).
5#include <array>
6#include <cstdint>
7#include <vector>
8
9#include "place/legality.hpp"
10
11namespace tmk::place {
12
13struct Seg {
15 int net = -1;
16};
17
18// HPWL of one net (unweighted, nm).
19Coord net_hpwl(const Problem& p, const Placement& pl, int net);
20// Σ weight · HPWL over all nets (weights kSignalWeight / kPowerWeight).
21std::int64_t weighted_hpwl(const Problem& p, const Placement& pl);
22// Σ HPWL over all nets, unweighted (nm).
23std::int64_t total_hpwl(const Problem& p, const Placement& pl);
24
25// Via estimate of the side assignment (doc 04 §3 C, D48): a net whose surface-mount pins sit on both sides needs at
26// least one via per pin on its minority side, so it counts min(front, back) such pins. Through-hole pins reach
27// both sides and do not count; pseudo-nets never count. `weighted`: Σ weight · min(...), else Σ min(...).
28std::int64_t side_vias(const Problem& p, const Placement& pl, bool weighted);
29// Front/back surface-mount pin counts of one net in `pl` (as used by side_vias).
30std::array<int, 2> side_counts(const Problem& p, const Placement& pl, int net);
31
32// Minimum spanning tree of the pins (Prim, Manhattan metric, ties by pin order) appended to `out`.
33void net_mst(const std::vector<Point>& pts, int net, std::vector<Seg>& out);
34// True if the two segments cross at a single interior point (touching or collinear overlap does not count).
35bool proper_cross(const Seg& s, const Seg& t);
36// MST airwires of every signal net.
37std::vector<Seg> airwires(const Problem& p, const Placement& pl);
38// Number of crossing pairs of airwires that belong to different signal nets (reference: O(n²)).
39std::int64_t count_crossings(const Problem& p, const Placement& pl);
40
41} // namespace tmk::place
Placement legality (design doc 04 §3 D/E): exact integer tests of courtyards, through-hole obstacles,...
bool proper_cross(const Seg &s, const Seg &t)
True if the two segments cross at a single interior point (touching or collinear overlap does not cou...
std::int64_t count_crossings(const Problem &p, const Placement &pl)
Number of crossing pairs of airwires that belong to different signal nets (reference: O(n²)).
Coord net_hpwl(const Problem &p, const Placement &pl, int net)
HPWL of one net (unweighted, nm).
std::int64_t total_hpwl(const Problem &p, const Placement &pl)
Σ HPWL over all nets, unweighted (nm).
std::int64_t weighted_hpwl(const Problem &p, const Placement &pl)
Σ weight · HPWL over all nets (weights kSignalWeight / kPowerWeight).
std::int64_t side_vias(const Problem &p, const Placement &pl, bool weighted)
Via estimate of the side assignment (doc 04 §3 C, D48): a net whose surface-mount pins sit on both si...
std::vector< Seg > airwires(const Problem &p, const Placement &pl)
MST airwires of every signal net.
std::array< int, 2 > side_counts(const Problem &p, const Placement &pl, int net)
Front/back surface-mount pin counts of one net in pl (as used by side_vias).
void net_mst(const std::vector< Point > &pts, int net, std::vector< Seg > &out)
Minimum spanning tree of the pins (Prim, Manhattan metric, ties by pin order) appended to out.
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Definition units.hpp:12