From 44e2151ade70648ae815ca2e194876fdeb557c34 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 20 Mar 2021 21:18:18 +0000 Subject: [PATCH] Allow diffpair gap to override netclass clearance value. Fixes https://gitlab.com/kicad/code/kicad/issues/7975 --- pcbnew/drc/drc_engine.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index d41db072f3..4811f7a3df 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -245,7 +245,8 @@ void DRC_ENGINE::loadImplicitRules() if( nc->GetClearance() ) { DRC_CONSTRAINT constraint( CLEARANCE_CONSTRAINT ); - constraint.Value().SetMin( std::max( bds.m_MinClearance, nc->GetClearance() ) ); + constraint.Value().SetMin( std::max( bds.m_MinClearance, + nc->GetClearance() ) ); netclassRule->AddConstraint( constraint ); } @@ -261,7 +262,8 @@ void DRC_ENGINE::loadImplicitRules() if( nc->GetDiffPairWidth() || nc->GetDiffPairGap() ) { netclassRule = new DRC_RULE; - netclassRule->m_Name = wxString::Format( _( "netclass '%s'" ), ncName ); + netclassRule->m_Name = wxString::Format( _( "netclass '%s' (diff pair)" ), + ncName ); netclassRule->m_Implicit = true; expr = wxString::Format( "A.NetClass == '%s' && A.isDiffPair()", @@ -280,12 +282,32 @@ void DRC_ENGINE::loadImplicitRules() if( nc->GetDiffPairGap() ) { DRC_CONSTRAINT constraint( DIFF_PAIR_GAP_CONSTRAINT ); - constraint.Value().SetMin( std::max( bds.m_MinClearance, nc->GetClearance() ) ); + constraint.Value().SetMin( bds.m_MinClearance ); constraint.Value().SetOpt( nc->GetDiffPairGap() ); netclassRule->AddConstraint( constraint ); } } + if( nc->GetDiffPairGap() ) + { + netclassRule = new DRC_RULE; + netclassRule->m_Name = wxString::Format( _( "netclass '%s' (diff pair)" ), + ncName ); + netclassRule->m_Implicit = true; + + expr = wxString::Format( "A.NetClass == '%s' && A.isDiffPair() " + "&& B.NetClass == '%s' && B.isDiffPair()", + ncName, + ncName ); + netclassRule->m_Condition = new DRC_RULE_CONDITION( expr ); + netclassItemSpecificRules.push_back( netclassRule ); + + DRC_CONSTRAINT constraint( CLEARANCE_CONSTRAINT ); + constraint.Value().SetMin( std::max( bds.m_MinClearance, + nc->GetDiffPairGap() ) ); + netclassRule->AddConstraint( constraint ); + } + if( nc->GetViaDiameter() || nc->GetViaDrill() ) { netclassRule = new DRC_RULE;