2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2015 CERN
|
2016-08-29 14:38:11 +00:00
|
|
|
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-02-18 00:29:54 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __PNS_DIFF_PAIR_H
|
|
|
|
#define __PNS_DIFF_PAIR_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "pns_line.h"
|
|
|
|
#include "pns_via.h"
|
2020-04-15 20:16:24 +00:00
|
|
|
#include "pns_link_holder.h"
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
#include "ranged_num.h"
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
class DIFF_PAIR;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* DP_GATEWAY
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
|
|
|
* Defines a "gateway" for routing a differential pair - e.g. a pair of points (anchors) with certain
|
|
|
|
* orientation, spacing and (optionally) predefined entry paths. The routing algorithm connects such
|
|
|
|
* gateways with parallel lines, thus creating a difrerential pair.
|
|
|
|
**/
|
2016-08-29 17:31:13 +00:00
|
|
|
class DP_GATEWAY {
|
2015-02-18 00:29:54 +00:00
|
|
|
public:
|
2016-08-29 17:31:13 +00:00
|
|
|
DP_GATEWAY( const VECTOR2I& aAnchorP,
|
2015-02-18 16:53:46 +00:00
|
|
|
const VECTOR2I& aAnchorN,
|
|
|
|
bool aIsDiagonal,
|
|
|
|
int aAllowedEntryAngles = DIRECTION_45::ANG_OBTUSE,
|
|
|
|
int aPriority = 0 )
|
|
|
|
: m_anchorP( aAnchorP ),
|
|
|
|
m_anchorN( aAnchorN ),
|
|
|
|
m_isDiagonal( aIsDiagonal ),
|
|
|
|
m_allowedEntryAngles( aAllowedEntryAngles ),
|
|
|
|
m_priority( aPriority )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_hasEntryLines = false;
|
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
~DP_GATEWAY()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsDiagonal()
|
|
|
|
*
|
|
|
|
* @return true, if the gateway anchors lie on a diagonal line
|
|
|
|
*/
|
|
|
|
bool IsDiagonal() const
|
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
return m_isDiagonal;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
const VECTOR2I& AnchorP() const { return m_anchorP; }
|
|
|
|
|
|
|
|
const VECTOR2I& AnchorN() const { return m_anchorN; }
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
|
|
|
* Function AllowedAngles()
|
|
|
|
*
|
|
|
|
* @return a mask of 45-degree entry directoins allowed for the
|
|
|
|
* gateway.
|
|
|
|
*/
|
|
|
|
int AllowedAngles () const { return m_allowedEntryAngles; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Priority()
|
|
|
|
*
|
|
|
|
* @return priority/score value for gateway matching
|
|
|
|
*/
|
2015-02-18 16:53:46 +00:00
|
|
|
int Priority() const
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
return m_priority;
|
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
void SetPriority(int aPriority)
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_priority = aPriority;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
void SetEntryLines( const SHAPE_LINE_CHAIN& aEntryP, const SHAPE_LINE_CHAIN& aEntryN )
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
m_entryP = aEntryP;
|
|
|
|
m_entryN = aEntryN;
|
|
|
|
m_hasEntryLines = true;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
const SHAPE_LINE_CHAIN& EntryP() const { return m_entryP; }
|
|
|
|
const SHAPE_LINE_CHAIN& EntryN() const { return m_entryN; }
|
2016-08-29 17:31:13 +00:00
|
|
|
const DIFF_PAIR Entry() const ;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
void Reverse();
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
bool HasEntryLines () const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
return m_hasEntryLines;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
private:
|
2015-02-18 00:29:54 +00:00
|
|
|
SHAPE_LINE_CHAIN m_entryP, m_entryN;
|
|
|
|
bool m_hasEntryLines;
|
|
|
|
VECTOR2I m_anchorP, m_anchorN;
|
|
|
|
bool m_isDiagonal;
|
|
|
|
int m_allowedEntryAngles;
|
|
|
|
int m_priority;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* DP_PRIMITIVE_PAIR
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
|
|
|
* Stores staring/ending primitives (pads, vias or segments) for a differential pair.
|
|
|
|
**/
|
2016-08-29 17:31:13 +00:00
|
|
|
class DP_PRIMITIVE_PAIR
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-08-29 17:31:13 +00:00
|
|
|
DP_PRIMITIVE_PAIR():
|
2015-02-18 16:53:46 +00:00
|
|
|
m_primP( NULL ), m_primN( NULL ) {};
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DP_PRIMITIVE_PAIR( const DP_PRIMITIVE_PAIR& aOther );
|
|
|
|
DP_PRIMITIVE_PAIR( ITEM* aPrimP, ITEM* aPrimN );
|
|
|
|
DP_PRIMITIVE_PAIR( const VECTOR2I& aAnchorP, const VECTOR2I& aAnchorN );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
~DP_PRIMITIVE_PAIR();
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
void SetAnchors( const VECTOR2I& aAnchorP, const VECTOR2I& aAnchorN );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
const VECTOR2I& AnchorP() const { return m_anchorP; }
|
|
|
|
const VECTOR2I& AnchorN() const { return m_anchorN; }
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DP_PRIMITIVE_PAIR& operator=( const DP_PRIMITIVE_PAIR& aOther );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM* PrimP() const { return m_primP; }
|
|
|
|
ITEM* PrimN() const { return m_primN; }
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
bool Directional() const;
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
DIRECTION_45 DirP() const;
|
|
|
|
DIRECTION_45 DirN() const;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-15 15:16:49 +00:00
|
|
|
|
|
|
|
void CursorOrientation( const VECTOR2I& aCursorPos, VECTOR2I& aMidpoint, VECTOR2I& aDirection ) const;
|
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
void dump()
|
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
printf( "-- Prim-P %p anchor [%d, %d]\n", m_primP, m_anchorP.x, m_anchorP.y );
|
|
|
|
printf( "-- Prim-N %p anchor [%d, %d]\n", m_primN, m_anchorN.x, m_anchorN.y );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
private:
|
2019-05-17 00:13:21 +00:00
|
|
|
DIRECTION_45 anchorDirection( const ITEM* aItem, const VECTOR2I& aP ) const;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM* m_primP;
|
|
|
|
ITEM* m_primN;
|
2015-02-18 00:29:54 +00:00
|
|
|
VECTOR2I m_anchorP, m_anchorN;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* DP_GATEWAYS
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
|
|
|
* A set of gateways calculated for the cursor or starting/ending primitive pair.
|
|
|
|
**/
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
class DP_GATEWAYS
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-08-29 17:31:13 +00:00
|
|
|
DP_GATEWAYS( int aGap ):
|
2021-01-05 00:03:14 +00:00
|
|
|
m_gap( aGap ),
|
|
|
|
m_viaGap( aGap )
|
2015-04-28 15:07:36 +00:00
|
|
|
{
|
2021-06-09 19:32:58 +00:00
|
|
|
// Do not leave uninitialized members, and keep static analyser quiet:
|
2015-04-28 15:07:36 +00:00
|
|
|
m_viaDiameter = 0;
|
|
|
|
m_fitVias = true;
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
m_gateways.clear();
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:54 +00:00
|
|
|
void SetFitVias( bool aEnable, int aDiameter = 0, int aViaGap = -1 )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_fitVias = aEnable;
|
|
|
|
m_viaDiameter = aDiameter;
|
2021-01-05 00:03:14 +00:00
|
|
|
|
|
|
|
if( aViaGap < 0 )
|
2015-02-18 00:29:54 +00:00
|
|
|
m_viaGap = m_gap;
|
|
|
|
else
|
|
|
|
m_viaGap = aViaGap;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-15 15:16:54 +00:00
|
|
|
void BuildForCursor( const VECTOR2I& aCursorPos );
|
2016-08-29 17:31:13 +00:00
|
|
|
void BuildOrthoProjections( DP_GATEWAYS &aEntries, const VECTOR2I& aCursorPos, int aOrthoScore );
|
2016-08-15 15:16:54 +00:00
|
|
|
void BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool aBuildEntries = false, bool aViaMode = false );
|
2017-09-23 09:20:10 +00:00
|
|
|
void BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool aPreferDiagonal );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool FitGateways( DP_GATEWAYS& aEntry, DP_GATEWAYS& aTarget, bool aPrefDiagonal, DIFF_PAIR& aDp );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
std::vector<DP_GATEWAY>& Gateways()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
return m_gateways;
|
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const std::vector<DP_GATEWAY>& CGateways() const
|
2016-08-15 15:16:49 +00:00
|
|
|
{
|
|
|
|
return m_gateways;
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
void FilterByOrientation( int aAngleMask, DIRECTION_45 aRefOrientation );
|
2016-08-15 15:16:49 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
private:
|
2015-02-18 16:53:46 +00:00
|
|
|
struct DP_CANDIDATE
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
SHAPE_LINE_CHAIN p, n;
|
|
|
|
VECTOR2I gw_p, gw_n;
|
|
|
|
int score;
|
|
|
|
};
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
bool checkDiagonalAlignment( const VECTOR2I& a, const VECTOR2I& b ) const;
|
2017-09-23 09:20:10 +00:00
|
|
|
void buildDpContinuation( const DP_PRIMITIVE_PAIR& aPair, bool aIsDiagonal );
|
2016-08-15 15:16:53 +00:00
|
|
|
void buildEntries( const VECTOR2I& p0_p, const VECTOR2I& p0_n );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
int m_gap;
|
|
|
|
int m_viaGap;
|
|
|
|
int m_viaDiameter;
|
|
|
|
bool m_fitVias;
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
std::vector<DP_GATEWAY> m_gateways;
|
2015-02-18 00:29:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* DIFF_PAIR
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
2020-12-12 02:52:33 +00:00
|
|
|
* Basic class for a differential pair. Stores two PNS_LINEs (for positive and negative nets,
|
|
|
|
* respectively), the gap and coupling constraints.
|
2015-02-18 00:29:54 +00:00
|
|
|
**/
|
2020-12-12 02:52:33 +00:00
|
|
|
class DIFF_PAIR : public LINK_HOLDER
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
public:
|
2020-12-12 02:52:33 +00:00
|
|
|
struct COUPLED_SEGMENTS
|
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
COUPLED_SEGMENTS ( const SEG& aCoupledP, const SEG& aParentP, int aIndexP,
|
2015-02-18 00:29:54 +00:00
|
|
|
const SEG& aCoupledN, const SEG& aParentN, int aIndexN ) :
|
2016-08-15 15:16:53 +00:00
|
|
|
coupledP( aCoupledP ),
|
|
|
|
coupledN( aCoupledN ),
|
|
|
|
parentP( aParentP ),
|
|
|
|
parentN( aParentN ),
|
|
|
|
indexP( aIndexP ),
|
|
|
|
indexN( aIndexN )
|
2015-02-18 00:29:54 +00:00
|
|
|
{}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
SEG coupledP;
|
|
|
|
SEG coupledN;
|
|
|
|
SEG parentP;
|
|
|
|
SEG parentN;
|
|
|
|
int indexP;
|
|
|
|
int indexN;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<COUPLED_SEGMENTS> COUPLED_SEGMENTS_VEC;
|
|
|
|
|
2020-12-12 02:52:33 +00:00
|
|
|
DIFF_PAIR() :
|
|
|
|
LINK_HOLDER( ITEM::DIFF_PAIR_T ),
|
|
|
|
m_hasVias( false )
|
2015-04-22 16:39:49 +00:00
|
|
|
{
|
|
|
|
// Initialize some members, to avoid uninitialized variables.
|
|
|
|
m_net_p = 0;
|
|
|
|
m_net_n = 0;;
|
|
|
|
m_width = 0;
|
|
|
|
m_gap = 0;
|
|
|
|
m_viaGap = 0;
|
|
|
|
m_maxUncoupledLength = 0;
|
|
|
|
m_chamferLimit = 0;
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DIFF_PAIR( int aGap ) :
|
2020-04-15 20:16:24 +00:00
|
|
|
LINK_HOLDER( ITEM::DIFF_PAIR_T ),
|
2016-08-15 15:16:53 +00:00
|
|
|
m_hasVias( false )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_gapConstraint = aGap;
|
2015-04-22 16:39:49 +00:00
|
|
|
|
|
|
|
// Initialize other members, to avoid uninitialized variables.
|
|
|
|
m_net_p = 0;
|
|
|
|
m_net_n = 0;;
|
|
|
|
m_width = 0;
|
|
|
|
m_gap = 0;
|
|
|
|
m_viaGap = 0;
|
|
|
|
m_maxUncoupledLength = 0;
|
|
|
|
m_chamferLimit = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2020-12-12 02:52:33 +00:00
|
|
|
DIFF_PAIR( const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN& aN, int aGap = 0 ) :
|
2020-04-15 20:16:24 +00:00
|
|
|
LINK_HOLDER( ITEM::DIFF_PAIR_T ),
|
2016-08-15 15:16:53 +00:00
|
|
|
m_n( aN ),
|
|
|
|
m_p( aP ),
|
|
|
|
m_hasVias( false )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_gapConstraint = aGap;
|
2015-04-22 16:39:49 +00:00
|
|
|
|
|
|
|
// Initialize other members, to avoid uninitialized variables.
|
|
|
|
m_net_p = 0;
|
|
|
|
m_net_n = 0;;
|
|
|
|
m_width = 0;
|
|
|
|
m_gap = 0;
|
|
|
|
m_viaGap = 0;
|
|
|
|
m_maxUncoupledLength = 0;
|
|
|
|
m_chamferLimit = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2020-12-12 02:52:33 +00:00
|
|
|
DIFF_PAIR( const LINE &aLineP, const LINE &aLineN, int aGap = 0 ) :
|
2020-04-15 20:16:24 +00:00
|
|
|
LINK_HOLDER( ITEM::DIFF_PAIR_T ),
|
2016-08-15 15:16:53 +00:00
|
|
|
m_line_p( aLineP ),
|
|
|
|
m_line_n( aLineN ),
|
|
|
|
m_hasVias( false )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_gapConstraint = aGap;
|
|
|
|
m_net_p = aLineP.Net();
|
|
|
|
m_net_n = aLineN.Net();
|
|
|
|
m_p = aLineP.CLine();
|
|
|
|
m_n = aLineN.CLine();
|
2015-04-28 15:07:36 +00:00
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Do not leave uninitialized members, and keep static analyser quiet:
|
2015-04-28 15:07:36 +00:00
|
|
|
m_width = 0;
|
|
|
|
m_gap = 0;
|
|
|
|
m_viaGap = 0;
|
|
|
|
m_maxUncoupledLength = 0;
|
|
|
|
m_chamferLimit = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
static inline bool ClassOf( const ITEM* aItem )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2020-04-15 20:16:24 +00:00
|
|
|
return aItem && ITEM::DIFF_PAIR_T == aItem->Kind();
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
DIFF_PAIR* Clone() const override { assert( false ); return NULL; }
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2020-04-15 20:16:24 +00:00
|
|
|
virtual void ClearLinks() override
|
|
|
|
{
|
|
|
|
m_links.clear();
|
|
|
|
m_line_p.ClearLinks();
|
|
|
|
m_line_n.ClearLinks();
|
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
static DIFF_PAIR* AssembleDp( LINE *aLine );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
void SetShape( const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN& aN, bool aSwapLanes = false )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
if( aSwapLanes )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_p = aN;
|
|
|
|
m_n = aP;
|
2016-08-15 15:16:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
m_p = aP;
|
|
|
|
m_n = aN;
|
|
|
|
}
|
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void SetShape( const DIFF_PAIR& aPair )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_p = aPair.m_p;
|
|
|
|
m_n = aPair.m_n;
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
void SetNets( int aP, int aN )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
m_net_p = aP;
|
|
|
|
m_net_n = aN;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
void SetWidth( int aWidth )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
m_width = aWidth;
|
2020-12-12 02:52:33 +00:00
|
|
|
m_n.SetWidth( aWidth );
|
|
|
|
m_p.SetWidth( aWidth );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
int Width() const { return m_width; }
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
void SetGap( int aGap )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
m_gap = aGap;
|
2016-08-15 15:16:53 +00:00
|
|
|
m_gapConstraint = RANGED_NUM<int>( m_gap, 10000, 10000 );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
int Gap() const
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
return m_gap;
|
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void AppendVias( const VIA &aViaP, const VIA& aViaN )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_hasVias = true;
|
|
|
|
m_via_p = aViaP;
|
|
|
|
m_via_n = aViaN;
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
void RemoveVias()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_hasVias = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EndsWithVias() const
|
|
|
|
{
|
|
|
|
return m_hasVias;
|
|
|
|
}
|
|
|
|
|
2020-12-12 02:52:33 +00:00
|
|
|
void SetViaDiameter( int aDiameter )
|
|
|
|
{
|
|
|
|
m_via_p.SetDiameter( aDiameter );
|
|
|
|
m_via_n.SetDiameter( aDiameter );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetViaDrill( int aDrill )
|
|
|
|
{
|
|
|
|
m_via_p.SetDrill( aDrill );
|
|
|
|
m_via_n.SetDrill( aDrill );
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
int NetP() const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
return m_net_p;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
int NetN() const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
return m_net_n;
|
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE& PLine()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
if( !m_line_p.IsLinked() )
|
|
|
|
updateLine( m_line_p, m_p, m_net_p, m_via_p );
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return m_line_p;
|
2015-02-18 16:53:46 +00:00
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE& NLine()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
if( !m_line_n.IsLinked() )
|
|
|
|
updateLine( m_line_n, m_n, m_net_n, m_via_n );
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return m_line_n;
|
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DP_PRIMITIVE_PAIR EndingPrimitives();
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
double CoupledLength() const;
|
|
|
|
double TotalLength() const;
|
2016-08-15 15:16:53 +00:00
|
|
|
double CoupledLengthFactor() const;
|
|
|
|
double Skew() const;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
void CoupledSegmentPairs( COUPLED_SEGMENTS_VEC& aPairs ) const;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
m_n.Clear();
|
|
|
|
m_p.Clear();
|
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void Append( const DIFF_PAIR& aOther )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
m_n.Append( aOther.m_n );
|
|
|
|
m_p.Append( aOther.m_p );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Empty() const
|
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
return ( m_n.SegmentCount() == 0 ) || ( m_p.SegmentCount() == 0 );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
const SHAPE_LINE_CHAIN& CP() const { return m_p; }
|
|
|
|
const SHAPE_LINE_CHAIN& CN() const { return m_n; }
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool BuildInitial( const DP_GATEWAY& aEntry, const DP_GATEWAY& aTarget, bool aPrefDiagonal );
|
|
|
|
bool CheckConnectionAngle( const DIFF_PAIR &aOther, int allowedAngles ) const;
|
2016-08-15 15:16:53 +00:00
|
|
|
int CoupledLength( const SEG& aP, const SEG& aN ) const;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
int64_t CoupledLength( const SHAPE_LINE_CHAIN& aP, const SHAPE_LINE_CHAIN& aN ) const;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
const RANGED_NUM<int> GapConstraint() const
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
return m_gapConstraint;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-11-18 19:50:36 +00:00
|
|
|
void updateLine( LINE &aLine, const SHAPE_LINE_CHAIN& aShape, int aNet, const VIA& aVia )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
aLine.SetShape( aShape );
|
|
|
|
aLine.SetWidth( m_width );
|
2016-08-15 15:16:53 +00:00
|
|
|
aLine.SetNet( aNet );
|
|
|
|
aLine.SetLayer( Layers().Start() );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
if( m_hasVias )
|
|
|
|
aLine.AppendVia( aVia );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SHAPE_LINE_CHAIN m_n, m_p;
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE m_line_p, m_line_n;
|
|
|
|
VIA m_via_p, m_via_n;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
bool m_hasVias;
|
|
|
|
int m_net_p, m_net_n;
|
|
|
|
int m_width;
|
|
|
|
int m_gap;
|
|
|
|
int m_viaGap;
|
|
|
|
int m_maxUncoupledLength;
|
|
|
|
int m_chamferLimit;
|
|
|
|
RANGED_NUM<int> m_gapConstraint;
|
|
|
|
};
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
#endif
|