TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
router.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// TraceMaker's detailed router, version 1 (roadmap M4; design doc 05 §2, §5).
4//
5// Octilinear A* on a fine lattice (optimal under its cost model), with legality decided lazily by exact
6// clearance tests against the DRC's rule engine, then exact verification of every committed segment and via.
7#include <array>
8#include <atomic>
9#include <cstdint>
10#include <string>
11#include <vector>
12
13#include "core/events.hpp"
14#include "model/board.hpp"
15#include "model/rules.hpp"
17
18namespace tmk::route {
19
20// The copper of one routed connection, keyed by its two pads: what a later run can start from (RouterOptions::warm).
21struct ConnRoute {
22 int pad_a = -1, pad_b = -1;
23 std::vector<model::Track> tracks;
24 std::vector<model::Via> vias;
25};
26
28 Coord pitch = 0; // lattice pitch; 0 = automatic from net-class widths and clearances
29 // Auto pitch multiplier on small lattices (< 1M points per layer): a finer lattice finds fan-outs the default one
30 // misses and small boards have the time for it (doc 05 §25).
31 double pitch_scale_small = 1.0;
32 bool fine_variant = true; // portfolio: the cheap-vias variant routes small boards at half pitch
33 double pitch_scale = 1.0; // auto pitch multiplier, applied only on large lattices (>= 3M points per layer)
34 double time_limit_s = 120; // wall-clock safety limit for the whole run
35 // Portfolio with more variants than threads: successive halving (Jamieson and Talwalkar, AISTATS 2016) instead of
36 // running only `threads` variants. Every variant runs on a small budget, the better half runs again on twice as
37 // much, until `threads` variants are left; each rung takes an equal share of the wall time (or work) that
38 // `threads` variants would have used. Runs restart from scratch at each rung (a router run cannot be resumed).
39 bool halving = false;
40 long work_budget = 0; // deterministic budget in search expansions (0 = none): same input + seed => same output
41 // Per search attempt. One variant at a fixed budget prefers 1M (10 hard boards: 3M / 2M / 1M / 750k / 500k routed
42 // 8,285 / 8,309 / 8,381 / 8,371 / 8,363), but the 8-variant 120 s tiers did not confirm it (tier B 5,167 -> 5,161,
43 // tier C 9,523 -> 9,512 and 63.3 % -> 60.0 % clean), so it stays 3M (doc 05 §13; --max-expansions to experiment).
44 long max_expansions = 3'000'000;
45 bool reach_verify = false; // test only: run the A* even where the pre-check proved no path, count mismatches
46 int reach_check = 1; // flood-fill reachability check before strict searches (exact): 0 off, 1 likely failures, 2 all
47 // Late reachability proof (doc 05 §62, D154): a strict search still open after this many expansions floods from both ends; when one
48 // end's region runs out first there is no path (exact) and the search stops. 0 = off. Up to reach_after_cap flood cells (0 = no cap).
49 long reach_after = 100'000;
50 long reach_after_cap = 10'000;
51 long field_after = 0; // > 0: the cost-to-go field is built only when a search has expanded this many states (doc 05 §62)
52 bool tie_deep = false; // A* ties on f go to the state with the larger g (the deeper one) instead of the lower state index
53 bool bend_states = true; // direction in the A* state (exact bend costs) vs. parent-direction approximation
54 double heuristic_weight = 1.0;
55 // Plane-aware routing of all-SMD boards (doc 05 §26), all opt-in:
56 bool soft_zones = false; // zone fills do not block other nets (refilled afterwards); unused fills become plane targets
57 bool via_in_pad = false; // inner balls / enclosed SMD pads may take a minimum-size via in the pad
58 bool vias_off_pads = false; // vias keep clear of SMD pads narrower than vias_off_pads_below_mm (except via-in-pad)
60 bool field_heuristic = true; // GPU cost-to-go field as the A* heuristic on large windows
61 int field_min_cells = 60'000; // window size (lattice points x layers) from which the field is used
62 int gpu_device = 0; // GPU backend device for fields (-1 = CPU reference)
63 int max_attempts = 4; // per connection (window growth and learned blocks between attempts)
64 int soft_attempts = 3; // window sizes tried by negotiated searches
65 double via_cost_mm = 3.0; // equivalent track length of one via
66 bool allow_vias = true;
67 double polish_fraction = 0; // share of the budget reserved for rebuilding the open connections of the best state (doc 16)
68 int polish_trials = 20; // seeded orders tried per open connection in the polish
69 int lns_open_trials = 0; // regional rebuild of open connections: seeded orders tried per open connection (0 = off, doc 16 F4)
70 double lns_open_radius_mm = 2.5; // copper within this distance of the open connection's first pad is lifted
71 double layer_dir_pen = -1; // negative = automatic (-1: 0.3; otherwise the strength is the absolute value) on breakout boards only, else 0; extra cost (pitches per orthogonal step) against a layer's preferred direction: even layers horizontal, odd vertical (doc 16)
72 bool layer_dir_swap = false; // preferred directions the other way round: even layers vertical, odd horizontal
73 double package_pen = -1; // -1 = automatic (3 on a two-layer board with a ball-grid package, else 0); pitches per lattice step for tracks on the pad layer inside a ball-grid package (doc 16 F3; 0 = off)
74 // Strict searches from the crowded end (doc 05 §55, M20 C5): a strict search starts from the end with more routed copper of other nets
75 // and more pads of other nets of its own part near it. A boxed-in source is proved in a few expansions; a boxed-in target only after the
76 // search has flooded its window, which on the failing tier B-D boards spent most of the budget of the first pass.
77 bool crowded_source = false;
78 bool crowded_portfolio = true; // crowded_source in four of the portfolio's designed eight variants (1, 5, 6, 7; D143)
79 bool layer_assign_angle = false; // layer preference by chord direction instead of by crossings (uses layer_assign_pen)
80 bool layer_assign = false; // doc 16 F2: prefer, per connection, the layer that leaves the fewest crossings (two-layer boards)
81 double layer_assign_pen = 0.4; // pitches per lattice step on the other layer
82 bool strict_first = true; // the first pass is strict (no crossing of routed copper); off: negotiate from the first pass
83 bool rip_up = true; // negotiated rip-up and reroute (design doc 05 §6 rung R2, doc 06 §3)
84 double history_weight = 2.0; // PathFinder history: pitches of cost per recorded conflict on a cell
85 int max_victims = 0; // a negotiated route may rip at most this many connections at once (0 = no limit)
86 double txn_temp = -1; // transactional negotiation: a route that loses k connections net is kept with probability exp(-k / txn_temp) (0 = never, -1 = automatic: 1.5 on a breakout board)
87 int txn_cool = 0; // 1: the temperature falls linearly to zero over the work budget (simulated-annealing schedule)
88 int stall_passes = 0; // > 0: a restart begins when this many passes in a row set no new best for the run since its last restart
89 long txn_cap = 0; // transactional negotiation: expansion cap of each victim's re-route search (0 = none)
90 int txn_depth = 0; // transactional negotiation: victims that cannot be re-routed strictly get a nested transaction of their own, this deep
91 int txn_nested = 4; // nested transactions allowed per top-level transaction
92 int field_cache_mb = 0; // > 0: cost-to-go fields are kept (this many MB per router) and reused when every input is identical; results are unchanged
93 int flood_work_pct = 100; // reachability-flood cells count this percent of an expansion against the work budget (a flood cell costs far less time)
94 int field_prefill = 0; // 1: fill a class's fixed-copper cache for the whole board before its first field, so fields depend on nothing learned later (and can be cached)
95 int tidy = 0; // > 0: every this many passes, with connections still open, each routed connection is re-routed alone and kept if shorter (frees room)
96 int txn_orders = 1; // transactional negotiation: orders tried for re-routing the victims (the ones that failed go first in the next try)
97 int breakout_profile = 1; // 1: a breakout board (D98) also gets reach_check 2, flood_work_pct 25, field prefill and cache (when those are at their defaults)
98 const std::vector<ConnRoute>* warm = nullptr; // start from these routes (a previous result's conn_routes): they are kept, negotiation starts at once
99 std::string state_out; // portfolio: after every round the best routes so far are written here (atomically), so an interrupted or out-of-time run can be resumed
100 std::string state_in; // portfolio: start from the routes saved in this file (written by state_out); a missing file is ignored
101 bool relax_late = false; // with relax: plain rounds under the board's rules first; when they stall, start the stages afresh (not from the stalled state), and keep the best legal result of all
102 bool relax = false; // portfolio: relax, route, legalise: ramp stages at 60 % and 80 % of the board's clearance with legalisation and breathing between (D104); needs round_work (20 M by default)
103 double ramp_from_mm = 0; // portfolio: > 0 starts at this clearance (every class and the board minimum lowered by the difference) and raises it by ramp_step_mm per stage up to the board's own; each stage warm-starts from the last one's routes that are still legal (clearance continuation, doc 16 §12.3)
104 double ramp_step_mm = 0.005; // clearance added per stage
105 int ramp_rounds = 2; // a ramp stage ends after this many rounds in a row without gain over the best round of the stage (or when complete)
106 int ramp_cycle = 0; // > 0: when the final stage (the board's rules) has not improved for ramp_stall rounds, go back this many stages and climb again ("breathing"); the best result under the board's rules is returned
107 bool ramp_late = false; // start at the board's rules and use the ramp (with ramp_cycle) only once those stall
108 int ramp_fresh = 0; // > 0: every n-th breathing cycle starts from nothing instead of the best state (a new topology; the best result under the board's rules is kept)
109 int ramp_stall = 3; // rounds without improvement at the final stage before breathing
110 int island_slack = -1; // portfolio rounds: >= 0 lets every variant continue the next round from its own final state when that routes at least (best - island_slack) connections, instead of all from the best (islands; the best state ever seen is returned)
111 bool keep_final = false; // also return the live state at the end of the run (RouteResult::final_routes)
112 std::vector<model::Track> warm_tracks; // copper of a routed board (--warm-pcb) to start from: a net with one connection takes all of its tracks and vias; only what is legal under this board's rules is kept
113 std::vector<model::Via> warm_vias;
114 double legalize_subdivide_mm = 0; // > 0 with legalize: route tracks are cut into pieces of at most this length so they can bend (route/legalize.hpp)
115 bool legalize = false; // warm start: first move the vertices of the taken-over routes until the board's clearances hold (route/legalize.hpp), then keep what is legal
116 bool state_recheck = false; // warm start: take over only the routes that are legal under this board's rules (continuation from looser rules)
117 int breakout_portfolio = 1; // 1: with more than one variant, a board that looks like a ball-grid breakout gets the breakout portfolio (D101) instead of the designed eight
118 long round_work = 0; // portfolio: > 0 gives every round this work budget (instead of splitting the total), and rounds continue until the board is complete, `rounds` is reached or `time_limit_s` of the whole portfolio is used (--until-complete)
119 int rounds = 0; // portfolio: the work budget is split into this many rounds; after each, every variant continues from the best result so far (0 = automatic: 4 with the breakout portfolio, else 1)
120 int txn = -1; // transactional negotiation (doc 16 §12): a route that rips victims is kept only if the victims can be re-routed
121 // without ripping: 0 = off, 1 = keep ties (net 0), 2 = strict gain only, -1 = automatic (1 on a breakout board, else 0)
122 int max_rips_per_connection = 40; // was 8: at 50 M work on dense breakouts 33 % -> 54 % clean (doc 16 §4)
123 int max_passes = 40; // passes over still-unrouted connections (was 12)
124 // Micro vias (outer layer to the next one, the net class's microvia size) where a through via is blocked, on
125 // boards whose rules allow them (doc 05 §21).
126 bool micro_vias = false;
127 bool blind_vias = false; // use blind/buried vias where a through via is blocked, if the board allows them
128 bool diff_pairs = false; // route P/N pairs together as coupled tracks first (falls back to single routing)
129 // Component rules (doc 15 P3): these net pairs only are routed coupled first when diff_pairs is off (e.g. USB 2.0
130 // D+/D- bound by tm::crules, whose names need not end in P/N or +/-). Empty = none.
131 std::vector<std::pair<model::NetId, model::NetId>> pair_nets;
132 // Intra-pair skew limit for pairs routed coupled (0 = only KiCad custom `skew` rules): the shorter half gets meanders
133 // in the clean-up until the halves differ by at most half of it (length tuning code, doc 05 §15).
134 // Coupled pairs may twist: change layer one half after the other and cross in between, so that a pair whose
135 // pin order is mirrored between its ends can still be routed coupled (doc 05 §24).
136 bool pair_twists = true;
138 // Per-pair limits for RouterOptions::pair_nets (same index; 0 or missing = pair_skew): component rules give each
139 // interface its own limit (USB 2.0 1.27 mm, doc 15 USB2-02).
140 std::vector<Coord> pair_net_skew;
141 bool global_route = false; // plan every connection on a coarse tile graph first; detailed search follows the corridors
142 // Global router v2 (M6): the first search of each connection is confined to its corridor (cells outside are
143 // blocked, window cropped to the corridor); only if that fails do the usual unconfined windows run.
144 bool global_confine = false;
145 // Strict pass with corridors: a connection that cannot be routed inside its corridor goes straight to
146 // negotiation instead of flooding the wide strict windows (on logicbone those failed floods were 76 % of all
147 // search expansions; doc 05 §13).
149 // Global congestion map (M6, doc 05 §16): plan on the tile graph, then charge detailed steps through tiles the
150 // plan fills beyond global_congestion_from eighths of capacity, except near the connection's own ends. No corridors.
151 bool global_congestion = false;
153 double global_congestion_pen = 0.5; // pitches per lattice step, per eighth of capacity above the threshold
154 // Connection planning measures pad copper to pad copper instead of centre to centre (doc 05 §17).
155 bool plan_gap = true;
156 bool optimize = true; // post-routing clean-up: re-route connections to save vias and length
157 bool escape_plan = false; // reserve escape corridors for the pins of dense packages (route/escape.hpp, M9)
158 // Corridors of the review of the EtherCAT shield (reports/realworld/ethercat_qfn_analysis.md, doc 05 §47). All off by default: no change without them.
159 double escape_length_mm = 0; // > 0: perimeter corridors run this far past the package edge (2 mm by default), as far as no fixed copper is in the way (bundles of parallel straight escapes)
160 bool escape_stubs = false; // with the escape plan: a pin offers the end of its (long, straight) corridor as a start point, reached by one exact off-lattice segment at a discount: parallel escapes at the pad pitch, which the lattice cannot draw
161 bool soft_mask_graphics = false; // net-less solder-mask openings drawn as footprint graphics (solder jumpers, MEMS microphones) do not keep tracks and vias out; KiCad flags what lies in them
162 bool soft_copper_graphics = false; // board copper graphics (polygons on a copper layer) take the net of the pads, tracks and vias of the one net they touch (a manual pour), so that net's pins inside are not enclosed and no other net may touch them
163 bool via_drops = false; // pins of dense packages may drop to a via 0.7-1.5 mm out, off the lattice, between the neighbours' tracks (the designer's supply vias), then go on on the other layer
164 bool bundle_escape = false; // doc 05 §50: the connections that leave one side of a dense package for one side of another part are placed first as a block of parallel straight lanes in pin order (route/bundle.hpp); the rest is routed as usual and may not rip the lanes
165 int bundle_min_lanes = 3; // fewer connections than this in a group are left to the ordinary router
166 bool package_tunnels = false; // doc 05 §52: a connection between two perimeter pins of one dense package on one net gets a stub and a via at each pin and its run between them on the other layer (the core rail's tunnel under the package), placed before the search
167 bool supply_first = false; // doc 05 §51: nets with 2+ perimeter pins on one dense package (supply and core nets: +3V3, a core rail) and no pour are routed before everything else and may not be ripped (as --first-nets); the bundles of --bundle-escape are still placed first (placing them after the supply nets was worse: 20 against 13 unrouted on the EtherCAT shield)
168 bool escape_persist = false; // a ripped-up connection gets its pins' corridors back; a corridor is kept while the net has other open connections at that package
169 bool radial_supply = false; // spanning tree: no edge between two pins of one dense package for a net with 3+ pins there (each pin goes to a capacitor or via; the trunk forms outside the escape band)
170 double radial_penalty_mm = 10; // what such an edge costs in the spanning tree
171 bool escape_second_ring = false; // second-ring balls escape between two outer balls instead of by dog-bone
172 // Escape planning version 2 (route/escape_flow.hpp): deep ball-grid arrays get min-cost-flow channel and layer
173 // assignment; other dense packages keep version 1's corridors. Implies escape_plan.
174 bool escape_flow = false;
175 // R6 cut proofs (doc 05 §20): measure every straight line across the board (capacity past fixed copper against
176 // the nets that must cross) and fill RouteResult::over_cuts / tightest_cut. Costs the global router's set-up.
177 bool cut_report = false;
178 bool escape_report = false; // fill RouteResult::escape_rings (pins of deep arrays per ring, and how many connected)
179 int max_restarts = 6; // full restarts (hardest first, history kept) when negotiation stalls
180 double soft_growth = 0.0; // crossing cost grows by this fraction of soft_cost_mm per negotiation pass (PathFinder, doc 16)
181 double soft_cost_mm = 1.0; // base cost of crossing another net's routed copper (before history)
182 std::uint64_t seed = 1;
183 int order = 0; // connection order: 0 shortest first, 1 longest first, 2 shortest first with seeded jitter
184 // Connections to route first ("REF.NUM" pairs, either orientation): learned from earlier failures (doc 06 T3).
185 std::vector<std::pair<std::string, std::string>> priority;
186 std::vector<std::string> first_nets; // routed first, also after restarts; other nets do not rip them (crystal lines)
187 bool first_nets_ordered = false; // route the --first-nets in the order of the list (default: the router's own order within the group)
188 // Nets that are never narrowed below their class width nor given the neck-down via (power nets in a rule-relaxed routing: they have the least margin,
189 // so the relaxation is spent on signals only). Empty = every net may be necked down.
190 std::vector<std::string> no_neck_nets;
191 // Buses (doc 05 §38): groups of nets routed lane by lane. The connections of a group between two components are
192 // routed one after the other in the order of their pins, each steered along the neighbour routed before it, on
193 // the same layers; nets outside the groups do not rip them. `skew` > 0: meanders in the clean-up bring the
194 // members' lengths (tracks and via height, as KiCad's skew check) within it. Empty = off.
195 struct Bus {
196 std::string name;
197 std::vector<model::NetId> nets; // in bus order
199 };
200 std::vector<Bus> buses;
201 bool bus_first = false; // the groups' connections before all others (after first_nets), also after restarts
202 // Path guidance (doc 16 F1): a preferred path for a connection, found by matching its two pad centres. Cells off
203 // the guide cost `guide_pen` pitches per lattice step in every search of that connection (a preference, never a
204 // block), so a guide that does not pass the exact checks only costs search effort. `--guide FILE` fills it
205 // from JSON (experiments); the breakout planner fills it itself.
206 struct GuidePath {
207 geom::Point a{}, b{}; // pad centres of the two ends
208 std::vector<std::array<geom::Point, 2>> segs; // track segments
209 std::vector<int> seg_layer; // copper layer index of each segment
210 std::vector<geom::Point> vias; // through vias (all layers)
211 };
212 std::vector<GuidePath> guides;
213 double guide_pen = 0.1; // pitches per lattice step off the guide
214 double guide_radius = 1.5; // pitches around the guide that count as on it
215 std::string only_net; // debugging: route only this net
216 // Plan the connections and stop: RouteResult::connections and ::unrouted list every connection that is open (reason `not_attempted`), nothing is
217 // searched or committed. A board session (doc 19) lists the open connections of a state this way. Off by default: a run is what it was.
218 bool plan_only = false;
219 std::vector<std::string> skip_nets; // experiments: leave these nets unrouted (e.g. nets a designer would pour)
220 // Layer limits (doc 05 §29; route/layer_limits.hpp turns layer names into these). Layers in no_track_layers get
221 // no new tracks: vias still pass through them and still connect into zone fills there, and pads that exist only
222 // on such layers stay unrouted. layer_cost_pm[l] is the cost of a track on copper layer l per mille of its
223 // length (1000 = normal, never less; missing entries are 1000).
225 std::vector<std::int32_t> layer_cost_pm;
226 // Critical nets (issue #24, doc 05 §44; route_job fills these from --critical-nets and the component rules' roles). `critical` is net name and tier
227 // (1 = most critical). With `critical_first` they are routed before all other nets, tier by tier (after first_nets), also after restarts. A via
228 // costs them `critical_via_mult` times as much (>= 1). A track of theirs over a void of the adjacent reference plane (route/ref_map.hpp) costs
229 // `split_cost` pitches more per lattice step; `split_hard` closes those cells to them instead. All off by default: a run without these options is
230 // the run it was.
231 std::vector<std::pair<std::string, int>> critical;
232 bool critical_first = false;
233 double critical_via_mult = 1.0;
234 double split_cost = 0;
235 bool split_hard = false;
236 double split_min_coverage = 0.3; // a layer is a reference plane when its zone fills cover this share of the board
237 // The board with its zones refilled by the engine, for the reference map: made once by the caller when the file's zones have no fills (every portfolio variant
238 // would otherwise refill the whole board itself). Null = use the board's own fills, refilling here if it has none.
239 std::shared_ptr<const model::Board> reference_fills;
240 // Rule areas and custom rules that exist only in this router's working copy of the board and rules (advice regions, doc 17
241 // §4): never written to the output, judged by the same exact checks as the board's own positional rules (doc 05 §34).
242 std::vector<model::Zone> extra_zones;
243 std::vector<model::CustomRule> extra_rules;
244 // Hints from an advice file (src/advice, doc 17). They are not applied to the variants the portfolio would run
245 // anyway: route_portfolio adds `variants` extra variants that carry them (the next ones of its list, the variants a plain run
246 // with that many more would have added), so the winner of the total order can only be better than without advice,
247 // never worse (rule 4).
248 struct AdviceSet {
249 std::string source; // the advice file, for messages
250 std::vector<std::pair<std::string, std::string>> priority; // "REF.NUM" pairs routed first (as RouterOptions::priority)
251 std::vector<std::string> first_nets; // as RouterOptions::first_nets
252 model::LayerMask no_track_layers = 0; // added to RouterOptions::no_track_layers
253 std::vector<std::int32_t> layer_cost_pm; // per copper layer, per mille (1000 or more); replaces entries that are lower
254 std::vector<model::Zone> zones; // regions: rule areas (no keep-out flags) ...
255 std::vector<model::CustomRule> rules; // ... and the disallow rules that name them and their nets
256 int variants = 4; // advised variants added to the portfolio (at most the variants that run)
257 bool active() const {
258 return !priority.empty() || !first_nets.empty() || no_track_layers != 0 || !layer_cost_pm.empty() || !zones.empty() || !rules.empty();
259 }
261 events::Sink* sink = nullptr;
262 // Shared by portfolio variants (wall-clock mode only): when one variant has routed everything at time T, the
263 // others may continue until 2T + 5 s; a variant that is complete always finishes its clean-up.
264 std::atomic<double>* deadline = nullptr;
265 // Recording: every variant buffers its events and only the winning variant's are forwarded to `sink`
266 // (each message gains a leading "t" field, seconds since that variant started).
267 bool buffer_events = false;
268};
269
272 int pad_a = -1, pad_b = -1; // board pad indices (pad_b = -1 when the target is a zone fill)
273 int zone_b = -1; // copper item index of a zone fill (plane) to connect into, or -1
274 Coord length = 0; // straight-line distance
275};
276
277// Work profile (doc 10 §2, D88): how many of each costly operation a run did, per phase. The counts depend only on
278// the board, the options and the work budget, so the same job gives the same profile on any machine and at any
279// thread count. The --work budget charges expansions and flood cells; the other counts are what it does not charge.
281 long expansions = 0; // A* states expanded (strict, negotiated and coupled-pair searches)
282 long flood_cells = 0; // cells visited by the reachability pre-check
283 long searches = 0; // A* searches and pre-checks started
284 long cell_checks = 0; // lattice points whose legality a search evaluated (per-search cache misses)
285 long fixed_checks = 0; // fixed-copper legality computations (per-class cache misses, tracks and vias)
286 long field_cells = 0; // cost-to-go field cells computed (window x layers per field)
287 long fields = 0;
288 long commits = 0; // found paths checked exactly before committing
289 long rips = 0; // routed connections ripped up by negotiation
291};
292enum class WorkPhase { Setup, FirstPass, Negotiation, Cleanup }; // setup: plan, escape reservations, coupled pairs
293inline constexpr int kWorkPhases = 4;
296 std::array<WorkCounts, kWorkPhases> phase{};
298};
299
301 std::vector<model::Track> tracks; // new copper, in commit order
302 std::vector<model::Via> vias;
303 std::vector<ConnRoute> conn_routes; // the same copper per connection (best state), for a warm start
304 std::vector<ConnRoute> final_routes; // the state the search ended in (RouterOptions::keep_final): legal, perhaps worse than the best
306 int connections = 0, routed = 0;
307 long expansions = 0;
308 long pair_work = 0; // the part of `expansions` spent in coupled pair searches (closed states and leg checks)
309 int rips = 0, passes = 0;
310 int enclosed = 0; // searches that proved the source boxed in (no larger window tried)
311 long nogood_skips = 0; // attempts skipped because an identical attempt already failed
312 int necked = 0; // connections routed at the neck-down width
313 int restarts = 0;
314 int lns_fixed = 0; // open connections closed by the regional rebuild (doc 16 F4)
315 int tidied = 0; // connections shortened by tidy sweeps
316 int txn_tried = 0, txn_kept = 0; // transactional negotiation: routes with victims tried, and kept
317 int optimized = 0;
318 int pairs = 0;
320 // Buses: connections routed as a lane of their group (leaders and the members that followed one), and connections
321 // of a group routed otherwise ("left the bus"), in the state returned.
322 int bus_lanes = 0, bus_left = 0;
323 // Bundle escapes (--bundle-escape): groups found, groups with a spine, connections in them, lanes placed (in the state returned).
325 int tunnels = 0; // package tunnels placed (--package-tunnels)
326 int micro_vias = 0; // micro vias placed
327 int blind_vias = 0; // blind/buried vias placed
328 double escape_corridor_mm = 0; // total length of the corridors reserved (centrelines, version 1)
329 int package_pin_edges = 0; // spanning-tree edges between two pins of one dense package, for nets with 3+ pins there (--radial-supply makes them rarer)
330 int escape_reclaimed = 0; // --escape-persist: corridors given back to the pins of a ripped-up connection
331 int escape_corridors = 0; // escape corridors reserved (M9) // nets brought into their custom length range by meanders // differential pairs routed coupled // connections improved by the clean-up pass
332 // With escape_report: per ring of the deep arrays (index 0 = perimeter), {pins to route, pins with every
333 // connection routed}.
334 std::vector<std::pair<int, int>> escape_rings;
335 // With cut_report: lines across the board that more nets must cross than tracks fit, and the tightest line.
336 std::vector<CutLine> over_cuts;
338 double seconds = 0;
341 std::vector<std::string> failures; // one line per unrouted connection
342 // One unrouted connection of the state returned, structured for the stuck report (doc 17 §3): where it is, why the
343 // last attempt failed (a code, and the search's own words), how often it was ripped or failed, and which nets stood in the way.
344 struct Unrouted {
345 std::string net, a, b; // "REF.NUM" (b = "zone" for plane connections)
346 std::string reason; // code: boxed_in, exact_check, rip_limit, ripped_not_rerouted, layer_limit, out_of_budget, rolled_back, not_attempted, no_legal_path
347 std::string why; // the last explanation as the router wrote it (net and pad names are the board's)
348 int rips = 0, fails = 0;
349 int pad_a = -1, pad_b = -1; // board pad indices (pad_b = -1: a zone fill)
350 geom::Point pos_a{}, pos_b{}; // pad centres (pos_b = pos_a for a zone)
351 std::vector<std::string> blockers; // nets whose routed copper the last rejected route would have had to rip (at most 6)
352 };
353 std::vector<Unrouted> unrouted;
354 bool time_limited = false; // the wall-clock limit (--time), not the work budget, ended a search: the result depends on machine speed
355};
356
357// The reason code of a failure explanation (RouteResult::Unrouted::reason). The text is matched, not parsed: the
358// router's explanations are sentences, and the code is only the class of the cause.
359std::string failure_reason_code(const std::string& why);
360
361// Runs several differently configured routers (portfolio variants) and keeps the best result. Variant i is a pure
362// function of (base options, i): it never depends on the thread count, and with a work budget each variant's result
363// is deterministic. The variants are scheduled on `threads` worker threads (0 = one per variant) in index order and
364// the winner is the minimum of a total order (most connections routed, then fewest vias, then shortest copper, then
365// the lowest variant index), so with `base.work_budget` > 0 the output is the same for any `threads` (requirement
366// N3, decision D47). Only the first variant streams events live.
369 int best_variant = 0; // position in `variants`
370 std::vector<int> indices; // portfolio variant index per position
371 std::vector<std::string> variants; // description per variant
372 std::vector<int> routed; // routed count per variant
373 std::vector<double> seconds; // wall time per variant (its own clock)
374 std::vector<WorkProfile> work; // work profile per variant
375};
376// `variants`: how many variants to run (the first `variants` of the portfolio); `pick`: which variant indices to
377// run instead (non-empty: overrides `variants`). `threads`: concurrency only (0 = one thread per variant).
378PortfolioResult route_portfolio(const model::Board& board, const model::DesignRules& rules, const RouterOptions& base, int variants,
379 const std::vector<int>& pick = {}, int threads = 0);
381// The portfolio's total order on results: true when `a` beats `b` (more routed, then fewer connections off their bus lanes, then
382// fewer vias, then shorter copper). Ties are not "better": the caller keeps the earlier result.
384// Variant indices from here up are the advised copies the portfolio adds when RouterOptions::advice is active (position
385// k of the advice's variants has index kAdvisedIndex + k).
386inline constexpr int kAdvisedIndex = 1000;
387
388class Router {
389 public:
390 Router(const model::Board& board, const model::DesignRules& rules, RouterOptions opt);
392
393 private:
394 struct Impl;
395 const model::Board& in_;
396 const model::DesignRules& rules_;
397 RouterOptions opt_;
398};
399
400} // namespace tmk::route
The board model (design doc 02 §3): every object TraceMaker reads from a .kicad_pcb,...
Router(const model::Board &board, const model::DesignRules &rules, RouterOptions opt)
RouteResult run()
Event sink for live visualisation and replay (design doc 02 §7, protocol in docs/13-viewer-protocol....
Global routing on a coarse 3-D tile graph (design doc 05 §4 and §19, roadmap M6; CPU,...
std::int32_t NetId
0 = no net
Definition board.hpp:21
std::uint64_t LayerMask
bit i = copper layer i in stack order (0 = F.Cu, last = B.Cu)
Definition board.hpp:22
constexpr int kWorkPhases
Definition router.hpp:293
constexpr int kAdvisedIndex
Variant indices from here up are the advised copies the portfolio adds when RouterOptions::advice is ...
Definition router.hpp:386
std::string failure_reason_code(const std::string &why)
The reason code of a failure explanation (RouteResult::Unrouted::reason).
PortfolioResult route_portfolio(const model::Board &board, const model::DesignRules &rules, const RouterOptions &base, int variants, const std::vector< int > &pick={}, int threads=0)
variants: how many variants to run (the first variants of the portfolio); pick: which variant indices...
bool route_result_better(const RouteResult &a, const RouteResult &b)
The portfolio's total order on results: true when a beats b (more routed, then fewer connections off ...
int portfolio_size()
const char * work_phase_name(WorkPhase p)
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Definition units.hpp:12
Design rules as KiCad defines them (design doc 08 §3–4): board minimums and net classes from the ....
The copper of one routed connection, keyed by its two pads: what a later run can start from (RouterOp...
Definition router.hpp:21
std::vector< model::Via > vias
Definition router.hpp:24
std::vector< model::Track > tracks
Definition router.hpp:23
int zone_b
copper item index of a zone fill (plane) to connect into, or -1
Definition router.hpp:273
int pad_b
board pad indices (pad_b = -1 when the target is a zone fill)
Definition router.hpp:272
Coord length
straight-line distance
Definition router.hpp:274
A straight line across the whole board and what has to cross it (escalation rung R6,...
Runs several differently configured routers (portfolio variants) and keeps the best result.
Definition router.hpp:367
std::vector< int > indices
portfolio variant index per position
Definition router.hpp:370
int best_variant
position in variants
Definition router.hpp:369
std::vector< WorkProfile > work
work profile per variant
Definition router.hpp:374
std::vector< std::string > variants
description per variant
Definition router.hpp:371
std::vector< double > seconds
wall time per variant (its own clock)
Definition router.hpp:373
std::vector< int > routed
routed count per variant
Definition router.hpp:372
One unrouted connection of the state returned, structured for the stuck report (doc 17 §3): where it ...
Definition router.hpp:344
std::string reason
code: boxed_in, exact_check, rip_limit, ripped_not_rerouted, layer_limit, out_of_budget,...
Definition router.hpp:346
std::string b
"REF.NUM" (b = "zone" for plane connections)
Definition router.hpp:345
std::vector< std::string > blockers
nets whose routed copper the last rejected route would have had to rip (at most 6)
Definition router.hpp:351
std::string why
the last explanation as the router wrote it (net and pad names are the board's)
Definition router.hpp:347
geom::Point pos_b
pad centres (pos_b = pos_a for a zone)
Definition router.hpp:350
int pad_b
board pad indices (pad_b = -1: a zone fill)
Definition router.hpp:349
int tunnels
package tunnels placed (–package-tunnels)
Definition router.hpp:325
double escape_corridor_mm
total length of the corridors reserved (centrelines, version 1)
Definition router.hpp:328
int package_pin_edges
spanning-tree edges between two pins of one dense package, for nets with 3+ pins there (–radial-suppl...
Definition router.hpp:329
int bundle_groups
Bundle escapes (–bundle-escape): groups found, groups with a spine, connections in them,...
Definition router.hpp:324
int micro_vias
micro vias placed
Definition router.hpp:326
int tidied
connections shortened by tidy sweeps
Definition router.hpp:315
long pair_work
the part of expansions spent in coupled pair searches (closed states and leg checks)
Definition router.hpp:308
std::vector< model::Track > tracks
new copper, in commit order
Definition router.hpp:301
std::vector< std::string > failures
one line per unrouted connection
Definition router.hpp:341
int lns_fixed
open connections closed by the regional rebuild (doc 16 F4)
Definition router.hpp:314
int txn_kept
transactional negotiation: routes with victims tried, and kept
Definition router.hpp:316
int escape_reclaimed
–escape-persist: corridors given back to the pins of a ripped-up connection
Definition router.hpp:330
std::vector< std::pair< int, int > > escape_rings
With escape_report: per ring of the deep arrays (index 0 = perimeter), {pins to route,...
Definition router.hpp:334
long nogood_skips
attempts skipped because an identical attempt already failed
Definition router.hpp:311
std::vector< CutLine > over_cuts
With cut_report: lines across the board that more nets must cross than tracks fit,...
Definition router.hpp:336
int bus_lanes
Buses: connections routed as a lane of their group (leaders and the members that followed one),...
Definition router.hpp:322
int blind_vias
blind/buried vias placed
Definition router.hpp:327
std::vector< ConnRoute > conn_routes
the same copper per connection (best state), for a warm start
Definition router.hpp:303
std::vector< ConnRoute > final_routes
the state the search ended in (RouterOptions::keep_final): legal, perhaps worse than the best
Definition router.hpp:304
int escape_corridors
escape corridors reserved (M9) // nets brought into their custom length range by meanders // differen...
Definition router.hpp:331
int enclosed
searches that proved the source boxed in (no larger window tried)
Definition router.hpp:310
std::vector< Unrouted > unrouted
Definition router.hpp:353
int necked
connections routed at the neck-down width
Definition router.hpp:312
bool time_limited
the wall-clock limit (–time), not the work budget, ended a search: the result depends on machine spee...
Definition router.hpp:354
std::vector< model::Via > vias
Definition router.hpp:302
Hints from an advice file (src/advice, doc 17).
Definition router.hpp:248
std::vector< std::int32_t > layer_cost_pm
per copper layer, per mille (1000 or more); replaces entries that are lower
Definition router.hpp:253
model::LayerMask no_track_layers
added to RouterOptions::no_track_layers
Definition router.hpp:252
std::vector< model::CustomRule > rules
... and the disallow rules that name them and their nets
Definition router.hpp:255
std::string source
the advice file, for messages
Definition router.hpp:249
std::vector< model::Zone > zones
regions: rule areas (no keep-out flags) ...
Definition router.hpp:254
int variants
advised variants added to the portfolio (at most the variants that run)
Definition router.hpp:256
std::vector< std::string > first_nets
as RouterOptions::first_nets
Definition router.hpp:251
std::vector< std::pair< std::string, std::string > > priority
"REF.NUM" pairs routed first (as RouterOptions::priority)
Definition router.hpp:250
Buses (doc 05 §38): groups of nets routed lane by lane.
Definition router.hpp:195
std::vector< model::NetId > nets
in bus order
Definition router.hpp:197
Path guidance (doc 16 F1): a preferred path for a connection, found by matching its two pad centres.
Definition router.hpp:206
std::vector< std::array< geom::Point, 2 > > segs
track segments
Definition router.hpp:208
std::vector< geom::Point > vias
through vias (all layers)
Definition router.hpp:210
std::vector< int > seg_layer
copper layer index of each segment
Definition router.hpp:209
geom::Point b
pad centres of the two ends
Definition router.hpp:207
std::vector< std::int32_t > layer_cost_pm
Definition router.hpp:225
int txn
transactional negotiation (doc 16 §12): a route that rips victims is kept only if the victims can be ...
Definition router.hpp:120
int ramp_cycle
> 0: when the final stage (the board's rules) has not improved for ramp_stall rounds,...
Definition router.hpp:106
bool bundle_escape
doc 05 §50: the connections that leave one side of a dense package for one side of another part are p...
Definition router.hpp:164
bool layer_dir_swap
preferred directions the other way round: even layers vertical, odd horizontal
Definition router.hpp:72
double polish_fraction
share of the budget reserved for rebuilding the open connections of the best state (doc 16)
Definition router.hpp:67
bool soft_copper_graphics
board copper graphics (polygons on a copper layer) take the net of the pads, tracks and vias of the o...
Definition router.hpp:162
bool soft_zones
Plane-aware routing of all-SMD boards (doc 05 §26), all opt-in:
Definition router.hpp:56
double package_pen
-1 = automatic (3 on a two-layer board with a ball-grid package, else 0); pitches per lattice step fo...
Definition router.hpp:73
int soft_attempts
window sizes tried by negotiated searches
Definition router.hpp:64
std::vector< std::pair< model::NetId, model::NetId > > pair_nets
Component rules (doc 15 P3): these net pairs only are routed coupled first when diff_pairs is off (e....
Definition router.hpp:131
double txn_temp
transactional negotiation: a route that loses k connections net is kept with probability exp(-k / txn...
Definition router.hpp:86
bool crowded_portfolio
crowded_source in four of the portfolio's designed eight variants (1, 5, 6, 7; D143)
Definition router.hpp:78
model::LayerMask no_track_layers
Layer limits (doc 05 §29; route/layer_limits.hpp turns layer names into these).
Definition router.hpp:224
double soft_cost_mm
base cost of crossing another net's routed copper (before history)
Definition router.hpp:181
bool halving
Portfolio with more variants than threads: successive halving (Jamieson and Talwalkar,...
Definition router.hpp:39
long txn_cap
transactional negotiation: expansion cap of each victim's re-route search (0 = none)
Definition router.hpp:89
int txn_depth
transactional negotiation: victims that cannot be re-routed strictly get a nested transaction of thei...
Definition router.hpp:90
bool global_confine
Global router v2 (M6): the first search of each connection is confined to its corridor (cells outside...
Definition router.hpp:144
bool crowded_source
Strict searches from the crowded end (doc 05 §55, M20 C5): a strict search starts from the end with m...
Definition router.hpp:77
bool optimize
post-routing clean-up: re-route connections to save vias and length
Definition router.hpp:156
std::vector< std::string > no_neck_nets
Nets that are never narrowed below their class width nor given the neck-down via (power nets in a rul...
Definition router.hpp:190
int field_prefill
1: fill a class's fixed-copper cache for the whole board before its first field, so fields depend on ...
Definition router.hpp:94
bool buffer_events
Recording: every variant buffers its events and only the winning variant's are forwarded to sink (eac...
Definition router.hpp:267
bool plan_gap
Connection planning measures pad copper to pad copper instead of centre to centre (doc 05 §17).
Definition router.hpp:155
bool global_route
plan every connection on a coarse tile graph first; detailed search follows the corridors
Definition router.hpp:141
double ramp_step_mm
clearance added per stage
Definition router.hpp:104
bool via_in_pad
inner balls / enclosed SMD pads may take a minimum-size via in the pad
Definition router.hpp:57
bool fine_variant
portfolio: the cheap-vias variant routes small boards at half pitch
Definition router.hpp:32
bool cut_report
R6 cut proofs (doc 05 §20): measure every straight line across the board (capacity past fixed copper ...
Definition router.hpp:177
std::vector< Coord > pair_net_skew
Per-pair limits for RouterOptions::pair_nets (same index; 0 or missing = pair_skew): component rules ...
Definition router.hpp:140
int field_cache_mb
> 0: cost-to-go fields are kept (this many MB per router) and reused when every input is identical; r...
Definition router.hpp:92
int max_restarts
full restarts (hardest first, history kept) when negotiation stalls
Definition router.hpp:179
int max_attempts
per connection (window growth and learned blocks between attempts)
Definition router.hpp:63
bool layer_assign
doc 16 F2: prefer, per connection, the layer that leaves the fewest crossings (two-layer boards)
Definition router.hpp:80
double guide_radius
pitches around the guide that count as on it
Definition router.hpp:214
std::vector< model::Zone > extra_zones
Rule areas and custom rules that exist only in this router's working copy of the board and rules (adv...
Definition router.hpp:242
bool relax
portfolio: relax, route, legalise: ramp stages at 60 % and 80 % of the board's clearance with legalis...
Definition router.hpp:102
bool global_strict_corridor_only
Strict pass with corridors: a connection that cannot be routed inside its corridor goes straight to n...
Definition router.hpp:148
bool field_heuristic
GPU cost-to-go field as the A* heuristic on large windows.
Definition router.hpp:60
std::vector< Bus > buses
Definition router.hpp:200
bool pair_twists
Intra-pair skew limit for pairs routed coupled (0 = only KiCad custom skew rules): the shorter half g...
Definition router.hpp:136
bool blind_vias
use blind/buried vias where a through via is blocked, if the board allows them
Definition router.hpp:127
double lns_open_radius_mm
copper within this distance of the open connection's first pad is lifted
Definition router.hpp:70
bool keep_final
also return the live state at the end of the run (RouteResult::final_routes)
Definition router.hpp:111
std::vector< std::string > skip_nets
experiments: leave these nets unrouted (e.g.
Definition router.hpp:219
bool rip_up
negotiated rip-up and reroute (design doc 05 §6 rung R2, doc 06 §3)
Definition router.hpp:83
int breakout_portfolio
1: with more than one variant, a board that looks like a ball-grid breakout gets the breakout portfol...
Definition router.hpp:117
double guide_pen
pitches per lattice step off the guide
Definition router.hpp:213
int txn_orders
transactional negotiation: orders tried for re-routing the victims (the ones that failed go first in ...
Definition router.hpp:96
bool escape_plan
reserve escape corridors for the pins of dense packages (route/escape.hpp, M9)
Definition router.hpp:157
double pitch_scale
auto pitch multiplier, applied only on large lattices (>= 3M points per layer)
Definition router.hpp:33
double layer_dir_pen
negative = automatic (-1: 0.3; otherwise the strength is the absolute value) on breakout boards only,...
Definition router.hpp:71
std::vector< GuidePath > guides
Definition router.hpp:212
bool escape_second_ring
second-ring balls escape between two outer balls instead of by dog-bone
Definition router.hpp:171
long work_budget
deterministic budget in search expansions (0 = none): same input + seed => same output
Definition router.hpp:40
double layer_assign_pen
pitches per lattice step on the other layer
Definition router.hpp:81
double radial_penalty_mm
what such an edge costs in the spanning tree
Definition router.hpp:170
int txn_cool
1: the temperature falls linearly to zero over the work budget (simulated-annealing schedule)
Definition router.hpp:87
std::vector< model::CustomRule > extra_rules
Definition router.hpp:243
std::string state_in
portfolio: start from the routes saved in this file (written by state_out); a missing file is ignored
Definition router.hpp:100
int order
connection order: 0 shortest first, 1 longest first, 2 shortest first with seeded jitter
Definition router.hpp:183
int max_victims
a negotiated route may rip at most this many connections at once (0 = no limit)
Definition router.hpp:85
const std::vector< ConnRoute > * warm
start from these routes (a previous result's conn_routes): they are kept, negotiation starts at once
Definition router.hpp:98
std::string only_net
debugging: route only this net
Definition router.hpp:215
int field_min_cells
window size (lattice points x layers) from which the field is used
Definition router.hpp:61
bool strict_first
the first pass is strict (no crossing of routed copper); off: negotiate from the first pass
Definition router.hpp:82
double via_cost_mm
equivalent track length of one via
Definition router.hpp:65
double split_min_coverage
a layer is a reference plane when its zone fills cover this share of the board
Definition router.hpp:236
bool first_nets_ordered
route the –first-nets in the order of the list (default: the router's own order within the group)
Definition router.hpp:187
long field_after
> 0: the cost-to-go field is built only when a search has expanded this many states (doc 05 §62)
Definition router.hpp:51
int reach_check
flood-fill reachability check before strict searches (exact): 0 off, 1 likely failures,...
Definition router.hpp:46
bool package_tunnels
doc 05 §52: a connection between two perimeter pins of one dense package on one net gets a stub and a...
Definition router.hpp:166
bool escape_persist
a ripped-up connection gets its pins' corridors back; a corridor is kept while the net has other open...
Definition router.hpp:168
double pitch_scale_small
Auto pitch multiplier on small lattices (< 1M points per layer): a finer lattice finds fan-outs the d...
Definition router.hpp:31
double legalize_subdivide_mm
> 0 with legalize: route tracks are cut into pieces of at most this length so they can bend (route/le...
Definition router.hpp:114
bool layer_assign_angle
layer preference by chord direction instead of by crossings (uses layer_assign_pen)
Definition router.hpp:79
int max_rips_per_connection
was 8: at 50 M work on dense breakouts 33 % -> 54 % clean (doc 16 §4)
Definition router.hpp:122
bool plan_only
Plan the connections and stop: RouteResult::connections and unrouted list every connection that is op...
Definition router.hpp:218
bool diff_pairs
route P/N pairs together as coupled tracks first (falls back to single routing)
Definition router.hpp:128
int lns_open_trials
regional rebuild of open connections: seeded orders tried per open connection (0 = off,...
Definition router.hpp:69
int ramp_stall
rounds without improvement at the final stage before breathing
Definition router.hpp:109
std::vector< std::pair< std::string, std::string > > priority
Connections to route first ("REF.NUM" pairs, either orientation): learned from earlier failures (doc ...
Definition router.hpp:185
bool state_recheck
warm start: take over only the routes that are legal under this board's rules (continuation from loos...
Definition router.hpp:116
double soft_growth
crossing cost grows by this fraction of soft_cost_mm per negotiation pass (PathFinder,...
Definition router.hpp:180
bool legalize
warm start: first move the vertices of the taken-over routes until the board's clearances hold (route...
Definition router.hpp:115
int ramp_fresh
> 0: every n-th breathing cycle starts from nothing instead of the best state (a new topology; the be...
Definition router.hpp:108
int max_passes
passes over still-unrouted connections (was 12)
Definition router.hpp:123
std::shared_ptr< const model::Board > reference_fills
The board with its zones refilled by the engine, for the reference map: made once by the caller when ...
Definition router.hpp:239
bool tie_deep
A* ties on f go to the state with the larger g (the deeper one) instead of the lower state index.
Definition router.hpp:52
bool escape_stubs
with the escape plan: a pin offers the end of its (long, straight) corridor as a start point,...
Definition router.hpp:160
std::vector< model::Track > warm_tracks
copper of a routed board (–warm-pcb) to start from: a net with one connection takes all of its tracks...
Definition router.hpp:112
double escape_length_mm
Corridors of the review of the EtherCAT shield (reports/realworld/ethercat_qfn_analysis....
Definition router.hpp:159
long reach_after
Late reachability proof (doc 05 §62, D154): a strict search still open after this many expansions flo...
Definition router.hpp:49
bool ramp_late
start at the board's rules and use the ramp (with ramp_cycle) only once those stall
Definition router.hpp:107
bool micro_vias
Micro vias (outer layer to the next one, the net class's microvia size) where a through via is blocke...
Definition router.hpp:126
bool reach_verify
test only: run the A* even where the pre-check proved no path, count mismatches
Definition router.hpp:45
bool escape_report
fill RouteResult::escape_rings (pins of deep arrays per ring, and how many connected)
Definition router.hpp:178
int txn_nested
nested transactions allowed per top-level transaction
Definition router.hpp:91
int rounds
portfolio: the work budget is split into this many rounds; after each, every variant continues from t...
Definition router.hpp:119
std::vector< model::Via > warm_vias
Definition router.hpp:113
int breakout_profile
1: a breakout board (D98) also gets reach_check 2, flood_work_pct 25, field prefill and cache (when t...
Definition router.hpp:97
std::vector< std::pair< std::string, int > > critical
Critical nets (issue #24, doc 05 §44; route_job fills these from –critical-nets and the component rul...
Definition router.hpp:231
int ramp_rounds
a ramp stage ends after this many rounds in a row without gain over the best round of the stage (or w...
Definition router.hpp:105
double time_limit_s
wall-clock safety limit for the whole run
Definition router.hpp:34
double global_congestion_pen
pitches per lattice step, per eighth of capacity above the threshold
Definition router.hpp:153
Coord pitch
lattice pitch; 0 = automatic from net-class widths and clearances
Definition router.hpp:28
bool bend_states
direction in the A* state (exact bend costs) vs. parent-direction approximation
Definition router.hpp:53
bool radial_supply
spanning tree: no edge between two pins of one dense package for a net with 3+ pins there (each pin g...
Definition router.hpp:169
events::Sink * sink
Definition router.hpp:261
std::vector< std::string > first_nets
routed first, also after restarts; other nets do not rip them (crystal lines)
Definition router.hpp:186
bool via_drops
pins of dense packages may drop to a via 0.7-1.5 mm out, off the lattice, between the neighbours' tra...
Definition router.hpp:163
int stall_passes
> 0: a restart begins when this many passes in a row set no new best for the run since its last resta...
Definition router.hpp:88
std::string state_out
portfolio: after every round the best routes so far are written here (atomically),...
Definition router.hpp:99
double history_weight
PathFinder history: pitches of cost per recorded conflict on a cell.
Definition router.hpp:84
int island_slack
portfolio rounds: >= 0 lets every variant continue the next round from its own final state when that ...
Definition router.hpp:110
int flood_work_pct
reachability-flood cells count this percent of an expansion against the work budget (a flood cell cos...
Definition router.hpp:93
bool relax_late
with relax: plain rounds under the board's rules first; when they stall, start the stages afresh (not...
Definition router.hpp:101
bool escape_flow
Escape planning version 2 (route/escape_flow.hpp): deep ball-grid arrays get min-cost-flow channel an...
Definition router.hpp:174
bool soft_mask_graphics
net-less solder-mask openings drawn as footprint graphics (solder jumpers, MEMS microphones) do not k...
Definition router.hpp:161
bool supply_first
doc 05 §51: nets with 2+ perimeter pins on one dense package (supply and core nets: +3V3,...
Definition router.hpp:167
long round_work
portfolio: > 0 gives every round this work budget (instead of splitting the total),...
Definition router.hpp:118
double ramp_from_mm
portfolio: > 0 starts at this clearance (every class and the board minimum lowered by the difference)...
Definition router.hpp:103
int tidy
> 0: every this many passes, with connections still open, each routed connection is re-routed alone a...
Definition router.hpp:95
bool global_congestion
Global congestion map (M6, doc 05 §16): plan on the tile graph, then charge detailed steps through ti...
Definition router.hpp:151
int bundle_min_lanes
fewer connections than this in a group are left to the ordinary router
Definition router.hpp:165
int gpu_device
GPU backend device for fields (-1 = CPU reference).
Definition router.hpp:62
bool bus_first
the groups' connections before all others (after first_nets), also after restarts
Definition router.hpp:201
bool vias_off_pads
vias keep clear of SMD pads narrower than vias_off_pads_below_mm (except via-in-pad)
Definition router.hpp:58
std::atomic< double > * deadline
Shared by portfolio variants (wall-clock mode only): when one variant has routed everything at time T...
Definition router.hpp:264
int polish_trials
seeded orders tried per open connection in the polish
Definition router.hpp:68
long max_expansions
Per search attempt.
Definition router.hpp:44
Work profile (doc 10 §2, D88): how many of each costly operation a run did, per phase.
Definition router.hpp:280
WorkCounts & operator+=(const WorkCounts &o)
long cell_checks
lattice points whose legality a search evaluated (per-search cache misses)
Definition router.hpp:284
long expansions
A* states expanded (strict, negotiated and coupled-pair searches).
Definition router.hpp:281
long field_cells
cost-to-go field cells computed (window x layers per field)
Definition router.hpp:286
long rips
routed connections ripped up by negotiation
Definition router.hpp:289
long searches
A* searches and pre-checks started.
Definition router.hpp:283
long fixed_checks
fixed-copper legality computations (per-class cache misses, tracks and vias)
Definition router.hpp:285
long commits
found paths checked exactly before committing
Definition router.hpp:288
long flood_cells
cells visited by the reachability pre-check
Definition router.hpp:282
WorkCounts total() const
std::array< WorkCounts, kWorkPhases > phase
Definition router.hpp:296