|
KiCad PCB EDA Suite
|
Class which calculates lengths (and associated routing statistics) in a BOARD context. More...
#include <length_delay_calculation.h>
Public Member Functions | |
| LENGTH_DELAY_CALCULATION (BOARD *aBoard) | |
| Construct the calculator in the given BOARD context. | |
| int64_t | CalculateLength (std::vector< LENGTH_DELAY_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr) const |
| Calculates the electrical length of the given items. | |
| int64_t | CalculateDelay (std::vector< LENGTH_DELAY_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr) const |
| Calculates the electrical propagation delay of the given items. | |
| LENGTH_DELAY_STATS | CalculateLengthDetails (std::vector< LENGTH_DELAY_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr, LENGTH_DELAY_LAYER_OPT aLayerOpt=LENGTH_DELAY_LAYER_OPT::NO_LAYER_DETAIL, LENGTH_DELAY_DOMAIN_OPT aDomain=LENGTH_DELAY_DOMAIN_OPT::NO_DELAY_DETAIL) const |
| Calculates the electrical length of the given items. | |
| int64_t | CalculatePropagationDelayForShapeLineChain (const SHAPE_LINE_CHAIN &aShape, const TUNING_PROFILE_GEOMETRY_CONTEXT &aCtx) const |
| Gets the propagation delay for the given shape line chain. | |
| int64_t | CalculateLengthForDelay (int64_t aDesiredDelay, const TUNING_PROFILE_GEOMETRY_CONTEXT &aCtx) const |
| Calculates the length of track required for the given delay in a specific geometry context. | |
| LENGTH_DELAY_CALCULATION_ITEM | GetLengthCalculationItem (const BOARD_CONNECTED_ITEM *aBoardItem) const |
| Return a LENGTH_CALCULATION_ITEM constructed from the given BOARD_CONNECTED_ITEM. | |
| void | SetTuningProfileParametersProvider (std::unique_ptr< TUNING_PROFILE_PARAMETERS_IFACE > &&aProvider) |
| Sets the provider for tuning profile parameter resolution. | |
| void | SynchronizeTuningProfileProperties () const |
| Ensure time domain properties provider is synced with board / project settings if required. | |
| int | StackupHeight (PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const |
| Returns the stackup distance between the two given layers. | |
Static Public Member Functions | |
| static void | OptimiseTraceInPad (SHAPE_LINE_CHAIN &aLine, const PAD *aPad, PCB_LAYER_ID aPcbLayer) |
| Optimises the given trace / line to minimise the electrical path length within the given pad. | |
| static bool | IsPointInsideViaPad (const PCB_VIA *aVia, const VECTOR2I &aPoint, PCB_LAYER_ID aLayer) |
| Returns true if the given point falls inside VIA pad shape on the given layer. | |
| static void | OptimiseTraceInVia (SHAPE_LINE_CHAIN &aLine, const PCB_VIA *aVia, PCB_LAYER_ID aLayer) |
| Clips trace portions inside a VIA pad and replaces them with a straight-line segment from the VIA edge intersection to the VIA centre, analogous to OptimiseTraceInPad. | |
Protected Types | |
| enum class | MERGE_POINT { START , END } |
| Enum to describe whether track merging is attempted from the start or end of a track segment. More... | |
Protected Member Functions | |
| void | optimiseVias (const std::vector< LENGTH_DELAY_CALCULATION_ITEM * > &aVias, std::vector< LENGTH_DELAY_CALCULATION_ITEM * > &aLines, std::map< VECTOR2I, std::unordered_set< LENGTH_DELAY_CALCULATION_ITEM * > > &aLinesPositionMap, const std::map< VECTOR2I, std::unordered_set< LENGTH_DELAY_CALCULATION_ITEM * > > &aPadsPositionMap) const |
| Optimises the via layers. | |
| void | inferViaInPad (const PAD *aPad, const LENGTH_DELAY_CALCULATION_ITEM &aItem, LENGTH_DELAY_STATS &aDetails) const |
| Infers if there is a via in the given pad. | |
Static Protected Member Functions | |
| static void | optimiseTracesInPads (const std::vector< LENGTH_DELAY_CALCULATION_ITEM * > &aPads, const std::vector< LENGTH_DELAY_CALCULATION_ITEM * > &aLines) |
| Optimises the given set of items to minimise the electrical path length. | |
| static void | clipLineToPad (SHAPE_LINE_CHAIN &aLine, const PAD *aPad, PCB_LAYER_ID aLayer, bool aForward=true) |
| Clips the given line to the minimal direct electrical length within the pad. | |
| static void | clipLineToVia (SHAPE_LINE_CHAIN &aLine, const PCB_VIA *aVia, PCB_LAYER_ID aLayer, bool aForward) |
| Clips the given line to the minimal direct electrical length within the via. | |
| static void | mergeLines (std::vector< LENGTH_DELAY_CALCULATION_ITEM * > &aLines, std::map< VECTOR2I, std::unordered_set< LENGTH_DELAY_CALCULATION_ITEM * > > &aLinesPositionMap) |
| Merges any lines (traces) that are contiguous, on one layer, and with no junctions. | |
| static void | mergeShapeLineChains (SHAPE_LINE_CHAIN &aPrimary, const SHAPE_LINE_CHAIN &aSecondary, MERGE_POINT aMergePoint) |
| Merges two SHAPE_LINE_CHAINs where there is a shared endpoing. | |
| static bool | findArcPadIntersection (const SHAPE_ARC &aArc, const std::shared_ptr< SHAPE_POLY_SET > &aPadShape, const VECTOR2I &aInsidePoint, VECTOR2I &aIntersection) |
| Finds the intersection point between an arc and a pad shape. | |
Protected Attributes | |
| BOARD * | m_board |
| The parent board for all items. | |
| std::unique_ptr< TUNING_PROFILE_PARAMETERS_IFACE > | m_tuningProfileParameters |
| The active provider of tuning profile parameters. | |
Class which calculates lengths (and associated routing statistics) in a BOARD context.
Definition at line 123 of file length_delay_calculation.h.
|
strongprotected |
Enum to describe whether track merging is attempted from the start or end of a track segment.
| Enumerator | |
|---|---|
| START | |
| END | |
Definition at line 225 of file length_delay_calculation.h.
|
inlineexplicit |
Construct the calculator in the given BOARD context.
Also constructs a default user-defined time domain parameters provider
Definition at line 130 of file length_delay_calculation.h.
References m_board, and m_tuningProfileParameters.
| int64_t LENGTH_DELAY_CALCULATION::CalculateDelay | ( | std::vector< LENGTH_DELAY_CALCULATION_ITEM > & | aItems, |
| PATH_OPTIMISATIONS | aOptimisations, | ||
| const PAD * | aStartPad = nullptr, | ||
| const PAD * | aEndPad = nullptr ) const |
Calculates the electrical propagation delay of the given items.
| aItems | is the vector of items making up the route |
| aOptimisations | details the electrical path optimisations that should be applied to the board items |
| aStartPad | is the starting pad of the route |
| aEndPad | is the ending pad of the route |
Definition at line 444 of file length_delay_calculation.cpp.
References CalculateLengthDetails(), NO_LAYER_DETAIL, LENGTH_DELAY_STATS::TotalDelay(), and WITH_DELAY_DETAIL.
Referenced by PNS_KICAD_IFACE_BASE::CalculateRoutedPathDelay(), and PCB_TRACK::GetDelay().
| int64_t LENGTH_DELAY_CALCULATION::CalculateLength | ( | std::vector< LENGTH_DELAY_CALCULATION_ITEM > & | aItems, |
| PATH_OPTIMISATIONS | aOptimisations, | ||
| const PAD * | aStartPad = nullptr, | ||
| const PAD * | aEndPad = nullptr ) const |
Calculates the electrical length of the given items.
| aItems | is the vector of items making up the route |
| aOptimisations | details the electrical path optimisations that should be applied to the board items |
| aStartPad | is the starting pad of the route |
| aEndPad | is the ending pad of the route |
Definition at line 436 of file length_delay_calculation.cpp.
References CalculateLengthDetails(), and LENGTH_DELAY_STATS::TotalLength().
Referenced by PNS_KICAD_IFACE_BASE::CalculateRoutedPathLength().
| LENGTH_DELAY_STATS LENGTH_DELAY_CALCULATION::CalculateLengthDetails | ( | std::vector< LENGTH_DELAY_CALCULATION_ITEM > & | aItems, |
| PATH_OPTIMISATIONS | aOptimisations, | ||
| const PAD * | aStartPad = nullptr, | ||
| const PAD * | aEndPad = nullptr, | ||
| LENGTH_DELAY_LAYER_OPT | aLayerOpt = LENGTH_DELAY_LAYER_OPT::NO_LAYER_DETAIL, | ||
| LENGTH_DELAY_DOMAIN_OPT | aDomain = LENGTH_DELAY_DOMAIN_OPT::NO_DELAY_DETAIL ) const |
Calculates the electrical length of the given items.
| aItems | is the vector of items making up the route |
| aOptimisations | details the electrical path optimisations that should be applied to the board items |
| aStartPad | is the starting pad of the route |
| aEndPad | is the ending pad of the route |
| aLayerOpt | determines whether the layer details map is populated |
| aDomain | determines whether calculations include time domain (delay) details |
Definition at line 153 of file length_delay_calculation.cpp.
References LENGTH_DELAY_CALCULATION_ITEM::GetStartLayer(), PATH_OPTIMISATIONS::InferViaInPad, inferViaInPad(), LENGTH_DELAY_STATS::LayerDelays, LENGTH_DELAY_STATS::LayerLengths, m_board, m_tuningProfileParameters, LENGTH_DELAY_CALCULATION_ITEM::MERGED_IN_USE, LENGTH_DELAY_CALCULATION_ITEM::MERGED_RETIRED, mergeLines(), PATH_OPTIMISATIONS::MergeTracks, TUNING_PROFILE_GEOMETRY_CONTEXT::NetClass, LENGTH_DELAY_STATS::NumPads, LENGTH_DELAY_STATS::NumVias, OptimiseTraceInVia(), PATH_OPTIMISATIONS::OptimiseTracesInPads, optimiseTracesInPads(), PATH_OPTIMISATIONS::OptimiseVias, optimiseVias(), LENGTH_DELAY_STATS::PadToDieDelay, LENGTH_DELAY_STATS::PadToDieLength, StackupHeight(), LENGTH_DELAY_STATS::TotalLength(), LENGTH_DELAY_STATS::TrackDelay, LENGTH_DELAY_STATS::TrackLength, LENGTH_DELAY_CALCULATION_ITEM::Type(), via, LENGTH_DELAY_STATS::ViaDelay, LENGTH_DELAY_STATS::ViaLength, WITH_DELAY_DETAIL, and WITH_LAYER_DETAIL.
Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), CalculateDelay(), CalculateLength(), PCB_NET_INSPECTOR_PANEL::calculateNets(), and BOARD::GetTrackLength().
| int64_t LENGTH_DELAY_CALCULATION::CalculateLengthForDelay | ( | int64_t | aDesiredDelay, |
| const TUNING_PROFILE_GEOMETRY_CONTEXT & | aCtx ) const |
Calculates the length of track required for the given delay in a specific geometry context.
| aDesiredDelay | is the desired track delay (in IU) |
| aCtx | is the track geometry context to calculate propagation velocitiy against |
Definition at line 925 of file length_delay_calculation.cpp.
References m_tuningProfileParameters.
Referenced by PNS_KICAD_IFACE_BASE::CalculateLengthForDelay().
| int64_t LENGTH_DELAY_CALCULATION::CalculatePropagationDelayForShapeLineChain | ( | const SHAPE_LINE_CHAIN & | aShape, |
| const TUNING_PROFILE_GEOMETRY_CONTEXT & | aCtx ) const |
Gets the propagation delay for the given shape line chain.
| aShape | is the shape to calculate delay for |
| aCtx | is the geometry context for which to query to propagation delay |
Definition at line 932 of file length_delay_calculation.cpp.
References m_tuningProfileParameters.
Referenced by PNS_KICAD_IFACE_BASE::CalculateDelayForShapeLineChain().
|
staticprotected |
Clips the given line to the minimal direct electrical length within the pad.
Definition at line 78 of file length_delay_calculation.cpp.
References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::Arc(), SHAPE_LINE_CHAIN::ArcIndex(), delta, ERROR_INSIDE, findArcPadIntersection(), PAD::GetEffectivePolygon(), SHAPE_LINE_CHAIN::GetPoint(), PAD::GetPosition(), SHAPE_LINE_CHAIN::PointCount(), and SHAPE_LINE_CHAIN::Slice().
Referenced by OptimiseTraceInPad().
|
staticprotected |
Clips the given line to the minimal direct electrical length within the via.
Definition at line 731 of file length_delay_calculation.cpp.
References ALWAYS_FLASHED, SHAPE_LINE_CHAIN::Append(), circle(), delta, SHAPE_CIRCLE::GetCenter(), PCB_VIA::GetEffectiveShape(), SHAPE_LINE_CHAIN::GetPoint(), PCB_VIA::GetPosition(), SHAPE_CIRCLE::GetRadius(), SHAPE_LINE_CHAIN::PointCount(), and SHAPE_LINE_CHAIN::Slice().
Referenced by OptimiseTraceInVia().
|
staticprotected |
Finds the intersection point between an arc and a pad shape.
Definition at line 38 of file length_delay_calculation.cpp.
References SEG::Contains(), SHAPE_LINE_CHAIN::CSegment(), SHAPE_ARC::IntersectLine(), and SHAPE_LINE_CHAIN::SegmentCount().
Referenced by clipLineToPad().
| LENGTH_DELAY_CALCULATION_ITEM LENGTH_DELAY_CALCULATION::GetLengthCalculationItem | ( | const BOARD_CONNECTED_ITEM * | aBoardItem | ) | const |
Return a LENGTH_CALCULATION_ITEM constructed from the given BOARD_CONNECTED_ITEM.
Definition at line 841 of file length_delay_calculation.cpp.
References LENGTH_DELAY_CALCULATION_ITEM::CalculateViaLayers(), LSET::copper_layers_begin(), LSET::copper_layers_end(), BOARD_CONNECTED_ITEM::GetEffectiveNetClass(), PCB_TRACK::GetEnd(), PCB_ARC::GetMid(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), m_board, pad, PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, LENGTH_DELAY_CALCULATION_ITEM::SetEffectiveNetClass(), LENGTH_DELAY_CALCULATION_ITEM::SetLayers(), LENGTH_DELAY_CALCULATION_ITEM::SetLine(), LENGTH_DELAY_CALCULATION_ITEM::SetPad(), LENGTH_DELAY_CALCULATION_ITEM::SetVia(), UNDEFINED_LAYER, and via.
Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), PCB_NET_INSPECTOR_PANEL::calculateNets(), PCB_TRACK::GetDelay(), and BOARD::GetTrackLength().
|
protected |
Infers if there is a via in the given pad.
Adds via details to the length details data structure if found.
Definition at line 416 of file length_delay_calculation.cpp.
References B_Cu, LSET::Contains(), F_Cu, LENGTH_DELAY_CALCULATION_ITEM::GetStartLayer(), PADSTACK::LayerSet(), LENGTH_DELAY_STATS::NumVias, PAD::Padstack(), StackupHeight(), LENGTH_DELAY_CALCULATION_ITEM::Type(), and LENGTH_DELAY_STATS::ViaLength.
Referenced by CalculateLengthDetails().
|
static |
Returns true if the given point falls inside VIA pad shape on the given layer.
Definition at line 833 of file length_delay_calculation.cpp.
References ALWAYS_FLASHED, and PCB_VIA::GetEffectiveShape().
Referenced by PNS::TOPOLOGY::findLinesFromVia().
|
staticprotected |
Merges any lines (traces) that are contiguous, on one layer, and with no junctions.
Definition at line 473 of file length_delay_calculation.cpp.
References SHAPE_LINE_CHAIN::CArcs(), SHAPE_LINE_CHAIN::CLastPoint(), SHAPE_LINE_CHAIN::CPoint(), END, LENGTH_DELAY_CALCULATION_ITEM::GetLine(), LENGTH_DELAY_CALCULATION_ITEM::GetStartLayer(), LENGTH_DELAY_CALCULATION_ITEM::MERGED_IN_USE, LENGTH_DELAY_CALCULATION_ITEM::MERGED_RETIRED, mergeShapeLineChains(), LENGTH_DELAY_CALCULATION_ITEM::SetMergeStatus(), START, and LENGTH_DELAY_CALCULATION_ITEM::UNMERGED.
Referenced by CalculateLengthDetails().
|
staticprotected |
Merges two SHAPE_LINE_CHAINs where there is a shared endpoing.
aSecondary is merged in to aPrimary
Definition at line 552 of file length_delay_calculation.cpp.
References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::CLastPoint(), SHAPE_LINE_CHAIN::CPoints(), SHAPE_LINE_CHAIN::GetPoint(), SHAPE_LINE_CHAIN::Insert(), and START.
Referenced by mergeLines().
|
static |
Optimises the given trace / line to minimise the electrical path length within the given pad.
Definition at line 712 of file length_delay_calculation.cpp.
References SHAPE_LINE_CHAIN::CLastPoint(), clipLineToPad(), SHAPE_LINE_CHAIN::CPoint(), ERROR_INSIDE, PAD::FlashLayer(), PAD::GetEffectivePolygon(), and PAD::GetPosition().
Referenced by PNS::TOPOLOGY::AssembleTuningPath(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and optimiseTracesInPads().
|
static |
Clips trace portions inside a VIA pad and replaces them with a straight-line segment from the VIA edge intersection to the VIA centre, analogous to OptimiseTraceInPad.
Definition at line 819 of file length_delay_calculation.cpp.
References ALWAYS_FLASHED, SHAPE_LINE_CHAIN::CLastPoint(), clipLineToVia(), SHAPE_LINE_CHAIN::CPoint(), and PCB_VIA::GetEffectiveShape().
Referenced by PNS::TOPOLOGY::AssembleTuningPath(), CalculateLengthDetails(), and PNS::TOPOLOGY::walkTuningPath().
|
staticprotected |
Optimises the given set of items to minimise the electrical path length.
At the moment only optimises lines attached to pads, future work could optimise paths through pads
Assumes that any polylines are only connected at either end, and not at midpoints
Definition at line 588 of file length_delay_calculation.cpp.
References LENGTH_DELAY_CALCULATION_ITEM::MERGED_IN_USE, OptimiseTraceInPad(), and pad.
Referenced by CalculateLengthDetails().
|
protected |
Optimises the via layers.
Ensures that vias that are routed through only on one layer do not count towards total length calculations.
Definition at line 610 of file length_delay_calculation.cpp.
References ALWAYS_FLASHED, CONN, LSET::CuStack(), PADSTACK::ForEachUniqueLayer(), PAD::GetAttribute(), PCB_VIA::GetEffectiveShape(), FOOTPRINT::GetLayer(), PCB_VIA::GetLayer(), BOARD_ITEM::GetParentFootprint(), PCB_VIA::GetPosition(), PCB_VIA::GetWidth(), PADSTACK::LayerSet(), m_board, pad, PAD::Padstack(), PCB_VIA::Padstack(), BASE_SET::set(), SMD, via, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by CalculateLengthDetails().
| void LENGTH_DELAY_CALCULATION::SetTuningProfileParametersProvider | ( | std::unique_ptr< TUNING_PROFILE_PARAMETERS_IFACE > && | aProvider | ) |
Sets the provider for tuning profile parameter resolution.
Definition at line 912 of file length_delay_calculation.cpp.
References m_tuningProfileParameters.
| int LENGTH_DELAY_CALCULATION::StackupHeight | ( | PCB_LAYER_ID | aFirstLayer, |
| PCB_LAYER_ID | aSecondLayer ) const |
Returns the stackup distance between the two given layers.
Note: Can return 0 if the board design settings disallow stackup height calculations
Definition at line 454 of file length_delay_calculation.cpp.
References BOARD_STACKUP::BuildDefaultStackupList(), BOARD_STACKUP::GetLayerDistance(), and m_board.
Referenced by BOOST_FIXTURE_TEST_CASE(), CalculateLengthDetails(), and inferViaInPad().
| void LENGTH_DELAY_CALCULATION::SynchronizeTuningProfileProperties | ( | ) | const |
Ensure time domain properties provider is synced with board / project settings if required.
Definition at line 919 of file length_delay_calculation.cpp.
References m_tuningProfileParameters.
Referenced by PCB_EDIT_FRAME::OpenProjectFiles().
|
protected |
The parent board for all items.
Definition at line 219 of file length_delay_calculation.h.
Referenced by CalculateLengthDetails(), GetLengthCalculationItem(), LENGTH_DELAY_CALCULATION(), optimiseVias(), and StackupHeight().
|
protected |
The active provider of tuning profile parameters.
Definition at line 222 of file length_delay_calculation.h.
Referenced by CalculateLengthDetails(), CalculateLengthForDelay(), CalculatePropagationDelayForShapeLineChain(), LENGTH_DELAY_CALCULATION(), SetTuningProfileParametersProvider(), and SynchronizeTuningProfileProperties().