KiCad PCB EDA Suite
Loading...
Searching...
No Matches
net_chain_bridging.h File Reference
#include <algorithm>
#include <limits>
#include <tuple>
#include <vector>
#include <wx/string.h>
#include <base_units.h>
#include <board.h>
#include <footprint.h>
#include <math/vector2d.h>
#include <netinfo.h>
#include <pad.h>
#include <pcb_track.h>

Go to the source code of this file.

Classes

struct  CHAIN_BRIDGE
 One series-component bridge edge inside a chain graph. More...
 

Functions

double FootprintChainBridgingLength (const FOOTPRINT *aFootprint, const wxString &aNetChain)
 Compute the bridging length contributed by a single footprint to a net chain.
 
double BoardChainBridgingLength (const BOARD *aBoard, const wxString &aNetChain)
 Sum chain bridging length across every footprint on the board.
 
double ChainBridgingDelayPerMm (const BOARD *aBoard, const wxString &aNetChain)
 Compute both the chain bridging length and its associated propagation delay (in internal delay IU, i.e.
 
std::tuple< double, double > BoardChainBridging (const BOARD *aBoard, const wxString &aNetChain)
 
int SubtractBridgingClamped (int aValue, long long aDelta)
 Saturating subtract for bridge-adjusting MINOPTMAX<int> bounds without overflow when the delta is in attoseconds (time-domain bridging routinely exceeds INT_MAX).
 
std::vector< CHAIN_BRIDGEEnumerateChainBridges (const BOARD *aBoard, const wxString &aNetChain)
 Enumerate every per-pad-pair bridge edge contributed by every footprint on the board to the named chain.
 

Variables

constexpr double DEFAULT_PROPAGATION_DELAY_PS_PER_MM = 5.9
 

Function Documentation

◆ BoardChainBridging()

◆ BoardChainBridgingLength()

double BoardChainBridgingLength ( const BOARD * aBoard,
const wxString & aNetChain )
inline

◆ ChainBridgingDelayPerMm()

double ChainBridgingDelayPerMm ( const BOARD * aBoard,
const wxString & aNetChain )
inline

Compute both the chain bridging length and its associated propagation delay (in internal delay IU, i.e.

Pick a single per-IU-per-mm delay for a given chain.

attoseconds) in one pass. The delay is derived from the first chain track with a measurable per-mm propagation delay so the bridging contribution tracks the actual stackup; if no such track exists the helper falls back to ~5.9 ps/mm (150 ps/in).

The matched-length DRC provider and the tuning pattern generator share this helper so the time-domain DRC verdict and the tuner's per-net budget agree on bridging delay. The returned tuple is (lengthIU, delayIU).

Walks the chain's tracks until it finds one with a measurable per-mm propagation delay; falls back to the default constant if none. Shared between the aggregate and per-edge bridge helpers so they always apply the same scaling.

Definition at line 190 of file net_chain_bridging.h.

References DEFAULT_PROPAGATION_DELAY_PS_PER_MM, NETINFO_ITEM::GetNetChain(), BOARD::GetTrackLength(), BOARD::IsEmpty(), pcbIUScale, and BOARD::Tracks().

Referenced by BoardChainBridging(), CHAIN_TOPOLOGY::CHAIN_TOPOLOGY(), and EnumerateChainBridges().

◆ EnumerateChainBridges()

std::vector< CHAIN_BRIDGE > EnumerateChainBridges ( const BOARD * aBoard,
const wxString & aNetChain )
inline

Enumerate every per-pad-pair bridge edge contributed by every footprint on the board to the named chain.

Unlike FootprintChainBridgingLength (which returns a single max-span scalar per footprint), this returns one edge per qualifying cross-net pad pair, which is what the CHAIN_TOPOLOGY graph builder needs to compute trunk paths through series passives.

Definition at line 229 of file net_chain_bridging.h.

References ChainBridgingDelayPerMm(), delta, BOARD::Footprints(), NETINFO_ITEM::GetNetChain(), BOARD::IsEmpty(), pad, and pcbIUScale.

Referenced by CHAIN_TOPOLOGY::CHAIN_TOPOLOGY().

◆ FootprintChainBridgingLength()

double FootprintChainBridgingLength ( const FOOTPRINT * aFootprint,
const wxString & aNetChain )
inline

Compute the bridging length contributed by a single footprint to a net chain.

A footprint bridges two segments of the same chain when it has at least one chain pad on each of two distinct nets. The bridging contribution is the maximum pairwise Euclidean distance between any two chain pads on different nets. This is a conservative upper bound that handles 3+ pad devices (centre-tap beads, transformers, dual-winding parts) without silently dropping their contribution.

Returns 0.0 when the footprint has fewer than two chain pads, or when all chain pads share the same netcode (no cross-net bridging possible).

The DRC matched-length provider and the tuning pattern generator share this predicate so they always agree on which footprints bridge a chain and by how much.

Definition at line 58 of file net_chain_bridging.h.

References delta, NETINFO_ITEM::GetNetChain(), EMBEDDED_FILES::IsEmpty(), pad, and FOOTPRINT::Pads().

Referenced by BoardChainBridgingLength().

◆ SubtractBridgingClamped()

int SubtractBridgingClamped ( int aValue,
long long aDelta )
inline

Saturating subtract for bridge-adjusting MINOPTMAX<int> bounds without overflow when the delta is in attoseconds (time-domain bridging routinely exceeds INT_MAX).

Returns max(0, aValue - aDelta), clamped to fit in int.

Definition at line 157 of file net_chain_bridging.h.

Referenced by applyBridging(), and PCB_TUNING_PATTERN::CreateNew().

Variable Documentation

◆ DEFAULT_PROPAGATION_DELAY_PS_PER_MM

double DEFAULT_PROPAGATION_DELAY_PS_PER_MM = 5.9
constexpr