KiCad PCB EDA Suite
Loading...
Searching...
No Matches
net_chain_bridging.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef PCBNEW_NET_CHAIN_BRIDGING_H
21#define PCBNEW_NET_CHAIN_BRIDGING_H
22
23#include <algorithm>
24#include <limits>
25#include <set>
26#include <tuple>
27#include <vector>
28
29#include <wx/string.h>
30
31class BOARD;
32class FOOTPRINT;
33class PAD;
34
35
36constexpr double DEFAULT_PROPAGATION_DELAY_PS_PER_MM = 5.9; // 150 ps/in fallback when no track delay sample is available
37
38
54double FootprintChainBridgingLength( const FOOTPRINT* aFootprint, const wxString& aNetChain );
55
56
60double BoardChainBridgingLength( const BOARD* aBoard, const wxString& aNetChain );
61
62
69double ChainBridgingDelayPerMm( const BOARD* aBoard, const wxString& aNetChain );
70
71
82std::tuple<double, double> BoardChainBridging( const BOARD* aBoard, const wxString& aNetChain );
83
84
90inline int SubtractBridgingClamped( int aValue, long long aDelta )
91{
92 long long adjusted = static_cast<long long>( aValue ) - aDelta;
93
94 return static_cast<int>( std::clamp( adjusted,
95 0LL,
96 static_cast<long long>( std::numeric_limits<int>::max() ) ) );
97}
98
99
109{
112 double length;
113 double delay;
114};
115
116
124std::vector<CHAIN_BRIDGE> EnumerateChainBridges( const BOARD* aBoard, const wxString& aNetChain );
125
126
131{
133 INVALID_INPUT, // null board, equal pads, etc.
134 QUERY_NET_NOT_IN_CHAIN, // aQueryNet has no chain assignment
135 START_PAD_NOT_ON_QUERY, // aStartPad's netcode != aQueryNet
137 NO_CHAIN_BRIDGES, // the query net has no series-passive bridge in the chain
138 AMBIGUOUS_OVERLAP // the two sides share at least one netcode (cycle)
139};
140
141
154
155
177NET_CHAIN_PARTITION PartitionNetChainAroundNet( const BOARD* aBoard, int aQueryNet,
178 const PAD* aStartPad, const PAD* aEndPad );
179
180
181#endif // PCBNEW_NET_CHAIN_BRIDGING_H
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
Definition pad.h:61
#define OK
double ChainBridgingDelayPerMm(const BOARD *aBoard, const wxString &aNetChain)
Pick a single per-IU-per-mm delay for a given chain.
NET_CHAIN_PARTITION PartitionNetChainAroundNet(const BOARD *aBoard, int aQueryNet, const PAD *aStartPad, const PAD *aEndPad)
Partition the chain containing aQueryNet around it, cut at the bridges incident on aStartPad and aEnd...
constexpr double DEFAULT_PROPAGATION_DELAY_PS_PER_MM
std::tuple< double, double > BoardChainBridging(const BOARD *aBoard, const wxString &aNetChain)
Compute both the chain bridging length and its associated propagation delay (in internal delay IU,...
std::vector< CHAIN_BRIDGE > EnumerateChainBridges(const BOARD *aBoard, const wxString &aNetChain)
Enumerate every per-pad-pair bridge edge contributed by every footprint on the board to the named cha...
int SubtractBridgingClamped(int aValue, long long aDelta)
Saturating subtract for bridge-adjusting MINOPTMAX<int> bounds without overflow when the delta is in ...
double BoardChainBridgingLength(const BOARD *aBoard, const wxString &aNetChain)
Sum chain bridging length across every footprint on the board.
NET_CHAIN_PARTITION_STATUS
Status returned by PartitionNetChainAroundNet().
double FootprintChainBridgingLength(const FOOTPRINT *aFootprint, const wxString &aNetChain)
Compute the bridging length contributed by a single footprint to a net chain.
One series-component bridge edge inside a chain graph.
Result of PartitionNetChainAroundNet().
std::set< int > beforeStart
NET_CHAIN_PARTITION_STATUS status