PNS: Account for via stack height in diff pair length tuner

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8256
This commit is contained in:
Jon Evans 2021-04-20 19:31:10 -04:00
parent a7f956581c
commit 2535daf661
6 changed files with 39 additions and 56 deletions

View File

@ -141,22 +141,8 @@ void DP_MEANDER_PLACER::release()
long long int DP_MEANDER_PLACER::origPathLength() const
{
long long int totalP = m_padToDieLength;
long long int totalN = m_padToDieLength;
for( const ITEM* item : m_tunedPathP.CItems() )
{
if( const LINE* l = dyn_cast<const LINE*>( item ) )
totalP += l->CLine().Length();
}
for( const ITEM* item : m_tunedPathN.CItems() )
{
if( const LINE* l = dyn_cast<const LINE*>( item ) )
totalN += l->CLine().Length();
}
long long int totalP = m_padToDieLength + lineLength( m_tunedPathP );
long long int totalN = m_padToDieLength + lineLength( m_tunedPathN );
return std::max( totalP, totalN );
}

View File

@ -97,27 +97,7 @@ bool MEANDER_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
long long int MEANDER_PLACER::origPathLength() const
{
long long int total = m_padToDieLength;
for( int idx = 0; idx < m_tunedPath.Size(); idx++ )
{
const ITEM* item = m_tunedPath[idx];
if( const LINE* l = dyn_cast<const LINE*>( item ) )
{
total += l->CLine().Length();
}
else if( item->OfKind( ITEM::VIA_T ) && idx > 0 && idx < m_tunedPath.Size() - 1 )
{
int layerPrev = m_tunedPath[idx - 1]->Layer();
int layerNext = m_tunedPath[idx + 1]->Layer();
if( layerPrev != layerNext )
total += m_router->GetInterface()->StackupHeight( layerPrev, layerNext );
}
}
return total;
return m_padToDieLength + lineLength( m_tunedPath );
}

View File

@ -260,4 +260,30 @@ VECTOR2I MEANDER_PLACER_BASE::getSnappedStartPoint( LINKED_ITEM* aStartItem, VEC
}
}
long long int MEANDER_PLACER_BASE::lineLength( const ITEM_SET& aLine ) const
{
long long int total = 0;
for( int idx = 0; idx < aLine.Size(); idx++ )
{
const ITEM* item = aLine[idx];
if( const LINE* l = dyn_cast<const LINE*>( item ) )
{
total += l->CLine().Length();
}
else if( item->OfKind( ITEM::VIA_T ) && idx > 0 && idx < aLine.Size() - 1 )
{
int layerPrev = aLine[idx - 1]->Layer();
int layerNext = aLine[idx + 1]->Layer();
if( layerPrev != layerNext )
total += m_router->GetInterface()->StackupHeight( layerPrev, layerNext );
}
}
return total;
}
}

View File

@ -137,6 +137,13 @@ protected:
VECTOR2I getSnappedStartPoint( LINKED_ITEM* aStartItem, VECTOR2I aStartPoint );
/**
* Calculate the total length of the line represented by an item set (tracks and vias)
* @param aLine
* @return
*/
long long int lineLength( const ITEM_SET& aLine ) const;
///< Pointer to world to search colliding items.
NODE* m_world;

View File

@ -111,12 +111,12 @@ bool MEANDER_SKEW_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
if ( m_originPair.PLine().Net() == m_originLine.Net() )
{
m_padToDieLength = m_padToDieN;
m_coupledLength = itemsetLength( m_tunedPathN );
m_coupledLength = lineLength( m_tunedPathN );
}
else
{
m_padToDieLength = m_padToDieP;
m_coupledLength = itemsetLength( m_tunedPathP );
m_coupledLength = lineLength( m_tunedPathP );
}
return true;
@ -125,22 +125,7 @@ bool MEANDER_SKEW_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
long long int MEANDER_SKEW_PLACER::origPathLength() const
{
return itemsetLength ( m_tunedPath );
}
long long int MEANDER_SKEW_PLACER::itemsetLength( const ITEM_SET& aSet ) const
{
long long int total = m_padToDieLength;
for( const ITEM* item : aSet.CItems() )
{
if( const LINE* l = dyn_cast<const LINE*>( item ) )
{
total += l->CLine().Length();
}
}
return total;
return lineLength( m_tunedPath );
}

View File

@ -53,7 +53,6 @@ public:
private:
long long int currentSkew() const;
long long int itemsetLength( const ITEM_SET& aSet ) const;
long long int origPathLength() const override;