Update diff pair rule syntax to be clearer.

Fixes https://gitlab.com/kicad/code/kicad/issues/8010
This commit is contained in:
Jeff Young 2021-03-25 00:34:57 +00:00
parent 040cdd64f2
commit a2ffb45698
3 changed files with 9 additions and 34 deletions

View File

@ -110,10 +110,6 @@ True if any part of `A` lies within the given zone's outline.
A.isPlated()
True if `A` has a hole which is plated.
<br><br>
A.isDiffPair()
True if `A` has a net that is part of a differential pair.
<br><br>
A.inDiffPair('<net_name>')
@ -122,7 +118,7 @@ True if `A` has net that is part of the specified differential pair.
matches items in the `CLK_P` and `CLK_N` nets.
<br><br>
A.isCoupledDiffPair()
AB.isCoupledDiffPair()
True if `A` and `B` are members of the same diff pair.
<br><br>
@ -191,12 +187,12 @@ For the latter use a `(layer "layer_name")` clause in the rule.
(condition "A.Pad_Type == 'Through-hole'"))
# Specify a larger clearance around a particular diff-pair
(rule "dp clearance"
(constraint clearance (min "1.5mm"))
(condition "A.inDiffPair('CLK')"))
# Specify an optimal gap for a particular diff-pair
(rule "dp clock gap"
(constraint diff_pair_gap (opt "0.8mm"))
(condition "A.inDiffPair('CLK') && AB.isCoupledDiffPair()"))
# Specify a larger clearance around any diff-pair
(rule "dp clearance"
(constraint clearance (min "1.5mm"))
(condition "A.isDiffPair() && !A.isCoupledDiffPair()"))
(condition "A.inDiffPair('*') && !AB.isCoupledDiffPair()"))

View File

@ -266,7 +266,7 @@ void DRC_ENGINE::loadImplicitRules()
ncName );
netclassRule->m_Implicit = true;
expr = wxString::Format( "A.NetClass == '%s' && A.isDiffPair()",
expr = wxString::Format( "A.NetClass == '%s' && A.inDiffPair('*')",
ncName );
netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
netclassItemSpecificRules.push_back( netclassRule );
@ -295,7 +295,7 @@ void DRC_ENGINE::loadImplicitRules()
ncName );
netclassRule->m_Implicit = true;
expr = wxString::Format( "A.NetClass == '%s' && A.isCoupledDiffPair()",
expr = wxString::Format( "A.NetClass == '%s' && AB.isCoupledDiffPair()",
ncName );
netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
netclassItemSpecificRules.push_back( netclassRule );

View File

@ -708,26 +708,6 @@ static void isBlindBuriedVia( LIBEVAL::CONTEXT* aCtx, void* self )
}
static void isDiffPair( LIBEVAL::CONTEXT* aCtx, void* self )
{
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( item && item->IsConnected() )
{
NETINFO_ITEM* netinfo = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNet();
int dummy_p, dummy_n;
if( netinfo && DRC_ENGINE::IsNetADiffPair( item->GetBoard(), netinfo, dummy_p, dummy_n ) )
result->Set( 1.0 );
}
}
static void isCoupledDiffPair( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
@ -806,7 +786,6 @@ void PCB_EXPR_BUILTIN_FUNCTIONS::RegisterAllFunctions()
RegisterFunc( "isBlindBuriedVia()", isBlindBuriedVia );
RegisterFunc( "memberOf('x')", memberOf );
RegisterFunc( "fromTo('x','y')", exprFromTo );
RegisterFunc( "isDiffPair()", isDiffPair );
RegisterFunc( "isCoupledDiffPair()", isCoupledDiffPair );
RegisterFunc( "inDiffPair('x')", inDiffPair );
}
@ -964,7 +943,7 @@ std::unique_ptr<LIBEVAL::VAR_REF> PCB_EXPR_UCODE::CreateVarRef( const wxString&
return nullptr;
}
if( aVar == "A" )
if( aVar == "A" || aVar == "AB" )
vref = std::make_unique<PCB_EXPR_VAR_REF>( 0 );
else if( aVar == "B" )
vref = std::make_unique<PCB_EXPR_VAR_REF>( 1 );