DRC: allow testing against particular diff pair membership
This commit is contained in:
parent
1d3159c1cb
commit
65531accf6
|
@ -94,6 +94,14 @@ True if any part of `A` lies within the given zone's outline.
|
||||||
A.isPlated()
|
A.isPlated()
|
||||||
True if `A` has a hole which is plated.
|
True if `A` has a hole which is plated.
|
||||||
|
|
||||||
|
A.isDiffPair()
|
||||||
|
True if `A` has a net that is part of a differential pair.
|
||||||
|
|
||||||
|
A.inDiffPair('<net_name>')
|
||||||
|
True if `A` has net that is part of the specified differential pair.
|
||||||
|
`<net_name>` is the base name of the differential pair. For example, `inDiffPair('CLK')`
|
||||||
|
matches items in the `CLK_P` and `CLK_N` nets.
|
||||||
|
|
||||||
A.memberOf('<group_name>')
|
A.memberOf('<group_name>')
|
||||||
True if `A` is a member of the given group. Includes nested membership.
|
True if `A` is a member of the given group. Includes nested membership.
|
||||||
|
|
||||||
|
@ -161,7 +169,7 @@ For the latter use a `(layer "layer_name")` clause in the rule.
|
||||||
# Specify a larger clearance around a particular diff-pair
|
# Specify a larger clearance around a particular diff-pair
|
||||||
(rule "dp clearance"
|
(rule "dp clearance"
|
||||||
(constraint clearance (min "1.5mm"))
|
(constraint clearance (min "1.5mm"))
|
||||||
(condition "A.NetClass == 'diffPairClass' && B.NetClass != 'diffPairClass'"))
|
(condition "A.inDiffPair('CLK')"))
|
||||||
|
|
||||||
# Specify a larger clearance around any diff-pair
|
# Specify a larger clearance around any diff-pair
|
||||||
(rule "dp clearance"
|
(rule "dp clearance"
|
||||||
|
|
|
@ -1155,8 +1155,8 @@ bool DRC_ENGINE::QueryWorstConstraint( DRC_CONSTRAINT_T aConstraintId, DRC_CONST
|
||||||
|
|
||||||
|
|
||||||
// fixme: move two functions below to pcbcommon?
|
// fixme: move two functions below to pcbcommon?
|
||||||
static int matchDpSuffix( const wxString& aNetName, wxString& aComplementNet,
|
int DRC_ENGINE::MatchDpSuffix( const wxString& aNetName, wxString& aComplementNet,
|
||||||
wxString& aBaseDpName )
|
wxString& aBaseDpName )
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
|
@ -1219,7 +1219,7 @@ bool DRC_ENGINE::IsNetADiffPair( BOARD* aBoard, NETINFO_ITEM* aNet, int& aNetP,
|
||||||
wxString refName = aNet->GetNetname();
|
wxString refName = aNet->GetNetname();
|
||||||
wxString dummy, coupledNetName;
|
wxString dummy, coupledNetName;
|
||||||
|
|
||||||
if( int polarity = matchDpSuffix( refName, coupledNetName, dummy ) )
|
if( int polarity = MatchDpSuffix( refName, coupledNetName, dummy ) )
|
||||||
{
|
{
|
||||||
NETINFO_ITEM* net = aBoard->FindNet( coupledNetName );
|
NETINFO_ITEM* net = aBoard->FindNet( coupledNetName );
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,16 @@ public:
|
||||||
|
|
||||||
static bool IsNetADiffPair( BOARD* aBoard, NETINFO_ITEM* aNet, int& aNetP, int& aNetN );
|
static bool IsNetADiffPair( BOARD* aBoard, NETINFO_ITEM* aNet, int& aNetP, int& aNetN );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given net is a diff pair, returning its polarity and complement if so
|
||||||
|
* @param aNetName is the input net name, like DIFF_P
|
||||||
|
* @param aComplementNet will be filled with the complement, like DIFF_N
|
||||||
|
* @param aBaseDpName will be filled with the base name, like DIFF
|
||||||
|
* @return 1 if aNetName is the positive half of a pair, -1 if negative, 0 if not a diff pair
|
||||||
|
*/
|
||||||
|
static int MatchDpSuffix( const wxString& aNetName, wxString& aComplementNet,
|
||||||
|
wxString& aBaseDpName );
|
||||||
|
|
||||||
static bool IsNetTie( BOARD_ITEM* aItem );
|
static bool IsNetTie( BOARD_ITEM* aItem );
|
||||||
|
|
||||||
static std::shared_ptr<SHAPE> GetShape( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer );
|
static std::shared_ptr<SHAPE> GetShape( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer );
|
||||||
|
|
|
@ -566,6 +566,41 @@ static void isDiffPair( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void inDiffPair( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||||
|
{
|
||||||
|
LIBEVAL::VALUE* arg = aCtx->Pop();
|
||||||
|
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
|
||||||
|
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
|
||||||
|
LIBEVAL::VALUE* result = aCtx->AllocValue();
|
||||||
|
|
||||||
|
result->Set( 0.0 );
|
||||||
|
aCtx->Push( result );
|
||||||
|
|
||||||
|
if( !arg )
|
||||||
|
{
|
||||||
|
aCtx->ReportError( wxString::Format( _( "Missing argument to '%s'" ),
|
||||||
|
wxT( "inDiffPair()" ) ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( item && item->IsConnected() )
|
||||||
|
{
|
||||||
|
NETINFO_ITEM* netinfo = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNet();
|
||||||
|
|
||||||
|
wxString refName = netinfo->GetNetname();
|
||||||
|
wxString baseName, coupledNet;
|
||||||
|
|
||||||
|
int polarity = DRC_ENGINE::MatchDpSuffix( refName, coupledNet, baseName );
|
||||||
|
|
||||||
|
if( polarity == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( baseName.Matches( arg->AsString() ) )
|
||||||
|
result->Set( 1.0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PCB_EXPR_BUILTIN_FUNCTIONS::PCB_EXPR_BUILTIN_FUNCTIONS()
|
PCB_EXPR_BUILTIN_FUNCTIONS::PCB_EXPR_BUILTIN_FUNCTIONS()
|
||||||
{
|
{
|
||||||
RegisterAllFunctions();
|
RegisterAllFunctions();
|
||||||
|
@ -584,6 +619,7 @@ void PCB_EXPR_BUILTIN_FUNCTIONS::RegisterAllFunctions()
|
||||||
RegisterFunc( "memberOf('x')", memberOf );
|
RegisterFunc( "memberOf('x')", memberOf );
|
||||||
RegisterFunc( "fromTo('x','y')", exprFromTo );
|
RegisterFunc( "fromTo('x','y')", exprFromTo );
|
||||||
RegisterFunc( "isDiffPair()", isDiffPair );
|
RegisterFunc( "isDiffPair()", isDiffPair );
|
||||||
|
RegisterFunc( "inDiffPair('x')", inDiffPair );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue