108 "net for length tuning. Make sure the names of the nets "
109 "belonging to a differential pair end with either _N/_P "
184 return std::max( totalP, totalN );
192 return std::max( totalP, totalN );
229 long long budgetMin = std::max( 0LL,
m_settings.m_targetSignalLength.Min() - otherLen );
230 long long budgetOpt = std::max( 0LL,
m_settings.m_targetSignalLength.Opt() - otherLen );
231 long long budgetMax = std::max( budgetOpt,
m_settings.m_targetSignalLength.Max() - otherLen );
235 m_settings.m_targetLength.SetMin( budgetMin );
236 m_settings.m_targetLength.SetOpt( budgetOpt );
237 m_settings.m_targetLength.SetMax( budgetMax );
297 if( coupledSegments.size() == 0 )
313 int offset = ( tuned.
Gap() + tuned.
Width() ) / 2;
318 m_result.SetBaselineOffset( offset );
324 PNS_DBG(
Dbg(), AddShape, &l->CLine(),
YELLOW, 10000, wxT(
"tuned-path-p" ) );
326 m_router->GetInterface()->DisplayPathLine( l->CLine(), 1 );
334 PNS_DBG(
Dbg(), AddShape, &l->CLine(),
YELLOW, 10000, wxT(
"tuned-path-n" ) );
336 m_router->GetInterface()->DisplayPathLine( l->CLine(), 1 );
342 std::optional<SHAPE_ARC> arc;
347 auto getItem = [&](
const SHAPE_LINE_CHAIN& aChain,
int aIndex,
int aLastIndex )
349 std::optional<SHAPE_ARC> optArc;
367 return GET_ITEM_RET{ optArc, startPt, endPt };
370 auto checkIndex = [&](
bool& aOk,
int aCurIndex,
int aLastIndex ) ->
bool
372 aOk = aCurIndex <= aLastIndex && aCurIndex != -1;
376 int curIndexP = 0, curIndexN = 0;
378 auto addCornersUntilIndex = [&](
int aLastIndexP,
int aLastIndexN )
383 checkIndex( p_ok, curIndexP, aLastIndexP );
384 checkIndex( n_ok, curIndexN, aLastIndexN );
389 auto p_item = getItem( tunedP, curIndexP, aLastIndexP );
390 auto n_item = getItem( tunedN, curIndexN, aLastIndexN );
392 if( !p_item.arc && !n_item.arc )
394 m_result.AddCorner( p_item.startPt, n_item.startPt );
396 else if( p_item.arc && n_item.arc )
398 m_result.AddArc( *p_item.arc, *n_item.arc );
400 else if( p_item.arc && !n_item.arc )
402 m_result.AddCorner( p_item.startPt, n_item.startPt );
405 while( checkIndex( n_ok, curIndexN, aLastIndexN ) )
407 curIndexN = tunedN.
NextShape( curIndexN );
408 n_item = getItem( tunedN, curIndexN, aLastIndexN );
412 m_result.AddArc( *p_item.arc, *n_item.arc );
417 m_result.AddCorner( p_item.startPt, n_item.startPt );
421 else if( !p_item.arc && n_item.arc )
423 m_result.AddCorner( p_item.startPt, n_item.startPt );
426 while( checkIndex( p_ok, curIndexP, aLastIndexP ) )
428 curIndexP = tunedP.
NextShape( curIndexP );
429 p_item = getItem( tunedP, curIndexP, aLastIndexP );
433 m_result.AddArc( *p_item.arc, *n_item.arc );
438 m_result.AddCorner( p_item.startPt, n_item.startPt );
444 curIndexP = tunedP.
NextShape( curIndexP );
447 curIndexN = tunedN.
NextShape( curIndexN );
457 side = base.
Side( aP ) < 0;
463 addCornersUntilIndex( sp.indexP, sp.indexN );
465 m_result.MeanderSegment( base, side );
489 int64_t tunedPDelay =
m_router->GetInterface()->CalculateDelayForShapeLineChain(
492 int64_t tunedNDelay =
m_router->GetInterface()->CalculateDelayForShapeLineChain(
496 m_lastDelay = dpDelay - std::max( tunedPDelay, tunedNDelay );
511 tunedP.
Append( m->CLine( 0 ) );
512 tunedN.
Append( m->CLine( 1 ) );
520 int64_t tunedPDelay =
m_router->GetInterface()->CalculateDelayForShapeLineChain(
523 int64_t tunedNDelay =
m_router->GetInterface()->CalculateDelayForShapeLineChain(
527 m_lastDelay += std::max( tunedPDelay, tunedNDelay );
619 int w = aShape->
Width();
698 std::vector<NET_HANDLE> rv;
711 const int64_t curDelayPair = curDelayChain -
m_settings.m_signalExtraDelay;
717 int64_t desiredDelayMin = targetDelaySet.
Min();
718 int64_t desiredDelayOpt = targetDelaySet.
Opt();
719 int64_t desiredDelayMax = targetDelaySet.
Max();
721 if( useSignalTarget )
723 desiredDelayMin = std::max<int64_t>( 0, desiredDelayMin -
m_settings.m_signalExtraDelay );
724 desiredDelayOpt = std::max<int64_t>( 0, desiredDelayOpt -
m_settings.m_signalExtraDelay );
725 desiredDelayMax = std::max<int64_t>( desiredDelayOpt, desiredDelayMax -
m_settings.m_signalExtraDelay );
728 const int64_t curDelay = useSignalTarget ? curDelayPair : curDelayChain;
730 const int64_t delayDifferenceOpt = desiredDelayOpt - curDelay;
733 const int64_t lengthDiffMin =
m_router->GetInterface()->CalculateLengthForDelay(
736 int64_t lengthDiffOpt =
m_router->GetInterface()->CalculateLengthForDelay(
739 const int64_t lengthDiffMax =
m_router->GetInterface()->CalculateLengthForDelay(
743 lengthDiffOpt = delayDifferenceOpt > 0 ? lengthDiffOpt : -lengthDiffOpt;
745 m_settings.m_targetLength.SetMin( curLength + lengthDiffOpt - lengthDiffMin );
746 m_settings.m_targetLength.SetOpt( curLength + lengthDiffOpt );
747 m_settings.m_targetLength.SetMax( curLength + lengthDiffOpt + lengthDiffMax );
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
ROUTER * Router() const
Return current router settings.
DEBUG_DECORATOR * Dbg() const
Basic class for a differential pair.
std::vector< COUPLED_SEGMENTS > COUPLED_SEGMENTS_VEC
void SetShape(const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN, bool aSwapLanes=false)
void CoupledSegmentPairs(COUPLED_SEGMENTS_VEC &aPairs) const
bool Start(const VECTOR2I &aP, ITEM *aStartItem) override
Start routing a single track at point aP, taking item aStartItem as anchor (unless NULL).
bool CheckFit(MEANDER_SHAPE *aShape) override
Checks if it's OK to place the shape aShape (i.e.
const ITEM_SET Traces() override
Function Traces()
SHAPE_LINE_CHAIN m_finalShapeP
bool AbortPlacement() override
friend class MEANDER_SHAPE
bool pairOrientation(const DIFF_PAIR::COUPLED_SEGMENTS &aPair)
DP_MEANDER_PLACER(ROUTER *aRouter)
SHAPE_LINE_CHAIN m_finalShapeN
void calculateTimeDomainTargets()
Current routing start point (end of tail, beginning of head).
VECTOR2I m_currentStart
Current world state.
bool FixRoute(const VECTOR2I &aP, ITEM *aEndItem, bool aForceFinish=false) override
Commit the currently routed track to the parent node, taking aP as the final end point and aEndItem a...
int CurrentLayer() const override
Function CurrentLayer()
TUNING_STATUS TuningStatus() const override
Return the tuning status (too short, too long, etc.) of the trace(s) being tuned.
long long int TuningLengthResult() const override
Return the resultant length or skew of the tuned traces.
const SEG baselineSegment(const DIFF_PAIR::COUPLED_SEGMENTS &aCoupledSegs)
TUNING_STATUS m_lastStatus
const DIFF_PAIR & GetOriginPair()
int64_t origPathDelay() const
const ITEM_SET TunedPath() override
bool HasPlacedAnything() const override
bool CommitPlacement() override
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Move the end of the currently routed trace to the point aP, taking aEndItem as anchor (if not NULL).
const VECTOR2I & CurrentEnd() const override
Function CurrentEnd()
long long int m_lastLength
const VECTOR2I & CurrentStart() const override
Function CurrentStart()
LINKED_ITEM * m_initialSegment
int64_t TuningDelayResult() const override
Return the resultant delay or skew of the tuned traces.
long long int origPathLength() const
const std::vector< NET_HANDLE > CurrentNets() const override
Function CurrentNets()
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Return the most recent world state.
void Add(const LINE &aLine)
Base class for PNS router board items.
BOARD_ITEM * GetSourceItem() const
bool OfKind(int aKindMask) const
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Represent a set of meanders fitted over a single or two lines.
long long int chainNarrowingOffset() const
Return the length offset to subtract when converting a user-facing total signal length target into a ...
void tuneLineLength(MEANDERED_LINE &aTuned, long long int aElongation)
Take a set of meanders in aTuned and tunes their length to extend the original line length by aElonga...
int64_t m_baselineDelay
Aggregate length/delay of other nets in the same chain, cached at Start().
TUNING_STATUS
< Result of the length tuning operation
int m_currentWidth
Meander settings.
bool m_chainExtrasValid
Pointer to world to search colliding items.
MEANDER_PLACER_BASE(ROUTER *aRouter)
long long int m_chainExtrasDelay
void initChainExtras()
Cache the per-session chain-extras length/delay (other nets in the same chain) so per-Move use does n...
MEANDER_SETTINGS m_settings
The current end point.
int64_t lineDelay(const ITEM_SET &aLine, const SOLID *aStartPad, const SOLID *aEndPad) const
Calculate the total delay of the line represented by an item set (tracks and vias)
NODE * m_world
Width of the meandered trace(s).
long long int lineLength(const ITEM_SET &aLine, const SOLID *aStartPad, const SOLID *aEndPad) const
Calculate the total length of the line represented by an item set (tracks and vias)
long long int m_baselineLength
static const long long int LENGTH_UNCONSTRAINED
static const long long int DELAY_UNCONSTRAINED
const SHAPE_LINE_CHAIN & CLine(int aShape) const
Keep the router "world" - i.e.
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
void SetFailureReason(const wxString &aReason)
const DIFF_PAIR AssembleDiffPair(SEGMENT *aStart)
const ITEM_SET AssembleTuningPath(ROUTER_IFACE *aRouterIface, ITEM *aStart, SOLID **aStartPad=nullptr, SOLID **aEndPad=nullptr)
Like AssembleTrivialPath, but follows the track length algorithm, which discards segments that are fu...
int Side(const VECTOR2I &aP) const
Determine on which side of directed line passing via segment ends point aP lies.
VECTOR2I GetEnd() const override
VECTOR2I GetStart() const override
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_ARC & Arc(size_t aArc) const
int PointCount() const
Return the number of points (vertices) in this line chain.
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
void Clear()
Remove all points from the line chain.
void Simplify(int aTolerance=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
int NextShape(int aPointIndex) const
Return the vertex index of the next shape in the chain, or -1 if aPointIndex is the last shape.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
virtual const SEG GetSegment(int aIndex) const override
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
bool IsArcSegment(size_t aSegment) const
long long int Length() const
Return length of the line chain in Euclidean metric.
Push and Shove diff pair dimensions (gap) settings dialog.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
#define PNS_DBG(dbg, method,...)
static VECTOR2I GetSnappedStartPoint(LINKED_ITEM *aStartItem, VECTOR2I aStartPoint)
Casted dyn_cast(From aObject)
A lightweight dynamic downcast.
VECTOR2< int32_t > VECTOR2I