TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
widen.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Power track widening (doc 05 §39.1): after routing, new tracks that are narrower than they should be are made
4// wider where the exact check allows it. Only the width of new, unlocked tracks changes: nothing is moved, and no
5// other copper is touched.
6#include <map>
7#include <string>
8#include <vector>
9
10#include "model/board.hpp"
11#include "model/rules.hpp"
12
13namespace tmk::passes {
14
16 // Tracks narrower than their net class's width (the router's neck-down) go back up to the class width.
17 bool restore_necked = true;
18 // Width targets by net (explicit options and component rules); a target below a track's width changes nothing.
19 // The largest target of a net counts.
20 struct Target {
23 std::string source; // "option", or the component rule that asked for it
24 };
25 std::vector<Target> targets;
26 // Nets left alone: coupled differential pairs are routed at their pair width on purpose.
27 std::vector<model::NetId> skip_nets;
28 // Candidate widths per track: the target, then `steps` - 1 evenly spaced widths below it, down to (not including)
29 // the track's own width, each rounded down to a micrometre. The widest that passes the exact check is kept.
30 int steps = 8;
31 // Work budget in exact checks (rule 5). When it runs out the remaining tracks keep their width.
32 long work_limit = 2'000'000;
33 bool soft_zones = false; // as RouterOptions::soft_zones: stale fills do not block (the caller refills and judges)
34};
35
36struct WidenNet {
39 std::string source; // "net class" (neck-down restored), "option", or a rule id
40 std::map<Coord, Coord> before, after; // track width -> length at that width, nm
41 int tracks = 0; // tracks below the target before the pass
42 int widened = 0; // of them: made wider (to the target or part of the way)
43 int at_target = 0; // of them: at the target (or at a pad's or via's size, see the doc) afterwards
44 Coord widened_length = 0; // length of the tracks made wider
45};
46
48 std::vector<WidenNet> nets; // nets with at least one track below its target, by net id
49 long checks = 0; // exact checks done (the pass's work)
50 bool out_of_work = false;
51 int widened = 0;
52};
53
54// `board` is the board as the router saw it (without the new copper); `tracks` and `vias` are the run's new
55// copper. On return the widths in `tracks` are the widened ones; order and end points are unchanged.
56WidenResult widen_tracks(const model::Board& board, const model::DesignRules& rules, std::vector<model::Track>& tracks,
57 const std::vector<model::Via>& vias, const WidenOptions& opt);
58
59} // namespace tmk::passes
The board model (design doc 02 §3): every object TraceMaker reads from a .kicad_pcb,...
std::int32_t NetId
0 = no net
Definition board.hpp:21
WidenResult widen_tracks(const model::Board &board, const model::DesignRules &rules, std::vector< model::Track > &tracks, const std::vector< model::Via > &vias, const WidenOptions &opt)
board is the board as the router saw it (without the new copper); tracks and vias are the run's new c...
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 ....
std::map< Coord, Coord > after
track width -> length at that width, nm
Definition widen.hpp:40
std::string source
"net class" (neck-down restored), "option", or a rule id
Definition widen.hpp:39
int tracks
tracks below the target before the pass
Definition widen.hpp:41
model::NetId net
Definition widen.hpp:37
std::map< Coord, Coord > before
Definition widen.hpp:40
int widened
of them: made wider (to the target or part of the way)
Definition widen.hpp:42
Coord widened_length
length of the tracks made wider
Definition widen.hpp:44
int at_target
of them: at the target (or at a pad's or via's size, see the doc) afterwards
Definition widen.hpp:43
Width targets by net (explicit options and component rules); a target below a track's width changes n...
Definition widen.hpp:20
std::string source
"option", or the component rule that asked for it
Definition widen.hpp:23
int steps
Candidate widths per track: the target, then steps - 1 evenly spaced widths below it,...
Definition widen.hpp:30
std::vector< model::NetId > skip_nets
Nets left alone: coupled differential pairs are routed at their pair width on purpose.
Definition widen.hpp:27
std::vector< Target > targets
Definition widen.hpp:25
long work_limit
Work budget in exact checks (rule 5). When it runs out the remaining tracks keep their width.
Definition widen.hpp:32
bool soft_zones
as RouterOptions::soft_zones: stale fills do not block (the caller refills and judges)
Definition widen.hpp:33
bool restore_necked
Tracks narrower than their net class's width (the router's neck-down) go back up to the class width.
Definition widen.hpp:17
long checks
exact checks done (the pass's work)
Definition widen.hpp:49
std::vector< WidenNet > nets
nets with at least one track below its target, by net id
Definition widen.hpp:48