KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ERC_TESTER Class Reference

Runs the electrical rules checks and adds a SCH_MARKER for each violation. More...

#include <erc.h>

Public Member Functions

 ERC_TESTER (SCHEMATIC *aSchematic, bool aShowAllErrors=false)
 
int TestDuplicateSheetNames (bool aCreateMarker)
 Inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
 
int TestPinMap (KIFACE *aCvPcb, PROJECT *aProject)
 Check pin-to-pad maps (issue #2282): stale pin references, duplicate pad targets, bad pads and unmapped connected pins.
 
void TestTextVars (DS_PROXY_VIEW_ITEM *aDrawingSheet)
 Check for any unresolved text variable references.
 
int TestFieldNameWhitespace ()
 Check for field names with leading or trailing whitespace.
 
int TestEmptyLabelNames ()
 Check for labels with empty or whitespace-only names.
 
int TestMultiunitFootprints ()
 Test if all units of each multiunit symbol have the same footprint assigned.
 
int TestNoConnectPins ()
 In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
 
int TestPinToPin ()
 Checks the full netlist against the pin-to-pin connectivity requirements.
 
int TestMultUnitPinConflicts ()
 Checks if shared pins on multi-unit symbols have been connected to different nets.
 
int TestDuplicatePinNets ()
 Checks if duplicate pin numbers within a symbol are connected to different nets.
 
int TestGroundPins ()
 Checks for ground-labeled pins not on a ground net while another pin is.
 
int TestStackedPinNotation ()
 Checks for pin numbers that resemble stacked pin notation but are invalid.
 
int TestSameLocalGlobalLabel ()
 Checks for global and local labels with the same name.
 
int TestSimilarLabels ()
 Checks for labels that differ only in capitalization.
 
int TestFourWayJunction ()
 Test to see if there are potentially confusing 4-way junctions in the schematic.
 
int TestLabelMultipleWires ()
 Test to see if there are labels that are connected to more than one wire.
 
int TestLibSymbolIssues ()
 Test symbols for changed library symbols and broken symbol library links.
 
int TestFootprintLinkIssues (KIFACE *aCvPcb, PROJECT *aProject)
 Test footprint links against the current footprint libraries.
 
int TestFootprintFilters ()
 Test symbols to ensure that assigned footprint passes any given footprint filters.
 
int TestOffGridEndpoints ()
 Test pins and wire ends for being off grid.
 
int TestSimModelIssues ()
 Test SPICE models for various issues.
 
int TestMissingUnits ()
 Test for uninstantiated units of multi unit symbols.
 
int TestMissingNetclasses ()
 Tests for netclasses that are referenced but not defined.
 
int TestVariantSymbols ()
 Test all variant symbol overrides for resolution and pin compatibility.
 
void RunTests (DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
 

Static Public Member Functions

static int TestConnectivity (SCHEMATIC &aSchematic)
 

Private Member Functions

std::vector< SCH_CONNECTIVITY::MULTI_UNIT_GROUP > multiUnitSources () const
 

Private Attributes

SCHEMATIC * m_schematic
 
ERC_SETTINGS & m_settings
 
SCH_SHEET_LIST m_sheetList
 
SCH_SCREENS m_screens
 
SCH_MULTI_UNIT_REFERENCE_MAP m_refMap
 
const NET_MAP & m_nets
 
bool m_showAllErrors
 

Detailed Description

Runs the electrical rules checks and adds a SCH_MARKER for each violation.

With ADVANCED_CFG::m_ConnectivityEngine on, most checks read the published connectivity through SCHEMATIC::Connectivity() and the SCH_CONNECTIVITY::ENGINE diagnostic accessors, and some still read the live model. Otherwise the checks read CONNECTION_GRAPH and the live model.

Definition at line 59 of file erc.h.

Constructor & Destructor Documentation

◆ ERC_TESTER()

ERC_TESTER::ERC_TESTER ( SCHEMATIC * aSchematic,
bool aShowAllErrors = false )

Member Function Documentation

◆ multiUnitSources()

◆ RunTests()

void ERC_TESTER::RunTests ( DS_PROXY_VIEW_ITEM * aDrawingSheet,
SCH_EDIT_FRAME * aEditFrame,
KIFACE * aCvPcb,
PROJECT * aProject,
PROGRESS_REPORTER * aProgressReporter )

Definition at line 3338 of file erc.cpp.

References _, PROGRESS_REPORTER::AdvancePhase(), ERCE_DIFFERENT_UNIT_FP, ERCE_DIFFERENT_UNIT_NET, ERCE_DUPLICATE_PIN_ERROR, ERCE_DUPLICATE_SHEET_NAME, ERCE_EMPTY_LABEL_NAME, ERCE_ENDPOINT_OFF_GRID, ERCE_FIELD_NAME_WHITESPACE, ERCE_FOOTPRINT_FILTERS, ERCE_FOOTPRINT_LINK_ISSUES, ERCE_FOUR_WAY_JUNCTION, ERCE_GROUND_PIN_NOT_GROUND, ERCE_LABEL_MULTIPLE_WIRES, ERCE_LIB_SYMBOL_ISSUES, ERCE_LIB_SYMBOL_MISMATCH, ERCE_MISSING_BIDI_PIN, ERCE_MISSING_INPUT_PIN, ERCE_MISSING_POWER_INPUT_PIN, ERCE_MISSING_UNIT, ERCE_NOCONNECT_CONNECTED, ERCE_PIN_MAP_BAD_PAD, ERCE_PIN_MAP_DUPLICATE_PAD, ERCE_PIN_MAP_STALE_PIN, ERCE_PIN_MAP_UNMAPPED_PIN, ERCE_PIN_NOT_DRIVEN, ERCE_PIN_TO_PIN_ERROR, ERCE_PIN_TO_PIN_WARNING, ERCE_POWERPIN_NOT_DRIVEN, ERCE_SAME_LOCAL_GLOBAL_LABEL, ERCE_SAME_LOCAL_GLOBAL_POWER, ERCE_SIMILAR_LABEL_AND_POWER, ERCE_SIMILAR_LABELS, ERCE_SIMILAR_POWER, ERCE_SIMULATION_MODEL, ERCE_STACKED_PIN_SYNTAX, ERCE_UNDEFINED_NETCLASS, ERCE_UNRESOLVED_VARIABLE, ERCE_VARIANT_SYMBOL_INCOMPATIBLE, ERCE_VARIANT_SYMBOL_INVALID, ADVANCED_CFG::GetCfg(), GLOBAL_CLEANUP, m_schematic, m_screens, m_settings, MARKER_BASE::MARKER_ERC, NO_CLEANUP, SCH_EDIT_FRAME::RecalculateConnections(), TestConnectivity(), TestDuplicatePinNets(), TestDuplicateSheetNames(), TestEmptyLabelNames(), TestFieldNameWhitespace(), TestFootprintFilters(), TestFootprintLinkIssues(), TestFourWayJunction(), TestGroundPins(), TestLabelMultipleWires(), TestLibSymbolIssues(), TestMissingNetclasses(), TestMissingUnits(), TestMultiunitFootprints(), TestMultUnitPinConflicts(), TestNoConnectPins(), TestOffGridEndpoints(), TestPinMap(), TestPinToPin(), TestSameLocalGlobalLabel(), TestSimilarLabels(), TestSimModelIssues(), TestStackedPinNotation(), TestTextVars(), and TestVariantSymbols().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), EESCHEMA_JOBS_HANDLER::JobSchErc(), and DIALOG_ERC::testErc().

◆ TestConnectivity()

◆ TestDuplicatePinNets()

int ERC_TESTER::TestDuplicatePinNets ( )

Checks if duplicate pin numbers within a symbol are connected to different nets.

Symbols may have multiple pins with the same number if they are all connected to the same net. If duplicate pins are on different nets, an error is reported.

Returns
the error count

Definition at line 2446 of file erc.cpp.

References _, SCH_SCREEN::Append(), ERC_ITEM::Create(), ERCE_DUPLICATE_PIN_ERROR, ADVANCED_CFG::GetCfg(), LIB_SYMBOL::GetDuplicatePinNumbersAreJumpers(), SCH_SYMBOL::GetLibSymbolRef(), SCH_SYMBOL::GetPins(), SCH_SYMBOL::GetRef(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), ADVANCED_CFG::m_ConnectivityEngine, m_sheetList, EE_RTREE::OfType(), pin, and SCH_SYMBOL_T.

Referenced by BOOST_FIXTURE_TEST_CASE(), and RunTests().

◆ TestDuplicateSheetNames()

int ERC_TESTER::TestDuplicateSheetNames ( bool aCreateMarker)

Inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).

Returns
the error count
Parameters
aCreateMarkerTrue creates markers from captured connectivity when the new engine is enabled; call after rebuilding. False checks fresh model state without rebuilding, for export and highlight preflight. The legacy engine always reads live state.

Definition at line 350 of file erc.cpp.

References SCH_SCREEN::Append(), ERC_ITEM::Create(), ERCE_DUPLICATE_SHEET_NAME, ADVANCED_CFG::GetCfg(), SCH_SHEET::GetField(), SCH_SHEET::GetPosition(), SCH_FIELD::GetShownText(), SCH_SCREEN::Items(), m_schematic, name, EE_RTREE::OfType(), path, RESOLVED, SCH_SHEET_T, and SHEET_NAME.

Referenced by BOOST_AUTO_TEST_CASE(), and RunTests().

◆ TestEmptyLabelNames()

◆ TestFieldNameWhitespace()

int ERC_TESTER::TestFieldNameWhitespace ( )

◆ TestFootprintFilters()

int ERC_TESTER::TestFootprintFilters ( )

Test symbols to ensure that assigned footprint passes any given footprint filters.

Returns
the number of issues found

Definition at line 3011 of file erc.cpp.

References _, collectFootprints(), ERCE_FOOTPRINT_FILTERS, filter, LIB_ID::GetUniStringLibItemName(), m_schematic, LIB_ID::Parse(), and source.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and RunTests().

◆ TestFootprintLinkIssues()

int ERC_TESTER::TestFootprintLinkIssues ( KIFACE * aCvPcb,
PROJECT * aProject )

◆ TestFourWayJunction()

◆ TestGroundPins()

◆ TestLabelMultipleWires()

◆ TestLibSymbolIssues()

◆ TestMissingNetclasses()

◆ TestMissingUnits()

int ERC_TESTER::TestMissingUnits ( )

Test for uninstantiated units of multi unit symbols.

Definition at line 970 of file erc.cpp.

References _, ERCE_MISSING_BIDI_PIN, ERCE_MISSING_INPUT_PIN, ERCE_MISSING_POWER_INPUT_PIN, ERCE_MISSING_UNIT, group, m_schematic, m_settings, message, and multiUnitSources().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and RunTests().

◆ TestMultiunitFootprints()

◆ TestMultUnitPinConflicts()

◆ TestNoConnectPins()

◆ TestOffGridEndpoints()

◆ TestPinMap()

◆ TestPinToPin()

◆ TestSameLocalGlobalLabel()

int ERC_TESTER::TestSameLocalGlobalLabel ( )

Checks for global and local labels with the same name.

Returns
the error count

Definition at line 2655 of file erc.cpp.

References ERCE_SAME_LOCAL_GLOBAL_LABEL, ERCE_SAME_LOCAL_GLOBAL_POWER, m_schematic, m_settings, name, SCH_HIER_LABEL_T, and SCH_PIN_T.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and RunTests().

◆ TestSimilarLabels()

◆ TestSimModelIssues()

◆ TestStackedPinNotation()

int ERC_TESTER::TestStackedPinNotation ( )

Checks for pin numbers that resemble stacked pin notation but are invalid.

Returns
warning count

Definition at line 2613 of file erc.cpp.

References SCH_SCREEN::Append(), ERC_ITEM::Create(), ERCE_STACKED_PIN_SYNTAX, ADVANCED_CFG::GetCfg(), SCH_SYMBOL::GetPins(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), m_schematic, m_sheetList, EE_RTREE::OfType(), pin, and SCH_SYMBOL_T.

Referenced by BOOST_AUTO_TEST_CASE(), and RunTests().

◆ TestTextVars()

◆ TestVariantSymbols()

int ERC_TESTER::TestVariantSymbols ( )

Test all variant symbol overrides for resolution and pin compatibility.

Creates ERCE_VARIANT_SYMBOL_INVALID markers when a variant's symbol override LIB_ID cannot be resolved, and ERCE_VARIANT_SYMBOL_INCOMPATIBLE markers when the alternate symbol fails pin compatibility validation against the base symbol.

Definition at line 3185 of file erc.cpp.

References _, SCH_SCREEN::Append(), ERC_ITEM::Create(), ERCE_VARIANT_SYMBOL_INCOMPATIBLE, ERCE_VARIANT_SYMBOL_INVALID, SCH_CONNECTIVITY::ExtractLibrarySymbolFact(), SCH_CONNECTIVITY::ExtractVariantSymbolFact(), ADVANCED_CFG::GetCfg(), SCH_SYMBOL::GetLibId(), SCH_SYMBOL::GetLibSymbolRef(), SCH_SYMBOL::GetPosition(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), SYMBOL_LIBRARY_ADAPTER::LoadSymbol(), m_schematic, m_settings, m_sheetList, EDA_ITEM::m_Uuid, EE_RTREE::OfType(), SCH_SHEET_PATH::PathRef(), SCH_SYMBOL_T, source, PROJECT_SCH::SymbolLibAdapter(), and ValidateVariantSymbolCompatibility().

Referenced by BOOST_FIXTURE_TEST_CASE(), and RunTests().

Member Data Documentation

◆ m_nets

const NET_MAP& ERC_TESTER::m_nets
private

Definition at line 234 of file erc.h.

Referenced by ERC_TESTER(), TestMultUnitPinConflicts(), and TestPinToPin().

◆ m_refMap

SCH_MULTI_UNIT_REFERENCE_MAP ERC_TESTER::m_refMap
private

Definition at line 233 of file erc.h.

Referenced by ERC_TESTER(), and multiUnitSources().

◆ m_schematic

◆ m_screens

SCH_SCREENS ERC_TESTER::m_screens
private

Definition at line 232 of file erc.h.

Referenced by ERC_TESTER(), RunTests(), TestOffGridEndpoints(), and TestPinMap().

◆ m_settings

◆ m_sheetList

◆ m_showAllErrors

bool ERC_TESTER::m_showAllErrors
private

Definition at line 235 of file erc.h.

Referenced by ERC_TESTER(), and TestPinToPin().


The documentation for this class was generated from the following files: