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 TIME_DOMAIN_GEOMETRY_CONTEXT &aCtx) const |
Gets the propagation delay for the given shape line chain. | |
int64_t | CalculateLengthForDelay (int64_t aDesiredDelay, const TIME_DOMAIN_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 | SetTimeDomainParametersProvider (std::unique_ptr< TIME_DOMAIN_PARAMETERS_IFACE > &&aProvider) |
Sets the provider for time domain parameter resolution. | |
void | SynchronizeTimeDomainProperties () 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. | |
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 | 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 | optimiseViaLayers (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) |
Optimises the via layers. | |
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. | |
Protected Attributes | |
BOARD * | m_board |
The parent board for all items. | |
std::unique_ptr< TIME_DOMAIN_PARAMETERS_IFACE > | m_timeDomainParameters |
The active provider of time domain parameters. | |
Class which calculates lengths (and associated routing statistics) in a BOARD context.
Definition at line 122 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 217 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 129 of file length_delay_calculation.h.
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 249 of file length_delay_calculation.cpp.
References CalculateLengthDetails(), and LENGTH_DELAY_STATS::TotalDelay().
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 241 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 81 of file length_delay_calculation.cpp.
References BOARD::GetDesignSettings(), LENGTH_DELAY_CALCULATION_ITEM::GetStartLayer(), PATH_OPTIMISATIONS::InferViaInPad, inferViaInPad(), LENGTH_DELAY_STATS::LayerDelays, LENGTH_DELAY_STATS::LayerLengths, m_board, m_timeDomainParameters, BOARD_DESIGN_SETTINGS::m_UseHeightForLengthCalcs, LENGTH_DELAY_CALCULATION_ITEM::MERGED_RETIRED, mergeLines(), PATH_OPTIMISATIONS::MergeTracks, TIME_DOMAIN_GEOMETRY_CONTEXT::NetClass, LENGTH_DELAY_STATS::NumPads, LENGTH_DELAY_STATS::NumVias, PATH_OPTIMISATIONS::OptimiseTracesInPads, optimiseTracesInPads(), PATH_OPTIMISATIONS::OptimiseViaLayers, optimiseViaLayers(), LENGTH_DELAY_STATS::PadToDieDelay, LENGTH_DELAY_STATS::PadToDieLength, StackupHeight(), LENGTH_DELAY_STATS::TrackDelay, LENGTH_DELAY_STATS::TrackLength, LENGTH_DELAY_CALCULATION_ITEM::Type(), LENGTH_DELAY_STATS::ViaDelay, and LENGTH_DELAY_STATS::ViaLength.
Referenced by CalculateDelay(), CalculateLength(), and BOARD::GetTrackLength().
int64_t LENGTH_DELAY_CALCULATION::CalculateLengthForDelay | ( | int64_t | aDesiredDelay, |
const TIME_DOMAIN_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 601 of file length_delay_calculation.cpp.
References m_timeDomainParameters.
Referenced by PNS_KICAD_IFACE_BASE::CalculateLengthForDelay().
int64_t LENGTH_DELAY_CALCULATION::CalculatePropagationDelayForShapeLineChain | ( | const SHAPE_LINE_CHAIN & | aShape, |
const TIME_DOMAIN_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 609 of file length_delay_calculation.cpp.
References m_timeDomainParameters.
Referenced by PNS_KICAD_IFACE_BASE::CalculateDelayForShapeLineChain().
|
staticprotected |
Clips the given line to the minimal direct electrical length within the pad.
Definition at line 31 of file length_delay_calculation.cpp.
References SEG::A, SEG::B, delta, ERROR_INSIDE, PAD::GetEffectivePolygon(), SHAPE_LINE_CHAIN::GetPoint(), PAD::GetPosition(), SHAPE_LINE_CHAIN::Insert(), SHAPE_LINE_CHAIN::IsPtOnArc(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN::Remove(), and SHAPE_LINE_CHAIN::Replace().
Referenced by OptimiseTraceInPad().
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 517 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 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 221 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().
|
staticprotected |
Merges any lines (traces) that are contiguous, on one layer, and with no junctions.
Definition at line 278 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 357 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 497 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(), and optimiseTracesInPads().
|
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 393 of file length_delay_calculation.cpp.
References LENGTH_DELAY_CALCULATION_ITEM::MERGED_IN_USE, OptimiseTraceInPad(), and pad.
Referenced by CalculateLengthDetails().
|
staticprotected |
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 415 of file length_delay_calculation.cpp.
References LSET::Contains(), LSET::CuStack(), LENGTH_DELAY_CALCULATION_ITEM::GetPad(), LENGTH_DELAY_CALCULATION_ITEM::GetStartLayer(), PADSTACK::LayerSet(), PAD::Padstack(), BASE_SET::set(), UNDEFINED_LAYER, and via.
Referenced by CalculateLengthDetails().
void LENGTH_DELAY_CALCULATION::SetTimeDomainParametersProvider | ( | std::unique_ptr< TIME_DOMAIN_PARAMETERS_IFACE > && | aProvider | ) |
Sets the provider for time domain parameter resolution.
Definition at line 588 of file length_delay_calculation.cpp.
References m_timeDomainParameters.
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 259 of file length_delay_calculation.cpp.
References BOARD_STACKUP::BuildDefaultStackupList(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), BOARD_STACKUP::GetLayerDistance(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), m_board, BOARD_DESIGN_SETTINGS::m_HasStackup, and BOARD_DESIGN_SETTINGS::m_UseHeightForLengthCalcs.
Referenced by CalculateLengthDetails(), TIME_DOMAIN_PARAMETERS_USER_DEFINED::getPropagationDelay(), and inferViaInPad().
void LENGTH_DELAY_CALCULATION::SynchronizeTimeDomainProperties | ( | ) | const |
Ensure time domain properties provider is synced with board / project settings if required.
Definition at line 595 of file length_delay_calculation.cpp.
References m_timeDomainParameters.
Referenced by PCB_EDIT_FRAME::OpenProjectFiles().
|
protected |
The parent board for all items.
Definition at line 211 of file length_delay_calculation.h.
Referenced by CalculateLengthDetails(), GetLengthCalculationItem(), and StackupHeight().
|
protected |
The active provider of time domain parameters.
Definition at line 214 of file length_delay_calculation.h.
Referenced by CalculateLengthDetails(), CalculateLengthForDelay(), CalculatePropagationDelayForShapeLineChain(), SetTimeDomainParametersProvider(), and SynchronizeTimeDomainProperties().