TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
stackup.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// The board's physical stackup as KiCad stores it in (setup (stackup ...)) (design doc 15 ยง5.3): read-only,
4// used to turn impedance rules into widths and gaps. Boards without a stackup block (KiCad 5 and older, or
5// boards whose stackup was never edited) have `present == false`; nothing is guessed (CLAUDE.md rule 6).
6#include <string>
7#include <vector>
8
9#include "core/units.hpp"
10
11namespace tmk::model {
12
14 std::string name; // "F.Cu", "dielectric 1", "F.Mask", ...
15 std::string type; // "copper", "core", "prepreg", "Top Solder Mask", ... as written
16 std::string material; // first sublayer's material ("FR4"), empty if not given
17 Coord thickness = 0; // nm; a dielectric with sublayers (addsublayer) sums them
18 // Relative permittivity; 0 = not given. Sublayers combine as parallel-plate capacitors in series:
19 // er = sum(h) / sum(h / er_i) (exact for a field normal to the layers).
20 double epsilon_r = 0;
21 double loss_tangent = 0; // thickness-weighted mean over sublayers; 0 = not given
22 int sublayers = 1;
23 bool epsilon_complete = false; // every sublayer gave epsilon_r
24 int copper_index = -1; // stack index for copper layers, -1 otherwise
25
26 bool is_copper() const { return type == "copper"; }
27 bool is_mask() const; // "Top Solder Mask" / "Bottom Solder Mask"
28};
29
30// The dielectric between two adjacent copper layers, combined over every stackup layer between them.
32 Coord thickness = 0; // nm
33 double epsilon_r = 0; // series combination (see StackupLayer::epsilon_r); 0 = unknown
34 double loss_tangent = 0;
35 bool complete = false; // thickness > 0 and every layer gave epsilon_r
36 std::string materials; // "FR4" or "FR4+R-1551(W)"
37};
38
39struct Stackup {
40 bool present = false; // the board has a (stackup ...) block
41 std::vector<StackupLayer> layers; // file order (top to bottom)
42 std::string copper_finish;
44
45 // Stack position of copper layer `copper_index` in `layers`, -1 if the stackup does not list it.
46 int position_of_copper(int copper_index) const;
47 // Dielectric between copper layers `a` and `b` (stack indices, a < b, any distance apart; copper layers in between
48 // are not counted). complete = false if either copper layer is missing from the stackup.
49 DielectricGap between(int a, int b) const;
50 // Copper thickness of copper layer `copper_index`, 0 if unknown.
51 Coord copper_thickness(int copper_index) const;
52 // Solder mask over the given outer side (front = true), nullptr if the stackup has none.
53 const StackupLayer* mask(bool front) const;
54};
55
56} // namespace tmk::model
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Definition units.hpp:12
The dielectric between two adjacent copper layers, combined over every stackup layer between them.
Definition stackup.hpp:31
std::string materials
"FR4" or "FR4+R-1551(W)"
Definition stackup.hpp:36
double epsilon_r
series combination (see StackupLayer::epsilon_r); 0 = unknown
Definition stackup.hpp:33
bool complete
thickness > 0 and every layer gave epsilon_r
Definition stackup.hpp:35
std::string name
"F.Cu", "dielectric 1", "F.Mask", ...
Definition stackup.hpp:14
bool is_mask() const
"Top Solder Mask" / "Bottom Solder Mask"
double loss_tangent
thickness-weighted mean over sublayers; 0 = not given
Definition stackup.hpp:21
int copper_index
stack index for copper layers, -1 otherwise
Definition stackup.hpp:24
bool is_copper() const
Definition stackup.hpp:26
std::string type
"copper", "core", "prepreg", "Top Solder Mask", ... as written
Definition stackup.hpp:15
Coord thickness
nm; a dielectric with sublayers (addsublayer) sums them
Definition stackup.hpp:17
std::string material
first sublayer's material ("FR4"), empty if not given
Definition stackup.hpp:16
double epsilon_r
Relative permittivity; 0 = not given.
Definition stackup.hpp:20
bool epsilon_complete
every sublayer gave epsilon_r
Definition stackup.hpp:23
int position_of_copper(int copper_index) const
Stack position of copper layer copper_index in layers, -1 if the stackup does not list it.
std::vector< StackupLayer > layers
file order (top to bottom)
Definition stackup.hpp:41
Coord copper_thickness(int copper_index) const
Copper thickness of copper layer copper_index, 0 if unknown.
DielectricGap between(int a, int b) const
Dielectric between copper layers a and b (stack indices, a < b, any distance apart; copper layers in ...
bool dielectric_constraints
Definition stackup.hpp:43
std::string copper_finish
Definition stackup.hpp:42
const StackupLayer * mask(bool front) const
Solder mask over the given outer side (front = true), nullptr if the stackup has none.
bool present
the board has a (stackup ...) block
Definition stackup.hpp:40