2020-06-13 23:28:08 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com
|
2022-04-02 14:08:32 +00:00
|
|
|
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-06-13 23:28:08 +00:00
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2022-03-11 22:02:43 +00:00
|
|
|
#include <atomic>
|
2020-06-18 16:55:22 +00:00
|
|
|
#include <reporter.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <progress_reporter.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2020-09-11 15:04:11 +00:00
|
|
|
#include <drc/drc_engine.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <drc/drc_rtree.h>
|
2020-09-11 15:04:11 +00:00
|
|
|
#include <drc/drc_rule_parser.h>
|
|
|
|
#include <drc/drc_rule.h>
|
2020-09-12 23:05:32 +00:00
|
|
|
#include <drc/drc_rule_condition.h>
|
2020-09-11 15:04:11 +00:00
|
|
|
#include <drc/drc_test_provider.h>
|
2021-12-01 14:42:44 +00:00
|
|
|
#include <drc/drc_item.h>
|
2022-06-17 21:50:59 +00:00
|
|
|
#include <drc/drc_cache_generator.h>
|
2021-02-20 13:25:16 +00:00
|
|
|
#include <footprint.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <pad.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2022-06-15 00:41:10 +00:00
|
|
|
#include <thread_pool.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <zone.h>
|
2021-08-15 15:09:19 +00:00
|
|
|
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2021-09-05 15:06:12 +00:00
|
|
|
// wxListBox's performance degrades horrifically with very large datasets. It's not clear
|
|
|
|
// they're useful to the user anyway.
|
2022-02-09 15:34:22 +00:00
|
|
|
#define ERROR_LIMIT 199
|
|
|
|
#define EXTENDED_ERROR_LIMIT 499
|
2021-09-05 15:06:12 +00:00
|
|
|
|
|
|
|
|
2020-09-15 11:06:15 +00:00
|
|
|
void drcPrintDebugMessage( int level, const wxString& msg, const char *function, int line )
|
2020-08-12 22:19:34 +00:00
|
|
|
{
|
|
|
|
wxString valueStr;
|
2020-09-11 15:04:11 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
if( wxGetEnv( wxT( "DRC_DEBUG" ), &valueStr ) )
|
2020-08-12 22:19:34 +00:00
|
|
|
{
|
|
|
|
int setLevel = wxAtoi( valueStr );
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2020-08-25 17:42:52 +00:00
|
|
|
if( level <= setLevel )
|
2022-02-05 02:06:25 +00:00
|
|
|
printf( "%-30s:%d | %s\n", function, line, (const char *) msg.c_str() );
|
2020-08-12 22:19:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-18 14:17:16 +00:00
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
DRC_ENGINE::DRC_ENGINE( BOARD* aBoard, BOARD_DESIGN_SETTINGS *aSettings ) :
|
2022-09-19 16:09:59 +00:00
|
|
|
UNITS_PROVIDER( pcbIUScale, EDA_UNITS::MILLIMETRES ),
|
2020-06-19 21:34:19 +00:00
|
|
|
m_designSettings ( aSettings ),
|
2020-09-11 15:04:11 +00:00
|
|
|
m_board( aBoard ),
|
2021-02-22 23:47:17 +00:00
|
|
|
m_drawingSheet( nullptr ),
|
2020-08-25 17:42:52 +00:00
|
|
|
m_schematicNetlist( nullptr ),
|
2020-10-17 19:15:26 +00:00
|
|
|
m_rulesValid( false ),
|
2020-09-15 11:06:15 +00:00
|
|
|
m_reportAllTrackErrors( false ),
|
|
|
|
m_testFootprints( false ),
|
2020-06-19 21:34:19 +00:00
|
|
|
m_reporter( nullptr ),
|
|
|
|
m_progressReporter( nullptr )
|
2020-08-18 14:17:16 +00:00
|
|
|
{
|
2020-09-16 11:45:12 +00:00
|
|
|
m_errorLimits.resize( DRCE_LAST + 1 );
|
2020-09-15 11:06:15 +00:00
|
|
|
|
2020-09-16 11:45:12 +00:00
|
|
|
for( int ii = DRCE_FIRST; ii <= DRCE_LAST; ++ii )
|
2022-02-09 15:34:22 +00:00
|
|
|
m_errorLimits[ ii ] = ERROR_LIMIT;
|
2020-08-18 14:17:16 +00:00
|
|
|
}
|
2020-06-13 23:28:08 +00:00
|
|
|
|
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
DRC_ENGINE::~DRC_ENGINE()
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2022-01-10 21:05:14 +00:00
|
|
|
m_rules.clear();
|
2020-10-24 21:16:07 +00:00
|
|
|
|
2021-01-01 22:29:15 +00:00
|
|
|
for( std::pair<DRC_CONSTRAINT_T, std::vector<DRC_ENGINE_CONSTRAINT*>*> pair : m_constraintMap )
|
2020-10-24 21:16:07 +00:00
|
|
|
{
|
2021-01-01 22:29:15 +00:00
|
|
|
for( DRC_ENGINE_CONSTRAINT* constraint : *pair.second )
|
|
|
|
delete constraint;
|
2020-10-24 21:16:07 +00:00
|
|
|
|
|
|
|
delete pair.second;
|
|
|
|
}
|
2020-08-11 22:15:50 +00:00
|
|
|
}
|
|
|
|
|
2020-08-18 14:17:16 +00:00
|
|
|
|
2020-11-17 17:41:57 +00:00
|
|
|
static bool isKeepoutZone( const BOARD_ITEM* aItem, bool aCheckFlags )
|
2020-10-22 13:45:12 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( !aItem || aItem->Type() != PCB_ZONE_T )
|
2020-11-17 17:41:57 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
const ZONE* zone = static_cast<const ZONE*>( aItem );
|
|
|
|
|
|
|
|
if( !zone->GetIsRuleArea() )
|
|
|
|
return false;
|
2020-10-22 13:45:12 +00:00
|
|
|
|
2020-11-17 17:41:57 +00:00
|
|
|
if( aCheckFlags )
|
|
|
|
{
|
|
|
|
if( !zone->GetDoNotAllowTracks()
|
|
|
|
&& !zone->GetDoNotAllowVias()
|
|
|
|
&& !zone->GetDoNotAllowPads()
|
|
|
|
&& !zone->GetDoNotAllowCopperPour()
|
|
|
|
&& !zone->GetDoNotAllowFootprints() )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-10-22 13:45:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-17 17:41:57 +00:00
|
|
|
return true;
|
2020-10-22 13:45:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-10 21:05:14 +00:00
|
|
|
std::shared_ptr<DRC_RULE> DRC_ENGINE::createImplicitRule( const wxString& name )
|
2020-08-26 22:07:31 +00:00
|
|
|
{
|
2022-01-10 21:05:14 +00:00
|
|
|
std::shared_ptr<DRC_RULE> rule = std::make_shared<DRC_RULE>();
|
2020-08-26 22:07:31 +00:00
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
rule->m_Name = name;
|
2020-09-13 10:37:20 +00:00
|
|
|
rule->m_Implicit = true;
|
2020-08-26 22:07:31 +00:00
|
|
|
|
|
|
|
addRule( rule );
|
|
|
|
|
|
|
|
return rule;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-13 10:37:20 +00:00
|
|
|
void DRC_ENGINE::loadImplicitRules()
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
ReportAux( wxString::Format( wxT( "Building implicit rules (per-item/class overrides, etc...)" ) ) );
|
2020-08-26 22:07:31 +00:00
|
|
|
|
2020-09-13 10:37:20 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
|
2020-08-26 22:07:31 +00:00
|
|
|
|
|
|
|
// 1) global defaults
|
|
|
|
|
2022-01-10 21:05:14 +00:00
|
|
|
std::shared_ptr<DRC_RULE> rule = createImplicitRule( _( "board setup constraints" ) );
|
2020-08-26 22:07:31 +00:00
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT widthConstraint( TRACK_WIDTH_CONSTRAINT );
|
2020-08-26 22:07:31 +00:00
|
|
|
widthConstraint.Value().SetMin( bds.m_TrackMinWidth );
|
|
|
|
rule->AddConstraint( widthConstraint );
|
|
|
|
|
2022-07-31 15:02:04 +00:00
|
|
|
DRC_CONSTRAINT connectionConstraint( CONNECTION_WIDTH_CONSTRAINT );
|
|
|
|
connectionConstraint.Value().SetMin( bds.m_MinConn );
|
|
|
|
rule->AddConstraint( connectionConstraint );
|
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT drillConstraint( HOLE_SIZE_CONSTRAINT );
|
2020-08-26 22:07:31 +00:00
|
|
|
drillConstraint.Value().SetMin( bds.m_MinThroughDrill );
|
|
|
|
rule->AddConstraint( drillConstraint );
|
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT annulusConstraint( ANNULAR_WIDTH_CONSTRAINT );
|
2021-06-26 09:11:22 +00:00
|
|
|
annulusConstraint.Value().SetMin( bds.m_ViasMinAnnularWidth );
|
2020-08-26 22:07:31 +00:00
|
|
|
rule->AddConstraint( annulusConstraint );
|
2020-09-14 08:02:07 +00:00
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT diameterConstraint( VIA_DIAMETER_CONSTRAINT );
|
2020-08-26 22:07:31 +00:00
|
|
|
diameterConstraint.Value().SetMin( bds.m_ViasMinSize );
|
|
|
|
rule->AddConstraint( diameterConstraint );
|
|
|
|
|
2020-11-29 22:01:40 +00:00
|
|
|
DRC_CONSTRAINT holeToHoleConstraint( HOLE_TO_HOLE_CONSTRAINT );
|
|
|
|
holeToHoleConstraint.Value().SetMin( bds.m_HoleToHoleMin );
|
|
|
|
rule->AddConstraint( holeToHoleConstraint );
|
|
|
|
|
2022-05-02 23:47:36 +00:00
|
|
|
rule = createImplicitRule( _( "board setup constraints zone fill strategy" ) );
|
2021-08-09 10:10:09 +00:00
|
|
|
DRC_CONSTRAINT thermalSpokeCountConstraint( MIN_RESOLVED_SPOKES_CONSTRAINT );
|
|
|
|
thermalSpokeCountConstraint.Value().SetMin( bds.m_MinResolvedSpokes );
|
|
|
|
rule->AddConstraint( thermalSpokeCountConstraint );
|
|
|
|
|
2021-08-06 12:15:01 +00:00
|
|
|
rule = createImplicitRule( _( "board setup constraints silk" ) );
|
2020-10-12 13:10:50 +00:00
|
|
|
rule->m_LayerCondition = LSET( 2, F_SilkS, B_SilkS );
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT silkClearanceConstraint( SILK_CLEARANCE_CONSTRAINT );
|
2020-10-12 13:10:50 +00:00
|
|
|
silkClearanceConstraint.Value().SetMin( bds.m_SilkClearance );
|
|
|
|
rule->AddConstraint( silkClearanceConstraint );
|
|
|
|
|
2022-04-15 21:09:35 +00:00
|
|
|
rule = createImplicitRule( _( "board setup constraints silk text height" ) );
|
|
|
|
rule->m_LayerCondition = LSET( 2, F_SilkS, B_SilkS );
|
2021-07-11 15:12:28 +00:00
|
|
|
DRC_CONSTRAINT silkTextHeightConstraint( TEXT_HEIGHT_CONSTRAINT );
|
|
|
|
silkTextHeightConstraint.Value().SetMin( bds.m_MinSilkTextHeight );
|
|
|
|
rule->AddConstraint( silkTextHeightConstraint );
|
|
|
|
|
2022-04-15 21:09:35 +00:00
|
|
|
rule = createImplicitRule( _( "board setup constraints silk text thickness" ) );
|
|
|
|
rule->m_LayerCondition = LSET( 2, F_SilkS, B_SilkS );
|
2021-07-11 15:12:28 +00:00
|
|
|
DRC_CONSTRAINT silkTextThicknessConstraint( TEXT_THICKNESS_CONSTRAINT );
|
|
|
|
silkTextThicknessConstraint.Value().SetMin( bds.m_MinSilkTextThickness );
|
|
|
|
rule->AddConstraint( silkTextThicknessConstraint );
|
|
|
|
|
2021-08-06 12:15:01 +00:00
|
|
|
rule = createImplicitRule( _( "board setup constraints hole" ) );
|
|
|
|
DRC_CONSTRAINT holeClearanceConstraint( HOLE_CLEARANCE_CONSTRAINT );
|
|
|
|
holeClearanceConstraint.Value().SetMin( bds.m_HoleClearance );
|
|
|
|
rule->AddConstraint( holeClearanceConstraint );
|
|
|
|
|
|
|
|
rule = createImplicitRule( _( "board setup constraints edge" ) );
|
|
|
|
DRC_CONSTRAINT edgeClearanceConstraint( EDGE_CLEARANCE_CONSTRAINT );
|
|
|
|
edgeClearanceConstraint.Value().SetMin( bds.m_CopperEdgeClearance );
|
|
|
|
rule->AddConstraint( edgeClearanceConstraint );
|
|
|
|
|
|
|
|
rule = createImplicitRule( _( "board setup constraints courtyard" ) );
|
|
|
|
DRC_CONSTRAINT courtyardClearanceConstraint( COURTYARD_CLEARANCE_CONSTRAINT );
|
|
|
|
holeToHoleConstraint.Value().SetMin( 0 );
|
|
|
|
rule->AddConstraint( courtyardClearanceConstraint );
|
|
|
|
|
2020-08-26 22:07:31 +00:00
|
|
|
// 2) micro-via specific defaults (new DRC doesn't treat microvias in any special way)
|
|
|
|
|
2022-01-10 21:05:14 +00:00
|
|
|
std::shared_ptr<DRC_RULE> uViaRule = createImplicitRule( _( "board setup micro-via constraints" ) );
|
2020-08-26 22:07:31 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
uViaRule->m_Condition = new DRC_RULE_CONDITION( wxT( "A.Via_Type == 'Micro'" ) );
|
2020-08-26 22:07:31 +00:00
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT uViaDrillConstraint( HOLE_SIZE_CONSTRAINT );
|
2020-08-26 22:07:31 +00:00
|
|
|
uViaDrillConstraint.Value().SetMin( bds.m_MicroViasMinDrill );
|
|
|
|
uViaRule->AddConstraint( uViaDrillConstraint );
|
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT uViaDiameterConstraint( VIA_DIAMETER_CONSTRAINT );
|
2020-08-26 22:07:31 +00:00
|
|
|
uViaDiameterConstraint.Value().SetMin( bds.m_MicroViasMinSize );
|
|
|
|
uViaRule->AddConstraint( uViaDiameterConstraint );
|
|
|
|
|
2020-09-13 10:37:20 +00:00
|
|
|
// 3) per-netclass rules
|
2020-09-04 23:19:01 +00:00
|
|
|
|
2022-01-10 21:05:14 +00:00
|
|
|
std::vector<std::shared_ptr<DRC_RULE>> netclassClearanceRules;
|
|
|
|
std::vector<std::shared_ptr<DRC_RULE>> netclassItemSpecificRules;
|
2020-09-04 23:19:01 +00:00
|
|
|
|
2020-10-11 10:19:07 +00:00
|
|
|
auto makeNetclassRules =
|
2022-08-14 11:03:18 +00:00
|
|
|
[&]( const std::shared_ptr<NETCLASS>& nc, bool isDefault )
|
2020-09-15 19:13:45 +00:00
|
|
|
{
|
2020-10-11 10:19:07 +00:00
|
|
|
wxString ncName = nc->GetName();
|
2022-01-10 21:05:14 +00:00
|
|
|
wxString expr;
|
2020-09-07 12:30:51 +00:00
|
|
|
|
2020-10-12 23:34:10 +00:00
|
|
|
if( nc->GetClearance() || nc->GetTrackWidth() )
|
2020-10-10 18:29:41 +00:00
|
|
|
{
|
2022-01-10 21:05:14 +00:00
|
|
|
std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->m_Name = wxString::Format( _( "netclass '%s'" ), ncName );
|
|
|
|
netclassRule->m_Implicit = true;
|
2020-10-11 10:19:07 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
expr = wxString::Format( wxT( "A.NetClass == '%s'" ), ncName );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
|
|
|
|
netclassClearanceRules.push_back( netclassRule );
|
2020-10-11 10:19:07 +00:00
|
|
|
|
2020-10-12 23:34:10 +00:00
|
|
|
if( nc->GetClearance() )
|
2020-10-11 10:19:07 +00:00
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT constraint( CLEARANCE_CONSTRAINT );
|
2022-05-02 23:47:36 +00:00
|
|
|
constraint.Value().SetMin( nc->GetClearance() );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->AddConstraint( constraint );
|
2020-10-11 10:19:07 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 23:34:10 +00:00
|
|
|
if( nc->GetTrackWidth() )
|
2020-10-11 10:19:07 +00:00
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT constraint( TRACK_WIDTH_CONSTRAINT );
|
2020-10-12 23:34:10 +00:00
|
|
|
constraint.Value().SetMin( bds.m_TrackMinWidth );
|
|
|
|
constraint.Value().SetOpt( nc->GetTrackWidth() );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->AddConstraint( constraint );
|
2020-10-11 10:19:07 +00:00
|
|
|
}
|
2020-10-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
|
2021-04-13 16:21:47 +00:00
|
|
|
if( nc->GetDiffPairWidth() )
|
2020-10-10 18:29:41 +00:00
|
|
|
{
|
2022-01-10 21:05:14 +00:00
|
|
|
std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
|
2021-03-20 21:18:18 +00:00
|
|
|
netclassRule->m_Name = wxString::Format( _( "netclass '%s' (diff pair)" ),
|
|
|
|
ncName );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->m_Implicit = true;
|
2020-10-11 10:19:07 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
expr = wxString::Format( wxT( "A.NetClass == '%s' && A.inDiffPair('*')" ),
|
|
|
|
ncName );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
|
|
|
|
netclassItemSpecificRules.push_back( netclassRule );
|
2020-10-11 10:19:07 +00:00
|
|
|
|
2021-04-13 16:21:47 +00:00
|
|
|
DRC_CONSTRAINT constraint( TRACK_WIDTH_CONSTRAINT );
|
|
|
|
constraint.Value().SetMin( bds.m_TrackMinWidth );
|
|
|
|
constraint.Value().SetOpt( nc->GetDiffPairWidth() );
|
|
|
|
netclassRule->AddConstraint( constraint );
|
2020-10-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
|
2021-03-20 21:18:18 +00:00
|
|
|
if( nc->GetDiffPairGap() )
|
|
|
|
{
|
2022-01-10 21:05:14 +00:00
|
|
|
std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
|
2021-03-20 21:18:18 +00:00
|
|
|
netclassRule->m_Name = wxString::Format( _( "netclass '%s' (diff pair)" ),
|
|
|
|
ncName );
|
|
|
|
netclassRule->m_Implicit = true;
|
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
expr = wxString::Format( wxT( "A.NetClass == '%s'" ), ncName );
|
2021-03-20 21:18:18 +00:00
|
|
|
netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
|
|
|
|
netclassItemSpecificRules.push_back( netclassRule );
|
|
|
|
|
2021-04-30 17:38:42 +00:00
|
|
|
DRC_CONSTRAINT constraint( DIFF_PAIR_GAP_CONSTRAINT );
|
|
|
|
constraint.Value().SetMin( bds.m_MinClearance );
|
|
|
|
constraint.Value().SetOpt( nc->GetDiffPairGap() );
|
|
|
|
netclassRule->AddConstraint( constraint );
|
2021-04-29 09:23:18 +00:00
|
|
|
|
2022-05-02 23:47:36 +00:00
|
|
|
// A narrower diffpair gap overrides the netclass min clearance
|
2021-06-24 15:54:59 +00:00
|
|
|
if( nc->GetDiffPairGap() < nc->GetClearance() )
|
|
|
|
{
|
2022-01-10 21:05:14 +00:00
|
|
|
netclassRule = std::make_shared<DRC_RULE>();
|
2021-06-24 15:54:59 +00:00
|
|
|
netclassRule->m_Name = wxString::Format( _( "netclass '%s' (diff pair)" ),
|
|
|
|
ncName );
|
|
|
|
netclassRule->m_Implicit = true;
|
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
expr = wxString::Format( wxT( "A.NetClass == '%s' && AB.isCoupledDiffPair()" ),
|
2021-06-24 15:54:59 +00:00
|
|
|
ncName );
|
|
|
|
netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
|
|
|
|
netclassItemSpecificRules.push_back( netclassRule );
|
|
|
|
|
|
|
|
DRC_CONSTRAINT min_clearanceConstraint( CLEARANCE_CONSTRAINT );
|
2022-05-02 23:47:36 +00:00
|
|
|
min_clearanceConstraint.Value().SetMin( nc->GetDiffPairGap() );
|
2021-06-24 15:54:59 +00:00
|
|
|
netclassRule->AddConstraint( min_clearanceConstraint );
|
|
|
|
}
|
2021-03-20 21:18:18 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 23:34:10 +00:00
|
|
|
if( nc->GetViaDiameter() || nc->GetViaDrill() )
|
2020-10-10 18:29:41 +00:00
|
|
|
{
|
2022-01-10 21:05:14 +00:00
|
|
|
std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->m_Name = wxString::Format( _( "netclass '%s'" ), ncName );
|
|
|
|
netclassRule->m_Implicit = true;
|
2020-10-11 10:19:07 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
expr = wxString::Format( wxT( "A.NetClass == '%s' && A.Via_Type != 'Micro'" ),
|
2020-10-11 10:19:07 +00:00
|
|
|
ncName );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
|
|
|
|
netclassItemSpecificRules.push_back( netclassRule );
|
2020-10-11 10:19:07 +00:00
|
|
|
|
2020-10-12 23:34:10 +00:00
|
|
|
if( nc->GetViaDiameter() )
|
2020-10-11 10:19:07 +00:00
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT constraint( VIA_DIAMETER_CONSTRAINT );
|
2020-10-12 23:34:10 +00:00
|
|
|
constraint.Value().SetMin( bds.m_ViasMinSize );
|
|
|
|
constraint.Value().SetOpt( nc->GetViaDiameter() );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->AddConstraint( constraint );
|
2020-10-11 10:19:07 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 23:34:10 +00:00
|
|
|
if( nc->GetViaDrill() )
|
2020-10-11 10:19:07 +00:00
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT constraint( HOLE_SIZE_CONSTRAINT );
|
2020-10-12 23:34:10 +00:00
|
|
|
constraint.Value().SetMin( bds.m_MinThroughDrill );
|
|
|
|
constraint.Value().SetOpt( nc->GetViaDrill() );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->AddConstraint( constraint );
|
2020-10-11 10:19:07 +00:00
|
|
|
}
|
2020-10-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 23:34:10 +00:00
|
|
|
if( nc->GetuViaDiameter() || nc->GetuViaDrill() )
|
2020-10-10 18:29:41 +00:00
|
|
|
{
|
2022-01-10 21:05:14 +00:00
|
|
|
std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
|
2023-02-28 18:02:04 +00:00
|
|
|
netclassRule->m_Name = wxString::Format( _( "netclass '%s' (uvia)" ), ncName );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->m_Implicit = true;
|
2020-10-11 10:19:07 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
expr = wxString::Format( wxT( "A.NetClass == '%s' && A.Via_Type == 'Micro'" ),
|
2020-10-11 10:19:07 +00:00
|
|
|
ncName );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
|
|
|
|
netclassItemSpecificRules.push_back( netclassRule );
|
2020-10-11 10:19:07 +00:00
|
|
|
|
2020-10-12 23:34:10 +00:00
|
|
|
if( nc->GetuViaDiameter() )
|
2020-10-11 10:19:07 +00:00
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT constraint( VIA_DIAMETER_CONSTRAINT );
|
2020-10-12 23:34:10 +00:00
|
|
|
constraint.Value().SetMin( bds.m_MicroViasMinSize );
|
2020-10-11 10:19:07 +00:00
|
|
|
constraint.Value().SetMin( nc->GetuViaDiameter() );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->AddConstraint( constraint );
|
2020-10-11 10:19:07 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 23:34:10 +00:00
|
|
|
if( nc->GetuViaDrill() )
|
2020-10-11 10:19:07 +00:00
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
DRC_CONSTRAINT constraint( HOLE_SIZE_CONSTRAINT );
|
2020-10-12 23:34:10 +00:00
|
|
|
constraint.Value().SetMin( bds.m_MicroViasMinDrill );
|
|
|
|
constraint.Value().SetOpt( nc->GetuViaDrill() );
|
2020-11-11 00:18:35 +00:00
|
|
|
netclassRule->AddConstraint( constraint );
|
2020-10-11 10:19:07 +00:00
|
|
|
}
|
2020-10-10 18:29:41 +00:00
|
|
|
}
|
2020-09-15 19:13:45 +00:00
|
|
|
};
|
2020-08-26 22:07:31 +00:00
|
|
|
|
2022-11-22 14:24:20 +00:00
|
|
|
m_board->SynchronizeNetsAndNetClasses( false );
|
2022-08-14 11:03:18 +00:00
|
|
|
makeNetclassRules( bds.m_NetSettings->m_DefaultNetClass, true );
|
2020-08-26 22:07:31 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
for( const auto& [ name, netclass ] : bds.m_NetSettings->m_NetClasses )
|
|
|
|
makeNetclassRules( netclass, false );
|
2020-09-15 19:13:45 +00:00
|
|
|
|
2020-10-11 10:19:07 +00:00
|
|
|
// The netclass clearance rules have to be sorted by min clearance so the right one fires
|
|
|
|
// if 'A' and 'B' belong to two different netclasses.
|
|
|
|
//
|
|
|
|
// The item-specific netclass rules are all unary, so there's no 'A' vs 'B' issue.
|
2020-10-08 22:40:11 +00:00
|
|
|
|
2020-10-11 10:19:07 +00:00
|
|
|
std::sort( netclassClearanceRules.begin(), netclassClearanceRules.end(),
|
2022-01-10 21:05:14 +00:00
|
|
|
[]( const std::shared_ptr<DRC_RULE>& lhs, const std::shared_ptr<DRC_RULE>& rhs )
|
2020-10-08 22:40:11 +00:00
|
|
|
{
|
|
|
|
return lhs->m_Constraints[0].m_Value.Min()
|
|
|
|
< rhs->m_Constraints[0].m_Value.Min();
|
|
|
|
} );
|
|
|
|
|
2022-01-10 21:05:14 +00:00
|
|
|
for( std::shared_ptr<DRC_RULE>& ncRule : netclassClearanceRules )
|
2020-10-11 10:19:07 +00:00
|
|
|
addRule( ncRule );
|
|
|
|
|
2022-01-10 21:05:14 +00:00
|
|
|
for( std::shared_ptr<DRC_RULE>& ncRule : netclassItemSpecificRules )
|
2020-10-11 10:19:07 +00:00
|
|
|
addRule( ncRule );
|
2020-10-08 22:40:11 +00:00
|
|
|
|
2020-10-21 23:59:40 +00:00
|
|
|
// 3) keepout area rules
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
std::vector<ZONE*> keepoutZones;
|
2020-10-21 23:59:40 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : m_board->Zones() )
|
2020-10-21 23:59:40 +00:00
|
|
|
{
|
2020-11-17 17:41:57 +00:00
|
|
|
if( isKeepoutZone( zone, true ) )
|
2020-10-21 23:59:40 +00:00
|
|
|
keepoutZones.push_back( zone );
|
|
|
|
}
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : m_board->Footprints() )
|
2020-10-21 23:59:40 +00:00
|
|
|
{
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : footprint->Zones() )
|
2020-10-21 23:59:40 +00:00
|
|
|
{
|
2020-11-17 17:41:57 +00:00
|
|
|
if( isKeepoutZone( zone, true ) )
|
2020-10-21 23:59:40 +00:00
|
|
|
keepoutZones.push_back( zone );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : keepoutZones )
|
2020-10-21 23:59:40 +00:00
|
|
|
{
|
2020-10-22 13:45:12 +00:00
|
|
|
wxString name = zone->GetZoneName();
|
|
|
|
|
2020-10-25 20:53:24 +00:00
|
|
|
if( name.IsEmpty() )
|
2020-10-22 13:45:12 +00:00
|
|
|
rule = createImplicitRule( _( "keepout area" ) );
|
|
|
|
else
|
|
|
|
rule = createImplicitRule( wxString::Format( _( "keepout area '%s'" ), name ) );
|
|
|
|
|
2022-12-21 18:20:04 +00:00
|
|
|
rule->m_ImplicitItemId = zone->m_Uuid;
|
|
|
|
|
|
|
|
rule->m_Condition = new DRC_RULE_CONDITION( wxString::Format( wxT( "A.intersectsArea('%s')" ),
|
2021-11-09 17:57:24 +00:00
|
|
|
zone->m_Uuid.AsString() ) );
|
2020-10-25 20:53:24 +00:00
|
|
|
|
2020-10-25 22:35:47 +00:00
|
|
|
rule->m_LayerCondition = zone->GetLayerSet();
|
|
|
|
|
2020-12-03 23:02:41 +00:00
|
|
|
int disallowFlags = 0;
|
|
|
|
|
2020-10-21 23:59:40 +00:00
|
|
|
if( zone->GetDoNotAllowTracks() )
|
2020-12-03 23:02:41 +00:00
|
|
|
disallowFlags |= DRC_DISALLOW_TRACKS;
|
2020-10-21 23:59:40 +00:00
|
|
|
|
|
|
|
if( zone->GetDoNotAllowVias() )
|
2020-12-03 23:02:41 +00:00
|
|
|
disallowFlags |= DRC_DISALLOW_VIAS;
|
2020-10-21 23:59:40 +00:00
|
|
|
|
|
|
|
if( zone->GetDoNotAllowPads() )
|
2020-12-03 23:02:41 +00:00
|
|
|
disallowFlags |= DRC_DISALLOW_PADS;
|
2020-10-21 23:59:40 +00:00
|
|
|
|
|
|
|
if( zone->GetDoNotAllowCopperPour() )
|
2020-12-03 23:02:41 +00:00
|
|
|
disallowFlags |= DRC_DISALLOW_ZONES;
|
2020-10-21 23:59:40 +00:00
|
|
|
|
|
|
|
if( zone->GetDoNotAllowFootprints() )
|
2020-12-03 23:02:41 +00:00
|
|
|
disallowFlags |= DRC_DISALLOW_FOOTPRINTS;
|
|
|
|
|
|
|
|
DRC_CONSTRAINT disallowConstraint( DISALLOW_CONSTRAINT );
|
|
|
|
disallowConstraint.m_DisallowFlags = disallowFlags;
|
|
|
|
rule->AddConstraint( disallowConstraint );
|
2020-10-21 23:59:40 +00:00
|
|
|
}
|
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
ReportAux( wxString::Format( wxT( "Building %d implicit netclass rules" ),
|
2020-10-11 10:19:07 +00:00
|
|
|
(int) netclassClearanceRules.size() ) );
|
2020-08-26 22:07:31 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 19:35:12 +00:00
|
|
|
|
2020-09-17 17:56:20 +00:00
|
|
|
void DRC_ENGINE::loadRules( const wxFileName& aPath )
|
2020-09-12 23:05:32 +00:00
|
|
|
{
|
|
|
|
if( aPath.FileExists() )
|
|
|
|
{
|
2022-01-10 21:05:14 +00:00
|
|
|
std::vector<std::shared_ptr<DRC_RULE>> rules;
|
2020-09-12 23:05:32 +00:00
|
|
|
|
|
|
|
FILE* fp = wxFopen( aPath.GetFullPath(), wxT( "rt" ) );
|
|
|
|
|
|
|
|
if( fp )
|
|
|
|
{
|
2020-09-17 17:56:20 +00:00
|
|
|
DRC_RULES_PARSER parser( fp, aPath.GetFullPath() );
|
|
|
|
parser.Parse( rules, m_reporter );
|
2020-10-04 11:44:22 +00:00
|
|
|
}
|
2020-09-17 17:56:20 +00:00
|
|
|
|
|
|
|
// Copy the rules into the member variable afterwards so that if Parse() throws then
|
|
|
|
// the possibly malformed rules won't contaminate the current ruleset.
|
|
|
|
|
2022-01-10 21:05:14 +00:00
|
|
|
for( std::shared_ptr<DRC_RULE>& rule : rules )
|
2020-09-17 17:56:20 +00:00
|
|
|
m_rules.push_back( rule );
|
2020-10-04 11:44:22 +00:00
|
|
|
}
|
2020-09-12 23:05:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-16 11:20:37 +00:00
|
|
|
void DRC_ENGINE::compileRules()
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
ReportAux( wxString::Format( wxT( "Compiling Rules (%d rules): " ), (int) m_rules.size() ) );
|
2021-08-15 15:09:19 +00:00
|
|
|
|
2022-01-10 21:05:14 +00:00
|
|
|
for( std::shared_ptr<DRC_RULE>& rule : m_rules )
|
2021-08-15 15:09:19 +00:00
|
|
|
{
|
2021-09-05 15:06:12 +00:00
|
|
|
DRC_RULE_CONDITION* condition = nullptr;
|
2020-06-18 16:55:22 +00:00
|
|
|
|
2021-09-05 15:06:12 +00:00
|
|
|
if( rule->m_Condition && !rule->m_Condition->GetExpression().IsEmpty() )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2021-09-05 15:06:12 +00:00
|
|
|
condition = rule->m_Condition;
|
|
|
|
condition->Compile( nullptr );
|
|
|
|
}
|
2020-08-26 22:07:31 +00:00
|
|
|
|
2021-09-05 15:06:12 +00:00
|
|
|
for( const DRC_CONSTRAINT& constraint : rule->m_Constraints )
|
|
|
|
{
|
|
|
|
if( !m_constraintMap.count( constraint.m_Type ) )
|
|
|
|
m_constraintMap[ constraint.m_Type ] = new std::vector<DRC_ENGINE_CONSTRAINT*>();
|
2020-09-11 15:04:11 +00:00
|
|
|
|
2021-09-05 15:06:12 +00:00
|
|
|
DRC_ENGINE_CONSTRAINT* engineConstraint = new DRC_ENGINE_CONSTRAINT;
|
2020-08-26 22:07:31 +00:00
|
|
|
|
2021-09-05 15:06:12 +00:00
|
|
|
engineConstraint->layerTest = rule->m_LayerCondition;
|
|
|
|
engineConstraint->condition = condition;
|
|
|
|
engineConstraint->constraint = constraint;
|
|
|
|
engineConstraint->parentRule = rule;
|
|
|
|
m_constraintMap[ constraint.m_Type ]->push_back( engineConstraint );
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-12 23:38:35 +00:00
|
|
|
void DRC_ENGINE::InitEngine( const wxFileName& aRulePath )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-06-17 22:36:54 +00:00
|
|
|
m_testProviders = DRC_TEST_PROVIDER_REGISTRY::Instance().GetTestProviders();
|
|
|
|
|
2020-09-12 00:22:46 +00:00
|
|
|
for( DRC_TEST_PROVIDER* provider : m_testProviders )
|
2020-06-18 16:55:22 +00:00
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
ReportAux( wxString::Format( wxT( "Create DRC provider: '%s'" ), provider->GetName() ) );
|
2020-06-17 22:36:54 +00:00
|
|
|
provider->SetDRCEngine( this );
|
2020-06-18 16:55:22 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 17:56:20 +00:00
|
|
|
m_rules.clear();
|
2020-10-16 11:20:37 +00:00
|
|
|
m_rulesValid = false;
|
2020-09-17 17:56:20 +00:00
|
|
|
|
2021-01-01 22:29:15 +00:00
|
|
|
for( std::pair<DRC_CONSTRAINT_T, std::vector<DRC_ENGINE_CONSTRAINT*>*> pair : m_constraintMap )
|
2020-10-24 21:16:07 +00:00
|
|
|
{
|
2021-01-01 22:29:15 +00:00
|
|
|
for( DRC_ENGINE_CONSTRAINT* constraint : *pair.second )
|
|
|
|
delete constraint;
|
2020-10-24 21:16:07 +00:00
|
|
|
|
|
|
|
delete pair.second;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_constraintMap.clear();
|
|
|
|
|
2021-03-25 17:19:29 +00:00
|
|
|
m_board->IncrementTimeStamp(); // Clear board-level caches
|
|
|
|
|
2020-10-16 11:41:19 +00:00
|
|
|
try // attempt to load full set of rules (implicit + user rules)
|
|
|
|
{
|
|
|
|
loadImplicitRules();
|
|
|
|
loadRules( aRulePath );
|
|
|
|
compileRules();
|
|
|
|
}
|
|
|
|
catch( PARSE_ERROR& original_parse_error )
|
|
|
|
{
|
|
|
|
try // try again with just our implicit rules
|
|
|
|
{
|
|
|
|
loadImplicitRules();
|
|
|
|
compileRules();
|
|
|
|
}
|
2021-02-20 16:50:10 +00:00
|
|
|
catch( PARSE_ERROR& )
|
2020-10-16 11:41:19 +00:00
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
wxFAIL_MSG( wxT( "Compiling implicit rules failed." ) );
|
2020-10-16 11:41:19 +00:00
|
|
|
}
|
2020-09-12 00:22:46 +00:00
|
|
|
|
2020-10-16 11:41:19 +00:00
|
|
|
throw original_parse_error;
|
|
|
|
}
|
2020-09-12 19:28:22 +00:00
|
|
|
|
|
|
|
for( int ii = DRCE_FIRST; ii < DRCE_LAST; ++ii )
|
2022-02-09 15:34:22 +00:00
|
|
|
m_errorLimits[ ii ] = ERROR_LIMIT;
|
2020-10-16 11:20:37 +00:00
|
|
|
|
|
|
|
m_rulesValid = true;
|
2020-09-11 23:25:10 +00:00
|
|
|
}
|
2020-07-23 14:22:45 +00:00
|
|
|
|
2020-09-11 23:25:10 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
void DRC_ENGINE::RunTests( EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aTestFootprints )
|
2020-09-11 23:25:10 +00:00
|
|
|
{
|
2022-09-19 16:09:59 +00:00
|
|
|
SetUserUnits( aUnits );
|
2020-09-14 17:54:14 +00:00
|
|
|
|
|
|
|
m_reportAllTrackErrors = aReportAllTrackErrors;
|
|
|
|
m_testFootprints = aTestFootprints;
|
|
|
|
|
2020-09-12 19:28:22 +00:00
|
|
|
for( int ii = DRCE_FIRST; ii < DRCE_LAST; ++ii )
|
|
|
|
{
|
|
|
|
if( m_designSettings->Ignore( ii ) )
|
|
|
|
m_errorLimits[ ii ] = 0;
|
2022-02-09 15:34:22 +00:00
|
|
|
else if( ii == DRCE_CLEARANCE || ii == DRCE_UNCONNECTED_ITEMS )
|
|
|
|
m_errorLimits[ ii ] = EXTENDED_ERROR_LIMIT;
|
2020-09-12 19:28:22 +00:00
|
|
|
else
|
2022-02-09 15:34:22 +00:00
|
|
|
m_errorLimits[ ii ] = ERROR_LIMIT;
|
2020-09-12 19:28:22 +00:00
|
|
|
}
|
|
|
|
|
2022-03-11 20:13:47 +00:00
|
|
|
DRC_TEST_PROVIDER::Init();
|
|
|
|
|
2022-06-17 21:50:59 +00:00
|
|
|
m_board->IncrementTimeStamp(); // Invalidate all caches...
|
2021-02-26 19:19:56 +00:00
|
|
|
|
2022-06-17 21:50:59 +00:00
|
|
|
DRC_CACHE_GENERATOR cacheGenerator;
|
|
|
|
cacheGenerator.SetDRCEngine( this );
|
2021-02-27 00:18:04 +00:00
|
|
|
|
2022-06-17 21:50:59 +00:00
|
|
|
if( !cacheGenerator.Run() ) // ... and regenerate them.
|
|
|
|
return;
|
2022-03-11 20:13:47 +00:00
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
int timestamp = m_board->GetTimeStamp();
|
|
|
|
|
2020-09-11 23:25:10 +00:00
|
|
|
for( DRC_TEST_PROVIDER* provider : m_testProviders )
|
2020-06-17 22:36:54 +00:00
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
ReportAux( wxString::Format( wxT( "Run DRC provider: '%s'" ), provider->GetName() ) );
|
2020-09-18 19:57:54 +00:00
|
|
|
|
2022-09-19 16:09:59 +00:00
|
|
|
if( !provider->RunTests( aUnits ) )
|
2021-09-09 20:49:16 +00:00
|
|
|
break;
|
2020-06-17 22:36:54 +00:00
|
|
|
}
|
2022-07-31 21:14:24 +00:00
|
|
|
|
|
|
|
// DRC tests are multi-threaded; anything that causes us to attempt to re-generate the
|
|
|
|
// caches while DRC is running is problematic.
|
|
|
|
wxASSERT( timestamp == m_board->GetTimeStamp() );
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-08 13:37:14 +00:00
|
|
|
#define REPORT( s ) { if( aReporter ) { aReporter->Report( s ); } }
|
|
|
|
|
|
|
|
DRC_CONSTRAINT DRC_ENGINE::EvalZoneConnection( const BOARD_ITEM* a, const BOARD_ITEM* b,
|
|
|
|
PCB_LAYER_ID aLayer, REPORTER* aReporter )
|
|
|
|
{
|
|
|
|
DRC_CONSTRAINT constraint = EvalRules( ZONE_CONNECTION_CONSTRAINT, a, b, aLayer, aReporter );
|
|
|
|
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Resolved zone connection type: %s." ),
|
|
|
|
EscapeHTML( PrintZoneConnection( constraint.m_ZoneConnection ) ) ) )
|
|
|
|
|
|
|
|
if( constraint.m_ZoneConnection == ZONE_CONNECTION::THT_THERMAL )
|
|
|
|
{
|
|
|
|
const PAD* pad = nullptr;
|
|
|
|
|
|
|
|
if( a->Type() == PCB_PAD_T )
|
|
|
|
pad = static_cast<const PAD*>( a );
|
|
|
|
else if( b->Type() == PCB_PAD_T )
|
|
|
|
pad = static_cast<const PAD*>( b );
|
|
|
|
|
|
|
|
if( pad && pad->GetAttribute() == PAD_ATTRIB::PTH )
|
|
|
|
{
|
|
|
|
constraint.m_ZoneConnection = ZONE_CONNECTION::THERMAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
REPORT( wxString::Format( _( "Pad is not a through hole pad; connection will be: %s." ),
|
|
|
|
EscapeHTML( PrintZoneConnection( ZONE_CONNECTION::FULL ) ) ) )
|
|
|
|
constraint.m_ZoneConnection = ZONE_CONNECTION::FULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-29 15:30:06 +00:00
|
|
|
bool hasDrilledHole( const BOARD_ITEM* aItem )
|
|
|
|
{
|
|
|
|
if( !aItem->HasHole() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case PCB_VIA_T:
|
2023-02-22 00:57:58 +00:00
|
|
|
return true;
|
2022-08-29 15:30:06 +00:00
|
|
|
|
|
|
|
case PCB_PAD_T:
|
|
|
|
{
|
|
|
|
const PAD* pad = static_cast<const PAD*>( aItem );
|
|
|
|
|
|
|
|
return pad->GetDrillSizeX() == pad->GetDrillSizeY();
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-06 12:15:01 +00:00
|
|
|
DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM* a,
|
2021-02-08 14:53:49 +00:00
|
|
|
const BOARD_ITEM* b, PCB_LAYER_ID aLayer,
|
|
|
|
REPORTER* aReporter )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-09-17 15:27:07 +00:00
|
|
|
/*
|
2021-01-02 16:31:35 +00:00
|
|
|
* NOTE: all string manipulation MUST BE KEPT INSIDE the REPORT macro. It absolutely
|
2020-09-17 15:27:07 +00:00
|
|
|
* kills performance when running bulk DRC tests (where aReporter is nullptr).
|
|
|
|
*/
|
2020-09-11 23:25:10 +00:00
|
|
|
|
2020-11-15 17:48:25 +00:00
|
|
|
const BOARD_CONNECTED_ITEM* ac = a && a->IsConnected() ?
|
|
|
|
static_cast<const BOARD_CONNECTED_ITEM*>( a ) : nullptr;
|
|
|
|
const BOARD_CONNECTED_ITEM* bc = b && b->IsConnected() ?
|
|
|
|
static_cast<const BOARD_CONNECTED_ITEM*>( b ) : nullptr;
|
|
|
|
|
2020-11-17 17:41:57 +00:00
|
|
|
bool a_is_non_copper = a && ( !a->IsOnCopperLayer() || isKeepoutZone( a, false ) );
|
|
|
|
bool b_is_non_copper = b && ( !b->IsOnCopperLayer() || isKeepoutZone( b, false ) );
|
2020-11-15 17:48:25 +00:00
|
|
|
|
2022-07-06 23:29:24 +00:00
|
|
|
const PAD* pad = nullptr;
|
|
|
|
const ZONE* zone = nullptr;
|
|
|
|
const FOOTPRINT* parentFootprint = nullptr;
|
2021-08-08 13:37:14 +00:00
|
|
|
|
|
|
|
if( aConstraintType == ZONE_CONNECTION_CONSTRAINT
|
|
|
|
|| aConstraintType == THERMAL_RELIEF_GAP_CONSTRAINT
|
|
|
|
|| aConstraintType == THERMAL_SPOKE_WIDTH_CONSTRAINT )
|
|
|
|
{
|
|
|
|
if( a && a->Type() == PCB_PAD_T )
|
|
|
|
pad = static_cast<const PAD*>( a );
|
2023-03-30 11:49:23 +00:00
|
|
|
else if( a && a->Type() == PCB_ZONE_T )
|
2021-08-08 13:37:14 +00:00
|
|
|
zone = static_cast<const ZONE*>( a );
|
|
|
|
|
|
|
|
if( b && b->Type() == PCB_PAD_T )
|
|
|
|
pad = static_cast<const PAD*>( b );
|
2023-03-30 11:49:23 +00:00
|
|
|
else if( b && b->Type() == PCB_ZONE_T )
|
2021-08-08 13:37:14 +00:00
|
|
|
zone = static_cast<const ZONE*>( b );
|
2022-07-06 23:29:24 +00:00
|
|
|
|
|
|
|
if( pad )
|
2023-03-30 11:49:23 +00:00
|
|
|
parentFootprint = pad->GetParentFootprint();
|
2021-08-08 13:37:14 +00:00
|
|
|
}
|
|
|
|
|
2021-08-21 00:58:21 +00:00
|
|
|
DRC_CONSTRAINT constraint;
|
|
|
|
constraint.m_Type = aConstraintType;
|
2020-09-14 17:54:14 +00:00
|
|
|
|
2023-02-28 18:02:04 +00:00
|
|
|
auto applyConstraint =
|
|
|
|
[&]( const DRC_ENGINE_CONSTRAINT* c )
|
|
|
|
{
|
|
|
|
if( c->constraint.m_Value.HasMin() )
|
|
|
|
constraint.m_Value.SetMin( c->constraint.m_Value.Min() );
|
|
|
|
|
|
|
|
if( c->constraint.m_Value.HasOpt() )
|
|
|
|
constraint.m_Value.SetOpt( c->constraint.m_Value.Opt() );
|
|
|
|
|
|
|
|
if( c->constraint.m_Value.HasMax() )
|
|
|
|
constraint .m_Value.SetMax( c->constraint.m_Value.Max() );
|
|
|
|
|
|
|
|
// While the expectation would be to OR the disallow flags, we've already
|
|
|
|
// masked them down to aItem's type -- so we're really only looking for a
|
|
|
|
// boolean here.
|
|
|
|
constraint.m_DisallowFlags = c->constraint.m_DisallowFlags;
|
|
|
|
|
|
|
|
constraint.m_ZoneConnection = c->constraint.m_ZoneConnection;
|
|
|
|
|
|
|
|
constraint.SetParentRule( c->constraint.GetParentRule() );
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:42:12 +00:00
|
|
|
// Local overrides take precedence over everything *except* board min clearance
|
2021-08-21 00:58:21 +00:00
|
|
|
if( aConstraintType == CLEARANCE_CONSTRAINT || aConstraintType == HOLE_CLEARANCE_CONSTRAINT )
|
2020-09-11 16:24:27 +00:00
|
|
|
{
|
2022-06-15 23:42:34 +00:00
|
|
|
int override_val = 0;
|
2022-06-16 15:26:28 +00:00
|
|
|
int overrideA = 0;
|
|
|
|
int overrideB = 0;
|
2020-09-11 23:25:10 +00:00
|
|
|
|
2021-08-21 00:58:21 +00:00
|
|
|
if( ac && !b_is_non_copper )
|
2022-06-16 15:26:28 +00:00
|
|
|
overrideA = ac->GetLocalClearanceOverrides( nullptr );
|
|
|
|
|
|
|
|
if( bc && !a_is_non_copper )
|
|
|
|
overrideB = bc->GetLocalClearanceOverrides( nullptr );
|
|
|
|
|
|
|
|
if( overrideA > 0 || overrideB > 0 )
|
2020-09-11 23:25:10 +00:00
|
|
|
{
|
2022-06-16 15:26:28 +00:00
|
|
|
wxString msg;
|
2021-08-22 02:24:51 +00:00
|
|
|
|
|
|
|
if( overrideA > 0 )
|
2021-08-21 00:58:21 +00:00
|
|
|
{
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Local override on %s; clearance: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( a->GetItemDescription( this ) ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( overrideA ) ) )
|
2020-09-11 23:25:10 +00:00
|
|
|
|
2022-06-15 23:42:34 +00:00
|
|
|
override_val = ac->GetLocalClearanceOverrides( &msg );
|
2021-08-21 00:58:21 +00:00
|
|
|
}
|
2021-08-22 02:24:51 +00:00
|
|
|
|
|
|
|
if( overrideB > 0 )
|
2021-08-21 00:58:21 +00:00
|
|
|
{
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Local override on %s; clearance: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( b->GetItemDescription( this ) ),
|
2022-09-19 16:09:59 +00:00
|
|
|
EscapeHTML( MessageTextFromValue( overrideB ) ) ) )
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2022-06-15 23:42:34 +00:00
|
|
|
if( overrideB > override_val )
|
|
|
|
override_val = bc->GetLocalClearanceOverrides( &msg );
|
2021-08-21 00:58:21 +00:00
|
|
|
}
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2022-06-16 15:26:28 +00:00
|
|
|
if( override_val )
|
2021-08-21 00:58:21 +00:00
|
|
|
{
|
2022-06-16 15:26:28 +00:00
|
|
|
if( aConstraintType == CLEARANCE_CONSTRAINT )
|
2021-08-21 00:58:21 +00:00
|
|
|
{
|
2022-06-16 15:26:28 +00:00
|
|
|
if( override_val < m_designSettings->m_MinClearance )
|
|
|
|
{
|
|
|
|
override_val = m_designSettings->m_MinClearance;
|
|
|
|
msg = _( "board minimum" );
|
2021-04-15 20:42:12 +00:00
|
|
|
|
2022-06-16 15:26:28 +00:00
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Board minimum clearance: %s." ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( override_val ) ) )
|
2022-06-16 15:26:28 +00:00
|
|
|
}
|
2021-08-21 00:58:21 +00:00
|
|
|
}
|
2022-06-16 15:26:28 +00:00
|
|
|
else
|
2021-08-21 00:58:21 +00:00
|
|
|
{
|
2022-06-16 15:26:28 +00:00
|
|
|
if( override_val < m_designSettings->m_HoleClearance )
|
|
|
|
{
|
|
|
|
override_val = m_designSettings->m_HoleClearance;
|
|
|
|
msg = _( "board minimum hole" );
|
2021-04-15 20:42:12 +00:00
|
|
|
|
2022-06-16 15:26:28 +00:00
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Board minimum hole clearance: %s." ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( override_val ) ) )
|
2022-06-16 15:26:28 +00:00
|
|
|
}
|
2021-08-21 00:58:21 +00:00
|
|
|
}
|
2021-04-15 20:42:12 +00:00
|
|
|
|
2022-06-16 15:26:28 +00:00
|
|
|
constraint.SetName( msg );
|
|
|
|
constraint.m_Value.SetMin( override_val );
|
|
|
|
return constraint;
|
|
|
|
}
|
2020-09-11 16:24:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-08 13:37:14 +00:00
|
|
|
else if( aConstraintType == ZONE_CONNECTION_CONSTRAINT )
|
|
|
|
{
|
|
|
|
if( pad && pad->GetLocalZoneConnectionOverride( nullptr ) != ZONE_CONNECTION::INHERITED )
|
|
|
|
{
|
2022-06-15 23:42:34 +00:00
|
|
|
wxString msg;
|
|
|
|
ZONE_CONNECTION override = pad->GetLocalZoneConnectionOverride( &msg );
|
2021-08-08 13:37:14 +00:00
|
|
|
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Local override on %s; zone connection: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( pad->GetItemDescription( this ) ),
|
2021-08-08 13:37:14 +00:00
|
|
|
EscapeHTML( PrintZoneConnection( override ) ) ) )
|
|
|
|
|
2022-06-15 23:42:34 +00:00
|
|
|
constraint.SetName( msg );
|
2021-08-08 13:37:14 +00:00
|
|
|
constraint.m_ZoneConnection = override;
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aConstraintType == THERMAL_RELIEF_GAP_CONSTRAINT )
|
|
|
|
{
|
|
|
|
if( pad && pad->GetLocalThermalGapOverride( nullptr ) > 0 )
|
|
|
|
{
|
2022-06-15 23:42:34 +00:00
|
|
|
wxString msg;
|
|
|
|
int gap_override = pad->GetLocalThermalGapOverride( &msg );
|
2021-08-08 13:37:14 +00:00
|
|
|
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Local override on %s; thermal relief gap: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( pad->GetItemDescription( this ) ),
|
2022-09-19 16:09:59 +00:00
|
|
|
EscapeHTML( MessageTextFromValue( gap_override ) ) ) )
|
2021-08-08 13:37:14 +00:00
|
|
|
|
2022-06-15 23:42:34 +00:00
|
|
|
constraint.SetName( msg );
|
2022-01-08 13:24:14 +00:00
|
|
|
constraint.m_Value.SetMin( gap_override );
|
2021-08-08 13:37:14 +00:00
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aConstraintType == THERMAL_SPOKE_WIDTH_CONSTRAINT )
|
|
|
|
{
|
|
|
|
if( pad && pad->GetLocalSpokeWidthOverride( nullptr ) > 0 )
|
|
|
|
{
|
2022-06-15 23:42:34 +00:00
|
|
|
wxString msg;
|
|
|
|
int spoke_override = pad->GetLocalSpokeWidthOverride( &msg );
|
2021-08-08 13:37:14 +00:00
|
|
|
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Local override on %s; thermal spoke width: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( pad->GetItemDescription( this ) ),
|
2022-09-19 16:09:59 +00:00
|
|
|
EscapeHTML( MessageTextFromValue( spoke_override ) ) ) )
|
2021-08-08 13:37:14 +00:00
|
|
|
|
2022-01-08 13:24:14 +00:00
|
|
|
if( zone && zone->GetMinThickness() > spoke_override )
|
2021-08-08 13:37:14 +00:00
|
|
|
{
|
2022-01-08 13:24:14 +00:00
|
|
|
spoke_override = zone->GetMinThickness();
|
2021-08-08 13:37:14 +00:00
|
|
|
|
|
|
|
REPORT( "" )
|
2022-05-02 23:47:36 +00:00
|
|
|
REPORT( wxString::Format( _( "%s min thickness: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( zone->GetItemDescription( this ) ),
|
2022-09-19 16:09:59 +00:00
|
|
|
EscapeHTML( MessageTextFromValue( spoke_override ) ) ) )
|
2021-08-08 13:37:14 +00:00
|
|
|
}
|
|
|
|
|
2022-06-15 23:42:34 +00:00
|
|
|
constraint.SetName( msg );
|
2022-01-08 13:24:14 +00:00
|
|
|
constraint.m_Value.SetMin( spoke_override );
|
2021-08-08 13:37:14 +00:00
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
}
|
2020-09-11 16:24:27 +00:00
|
|
|
|
2021-09-22 21:20:18 +00:00
|
|
|
auto testAssertion =
|
|
|
|
[&]( const DRC_ENGINE_CONSTRAINT* c )
|
|
|
|
{
|
|
|
|
REPORT( wxString::Format( _( "Checking assertion \"%s\"." ),
|
|
|
|
EscapeHTML( c->constraint.m_Test->GetExpression() ) ) )
|
|
|
|
|
2022-04-02 14:08:32 +00:00
|
|
|
if( c->constraint.m_Test->EvaluateFor( a, b, c->constraint.m_Type, aLayer,
|
|
|
|
aReporter ) )
|
|
|
|
{
|
2021-09-22 21:20:18 +00:00
|
|
|
REPORT( _( "Assertion passed." ) )
|
2022-04-02 14:08:32 +00:00
|
|
|
}
|
2021-09-22 21:20:18 +00:00
|
|
|
else
|
2022-04-02 14:08:32 +00:00
|
|
|
{
|
2021-09-22 21:20:18 +00:00
|
|
|
REPORT( EscapeHTML( _( "--> Assertion failed. <--" ) ) )
|
2022-04-02 14:08:32 +00:00
|
|
|
}
|
2021-09-22 21:20:18 +00:00
|
|
|
};
|
|
|
|
|
2020-10-15 19:18:49 +00:00
|
|
|
auto processConstraint =
|
2023-02-16 17:55:33 +00:00
|
|
|
[&]( const DRC_ENGINE_CONSTRAINT* c )
|
2020-10-11 10:51:23 +00:00
|
|
|
{
|
2021-08-21 00:58:21 +00:00
|
|
|
bool implicit = c->parentRule && c->parentRule->m_Implicit;
|
2020-09-15 15:35:09 +00:00
|
|
|
|
2020-10-15 19:18:49 +00:00
|
|
|
REPORT( "" )
|
|
|
|
|
2021-08-09 21:25:16 +00:00
|
|
|
switch( c->constraint.m_Type )
|
2020-10-15 19:18:49 +00:00
|
|
|
{
|
2021-08-09 21:25:16 +00:00
|
|
|
case CLEARANCE_CONSTRAINT:
|
|
|
|
case COURTYARD_CLEARANCE_CONSTRAINT:
|
|
|
|
case SILK_CLEARANCE_CONSTRAINT:
|
|
|
|
case HOLE_CLEARANCE_CONSTRAINT:
|
|
|
|
case EDGE_CLEARANCE_CONSTRAINT:
|
2022-05-06 13:46:24 +00:00
|
|
|
case PHYSICAL_CLEARANCE_CONSTRAINT:
|
|
|
|
case PHYSICAL_HOLE_CLEARANCE_CONSTRAINT:
|
2021-08-06 12:15:01 +00:00
|
|
|
REPORT( wxString::Format( _( "Checking %s clearance: %s." ),
|
2020-11-30 12:14:22 +00:00
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( c->constraint.m_Value.Min() ) ) )
|
2021-08-09 21:25:16 +00:00
|
|
|
break;
|
|
|
|
|
2022-04-15 21:09:35 +00:00
|
|
|
case DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT:
|
|
|
|
REPORT( wxString::Format( _( "Checking %s max uncoupled length: %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( c->constraint.m_Value.Max() ) ) )
|
2022-04-15 23:57:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SKEW_CONSTRAINT:
|
|
|
|
REPORT( wxString::Format( _( "Checking %s max skew: %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( c->constraint.m_Value.Max() ) ) )
|
2022-04-15 23:57:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case THERMAL_RELIEF_GAP_CONSTRAINT:
|
|
|
|
REPORT( wxString::Format( _( "Checking %s gap: %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( c->constraint.m_Value.Min() ) ) )
|
2022-04-15 23:57:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case THERMAL_SPOKE_WIDTH_CONSTRAINT:
|
|
|
|
REPORT( wxString::Format( _( "Checking %s thermal spoke width: %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( c->constraint.m_Value.Opt() ) ) )
|
2022-04-15 21:09:35 +00:00
|
|
|
break;
|
|
|
|
|
2022-05-02 23:47:36 +00:00
|
|
|
case MIN_RESOLVED_SPOKES_CONSTRAINT:
|
|
|
|
REPORT( wxString::Format( _( "Checking %s min spoke count: %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-09-19 16:09:59 +00:00
|
|
|
EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED,
|
|
|
|
c->constraint.m_Value.Min() ) ) )
|
2022-05-02 23:47:36 +00:00
|
|
|
break;
|
|
|
|
|
2022-04-15 23:57:08 +00:00
|
|
|
case ZONE_CONNECTION_CONSTRAINT:
|
|
|
|
REPORT( wxString::Format( _( "Checking %s zone connection: %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
|
|
|
EscapeHTML( PrintZoneConnection( c->constraint.m_ZoneConnection ) ) ) )
|
|
|
|
break;
|
2022-04-15 21:09:35 +00:00
|
|
|
|
2021-08-09 21:25:16 +00:00
|
|
|
case TRACK_WIDTH_CONSTRAINT:
|
|
|
|
case ANNULAR_WIDTH_CONSTRAINT:
|
|
|
|
case VIA_DIAMETER_CONSTRAINT:
|
2022-04-15 23:57:08 +00:00
|
|
|
case HOLE_SIZE_CONSTRAINT:
|
2021-08-15 15:09:19 +00:00
|
|
|
case TEXT_HEIGHT_CONSTRAINT:
|
|
|
|
case TEXT_THICKNESS_CONSTRAINT:
|
2022-04-15 21:09:35 +00:00
|
|
|
case DIFF_PAIR_GAP_CONSTRAINT:
|
2022-04-15 23:57:08 +00:00
|
|
|
case LENGTH_CONSTRAINT:
|
2022-07-31 15:02:04 +00:00
|
|
|
case CONNECTION_WIDTH_CONSTRAINT:
|
2022-08-29 15:30:06 +00:00
|
|
|
case HOLE_TO_HOLE_CONSTRAINT:
|
2020-10-15 19:18:49 +00:00
|
|
|
{
|
2021-08-09 21:25:16 +00:00
|
|
|
if( aReporter )
|
|
|
|
{
|
|
|
|
wxString min = wxT( "<i>" ) + _( "undefined" ) + wxT( "</i>" );
|
|
|
|
wxString opt = wxT( "<i>" ) + _( "undefined" ) + wxT( "</i>" );
|
|
|
|
wxString max = wxT( "<i>" ) + _( "undefined" ) + wxT( "</i>" );
|
|
|
|
|
|
|
|
if( implicit )
|
|
|
|
{
|
2022-09-19 16:09:59 +00:00
|
|
|
min = MessageTextFromValue( c->constraint.m_Value.Min() );
|
|
|
|
opt = MessageTextFromValue( c->constraint.m_Value.Opt() );
|
2021-08-09 21:25:16 +00:00
|
|
|
|
|
|
|
switch( c->constraint.m_Type )
|
|
|
|
{
|
2022-04-15 23:57:08 +00:00
|
|
|
case TRACK_WIDTH_CONSTRAINT:
|
|
|
|
if( c->constraint.m_Value.HasOpt() )
|
|
|
|
{
|
|
|
|
REPORT( wxString::Format( _( "Checking %s track width: opt %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
|
|
|
opt ) )
|
|
|
|
}
|
|
|
|
else if( c->constraint.m_Value.HasMin() )
|
|
|
|
{
|
2023-02-28 18:02:04 +00:00
|
|
|
REPORT( wxString::Format( _( "Checking %s track width: min %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-04-15 23:57:08 +00:00
|
|
|
min ) )
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ANNULAR_WIDTH_CONSTRAINT:
|
|
|
|
REPORT( wxString::Format( _( "Checking %s annular width: min %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
|
|
|
opt ) )
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIA_DIAMETER_CONSTRAINT:
|
|
|
|
if( c->constraint.m_Value.HasOpt() )
|
|
|
|
{
|
|
|
|
REPORT( wxString::Format( _( "Checking %s via diameter: opt %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
|
|
|
opt ) )
|
|
|
|
}
|
|
|
|
else if( c->constraint.m_Value.HasMin() )
|
|
|
|
{
|
2023-02-28 18:02:04 +00:00
|
|
|
REPORT( wxString::Format( _( "Checking %s via diameter: min %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-04-15 23:57:08 +00:00
|
|
|
min ) )
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HOLE_SIZE_CONSTRAINT:
|
|
|
|
if( c->constraint.m_Value.HasOpt() )
|
|
|
|
{
|
|
|
|
REPORT( wxString::Format( _( "Checking %s hole size: opt %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
|
|
|
opt ) )
|
|
|
|
}
|
|
|
|
else if( c->constraint.m_Value.HasMin() )
|
|
|
|
{
|
2023-02-28 18:02:04 +00:00
|
|
|
REPORT( wxString::Format( _( "Checking %s hole size: min %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-04-15 23:57:08 +00:00
|
|
|
min ) )
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXT_HEIGHT_CONSTRAINT:
|
|
|
|
case TEXT_THICKNESS_CONSTRAINT:
|
2022-07-31 15:02:04 +00:00
|
|
|
case CONNECTION_WIDTH_CONSTRAINT:
|
2022-04-15 23:57:08 +00:00
|
|
|
REPORT( wxString::Format( _( "Checking %s: min %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
|
|
|
min ) )
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIFF_PAIR_GAP_CONSTRAINT:
|
|
|
|
if( c->constraint.m_Value.HasOpt() )
|
|
|
|
{
|
2023-02-28 18:02:04 +00:00
|
|
|
REPORT( wxString::Format( _( "Checking %s diff pair gap: opt %s." ),
|
2022-04-15 23:57:08 +00:00
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
|
|
|
opt ) )
|
|
|
|
}
|
|
|
|
else if( c->constraint.m_Value.HasMin() )
|
|
|
|
{
|
2023-02-28 18:02:04 +00:00
|
|
|
REPORT( wxString::Format( _( "Checking %s clearance: min %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-04-15 23:57:08 +00:00
|
|
|
min ) )
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2022-08-29 15:30:06 +00:00
|
|
|
case HOLE_TO_HOLE_CONSTRAINT:
|
2023-02-28 18:02:04 +00:00
|
|
|
REPORT( wxString::Format( _( "Checking %s hole to hole: min %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
2022-08-29 15:30:06 +00:00
|
|
|
min ) )
|
|
|
|
break;
|
|
|
|
|
2022-04-15 23:57:08 +00:00
|
|
|
default:
|
|
|
|
REPORT( wxString::Format( _( "Checking %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ) ) )
|
2021-08-09 21:25:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( c->constraint.m_Value.HasMin() )
|
2022-09-19 16:09:59 +00:00
|
|
|
min = MessageTextFromValue( c->constraint.m_Value.Min() );
|
2021-08-09 21:25:16 +00:00
|
|
|
|
|
|
|
if( c->constraint.m_Value.HasOpt() )
|
2022-09-19 16:09:59 +00:00
|
|
|
opt = MessageTextFromValue( c->constraint.m_Value.Opt() );
|
2021-08-09 21:25:16 +00:00
|
|
|
|
|
|
|
if( c->constraint.m_Value.HasMax() )
|
2022-09-19 16:09:59 +00:00
|
|
|
max = MessageTextFromValue( c->constraint.m_Value.Max() );
|
2021-08-09 21:25:16 +00:00
|
|
|
|
|
|
|
REPORT( wxString::Format( _( "Checking %s: min %s; opt %s; max %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ),
|
|
|
|
min,
|
|
|
|
opt,
|
|
|
|
max ) )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2020-10-15 19:18:49 +00:00
|
|
|
}
|
2021-08-09 21:25:16 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
REPORT( wxString::Format( _( "Checking %s." ),
|
|
|
|
EscapeHTML( c->constraint.GetName() ) ) )
|
2020-10-22 13:45:12 +00:00
|
|
|
}
|
|
|
|
|
2021-08-06 12:15:01 +00:00
|
|
|
if( c->constraint.m_Type == CLEARANCE_CONSTRAINT )
|
2020-10-22 13:45:12 +00:00
|
|
|
{
|
2020-11-17 17:41:57 +00:00
|
|
|
if( implicit && ( a_is_non_copper || b_is_non_copper ) )
|
2020-10-22 13:45:12 +00:00
|
|
|
{
|
2023-03-26 19:56:18 +00:00
|
|
|
REPORT( _( "Netclass clearances apply only between copper items." ) );
|
2023-02-16 17:55:33 +00:00
|
|
|
return;
|
2020-10-22 13:45:12 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-06 12:15:01 +00:00
|
|
|
else if( c->constraint.m_Type == DISALLOW_CONSTRAINT )
|
2020-10-21 23:59:40 +00:00
|
|
|
{
|
|
|
|
int mask;
|
|
|
|
|
|
|
|
if( a->GetFlags() & HOLE_PROXY )
|
|
|
|
{
|
|
|
|
mask = DRC_DISALLOW_HOLES;
|
|
|
|
}
|
|
|
|
else if( a->Type() == PCB_VIA_T )
|
|
|
|
{
|
2021-08-06 12:15:01 +00:00
|
|
|
mask = DRC_DISALLOW_VIAS;
|
|
|
|
|
|
|
|
switch( static_cast<const PCB_VIA*>( a )->GetViaType() )
|
|
|
|
{
|
|
|
|
case VIATYPE::BLIND_BURIED: mask |= DRC_DISALLOW_BB_VIAS; break;
|
|
|
|
case VIATYPE::MICROVIA: mask |= DRC_DISALLOW_MICRO_VIAS; break;
|
|
|
|
default: break;
|
|
|
|
}
|
2020-10-21 23:59:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( a->Type() )
|
|
|
|
{
|
|
|
|
case PCB_TRACE_T: mask = DRC_DISALLOW_TRACKS; break;
|
|
|
|
case PCB_ARC_T: mask = DRC_DISALLOW_TRACKS; break;
|
|
|
|
case PCB_PAD_T: mask = DRC_DISALLOW_PADS; break;
|
2020-11-13 12:21:02 +00:00
|
|
|
case PCB_FOOTPRINT_T: mask = DRC_DISALLOW_FOOTPRINTS; break;
|
2020-10-21 23:59:40 +00:00
|
|
|
case PCB_SHAPE_T: mask = DRC_DISALLOW_GRAPHICS; break;
|
|
|
|
case PCB_TEXT_T: mask = DRC_DISALLOW_TEXTS; break;
|
2022-01-30 10:52:52 +00:00
|
|
|
case PCB_TEXTBOX_T: mask = DRC_DISALLOW_TEXTS; break;
|
2023-01-04 00:49:33 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_ZONE_T:
|
2023-01-04 00:49:33 +00:00
|
|
|
// Treat teardrop areas as tracks for DRC purposes
|
2023-03-30 11:49:23 +00:00
|
|
|
if( static_cast<const ZONE*>( a )->IsTeardropArea() )
|
2022-12-26 11:32:43 +00:00
|
|
|
mask = DRC_DISALLOW_TRACKS;
|
2023-01-04 00:49:33 +00:00
|
|
|
else
|
|
|
|
mask = DRC_DISALLOW_ZONES;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_LOCATE_HOLE_T: mask = DRC_DISALLOW_HOLES; break;
|
|
|
|
default: mask = 0; break;
|
2022-12-26 11:32:43 +00:00
|
|
|
}
|
2020-10-21 23:59:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( ( c->constraint.m_DisallowFlags & mask ) == 0 )
|
2020-10-22 13:45:12 +00:00
|
|
|
{
|
|
|
|
if( implicit )
|
|
|
|
REPORT( _( "Keepout constraint not met." ) )
|
2020-10-25 22:35:47 +00:00
|
|
|
else
|
|
|
|
REPORT( _( "Disallow constraint not met." ) )
|
|
|
|
|
2023-02-16 17:55:33 +00:00
|
|
|
return;
|
2020-10-25 22:35:47 +00:00
|
|
|
}
|
2020-10-22 13:45:12 +00:00
|
|
|
|
2021-02-20 13:25:16 +00:00
|
|
|
LSET itemLayers = a->GetLayerSet();
|
|
|
|
|
|
|
|
if( a->Type() == PCB_FOOTPRINT_T )
|
|
|
|
{
|
|
|
|
const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( a );
|
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
if( !footprint->GetCourtyard( F_CrtYd ).IsEmpty() )
|
2021-02-20 13:25:16 +00:00
|
|
|
itemLayers |= LSET::FrontMask();
|
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
if( !footprint->GetCourtyard( B_CrtYd ).IsEmpty() )
|
2021-02-20 13:25:16 +00:00
|
|
|
itemLayers |= LSET::BackMask();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !( c->layerTest & itemLayers ).any() )
|
2020-10-25 22:35:47 +00:00
|
|
|
{
|
|
|
|
if( implicit )
|
|
|
|
{
|
|
|
|
REPORT( _( "Keepout layer(s) not matched." ) )
|
|
|
|
}
|
|
|
|
else if( c->parentRule )
|
|
|
|
{
|
2021-09-22 21:20:18 +00:00
|
|
|
REPORT( wxString::Format( _( "Rule layer '%s' not matched; rule ignored." ),
|
2020-11-30 12:14:22 +00:00
|
|
|
EscapeHTML( c->parentRule->m_LayerSource ) ) )
|
2020-10-22 13:45:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-05 14:52:42 +00:00
|
|
|
REPORT( _( "Rule layer not matched; rule ignored." ) )
|
2020-10-22 13:45:12 +00:00
|
|
|
}
|
2020-10-25 22:35:47 +00:00
|
|
|
|
2023-02-16 17:55:33 +00:00
|
|
|
return;
|
2020-10-22 13:45:12 +00:00
|
|
|
}
|
2020-09-16 20:38:23 +00:00
|
|
|
}
|
|
|
|
|
2022-01-15 00:19:36 +00:00
|
|
|
if( ( aLayer != UNDEFINED_LAYER && !c->layerTest.test( aLayer ) )
|
|
|
|
|| ( m_board->GetEnabledLayers() & c->layerTest ).count() == 0 )
|
2020-09-16 20:38:23 +00:00
|
|
|
{
|
2020-10-25 22:35:47 +00:00
|
|
|
if( implicit )
|
|
|
|
{
|
2023-02-16 17:28:06 +00:00
|
|
|
REPORT( _( "Constraint layer not matched." ) )
|
2020-10-25 22:35:47 +00:00
|
|
|
}
|
|
|
|
else if( c->parentRule )
|
2020-10-15 19:18:49 +00:00
|
|
|
{
|
2021-01-05 14:52:42 +00:00
|
|
|
REPORT( wxString::Format( _( "Rule layer '%s' not matched; rule ignored." ),
|
2020-11-30 12:14:22 +00:00
|
|
|
EscapeHTML( c->parentRule->m_LayerSource ) ) )
|
2020-10-15 19:18:49 +00:00
|
|
|
}
|
2020-10-25 22:35:47 +00:00
|
|
|
else
|
|
|
|
{
|
2021-01-05 14:52:42 +00:00
|
|
|
REPORT( _( "Rule layer not matched; rule ignored." ) )
|
2020-10-25 22:35:47 +00:00
|
|
|
}
|
2020-09-16 20:38:23 +00:00
|
|
|
}
|
2023-02-16 17:55:33 +00:00
|
|
|
else if( c->constraint.m_Type == HOLE_TO_HOLE_CONSTRAINT
|
2022-08-29 15:30:06 +00:00
|
|
|
&& ( !hasDrilledHole( a ) || !hasDrilledHole( b ) ) )
|
|
|
|
{
|
|
|
|
// Report non-drilled-holes as an implicit condition
|
|
|
|
if( aReporter )
|
|
|
|
{
|
|
|
|
const BOARD_ITEM* x = !hasDrilledHole( a ) ? a : b;
|
|
|
|
|
|
|
|
REPORT( wxString::Format( _( "%s is not a drilled hole; rule ignored." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
x->GetItemDescription( this ) ) )
|
2022-08-29 15:30:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( !c->condition || c->condition->GetExpression().IsEmpty() )
|
2020-09-16 20:38:23 +00:00
|
|
|
{
|
2021-09-22 21:20:18 +00:00
|
|
|
if( aReporter )
|
|
|
|
{
|
|
|
|
if( implicit )
|
|
|
|
{
|
|
|
|
REPORT( _( "Unconditional constraint applied." ) )
|
|
|
|
}
|
|
|
|
else if( constraint.m_Type == ASSERTION_CONSTRAINT )
|
|
|
|
{
|
|
|
|
REPORT( _( "Unconditional rule applied." ) )
|
|
|
|
testAssertion( c );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
REPORT( _( "Unconditional rule applied; overrides previous constraints." ) )
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 20:38:23 +00:00
|
|
|
|
2023-02-28 18:02:04 +00:00
|
|
|
applyConstraint( c );
|
2020-09-16 20:38:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-25 22:35:47 +00:00
|
|
|
if( implicit )
|
|
|
|
{
|
|
|
|
// Don't report on implicit rule conditions; they're synthetic.
|
|
|
|
}
|
|
|
|
else
|
2020-10-15 19:18:49 +00:00
|
|
|
{
|
2021-11-08 20:19:45 +00:00
|
|
|
REPORT( wxString::Format( _( "Checking rule condition \"%s\"." ),
|
2020-11-30 12:14:22 +00:00
|
|
|
EscapeHTML( c->condition->GetExpression() ) ) )
|
2020-10-15 19:18:49 +00:00
|
|
|
}
|
|
|
|
|
2022-04-02 14:08:32 +00:00
|
|
|
if( c->condition->EvaluateFor( a, b, c->constraint.m_Type, aLayer, aReporter ) )
|
2020-10-15 19:18:49 +00:00
|
|
|
{
|
2021-09-22 21:20:18 +00:00
|
|
|
if( aReporter )
|
|
|
|
{
|
|
|
|
if( implicit )
|
|
|
|
{
|
|
|
|
REPORT( _( "Constraint applied." ) )
|
|
|
|
}
|
|
|
|
else if( constraint.m_Type == ASSERTION_CONSTRAINT )
|
|
|
|
{
|
|
|
|
REPORT( _( "Rule applied." ) )
|
|
|
|
testAssertion( c );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
REPORT( _( "Rule applied; overrides previous constraints." ) )
|
|
|
|
}
|
|
|
|
}
|
2020-10-15 19:18:49 +00:00
|
|
|
|
2023-02-28 18:02:04 +00:00
|
|
|
applyConstraint( c );
|
2020-10-15 19:18:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
REPORT( implicit ? _( "Membership not satisfied; constraint ignored." )
|
|
|
|
: _( "Condition not satisfied; rule ignored." ) )
|
|
|
|
}
|
2020-09-16 20:38:23 +00:00
|
|
|
}
|
2020-10-15 19:18:49 +00:00
|
|
|
};
|
|
|
|
|
2021-08-09 21:25:16 +00:00
|
|
|
if( m_constraintMap.count( aConstraintType ) )
|
2020-10-15 19:18:49 +00:00
|
|
|
{
|
2021-08-09 21:25:16 +00:00
|
|
|
std::vector<DRC_ENGINE_CONSTRAINT*>* ruleset = m_constraintMap[ aConstraintType ];
|
2020-10-15 19:18:49 +00:00
|
|
|
|
2021-08-21 15:35:08 +00:00
|
|
|
for( int ii = 0; ii < (int) ruleset->size(); ++ii )
|
|
|
|
processConstraint( ruleset->at( ii ) );
|
2020-06-17 22:36:54 +00:00
|
|
|
}
|
|
|
|
|
2021-08-21 00:58:21 +00:00
|
|
|
if( constraint.GetParentRule() && !constraint.GetParentRule()->m_Implicit )
|
|
|
|
return constraint;
|
2020-11-19 22:34:06 +00:00
|
|
|
|
2022-07-06 23:29:24 +00:00
|
|
|
// Special case for pad zone connections which can iherit from their parent footprints.
|
|
|
|
// We've already checked for local overrides, and there were no rules targetting the pad
|
|
|
|
// itself, so we know we're inheriting and need to see if there are any rules targetting
|
|
|
|
// the parent footprint.
|
|
|
|
if( pad && parentFootprint && ( aConstraintType == ZONE_CONNECTION_CONSTRAINT
|
|
|
|
|| aConstraintType == THERMAL_RELIEF_GAP_CONSTRAINT
|
|
|
|
|| aConstraintType == THERMAL_SPOKE_WIDTH_CONSTRAINT ) )
|
|
|
|
{
|
|
|
|
if( a == pad )
|
|
|
|
a = parentFootprint;
|
|
|
|
else
|
|
|
|
b = parentFootprint;
|
|
|
|
|
|
|
|
if( m_constraintMap.count( aConstraintType ) )
|
|
|
|
{
|
|
|
|
std::vector<DRC_ENGINE_CONSTRAINT*>* ruleset = m_constraintMap[ aConstraintType ];
|
|
|
|
|
|
|
|
for( int ii = 0; ii < (int) ruleset->size(); ++ii )
|
|
|
|
processConstraint( ruleset->at( ii ) );
|
|
|
|
|
|
|
|
if( constraint.GetParentRule() && !constraint.GetParentRule()->m_Implicit )
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
// Unfortunately implicit rules don't work for local clearances (such as zones) because
|
|
|
|
// they have to be max'ed with netclass values (which are already implicit rules), and our
|
|
|
|
// rule selection paradigm is "winner takes all".
|
2021-08-21 00:58:21 +00:00
|
|
|
if( aConstraintType == CLEARANCE_CONSTRAINT )
|
2020-09-14 17:54:14 +00:00
|
|
|
{
|
2021-08-21 00:58:21 +00:00
|
|
|
int global = constraint.m_Value.Min();
|
2020-11-15 17:48:25 +00:00
|
|
|
int localA = ac ? ac->GetLocalClearance( nullptr ) : 0;
|
|
|
|
int localB = bc ? bc->GetLocalClearance( nullptr ) : 0;
|
2020-09-14 17:54:14 +00:00
|
|
|
int clearance = global;
|
|
|
|
|
|
|
|
if( localA > 0 )
|
|
|
|
{
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Local clearance on %s; clearance: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( a->GetItemDescription( this ) ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( localA ) ) )
|
2020-09-14 17:54:14 +00:00
|
|
|
|
|
|
|
if( localA > clearance )
|
2022-05-02 23:47:36 +00:00
|
|
|
{
|
2022-06-15 23:42:34 +00:00
|
|
|
wxString msg;
|
|
|
|
clearance = ac->GetLocalClearance( &msg );
|
2022-05-02 23:47:36 +00:00
|
|
|
constraint.SetParentRule( nullptr );
|
2022-06-15 23:42:34 +00:00
|
|
|
constraint.SetName( msg );
|
2022-05-02 23:47:36 +00:00
|
|
|
constraint.m_Value.SetMin( clearance );
|
|
|
|
}
|
2020-09-14 17:54:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( localB > 0 )
|
|
|
|
{
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Local clearance on %s; clearance: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( b->GetItemDescription( this ) ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( localB ) ) )
|
2020-09-14 17:54:14 +00:00
|
|
|
|
|
|
|
if( localB > clearance )
|
2022-05-02 23:47:36 +00:00
|
|
|
{
|
2022-06-15 23:42:34 +00:00
|
|
|
wxString msg;
|
|
|
|
clearance = bc->GetLocalClearance( &msg );
|
2022-05-02 23:47:36 +00:00
|
|
|
constraint.SetParentRule( nullptr );
|
2022-06-15 23:42:34 +00:00
|
|
|
constraint.SetName( msg );
|
2022-05-02 23:47:36 +00:00
|
|
|
constraint.m_Value.SetMin( clearance );
|
|
|
|
}
|
2020-09-14 17:54:14 +00:00
|
|
|
}
|
|
|
|
|
2022-05-02 23:47:36 +00:00
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Board minimum clearance: %s." ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( m_designSettings->m_MinClearance ) ) )
|
2022-05-02 23:47:36 +00:00
|
|
|
|
|
|
|
if( clearance < m_designSettings->m_MinClearance )
|
2020-09-14 17:54:14 +00:00
|
|
|
{
|
2022-03-21 20:49:08 +00:00
|
|
|
constraint.SetParentRule( nullptr );
|
2022-05-02 23:47:36 +00:00
|
|
|
constraint.SetName( _( "board minimum" ) );
|
|
|
|
constraint.m_Value.SetMin( m_designSettings->m_MinClearance );
|
2020-09-14 17:54:14 +00:00
|
|
|
}
|
2022-05-02 23:47:36 +00:00
|
|
|
|
2023-03-26 19:56:18 +00:00
|
|
|
if( a_is_non_copper || b_is_non_copper )
|
|
|
|
{
|
|
|
|
REPORT( _( "Local and board clearances apply only between copper items." ) );
|
|
|
|
constraint.m_Type = NULL_CONSTRAINT;
|
|
|
|
constraint.m_DisallowFlags = 0;
|
|
|
|
}
|
|
|
|
|
2022-05-02 23:47:36 +00:00
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
else if( aConstraintType == DIFF_PAIR_GAP_CONSTRAINT )
|
|
|
|
{
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Board minimum clearance: %s." ),
|
2022-09-19 16:09:59 +00:00
|
|
|
MessageTextFromValue( m_designSettings->m_MinClearance ) ) )
|
2022-05-02 23:47:36 +00:00
|
|
|
|
|
|
|
if( constraint.m_Value.Min() < m_designSettings->m_MinClearance )
|
|
|
|
{
|
|
|
|
constraint.SetParentRule( nullptr );
|
|
|
|
constraint.SetName( _( "board minimum" ) );
|
|
|
|
constraint.m_Value.SetMin( m_designSettings->m_MinClearance );
|
|
|
|
}
|
|
|
|
|
|
|
|
return constraint;
|
2020-09-14 17:54:14 +00:00
|
|
|
}
|
2021-08-08 13:37:14 +00:00
|
|
|
else if( aConstraintType == ZONE_CONNECTION_CONSTRAINT )
|
|
|
|
{
|
2022-07-06 23:29:24 +00:00
|
|
|
if( pad && parentFootprint )
|
2021-08-08 13:37:14 +00:00
|
|
|
{
|
2022-07-06 23:29:24 +00:00
|
|
|
ZONE_CONNECTION local = parentFootprint->GetZoneConnection();
|
2021-08-08 13:37:14 +00:00
|
|
|
|
|
|
|
if( local != ZONE_CONNECTION::INHERITED )
|
|
|
|
{
|
|
|
|
REPORT( "" )
|
2022-05-02 23:47:36 +00:00
|
|
|
REPORT( wxString::Format( _( "%s zone connection: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( parentFootprint->GetItemDescription( this ) ),
|
2021-08-08 13:37:14 +00:00
|
|
|
EscapeHTML( PrintZoneConnection( local ) ) ) )
|
|
|
|
|
2022-03-21 20:49:08 +00:00
|
|
|
constraint.SetParentRule( nullptr );
|
2021-08-08 13:37:14 +00:00
|
|
|
constraint.SetName( _( "footprint" ) );
|
|
|
|
constraint.m_ZoneConnection = local;
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( zone )
|
|
|
|
{
|
|
|
|
ZONE_CONNECTION local = zone->GetPadConnection();
|
|
|
|
|
|
|
|
REPORT( "" )
|
2022-05-02 23:47:36 +00:00
|
|
|
REPORT( wxString::Format( _( "%s pad connection: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( zone->GetItemDescription( this ) ),
|
2021-08-08 13:37:14 +00:00
|
|
|
EscapeHTML( PrintZoneConnection( local ) ) ) )
|
|
|
|
|
2022-03-21 20:49:08 +00:00
|
|
|
constraint.SetParentRule( nullptr );
|
2021-08-08 13:37:14 +00:00
|
|
|
constraint.SetName( _( "zone" ) );
|
|
|
|
constraint.m_ZoneConnection = local;
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aConstraintType == THERMAL_RELIEF_GAP_CONSTRAINT )
|
|
|
|
{
|
|
|
|
if( zone )
|
|
|
|
{
|
2022-01-08 13:24:14 +00:00
|
|
|
int local = zone->GetThermalReliefGap();
|
2021-08-08 13:37:14 +00:00
|
|
|
|
|
|
|
REPORT( "" )
|
2022-05-02 23:47:36 +00:00
|
|
|
REPORT( wxString::Format( _( "%s thermal relief gap: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( zone->GetItemDescription( this ) ),
|
2022-09-19 16:09:59 +00:00
|
|
|
EscapeHTML( MessageTextFromValue( local ) ) ) )
|
2021-08-08 13:37:14 +00:00
|
|
|
|
2022-03-21 20:49:08 +00:00
|
|
|
constraint.SetParentRule( nullptr );
|
2021-08-08 13:37:14 +00:00
|
|
|
constraint.SetName( _( "zone" ) );
|
|
|
|
constraint.m_Value.SetMin( local );
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aConstraintType == THERMAL_SPOKE_WIDTH_CONSTRAINT )
|
|
|
|
{
|
|
|
|
if( zone )
|
|
|
|
{
|
|
|
|
int local = zone->GetThermalReliefSpokeWidth();
|
|
|
|
|
|
|
|
REPORT( "" )
|
2022-05-02 23:47:36 +00:00
|
|
|
REPORT( wxString::Format( _( "%s thermal spoke width: %s." ),
|
2023-01-12 03:27:44 +00:00
|
|
|
EscapeHTML( zone->GetItemDescription( this ) ),
|
2022-09-19 16:09:59 +00:00
|
|
|
EscapeHTML( MessageTextFromValue( local ) ) ) )
|
2021-08-08 13:37:14 +00:00
|
|
|
|
2022-03-21 20:49:08 +00:00
|
|
|
constraint.SetParentRule( nullptr );
|
2021-08-08 13:37:14 +00:00
|
|
|
constraint.SetName( _( "zone" ) );
|
|
|
|
constraint.m_Value.SetMin( local );
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
}
|
2021-08-22 19:16:26 +00:00
|
|
|
|
|
|
|
if( !constraint.GetParentRule() )
|
2021-08-21 00:58:21 +00:00
|
|
|
{
|
2021-08-22 19:16:26 +00:00
|
|
|
constraint.m_Type = NULL_CONSTRAINT;
|
|
|
|
constraint.m_DisallowFlags = 0;
|
2021-08-21 00:58:21 +00:00
|
|
|
}
|
2020-09-14 17:54:14 +00:00
|
|
|
|
2021-08-21 00:58:21 +00:00
|
|
|
return constraint;
|
2021-08-08 13:37:14 +00:00
|
|
|
}
|
2021-09-22 21:20:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DRC_ENGINE::ProcessAssertions( const BOARD_ITEM* a,
|
|
|
|
std::function<void( const DRC_CONSTRAINT* )> aFailureHandler,
|
|
|
|
REPORTER* aReporter )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* NOTE: all string manipulation MUST BE KEPT INSIDE the REPORT macro. It absolutely
|
|
|
|
* kills performance when running bulk DRC tests (where aReporter is nullptr).
|
|
|
|
*/
|
|
|
|
|
|
|
|
auto testAssertion =
|
|
|
|
[&]( const DRC_ENGINE_CONSTRAINT* c )
|
|
|
|
{
|
|
|
|
REPORT( wxString::Format( _( "Checking rule assertion \"%s\"." ),
|
|
|
|
EscapeHTML( c->constraint.m_Test->GetExpression() ) ) )
|
|
|
|
|
2022-04-02 14:08:32 +00:00
|
|
|
if( c->constraint.m_Test->EvaluateFor( a, nullptr, c->constraint.m_Type,
|
|
|
|
a->GetLayer(), aReporter ) )
|
2021-09-22 21:20:18 +00:00
|
|
|
{
|
|
|
|
REPORT( _( "Assertion passed." ) )
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
REPORT( EscapeHTML( _( "--> Assertion failed. <--" ) ) )
|
|
|
|
aFailureHandler( &c->constraint );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
auto processConstraint =
|
|
|
|
[&]( const DRC_ENGINE_CONSTRAINT* c )
|
|
|
|
{
|
|
|
|
REPORT( "" )
|
|
|
|
REPORT( wxString::Format( _( "Checking %s." ), c->constraint.GetName() ) )
|
|
|
|
|
|
|
|
if( !( a->GetLayerSet() & c->layerTest ).any() )
|
|
|
|
{
|
|
|
|
REPORT( wxString::Format( _( "Rule layer '%s' not matched; rule ignored." ),
|
|
|
|
EscapeHTML( c->parentRule->m_LayerSource ) ) )
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !c->condition || c->condition->GetExpression().IsEmpty() )
|
|
|
|
{
|
|
|
|
REPORT( _( "Unconditional rule applied." ) )
|
|
|
|
testAssertion( c );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
REPORT( wxString::Format( _( "Checking rule condition \"%s\"." ),
|
|
|
|
EscapeHTML( c->condition->GetExpression() ) ) )
|
|
|
|
|
2022-04-02 14:08:32 +00:00
|
|
|
if( c->condition->EvaluateFor( a, nullptr, c->constraint.m_Type,
|
|
|
|
a->GetLayer(), aReporter ) )
|
2021-09-22 21:20:18 +00:00
|
|
|
{
|
|
|
|
REPORT( _( "Rule applied." ) )
|
|
|
|
testAssertion( c );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
REPORT( _( "Condition not satisfied; rule ignored." ) )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if( m_constraintMap.count( ASSERTION_CONSTRAINT ) )
|
|
|
|
{
|
|
|
|
std::vector<DRC_ENGINE_CONSTRAINT*>* ruleset = m_constraintMap[ ASSERTION_CONSTRAINT ];
|
|
|
|
|
|
|
|
for( int ii = 0; ii < (int) ruleset->size(); ++ii )
|
|
|
|
processConstraint( ruleset->at( ii ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-12 23:05:32 +00:00
|
|
|
#undef REPORT
|
2020-06-13 23:28:08 +00:00
|
|
|
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
bool DRC_ENGINE::IsErrorLimitExceeded( int error_code )
|
|
|
|
{
|
2020-09-16 11:45:12 +00:00
|
|
|
assert( error_code >= 0 && error_code <= DRCE_LAST );
|
2020-09-14 17:54:14 +00:00
|
|
|
return m_errorLimits[ error_code ] <= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void DRC_ENGINE::ReportViolation( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2I& aPos,
|
2022-08-15 16:59:34 +00:00
|
|
|
int aMarkerLayer )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2022-07-31 15:02:04 +00:00
|
|
|
static std::mutex globalLock;
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
m_errorLimits[ aItem->GetErrorCode() ] -= 1;
|
|
|
|
|
|
|
|
if( m_violationHandler )
|
2022-07-31 15:02:04 +00:00
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard( globalLock );
|
2021-12-26 13:47:00 +00:00
|
|
|
m_violationHandler( aItem, aPos, aMarkerLayer );
|
2022-07-31 15:02:04 +00:00
|
|
|
}
|
2020-09-14 17:54:14 +00:00
|
|
|
|
2020-06-18 16:55:22 +00:00
|
|
|
if( m_reporter )
|
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
wxString msg = wxString::Format( wxT( "Test '%s': %s (code %d)" ),
|
2020-09-11 15:04:11 +00:00
|
|
|
aItem->GetViolatingTest()->GetName(),
|
|
|
|
aItem->GetErrorMessage(),
|
|
|
|
aItem->GetErrorCode() );
|
2020-08-25 17:42:52 +00:00
|
|
|
|
2020-09-12 23:05:32 +00:00
|
|
|
DRC_RULE* rule = aItem->GetViolatingRule();
|
2020-08-25 17:42:52 +00:00
|
|
|
|
|
|
|
if( rule )
|
2022-02-05 02:06:25 +00:00
|
|
|
msg += wxString::Format( wxT( ", violating rule: '%s'" ), rule->m_Name );
|
2020-09-14 08:02:07 +00:00
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
m_reporter->Report( msg );
|
2020-09-14 08:02:07 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
wxString violatingItemsStr = wxT( "Violating items: " );
|
2020-08-11 22:15:50 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
m_reporter->Report( wxString::Format( wxT( " |- violating position (%d, %d)" ),
|
2020-09-14 17:54:14 +00:00
|
|
|
aPos.x,
|
|
|
|
aPos.y ) );
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-26 19:35:12 +00:00
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
void DRC_ENGINE::ReportAux ( const wxString& aStr )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-06-18 16:55:22 +00:00
|
|
|
if( !m_reporter )
|
2020-06-13 23:28:08 +00:00
|
|
|
return;
|
|
|
|
|
2020-06-18 16:55:22 +00:00
|
|
|
m_reporter->Report( aStr, RPT_SEVERITY_INFO );
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-15 00:41:10 +00:00
|
|
|
bool DRC_ENGINE::KeepRefreshing( bool aWait )
|
|
|
|
{
|
|
|
|
if( !m_progressReporter )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return m_progressReporter->KeepRefreshing( aWait );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DRC_ENGINE::AdvanceProgress()
|
|
|
|
{
|
|
|
|
if( m_progressReporter )
|
|
|
|
m_progressReporter->AdvanceProgress();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DRC_ENGINE::SetMaxProgress( int aSize )
|
|
|
|
{
|
|
|
|
if( m_progressReporter )
|
|
|
|
m_progressReporter->SetMaxProgress( aSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
bool DRC_ENGINE::ReportProgress( double aProgress )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-06-18 16:55:22 +00:00
|
|
|
if( !m_progressReporter )
|
2020-09-18 19:57:54 +00:00
|
|
|
return true;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-06-18 16:55:22 +00:00
|
|
|
m_progressReporter->SetCurrentProgress( aProgress );
|
2020-09-18 19:57:54 +00:00
|
|
|
return m_progressReporter->KeepRefreshing( false );
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-18 14:17:16 +00:00
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
bool DRC_ENGINE::ReportPhase( const wxString& aMessage )
|
2020-06-13 23:28:08 +00:00
|
|
|
{
|
2020-06-18 16:55:22 +00:00
|
|
|
if( !m_progressReporter )
|
2020-09-18 19:57:54 +00:00
|
|
|
return true;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-09-15 11:06:15 +00:00
|
|
|
m_progressReporter->AdvancePhase( aMessage );
|
2020-09-18 19:57:54 +00:00
|
|
|
return m_progressReporter->KeepRefreshing( false );
|
2020-06-13 23:28:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-18 14:17:16 +00:00
|
|
|
|
2022-03-11 20:13:47 +00:00
|
|
|
bool DRC_ENGINE::IsCancelled() const
|
|
|
|
{
|
|
|
|
return m_progressReporter && m_progressReporter->IsCancelled();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-01 22:29:15 +00:00
|
|
|
bool DRC_ENGINE::HasRulesForConstraintType( DRC_CONSTRAINT_T constraintID )
|
2020-07-23 14:22:45 +00:00
|
|
|
{
|
2020-08-12 22:19:34 +00:00
|
|
|
//drc_dbg(10,"hascorrect id %d size %d\n", ruleID, m_ruleMap[ruleID]->sortedRules.size( ) );
|
2020-09-16 20:38:23 +00:00
|
|
|
if( m_constraintMap.count( constraintID ) )
|
|
|
|
return m_constraintMap[ constraintID ]->size() > 0;
|
|
|
|
|
|
|
|
return false;
|
2020-07-23 14:22:45 +00:00
|
|
|
}
|
|
|
|
|
2020-08-11 22:15:50 +00:00
|
|
|
|
2021-01-01 22:29:15 +00:00
|
|
|
bool DRC_ENGINE::QueryWorstConstraint( DRC_CONSTRAINT_T aConstraintId, DRC_CONSTRAINT& aConstraint )
|
2020-08-11 22:15:50 +00:00
|
|
|
{
|
2020-11-02 16:20:00 +00:00
|
|
|
int worst = 0;
|
2020-09-11 15:04:11 +00:00
|
|
|
|
2021-01-08 00:26:32 +00:00
|
|
|
if( m_constraintMap.count( aConstraintId ) )
|
2020-11-02 16:20:00 +00:00
|
|
|
{
|
2021-01-08 00:26:32 +00:00
|
|
|
for( DRC_ENGINE_CONSTRAINT* c : *m_constraintMap[aConstraintId] )
|
2020-08-11 22:15:50 +00:00
|
|
|
{
|
2021-01-08 00:26:32 +00:00
|
|
|
int current = c->constraint.GetValue().Min();
|
2020-08-11 22:15:50 +00:00
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
if( current > worst )
|
|
|
|
{
|
|
|
|
worst = current;
|
2021-01-08 00:26:32 +00:00
|
|
|
aConstraint = c->constraint;
|
2020-08-11 22:15:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-02 16:20:00 +00:00
|
|
|
return worst > 0;
|
2020-08-11 22:15:50 +00:00
|
|
|
}
|
2020-09-23 21:48:11 +00:00
|
|
|
|
|
|
|
|
2022-07-31 15:02:04 +00:00
|
|
|
std::set<int> DRC_ENGINE::QueryDistinctConstraints( DRC_CONSTRAINT_T aConstraintId )
|
|
|
|
{
|
|
|
|
std::set<int> distinctMinimums;
|
|
|
|
|
|
|
|
if( m_constraintMap.count( aConstraintId ) )
|
|
|
|
{
|
|
|
|
for( DRC_ENGINE_CONSTRAINT* c : *m_constraintMap[aConstraintId] )
|
|
|
|
distinctMinimums.emplace( c->constraint.GetValue().Min() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return distinctMinimums;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-08 23:05:22 +00:00
|
|
|
// fixme: move two functions below to pcbcommon?
|
2021-02-28 00:54:55 +00:00
|
|
|
int DRC_ENGINE::MatchDpSuffix( const wxString& aNetName, wxString& aComplementNet,
|
|
|
|
wxString& aBaseDpName )
|
2020-10-08 23:05:22 +00:00
|
|
|
{
|
|
|
|
int rv = 0;
|
2021-10-11 16:49:39 +00:00
|
|
|
int count = 0;
|
2020-10-08 23:05:22 +00:00
|
|
|
|
2021-10-11 16:49:39 +00:00
|
|
|
for( auto it = aNetName.rbegin(); it != aNetName.rend() && rv == 0; ++it, ++count )
|
2020-10-08 23:05:22 +00:00
|
|
|
{
|
2021-10-11 16:49:39 +00:00
|
|
|
int ch = *it;
|
|
|
|
|
|
|
|
if( ( ch >= '0' && ch <= '9' ) || ch == '_' )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if( ch == '+' )
|
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
aComplementNet = wxT( "-" );
|
2021-10-11 16:49:39 +00:00
|
|
|
rv = 1;
|
|
|
|
}
|
|
|
|
else if( ch == '-' )
|
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
aComplementNet = wxT( "+" );
|
2021-10-11 16:49:39 +00:00
|
|
|
rv = -1;
|
|
|
|
}
|
|
|
|
else if( ch == 'N' )
|
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
aComplementNet = wxT( "P" );
|
2021-10-11 16:49:39 +00:00
|
|
|
rv = -1;
|
|
|
|
}
|
|
|
|
else if ( ch == 'P' )
|
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
aComplementNet = wxT( "N" );
|
2021-10-11 16:49:39 +00:00
|
|
|
rv = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2020-10-08 23:05:22 +00:00
|
|
|
}
|
2021-10-11 16:49:39 +00:00
|
|
|
|
|
|
|
if( rv != 0 && count >= 1 )
|
2020-10-08 23:05:22 +00:00
|
|
|
{
|
2021-10-11 16:49:39 +00:00
|
|
|
aBaseDpName = aNetName.Left( aNetName.Length() - count );
|
2022-11-16 21:09:46 +00:00
|
|
|
aComplementNet = wxString( aBaseDpName ) << aComplementNet << aNetName.Right( count - 1 );
|
2020-10-08 23:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-01 00:38:20 +00:00
|
|
|
bool DRC_ENGINE::IsNetADiffPair( BOARD* aBoard, NETINFO_ITEM* aNet, int& aNetP, int& aNetN )
|
2020-10-08 23:05:22 +00:00
|
|
|
{
|
2020-10-10 15:10:04 +00:00
|
|
|
wxString refName = aNet->GetNetname();
|
2020-10-08 23:05:22 +00:00
|
|
|
wxString dummy, coupledNetName;
|
|
|
|
|
2021-02-28 00:54:55 +00:00
|
|
|
if( int polarity = MatchDpSuffix( refName, coupledNetName, dummy ) )
|
2020-10-08 23:05:22 +00:00
|
|
|
{
|
|
|
|
NETINFO_ITEM* net = aBoard->FindNet( coupledNetName );
|
|
|
|
|
|
|
|
if( !net )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( polarity > 0 )
|
|
|
|
{
|
2020-12-08 13:02:08 +00:00
|
|
|
aNetP = aNet->GetNetCode();
|
|
|
|
aNetN = net->GetNetCode();
|
2020-10-08 23:05:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-12-08 13:02:08 +00:00
|
|
|
aNetP = net->GetNetCode();
|
|
|
|
aNetN = aNet->GetNetCode();
|
2020-10-08 23:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-25 16:23:14 +00:00
|
|
|
/**
|
|
|
|
* Check if the given collision between a track and another item occurs during the track's entry
|
|
|
|
* into a net-tie pad.
|
|
|
|
*/
|
2022-08-19 17:34:53 +00:00
|
|
|
bool DRC_ENGINE::IsNetTieExclusion( int aTrackNetCode, PCB_LAYER_ID aTrackLayer,
|
|
|
|
const VECTOR2I& aCollisionPos, BOARD_ITEM* aCollidingItem )
|
2021-02-01 22:45:56 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
FOOTPRINT* parentFootprint = aCollidingItem->GetParentFootprint();
|
2022-08-19 17:34:53 +00:00
|
|
|
|
|
|
|
if( parentFootprint && parentFootprint->IsNetTie() )
|
|
|
|
{
|
2023-02-23 13:48:16 +00:00
|
|
|
int epsilon = GetDesignSettings()->GetDRCEpsilon();
|
2022-09-25 16:23:14 +00:00
|
|
|
std::map<wxString, int> padToNetTieGroupMap = parentFootprint->MapPadNumbersToNetTieGroups();
|
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
for( PAD* pad : parentFootprint->Pads() )
|
|
|
|
{
|
2022-09-25 16:23:14 +00:00
|
|
|
if( padToNetTieGroupMap[ pad->GetNumber() ] >= 0 && aTrackNetCode == pad->GetNetCode() )
|
2022-08-19 17:34:53 +00:00
|
|
|
{
|
2023-02-23 13:48:16 +00:00
|
|
|
if( pad->GetEffectiveShape( aTrackLayer )->Collide( aCollisionPos, epsilon ) )
|
2022-08-19 17:34:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-01 22:45:56 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-23 21:48:11 +00:00
|
|
|
DRC_TEST_PROVIDER* DRC_ENGINE::GetTestProvider( const wxString& name ) const
|
|
|
|
{
|
2022-08-15 17:47:23 +00:00
|
|
|
for( DRC_TEST_PROVIDER* prov : m_testProviders )
|
2021-07-26 19:35:12 +00:00
|
|
|
{
|
2020-09-23 21:48:11 +00:00
|
|
|
if( name == prov->GetName() )
|
|
|
|
return prov;
|
2021-07-26 19:35:12 +00:00
|
|
|
}
|
2020-09-23 21:48:11 +00:00
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|