|
TraceMaker
C++ API of the engine
|
Classes | |
| struct | BundleConn |
| struct | BundleHooks |
| struct | BundleOptions |
| struct | BundleStats |
| struct | TunnelStats |
| Package tunnels (doc 05 §52): a connection between two perimeter pins of one dense package on the same net (the core rail's three pins, the supply pins of a package) goes where the designer puts it: a short stub and a via straight out of each pin, and the run between the two vias on the other layer, under the package. More... | |
| struct | BusGroup |
| struct | ViaHeights |
| The length a via adds to its net in KiCad's length calculation, which its skew check uses (KiCad 10, BOARD_STACKUP::GetLayerDistance): the stackup between the two copper layers the via joins, with the copper of an outer layer in full and of an inner layer by half. More... | |
| struct | BusMember |
| A group as routed, measured on copper. More... | |
| struct | BusStats |
| struct | PairRule |
| What a pair is routed at. More... | |
| struct | Dir2 |
| Octilinear unit direction d (0..7, E, NE, N, NW, W, SW, S, SE with y down) and its left normal, as doubles. More... | |
| struct | PairStats |
| A routed pair, measured on its tracks: a sample of one half counts as coupled where a parallel track of the other half on the same layer lies within coupled_gap edge to edge. More... | |
| struct | EscapeCorridor |
| struct | EscapeOptions |
| struct | EscapeStats |
| struct | DeadPin |
| Escape feasibility (M9 analysis): can each pin of a dense package leave it at all under the board's rules? More... | |
| struct | PartEscape |
| struct | EscapeAnalysisOptions |
| struct | FlowEscapeInput |
| struct | RingPlan |
| Per ring (1 = perimeter) of the planned arrays: how the pins that need routing were assigned. More... | |
| struct | FlowEscapeStats |
| struct | GlobalNet |
| struct | GlobalOptions |
| struct | CutLine |
| A straight line across the whole board and what has to cross it (escalation rung R6, doc 05 §20; the cut argument of Maley, "Single-Layer Wire Routing and Compaction", 1990, at the resolution of the capacity samples). More... | |
| struct | GlobalResult |
| class | HeatGrid |
| struct | LayerLimits |
| struct | LegalizeOptions |
| struct | LegalizeResult |
| class | Obstacles |
| struct | ReferenceMap |
| struct | ConnRoute |
| The copper of one routed connection, keyed by its two pads: what a later run can start from (RouterOptions::warm). More... | |
| struct | RouterOptions |
| struct | Connection |
| struct | WorkCounts |
| Work profile (doc 10 §2, D88): how many of each costly operation a run did, per phase. More... | |
| struct | WorkProfile |
| struct | RouteResult |
| struct | PortfolioResult |
| Runs several differently configured routers (portfolio variants) and keeps the best result. More... | |
| class | Router |
| struct | Point |
Enumerations | |
| enum class | WorkPhase { Setup , FirstPass , Negotiation , Cleanup } |
Functions | |
| std::vector< int > | perimeter_directions (const model::Board &b, const BundleOptions &o) |
| Pins on the perimeter of a dense package and the direction they leave in (index into the 8 octilinear directions: 0 +x, 2 +y, 4 -x, 6 -y). | |
| TunnelStats | route_tunnels (const model::Board &b, const std::vector< BundleConn > &conns, const BundleHooks &h, const BundleOptions &o={}) |
| BundleStats | route_bundles (const model::Board &b, const std::vector< BundleConn > &conns, const BundleHooks &h, const BundleOptions &o={}) |
| Plans and places the bundles of conns (unrouted two-pad connections). Deterministic: groups, lanes and searches are in a fixed order. | |
| bool | natural_less (std::string_view a, std::string_view b) |
| Natural order of two names: runs of digits compare as numbers, everything else byte by byte. | |
| bool | bus_pattern_match (const std::string &pattern, const std::string &net_name) |
| Bus patterns select nets by their full name (KiCad's, with the sheet path: "/D0", "/MEM/DQ3"). | |
| BusGroup | bus_from_option (const model::Board &b, const std::string &spec) |
| "NAME=PATTERN" as given to –bus. | |
| std::vector< BusGroup > | detect_buses (const model::Board &b, int min_members=4) |
| Automatic detection (–buses), conservative: nets whose names differ only in a trailing decimal index ("D0", "A[3]", "/MEM/DQ12"), at least min_members of them with pads on the same two components. | |
| std::optional< Coord > | bus_rule_skew (const drc::RuleEngine &re, const BusGroup &g) |
| The skew limit the board's custom rules give a group: every member must match a rule with a skew constraint (the smallest maximum wins); rules restricted to differential pairs (within_diff_pairs) do not count. | |
| ViaHeights | via_heights (const model::Board &b, const model::DesignRules &rules) |
| double | net_via_length (const model::Board &b, const ViaHeights &vh, model::NetId net, const std::vector< model::Track > &tracks, const std::vector< model::ArcTrack > &arcs, const std::vector< model::Via > &vias) |
| The via length of one net on the given copper, as KiCad sums it: each via counts between the outermost layers on which a track of the net ends inside the via's pad, or a pad of the net touches the via (a surface pad's own layer, its footprint's side for a through-hole pad); a via that joins nothing on a second layer adds nothing. | |
| BusStats | measure_bus (const model::Board &b, const ViaHeights &vh, const std::vector< model::Track > &tracks, const std::vector< model::ArcTrack > &arcs, const std::vector< model::Via > &vias, const std::vector< std::uint8_t > &net_routed, const BusGroup &g) |
| net_routed[net]: nets_joined() of the board the copper belongs to; b gives the pads, vh its via heights. | |
| std::vector< std::uint8_t > | nets_joined (const model::Board &b, const model::DesignRules &rules) |
| Per net: 1 when all its pads are joined by copper (the router's own connectivity; nets without pads count as joined). | |
| PairRule | pair_rule (const model::Board &b, const model::DesignRules &rules, const drc::RuleEngine &re, model::NetId a, model::NetId c, Coord via_mask=0) |
| via_mask: solder-mask expansion of untented vias (route::Obstacles::via_mask()); two vias then need their mask openings apart as well. | |
| Dir2 | unit_dir (int d) |
| Dir2 | left_normal (int d) |
| geom::Point | offset_point (geom::Point p, Dir2 v, double s) |
| p + s * v, rounded half away from zero (KiCad's KiROUND), so offsets are symmetric about the centreline. | |
| geom::Point | miter_point (geom::Point c, int d1, int d2, double s) |
| Miter corner of a polyline offset by s (signed: + left) where the centreline turns from direction d1 to d2. | |
| Coord | coupled_threshold (const PairRule &r) |
| Edge gap up to which a sample counts as coupled: the pair's gap plus a quarter of it (at least 50 um), so lattice rounding and the miter at bends do not count as uncoupled while a single track wandering off does. | |
| PairStats | measure_pair (const std::vector< model::Track > &tracks, const std::vector< model::Via > &vias, model::NetId a, model::NetId c, Coord coupled_gap) |
| std::vector< std::pair< model::NetId, model::NetId > > | named_pairs (const model::Board &b, const drc::RuleEngine &re) |
| Net pairs KiCad treats as differential pairs (names ending in P/N or +/-), in net order. | |
| std::pair< Coord, Coord > | pad_half_extents (const model::Pad &p) |
| Half extents of a pad's bounding box along x and y (rotation applied). | |
| std::vector< EscapeCorridor > | plan_escapes (const model::Board &b, const std::vector< char > &needs, const std::function< Coord(model::NetId)> &keep, const EscapeOptions &o={}, EscapeStats *stats=nullptr, const std::function< Coord(model::NetId)> &channel={}) |
| Plans corridors for the pads with needs[pad] != 0. | |
| std::vector< PartEscape > | analyse_escapes (const model::Board &b, const model::DesignRules &r, Obstacles &obs, const EscapeAnalysisOptions &o={}, const EscapeOptions &eo={}) |
| std::vector< int > | array_rings (const model::Board &b, const std::vector< char > &needs, const EscapeOptions &o={}) |
| Deep arrays: SMD pads of one footprint on a regular square grid (every pad within pitch / 8 of a grid point, at most one pad per point, at least 30 % of the points populated, at least 5 x 5) with at least one pin that needs routing in the third ring or deeper. | |
| std::vector< EscapeCorridor > | plan_escapes_flow (const model::Board &b, const std::vector< char > &needs, const FlowEscapeInput &in, const EscapeOptions &o={}, FlowEscapeStats *stats=nullptr) |
| Plans the deep arrays by min-cost flow and every other dense package as version 1 does (plan_escapes). | |
| GlobalResult | global_route (const Obstacles &obs, const geom::Box &bounds, int layers, const std::vector< GlobalNet > &nets, const GlobalOptions &opt) |
| LayerLimits | layer_limits (const model::Board &b, const std::vector< std::string > &no_tracks_on, const std::vector< std::string > &layer_costs) |
| no_tracks_on: copper layer names. | |
| LegalizeResult | legalize_routes (const model::Board &board, const model::DesignRules &rules, std::vector< ConnRoute > &routes, const LegalizeOptions &opt={}) |
| Moves the vertices of routes (tracks and vias of the connections) so that the clearances of rules hold between nets, to the pads of board and to its fixed tracks and vias. | |
| long double | zone_fill_area (const drc::CopperModel &cm, const std::vector< int > &items) |
| Filled area of zone fill items (nm^2), shoelace over each item's outline. | |
| ReferenceMap | build_reference_map (const model::Board &b, const geom::Box &lat, Coord pitch, int nx, int ny, double min_coverage=0.3) |
| lat is the lattice box (cell (x, y) is at lat.x0 + x * pitch, lat.y0 + y * pitch), nx x ny its size. | |
| std::vector< std::uint8_t > | rasterise (const geom::Rings ®ion, const geom::Box &lat, Coord pitch, int nx, int ny) |
| Rasterises a region (rings under the non-zero rule, holes included): 1 where the cell centre is inside. | |
| const char * | work_phase_name (WorkPhase p) |
| 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 to run instead (non-empty: overrides variants). | |
| int | portfolio_size () |
| 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 their bus lanes, then fewer vias, then shorter copper). | |
Variables | |
| constexpr double | kMaxLayerCost = 1000.0 |
| constexpr long double | kPlaneTargetArea = 1e12L |
| With soft zones a fill of at least this area that no pad touches is its net's plane: a connection target of its own (doc 05 §26). | |
| constexpr int | kWorkPhases = 4 |
| constexpr int | kAdvisedIndex = 1000 |
| Variant indices from here up are the advised copies the portfolio adds when RouterOptions::advice is active (position k of the advice's variants has index kAdvisedIndex + k). | |
|
strong |
| Enumerator | |
|---|---|
| Setup | |
| FirstPass | |
| Negotiation | |
| Cleanup | |
Definition at line 281 of file router.hpp.
| std::vector< PartEscape > tmk::route::analyse_escapes | ( | const model::Board & | b, |
| const model::DesignRules & | r, | ||
| Obstacles & | obs, | ||
| const EscapeAnalysisOptions & | o = {}, | ||
| const EscapeOptions & | eo = {} ) |
| std::vector< int > tmk::route::array_rings | ( | const model::Board & | b, |
| const std::vector< char > & | needs, | ||
| const EscapeOptions & | o = {} ) |
Deep arrays: SMD pads of one footprint on a regular square grid (every pad within pitch / 8 of a grid point, at most one pad per point, at least 30 % of the points populated, at least 5 x 5) with at least one pin that needs routing in the third ring or deeper.
Pads larger than the pitch (thermal pads) are left to the fixed copper checks. ring_of(pad) is the pad's ring (1 = perimeter) for pads of deep arrays, 0 otherwise.
| ReferenceMap tmk::route::build_reference_map | ( | const model::Board & | b, |
| const geom::Box & | lat, | ||
| Coord | pitch, | ||
| int | nx, | ||
| int | ny, | ||
| double | min_coverage = 0.3 ) |
lat is the lattice box (cell (x, y) is at lat.x0 + x * pitch, lat.y0 + y * pitch), nx x ny its size.
The board's zones must carry their fills (refill first if they do not). A layer is a reference plane when its fills cover at least min_coverage of the board's bounding box.
| BusGroup tmk::route::bus_from_option | ( | const model::Board & | b, |
| const std::string & | spec ) |
"NAME=PATTERN" as given to –bus.
Throws std::runtime_error when there is no '=', the name or pattern is empty, or fewer than two nets with pads match.
| bool tmk::route::bus_pattern_match | ( | const std::string & | pattern, |
| const std::string & | net_name ) |
Bus patterns select nets by their full name (KiCad's, with the sheet path: "/D0", "/MEM/DQ3").
[N-M] or [N..M], N <= M decimal numbers: an index range, matching any decimal number in it ("D[0-15]" matches D0 .. D15, and D07 too). A range needs both bounds; "[[0-7]]" is a range in literal brackets, for nets named A[0] .. A[7].
| std::optional< Coord > tmk::route::bus_rule_skew | ( | const drc::RuleEngine & | re, |
| const BusGroup & | g ) |
The skew limit the board's custom rules give a group: every member must match a rule with a skew constraint (the smallest maximum wins); rules restricted to differential pairs (within_diff_pairs) do not count.
Edge gap up to which a sample counts as coupled: the pair's gap plus a quarter of it (at least 50 um), so lattice rounding and the miter at bends do not count as uncoupled while a single track wandering off does.
Definition at line 61 of file diff_pair.hpp.
| std::vector< BusGroup > tmk::route::detect_buses | ( | const model::Board & | b, |
| int | min_members = 4 ) |
Automatic detection (–buses), conservative: nets whose names differ only in a trailing decimal index ("D0", "A[3]", "/MEM/DQ12"), at least min_members of them with pads on the same two components.
KiCad's generated names ("Net-(U1-Pad3)", "unconnected-...") are never grouped. One stem may give several groups (D0-7 to one memory, D8-15 to another); they are then named STEM(REF-REF). Groups come in natural order of their names.
| std::string tmk::route::failure_reason_code | ( | const std::string & | why | ) |
The reason code of a failure explanation (RouteResult::Unrouted::reason).
The text is matched, not parsed: the router's explanations are sentences, and the code is only the class of the cause.
| GlobalResult tmk::route::global_route | ( | const Obstacles & | obs, |
| const geom::Box & | bounds, | ||
| int | layers, | ||
| const std::vector< GlobalNet > & | nets, | ||
| const GlobalOptions & | opt ) |
| LayerLimits tmk::route::layer_limits | ( | const model::Board & | b, |
| const std::vector< std::string > & | no_tracks_on, | ||
| const std::vector< std::string > & | layer_costs ) |
no_tracks_on: copper layer names.
layer_costs: "NAME=FACTOR" entries with 1 <= FACTOR <= kMaxLayerCost. Names are the board's canonical names ("In1.Cu"), the names written in the file, or the user's layer names. Throws std::invalid_argument on an unknown layer, a malformed entry, a factor out of range, or when no layer would be left for tracks: a limit the router cannot apply as written must stop the run, not be dropped.
| Dir2 tmk::route::left_normal | ( | int | d | ) |
| LegalizeResult tmk::route::legalize_routes | ( | const model::Board & | board, |
| const model::DesignRules & | rules, | ||
| std::vector< ConnRoute > & | routes, | ||
| const LegalizeOptions & | opt = {} ) |
Moves the vertices of routes (tracks and vias of the connections) so that the clearances of rules hold between nets, to the pads of board and to its fixed tracks and vias.
Locked or foreign copper never moves; track ends at the centre of their own pad stay. Deterministic.
| BusStats tmk::route::measure_bus | ( | const model::Board & | b, |
| const ViaHeights & | vh, | ||
| const std::vector< model::Track > & | tracks, | ||
| const std::vector< model::ArcTrack > & | arcs, | ||
| const std::vector< model::Via > & | vias, | ||
| const std::vector< std::uint8_t > & | net_routed, | ||
| const BusGroup & | g ) |
net_routed[net]: nets_joined() of the board the copper belongs to; b gives the pads, vh its via heights.
| PairStats tmk::route::measure_pair | ( | const std::vector< model::Track > & | tracks, |
| const std::vector< model::Via > & | vias, | ||
| model::NetId | a, | ||
| model::NetId | c, | ||
| Coord | coupled_gap ) |
| geom::Point tmk::route::miter_point | ( | geom::Point | c, |
| int | d1, | ||
| int | d2, | ||
| double | s ) |
Miter corner of a polyline offset by s (signed: + left) where the centreline turns from direction d1 to d2.
| std::vector< std::pair< model::NetId, model::NetId > > tmk::route::named_pairs | ( | const model::Board & | b, |
| const drc::RuleEngine & | re ) |
Net pairs KiCad treats as differential pairs (names ending in P/N or +/-), in net order.
| bool tmk::route::natural_less | ( | std::string_view | a, |
| std::string_view | b ) |
Natural order of two names: runs of digits compare as numbers, everything else byte by byte.
| double tmk::route::net_via_length | ( | const model::Board & | b, |
| const ViaHeights & | vh, | ||
| model::NetId | net, | ||
| const std::vector< model::Track > & | tracks, | ||
| const std::vector< model::ArcTrack > & | arcs, | ||
| const std::vector< model::Via > & | vias ) |
The via length of one net on the given copper, as KiCad sums it: each via counts between the outermost layers on which a track of the net ends inside the via's pad, or a pad of the net touches the via (a surface pad's own layer, its footprint's side for a through-hole pad); a via that joins nothing on a second layer adds nothing.
| std::vector< std::uint8_t > tmk::route::nets_joined | ( | const model::Board & | b, |
| const model::DesignRules & | rules ) |
Per net: 1 when all its pads are joined by copper (the router's own connectivity; nets without pads count as joined).
| geom::Point tmk::route::offset_point | ( | geom::Point | p, |
| Dir2 | v, | ||
| double | s ) |
p + s * v, rounded half away from zero (KiCad's KiROUND), so offsets are symmetric about the centreline.
| std::pair< Coord, Coord > tmk::route::pad_half_extents | ( | const model::Pad & | p | ) |
Half extents of a pad's bounding box along x and y (rotation applied).
| PairRule tmk::route::pair_rule | ( | const model::Board & | b, |
| const model::DesignRules & | rules, | ||
| const drc::RuleEngine & | re, | ||
| model::NetId | a, | ||
| model::NetId | c, | ||
| Coord | via_mask = 0 ) |
via_mask: solder-mask expansion of untented vias (route::Obstacles::via_mask()); two vias then need their mask openings apart as well.
| std::vector< int > tmk::route::perimeter_directions | ( | const model::Board & | b, |
| const BundleOptions & | o ) |
Pins on the perimeter of a dense package and the direction they leave in (index into the 8 octilinear directions: 0 +x, 2 +y, 4 -x, 6 -y).
Corner pins (within the ring of two sides) and thermal pads are not perimeter pins. by pad index; -1 = not a perimeter pin
| std::vector< EscapeCorridor > tmk::route::plan_escapes | ( | const model::Board & | b, |
| const std::vector< char > & | needs, | ||
| const std::function< Coord(model::NetId)> & | keep, | ||
| const EscapeOptions & | o = {}, | ||
| EscapeStats * | stats = nullptr, | ||
| const std::function< Coord(model::NetId)> & | channel = {} ) |
Plans corridors for the pads with needs[pad] != 0.
keep(net) is the distance another net's centreline must keep from this net's centreline (track width + clearance); the band is that, capped at a share of the pin pitch so the corridors of neighbouring pins never overlap. Deterministic: footprints and pads in board order. channel(net), when given, is the gap a track of that net needs between two pads (narrowest legal width plus twice the clearance): second-ring balls whose outer neighbours leave that much room escape on their own layer between them (the classic two-ring fanout) instead of taking a dog-bone via.
| std::vector< EscapeCorridor > tmk::route::plan_escapes_flow | ( | const model::Board & | b, |
| const std::vector< char > & | needs, | ||
| const FlowEscapeInput & | in, | ||
| const EscapeOptions & | o = {}, | ||
| FlowEscapeStats * | stats = nullptr ) |
Plans the deep arrays by min-cost flow and every other dense package as version 1 does (plan_escapes).
| int tmk::route::portfolio_size | ( | ) |
| std::vector< std::uint8_t > tmk::route::rasterise | ( | const geom::Rings & | region, |
| const geom::Box & | lat, | ||
| Coord | pitch, | ||
| int | nx, | ||
| int | ny ) |
Rasterises a region (rings under the non-zero rule, holes included): 1 where the cell centre is inside.
Exposed for the tests, which compare it with a point-in-region scan.
| BundleStats tmk::route::route_bundles | ( | const model::Board & | b, |
| const std::vector< BundleConn > & | conns, | ||
| const BundleHooks & | h, | ||
| const BundleOptions & | o = {} ) |
Plans and places the bundles of conns (unrouted two-pad connections). Deterministic: groups, lanes and searches are in a fixed order.
| PortfolioResult tmk::route::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 to run instead (non-empty: overrides variants).
threads: concurrency only (0 = one thread per variant).
| bool tmk::route::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 their bus lanes, then fewer vias, then shorter copper).
Ties are not "better": the caller keeps the earlier result.
| TunnelStats tmk::route::route_tunnels | ( | const model::Board & | b, |
| const std::vector< BundleConn > & | conns, | ||
| const BundleHooks & | h, | ||
| const BundleOptions & | o = {} ) |
| Dir2 tmk::route::unit_dir | ( | int | d | ) |
| ViaHeights tmk::route::via_heights | ( | const model::Board & | b, |
| const model::DesignRules & | rules ) |
| const char * tmk::route::work_phase_name | ( | WorkPhase | p | ) |
| long double tmk::route::zone_fill_area | ( | const drc::CopperModel & | cm, |
| const std::vector< int > & | items ) |
Filled area of zone fill items (nm^2), shoelace over each item's outline.
|
inlineconstexpr |
Variant indices from here up are the advised copies the portfolio adds when RouterOptions::advice is active (position k of the advice's variants has index kAdvisedIndex + k).
Definition at line 374 of file router.hpp.
|
inlineconstexpr |
Definition at line 18 of file layer_limits.hpp.
|
inlineconstexpr |
With soft zones a fill of at least this area that no pad touches is its net's plane: a connection target of its own (doc 05 §26).
Smaller ones are slivers of a stale fill, which a refill may drop or reshape. 1 mm^2
Definition at line 178 of file obstacles.hpp.
|
inlineconstexpr |
Definition at line 282 of file router.hpp.