Implement isCoupledDiffPair() DRC rule function.
Fixes https://gitlab.com/kicad/code/kicad/issues/7975
This commit is contained in:
parent
44e2151ade
commit
fe196771d8
|
@ -119,7 +119,12 @@ 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.<br>
|
||||
matches items in the `CLK_P` and `CLK_N` nets.
|
||||
<br><br>
|
||||
|
||||
A.isCoupledDiffPair()
|
||||
True if `A` and `B` are members of the same diff pair.
|
||||
<br><br>
|
||||
|
||||
A.memberOf('<group_name>')
|
||||
True if `A` is a member of the given group. Includes nested membership.
|
||||
|
|
|
@ -295,9 +295,7 @@ void DRC_ENGINE::loadImplicitRules()
|
|||
ncName );
|
||||
netclassRule->m_Implicit = true;
|
||||
|
||||
expr = wxString::Format( "A.NetClass == '%s' && A.isDiffPair() "
|
||||
"&& B.NetClass == '%s' && B.isDiffPair()",
|
||||
ncName,
|
||||
expr = wxString::Format( "A.NetClass == '%s' && A.isCoupledDiffPair()",
|
||||
ncName );
|
||||
netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
|
||||
netclassItemSpecificRules.push_back( netclassRule );
|
||||
|
|
|
@ -728,6 +728,30 @@ static void isDiffPair( LIBEVAL::CONTEXT* aCtx, void* self )
|
|||
}
|
||||
|
||||
|
||||
static void isCoupledDiffPair( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||
{
|
||||
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
|
||||
BOARD_CONNECTED_ITEM* a = dynamic_cast<BOARD_CONNECTED_ITEM*>( context->GetItem( 0 ) );
|
||||
BOARD_CONNECTED_ITEM* b = dynamic_cast<BOARD_CONNECTED_ITEM*>( context->GetItem( 1 ) );
|
||||
LIBEVAL::VALUE* result = aCtx->AllocValue();
|
||||
|
||||
result->Set( 0.0 );
|
||||
aCtx->Push( result );
|
||||
|
||||
if( a && b )
|
||||
{
|
||||
NETINFO_ITEM* netinfo = a->GetNet();
|
||||
wxString coupledNet, dummy;
|
||||
|
||||
if( netinfo && DRC_ENGINE::MatchDpSuffix( netinfo->GetNetname(), coupledNet, dummy ) != 0 )
|
||||
{
|
||||
if( b->GetNetname() == coupledNet )
|
||||
result->Set( 1.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void inDiffPair( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||
{
|
||||
LIBEVAL::VALUE* arg = aCtx->Pop();
|
||||
|
@ -783,6 +807,7 @@ void PCB_EXPR_BUILTIN_FUNCTIONS::RegisterAllFunctions()
|
|||
RegisterFunc( "memberOf('x')", memberOf );
|
||||
RegisterFunc( "fromTo('x','y')", exprFromTo );
|
||||
RegisterFunc( "isDiffPair()", isDiffPair );
|
||||
RegisterFunc( "isCoupledDiffPair()", isCoupledDiffPair );
|
||||
RegisterFunc( "inDiffPair('x')", inDiffPair );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue