KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LENGTH_DELAY_CALCULATION Class Reference

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

BOARDm_board
 The parent board for all items.
 
std::unique_ptr< TIME_DOMAIN_PARAMETERS_IFACEm_timeDomainParameters
 The active provider of time domain parameters.
 

Detailed Description

Class which calculates lengths (and associated routing statistics) in a BOARD context.

Definition at line 122 of file length_delay_calculation.h.

Member Enumeration Documentation

◆ MERGE_POINT

enum class LENGTH_DELAY_CALCULATION::MERGE_POINT
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.

Constructor & Destructor Documentation

◆ LENGTH_DELAY_CALCULATION()

LENGTH_DELAY_CALCULATION::LENGTH_DELAY_CALCULATION ( BOARD aBoard)
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.

Member Function Documentation

◆ CalculateDelay()

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.

Parameters
aItemsis the vector of items making up the route
aOptimisationsdetails the electrical path optimisations that should be applied to the board items
aStartPadis the starting pad of the route
aEndPadis 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().

◆ CalculateLength()

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.

Parameters
aItemsis the vector of items making up the route
aOptimisationsdetails the electrical path optimisations that should be applied to the board items
aStartPadis the starting pad of the route
aEndPadis 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().

◆ CalculateLengthDetails()

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

◆ CalculateLengthForDelay()

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.

Parameters
aDesiredDelayis the desired track delay (in IU)
aCtxis 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().

◆ CalculatePropagationDelayForShapeLineChain()

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.

Parameters
aShapeis the shape to calculate delay for
aCtxis 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().

◆ clipLineToPad()

void LENGTH_DELAY_CALCULATION::clipLineToPad ( SHAPE_LINE_CHAIN aLine,
const PAD aPad,
PCB_LAYER_ID  aLayer,
bool  aForward = true 
)
staticprotected

◆ GetLengthCalculationItem()

◆ inferViaInPad()

void LENGTH_DELAY_CALCULATION::inferViaInPad ( const PAD aPad,
const LENGTH_DELAY_CALCULATION_ITEM aItem,
LENGTH_DELAY_STATS aDetails 
) const
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().

◆ mergeLines()

◆ mergeShapeLineChains()

void LENGTH_DELAY_CALCULATION::mergeShapeLineChains ( SHAPE_LINE_CHAIN aPrimary,
const SHAPE_LINE_CHAIN aSecondary,
MERGE_POINT  aMergePoint 
)
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().

◆ OptimiseTraceInPad()

void LENGTH_DELAY_CALCULATION::OptimiseTraceInPad ( SHAPE_LINE_CHAIN aLine,
const PAD aPad,
PCB_LAYER_ID  aPcbLayer 
)
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().

◆ optimiseTracesInPads()

void LENGTH_DELAY_CALCULATION::optimiseTracesInPads ( const std::vector< LENGTH_DELAY_CALCULATION_ITEM * > &  aPads,
const std::vector< LENGTH_DELAY_CALCULATION_ITEM * > &  aLines 
)
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().

◆ optimiseViaLayers()

void LENGTH_DELAY_CALCULATION::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 
)
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().

◆ SetTimeDomainParametersProvider()

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.

◆ StackupHeight()

int LENGTH_DELAY_CALCULATION::StackupHeight ( PCB_LAYER_ID  aFirstLayer,
PCB_LAYER_ID  aSecondLayer 
) const

◆ SynchronizeTimeDomainProperties()

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().

Member Data Documentation

◆ m_board

BOARD* LENGTH_DELAY_CALCULATION::m_board
protected

The parent board for all items.

Definition at line 211 of file length_delay_calculation.h.

Referenced by CalculateLengthDetails(), GetLengthCalculationItem(), and StackupHeight().

◆ m_timeDomainParameters

std::unique_ptr<TIME_DOMAIN_PARAMETERS_IFACE> LENGTH_DELAY_CALCULATION::m_timeDomainParameters
protected

The documentation for this class was generated from the following files: