TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
stitch.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Stitching vias (doc 05 §39.3): after routing, vias of a plane's net are added where fills of that net lie over
4// each other on two or more layers (plane stitching), and next to the vias of signals that need a reference plane
5// (return-path stitching). Every via passes the router's exact check against the refilled zones, and is kept only
6// if a second refill still joins it to its net's fill on two layers.
7#include <string>
8#include <vector>
9
10#include "model/board.hpp"
11#include "model/rules.hpp"
12
13namespace tmk::passes {
14
16 bool planes = false; // plane stitching on a grid
17 // Grid pitch. The default is the catalogue's general high-speed value (TI SPRAAR7J: a stitching via within
18 // 200 mil); app code passes the catalogue's number, this is its fallback.
19 Coord pitch = 5'080'000;
20 // Return-path stitching: every via of `signal` wants a via (or plated through-hole pad) of `plane` within
21 // `distance`, centre to centre.
22 struct ReturnNet {
24 Coord distance = 5'080'000;
25 std::string source; // "option" or the component rule (e.g. "USB2-09 J1")
26 };
27 std::vector<ReturnNet> returns;
28 // Work budget (rule 5): sites examined plus exact checks. When it runs out no further site is tried.
29 long work_limit = 2'000'000;
30};
31
34 std::string source;
36 int signal_vias = 0; // vias of the signal net on the board (old and new)
37 int stitched_before = 0; // of them: with a plane via or plated pad within the distance before the pass
38 int stitched_after = 0; // ... and after it
39};
40
42 std::vector<model::Via> vias; // the vias to add, plane stitches first; all marked free
43 std::vector<std::uint8_t> return_path; // per via: 1 = placed for a signal via, 0 = grid
44 std::vector<StitchReturn> returns; // one row per StitchOptions::returns entry
45 int sites = 0; // grid sites inside overlapping fills
46 int site_served = 0; // of them: already tied by a via or plated pad of the net within half the pitch
47 int site_blocked = 0; // of them: refused by the exact check
48 int dropped = 0; // vias placed and then removed because the second refill did not join them on two layers
49 long checks = 0; // the pass's work
50 bool out_of_work = false;
51 bool discarded = false; // everything withdrawn: the refill with the vias left another net's zone in more pieces
52 std::vector<std::string> warnings;
53};
54
55// `board` holds the routed copper (the run's new tracks and vias appended). Zone fills on it may be stale: the
56// pass refills them in the engine (drc/refill.hpp) and places against that.
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
StitchResult stitch_vias(const model::Board &board, const model::DesignRules &rules, const StitchOptions &opt)
board holds the routed copper (the run's new tracks and vias appended).
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 ....
Return-path stitching: every via of signal wants a via (or plated through-hole pad) of plane within d...
Definition stitch.hpp:22
std::string source
"option" or the component rule (e.g. "USB2-09 J1")
Definition stitch.hpp:25
Coord pitch
Grid pitch.
Definition stitch.hpp:19
long work_limit
Work budget (rule 5): sites examined plus exact checks. When it runs out no further site is tried.
Definition stitch.hpp:29
std::vector< ReturnNet > returns
Definition stitch.hpp:27
bool planes
plane stitching on a grid
Definition stitch.hpp:16
int sites
grid sites inside overlapping fills
Definition stitch.hpp:45
bool discarded
everything withdrawn: the refill with the vias left another net's zone in more pieces
Definition stitch.hpp:51
int site_served
of them: already tied by a via or plated pad of the net within half the pitch
Definition stitch.hpp:46
std::vector< std::uint8_t > return_path
per via: 1 = placed for a signal via, 0 = grid
Definition stitch.hpp:43
int site_blocked
of them: refused by the exact check
Definition stitch.hpp:47
std::vector< std::string > warnings
Definition stitch.hpp:52
int dropped
vias placed and then removed because the second refill did not join them on two layers
Definition stitch.hpp:48
std::vector< model::Via > vias
the vias to add, plane stitches first; all marked free
Definition stitch.hpp:42
std::vector< StitchReturn > returns
one row per StitchOptions::returns entry
Definition stitch.hpp:44
long checks
the pass's work
Definition stitch.hpp:49
int stitched_before
of them: with a plane via or plated pad within the distance before the pass
Definition stitch.hpp:37
int stitched_after
... and after it
Definition stitch.hpp:38
int signal_vias
vias of the signal net on the board (old and new)
Definition stitch.hpp:36