Consolidate ERC label warnings

If global or local labels are floating -> error
If global or local labels are only connected to one pin -> warning

Rather than forcing two different errors depending on whether the label
is local or global
This commit is contained in:
Seth Hillbrand 2025-07-18 16:47:25 -07:00
parent 21b9200744
commit 3a06de0076
7 changed files with 668 additions and 36 deletions

View File

@ -3326,7 +3326,7 @@ int CONNECTION_GRAPH::RunERC()
}
if( settings.IsTestEnabled( ERCE_LABEL_NOT_CONNECTED )
|| settings.IsTestEnabled( ERCE_GLOBLABEL_DANGLING ) )
|| settings.IsTestEnabled( ERCE_LABEL_SINGLE_PIN ) )
{
if( !ercCheckLabels( subgraph ) )
error_count++;
@ -4073,9 +4073,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
// connected to other valid things by way of another label on the same sheet.
if( text->IsDangling() )
{
reportError( text, item->Type() == SCH_GLOBAL_LABEL_T ?
ERCE_GLOBLABEL_DANGLING :
ERCE_LABEL_NOT_CONNECTED );
reportError( text, ERCE_LABEL_NOT_CONNECTED );
return false;
}
@ -4128,20 +4126,6 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
for( auto& [type, label_vec] : label_map )
{
switch( type )
{
case SCH_GLOBAL_LABEL_T:
if( !settings.IsTestEnabled( ERCE_GLOBLABEL_DANGLING ) )
continue;
break;
default:
if( !settings.IsTestEnabled( ERCE_LABEL_NOT_CONNECTED ) )
continue;
break;
}
for( SCH_TEXT* text : label_vec )
{
size_t allPins = pinCount;
@ -4164,15 +4148,13 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
if( allPins == 1 && !has_nc )
{
reportError( text, type == SCH_GLOBAL_LABEL_T ? ERCE_GLOBLABEL_DANGLING
: ERCE_LABEL_NOT_CONNECTED );
reportError( text, ERCE_LABEL_SINGLE_PIN );
ok = false;
}
if( allPins == 0 )
{
reportError( text, type == SCH_GLOBAL_LABEL_T ? ERCE_GLOBLABEL_DANGLING
: ERCE_LABEL_NOT_CONNECTED );
reportError( text, ERCE_LABEL_NOT_CONNECTED );
ok = false;
}
}

View File

@ -102,12 +102,12 @@ ERC_ITEM ERC_ITEM::noConnectDangling( ERCE_NOCONNECT_NOT_CONNECTED,
wxT( "no_connect_dangling" ) );
ERC_ITEM ERC_ITEM::labelDangling( ERCE_LABEL_NOT_CONNECTED,
_HKI( "Label not connected to anything" ),
_HKI( "Label not connected" ),
wxT( "label_dangling" ) );
ERC_ITEM ERC_ITEM::globalLabelDangling( ERCE_GLOBLABEL_DANGLING,
_HKI( "Global label not connected anywhere else in the schematic" ),
wxT( "global_label_dangling" ) );
ERC_ITEM ERC_ITEM::isolatedPinLabel( ERCE_LABEL_SINGLE_PIN,
_HKI( "Label connected to only one pin" ),
wxT( "isolated_pin_label" ) );
ERC_ITEM ERC_ITEM::similarLabels( ERCE_SIMILAR_LABELS,
_HKI( "Labels are similar (lower/upper case difference only)"),
@ -237,8 +237,8 @@ std::vector<std::reference_wrapper<RC_ITEM>> ERC_ITEM::allItemTypes(
ERC_ITEM::powerpinNotDriven,
ERC_ITEM::noConnectConnected,
ERC_ITEM::noConnectDangling,
ERC_ITEM::globalLabelDangling,
ERC_ITEM::labelDangling,
ERC_ITEM::isolatedPinLabel,
ERC_ITEM::singleGlobalLabel,
ERC_ITEM::sameLocalGlobalLabel,
ERC_ITEM::wireDangling,
@ -326,7 +326,7 @@ std::shared_ptr<ERC_ITEM> ERC_ITEM::Create( int aErrorCode )
case ERCE_BUS_ENTRY_CONFLICT: return std::make_shared<ERC_ITEM>( netNotBusMember );
case ERCE_BUS_TO_BUS_CONFLICT: return std::make_shared<ERC_ITEM>( busToBusConflict );
case ERCE_BUS_TO_NET_CONFLICT: return std::make_shared<ERC_ITEM>( busToNetConflict );
case ERCE_GLOBLABEL_DANGLING: return std::make_shared<ERC_ITEM>( globalLabelDangling );
case ERCE_LABEL_SINGLE_PIN: return std::make_shared<ERC_ITEM>( isolatedPinLabel );
case ERCE_UNRESOLVED_VARIABLE: return std::make_shared<ERC_ITEM>( unresolvedVariable );
case ERCE_UNDEFINED_NETCLASS: return std::make_shared<ERC_ITEM>( undefinedNetclass );
case ERCE_SIMULATION_MODEL: return std::make_shared<ERC_ITEM>( simulationModelIssues );

View File

@ -213,7 +213,7 @@ private:
static ERC_ITEM labelMultipleWires;
static ERC_ITEM noConnectDangling;
static ERC_ITEM labelDangling;
static ERC_ITEM globalLabelDangling;
static ERC_ITEM isolatedPinLabel;
static ERC_ITEM singleGlobalLabel;
static ERC_ITEM sameLocalGlobalLabel;
static ERC_ITEM similarLabels;

View File

@ -100,9 +100,9 @@ ERC_SETTINGS::ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
m_ERCSeverities[ERCE_SIMILAR_LABELS] = RPT_SEVERITY_WARNING;
m_ERCSeverities[ERCE_SIMILAR_POWER] = RPT_SEVERITY_WARNING;
m_ERCSeverities[ERCE_SIMILAR_LABEL_AND_POWER] = RPT_SEVERITY_WARNING;
m_ERCSeverities[ERCE_SINGLE_GLOBAL_LABEL] = RPT_SEVERITY_IGNORE;
m_ERCSeverities[ERCE_SINGLE_GLOBAL_LABEL] = RPT_SEVERITY_IGNORE;
m_ERCSeverities[ERCE_SAME_LOCAL_GLOBAL_LABEL] = RPT_SEVERITY_WARNING;
m_ERCSeverities[ERCE_GLOBLABEL_DANGLING] = RPT_SEVERITY_WARNING;
m_ERCSeverities[ERCE_LABEL_SINGLE_PIN] = RPT_SEVERITY_WARNING;
m_ERCSeverities[ERCE_DRIVER_CONFLICT] = RPT_SEVERITY_WARNING;
m_ERCSeverities[ERCE_BUS_ENTRY_CONFLICT] = RPT_SEVERITY_WARNING;
m_ERCSeverities[ERCE_LIB_SYMBOL_ISSUES] = RPT_SEVERITY_WARNING;

View File

@ -47,11 +47,11 @@ enum ERCE_T
ERCE_HIERACHICAL_LABEL, ///< Mismatch between hierarchical labels and pins sheets.
ERCE_NOCONNECT_CONNECTED, ///< A no connect symbol is connected to more than 1 pin.
ERCE_NOCONNECT_NOT_CONNECTED, ///< A no connect symbol is not connected to anything.
ERCE_LABEL_NOT_CONNECTED, ///< Label not connected to anything.
ERCE_LABEL_NOT_CONNECTED, ///< Label not connected to any pins.
ERCE_SIMILAR_LABELS, ///< 2 labels are equal for case insensitive comparisons.
ERCE_SIMILAR_POWER, ///< 2 power pins are equal for case insensitive comparisons.
ERCE_SIMILAR_LABEL_AND_POWER, ///< label and pin are equal for case insensitive comparisons.
ERCE_SINGLE_GLOBAL_LABEL, ///< A global label only exists once in the schematic.
ERCE_SINGLE_GLOBAL_LABEL, ///< A label only exists once in the schematic.
ERCE_SAME_LOCAL_GLOBAL_LABEL, ///< 2 labels are equal for case insensitive comparisons.
ERCE_DIFFERENT_UNIT_FP, ///< Different units of the same symbol have different
///< footprints assigned.
@ -69,7 +69,7 @@ enum ERCE_T
///< one net.
ERCE_BUS_TO_NET_CONFLICT, ///< A bus wire is graphically connected to a net port/pin
///< (or vice versa).
ERCE_GLOBLABEL_DANGLING, ///< A global label is dangling.
ERCE_LABEL_SINGLE_PIN, ///< A label is connected only to a single pin
ERCE_UNRESOLVED_VARIABLE, ///< A text variable could not be resolved.
ERCE_UNDEFINED_NETCLASS, ///< A netclass was referenced but not defined.
ERCE_SIMULATION_MODEL, ///< An error was found in the simulation model.

View File

@ -0,0 +1,646 @@
(kicad_sch
(version 20250610)
(generator "eeschema")
(generator_version "9.99")
(uuid "942a3088-eb03-48aa-816e-fbc33f0effe3")
(paper "A4")
(lib_symbols
(symbol "Device:R"
(pin_numbers
(hide yes)
)
(pin_names
(offset 0)
)
(exclude_from_sim no)
(in_bom yes)
(on_board yes)
(duplicate_pin_numbers_are_jumpers no)
(property "Reference" "R"
(at 2.032 0 90)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Value" "R"
(at 0 0 90)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Footprint" ""
(at -1.778 0 90)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Datasheet" ""
(at 0 0 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Description" "Resistor"
(at 0 0 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "ki_keywords" "R res resistor"
(at 0 0 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "ki_fp_filters" "R_*"
(at 0 0 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(symbol "R_0_1"
(rectangle
(start -1.016 -2.54)
(end 1.016 2.54)
(stroke
(width 0.254)
(type default)
)
(fill
(type none)
)
)
)
(symbol "R_1_1"
(pin passive line
(at 0 3.81 270)
(length 1.27)
(name ""
(effects
(font
(size 1.27 1.27)
)
)
)
(number "1"
(effects
(font
(size 1.27 1.27)
)
)
)
)
(pin passive line
(at 0 -3.81 90)
(length 1.27)
(name ""
(effects
(font
(size 1.27 1.27)
)
)
)
(number "2"
(effects
(font
(size 1.27 1.27)
)
)
)
)
)
(embedded_fonts no)
)
)
(no_connect
(at 86.36 53.34)
(uuid "3d711396-d612-43e6-a8e0-bd2bc6ebcce1")
)
(no_connect
(at 77.47 53.34)
(uuid "75160693-737a-4849-ad0a-bc5a6fb3b66b")
)
(wire
(pts
(xy 99.06 45.72) (xy 95.25 45.72)
)
(stroke
(width 0)
(type default)
)
(uuid "545ebe25-388f-4c66-a90f-c65959c10775")
)
(wire
(pts
(xy 77.47 34.29) (xy 77.47 45.72)
)
(stroke
(width 0)
(type default)
)
(uuid "6af0df33-0ef3-4a03-adb6-d276908b1da2")
)
(wire
(pts
(xy 106.68 53.34) (xy 110.49 53.34)
)
(stroke
(width 0)
(type default)
)
(uuid "983fc37d-2a6d-4eeb-ac40-0b81f3216a08")
)
(wire
(pts
(xy 62.23 34.29) (xy 62.23 45.72)
)
(stroke
(width 0)
(type default)
)
(uuid "9a3ea013-3a03-4d0f-b5a1-0833e12e37a0")
)
(wire
(pts
(xy 95.25 45.72) (xy 95.25 53.34)
)
(stroke
(width 0)
(type default)
)
(uuid "a08f2706-2864-492b-9d03-b94ef70aa210")
)
(wire
(pts
(xy 68.58 34.29) (xy 68.58 45.72)
)
(stroke
(width 0)
(type default)
)
(uuid "a7f3ad27-c2c9-4323-8907-2e9aa8b3eec5")
)
(wire
(pts
(xy 106.68 45.72) (xy 106.68 53.34)
)
(stroke
(width 0)
(type default)
)
(uuid "b517eb6b-a60d-474a-8197-cd80627c9417")
)
(wire
(pts
(xy 95.25 53.34) (xy 99.06 53.34)
)
(stroke
(width 0)
(type default)
)
(uuid "be839ff5-336d-4431-8c89-3ed955bce742")
)
(wire
(pts
(xy 110.49 45.72) (xy 106.68 45.72)
)
(stroke
(width 0)
(type default)
)
(uuid "e13b7a44-f9e6-4bfb-ab16-aaa9c891bf9d")
)
(wire
(pts
(xy 86.36 41.91) (xy 86.36 45.72)
)
(stroke
(width 0)
(type default)
)
(uuid "f448298f-767a-40df-9ed2-aed97ba2f31b")
)
(label "LABEL6"
(at 106.68 45.72 0)
(effects
(font
(size 1.27 1.27)
)
(justify left bottom)
)
(uuid "1e85e8f9-9627-44de-9cfe-3c1ef00f179b")
)
(label "LABEL2"
(at 68.58 34.29 270)
(effects
(font
(size 1.27 1.27)
)
(justify right bottom)
)
(uuid "7b304836-912c-4573-a2b5-bbbe2454e73a")
)
(label "LABEL3"
(at 77.47 34.29 270)
(effects
(font
(size 1.27 1.27)
)
(justify right bottom)
)
(uuid "d208dc6d-4ecf-44df-9d6a-38de2810ab81")
)
(global_label "LABEL4"
(shape input)
(at 86.36 41.91 90)
(fields_autoplaced yes)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
(uuid "44660598-a763-4788-bc0c-17f4c643845b")
(property "Intersheetrefs" "${INTERSHEET_REFS}"
(at 86.36 32.1515 90)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
)
(global_label "LABEL1"
(shape input)
(at 62.23 34.29 90)
(fields_autoplaced yes)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
(uuid "4f51b7a1-99d8-4d6d-a021-01cb8986f065")
(property "Intersheetrefs" "${INTERSHEET_REFS}"
(at 62.23 24.5315 90)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
)
(global_label "LABEL5"
(shape input)
(at 95.25 45.72 90)
(fields_autoplaced yes)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
(uuid "8e264054-b5e7-4123-a1b2-000d2490df9e")
(property "Intersheetrefs" "${INTERSHEET_REFS}"
(at 95.25 35.9615 90)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
)
(global_label "LABEL0"
(shape input)
(at 57.15 34.29 90)
(fields_autoplaced yes)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
(uuid "e5142a1b-15a9-4909-8d91-7c0066c18b41")
(property "Intersheetrefs" "${INTERSHEET_REFS}"
(at 57.15 24.5315 90)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
)
(symbol
(lib_id "Device:R")
(at 86.36 49.53 0)
(unit 1)
(exclude_from_sim no)
(in_bom yes)
(on_board yes)
(dnp no)
(fields_autoplaced yes)
(uuid "4c3c33c5-61f2-44e9-ab20-236140282088")
(property "Reference" "R3"
(at 88.9 48.2599 0)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(property "Value" "R"
(at 88.9 50.7999 0)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(property "Footprint" ""
(at 84.582 49.53 90)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Datasheet" ""
(at 86.36 49.53 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Description" "Resistor"
(at 86.36 49.53 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(pin "1"
(uuid "7ed43e05-0d43-462e-8283-cec90481fb30")
)
(pin "2"
(uuid "e5826406-2c6d-46f6-b46f-3a9592d62237")
)
(instances
(project "erc_test"
(path "/942a3088-eb03-48aa-816e-fbc33f0effe3"
(reference "R3")
(unit 1)
)
)
)
)
(symbol
(lib_id "Device:R")
(at 77.47 49.53 0)
(unit 1)
(exclude_from_sim no)
(in_bom yes)
(on_board yes)
(dnp no)
(fields_autoplaced yes)
(uuid "522cdfb7-4285-4c07-841b-205231d6aa59")
(property "Reference" "R1"
(at 80.01 48.2599 0)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(property "Value" "R"
(at 80.01 50.7999 0)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(property "Footprint" ""
(at 75.692 49.53 90)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Datasheet" ""
(at 77.47 49.53 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Description" "Resistor"
(at 77.47 49.53 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(pin "1"
(uuid "5291396b-fd18-437f-bd45-0809ca052d89")
)
(pin "2"
(uuid "a852a95d-6ee7-4529-a4ea-be6c4829ac05")
)
(instances
(project ""
(path "/942a3088-eb03-48aa-816e-fbc33f0effe3"
(reference "R1")
(unit 1)
)
)
)
)
(symbol
(lib_id "Device:R")
(at 110.49 49.53 0)
(unit 1)
(exclude_from_sim no)
(in_bom yes)
(on_board yes)
(dnp no)
(fields_autoplaced yes)
(uuid "70792ae6-0ee4-4cf4-8c2c-29118b3d8264")
(property "Reference" "R4"
(at 113.03 48.2599 0)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(property "Value" "R"
(at 113.03 50.7999 0)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(property "Footprint" ""
(at 108.712 49.53 90)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Datasheet" ""
(at 110.49 49.53 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Description" "Resistor"
(at 110.49 49.53 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(pin "1"
(uuid "6254c357-7c49-42ef-a452-1ed5fd9e97dc")
)
(pin "2"
(uuid "7de9301c-c71d-47d7-8fd3-d5351cfe70dc")
)
(instances
(project "erc_test"
(path "/942a3088-eb03-48aa-816e-fbc33f0effe3"
(reference "R4")
(unit 1)
)
)
)
)
(symbol
(lib_id "Device:R")
(at 99.06 49.53 0)
(unit 1)
(exclude_from_sim no)
(in_bom yes)
(on_board yes)
(dnp no)
(fields_autoplaced yes)
(uuid "d74a21dc-02ca-46b7-8f2a-ade2b8b1dd7f")
(property "Reference" "R2"
(at 101.6 48.2599 0)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(property "Value" "R"
(at 101.6 50.7999 0)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(property "Footprint" ""
(at 97.282 49.53 90)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Datasheet" ""
(at 99.06 49.53 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Description" "Resistor"
(at 99.06 49.53 0)
(hide yes)
(effects
(font
(size 1.27 1.27)
)
)
)
(pin "1"
(uuid "9597f2fd-22a4-4bd7-994c-0261fcae8bb9")
)
(pin "2"
(uuid "1388f304-9bd5-45d4-bbfd-9dfa4df24a79")
)
(instances
(project "erc_test"
(path "/942a3088-eb03-48aa-816e-fbc33f0effe3"
(reference "R2")
(unit 1)
)
)
)
)
(sheet_instances
(path "/"
(page "1")
)
)
(embedded_fonts no)
)

View File

@ -94,7 +94,8 @@ BOOST_FIXTURE_TEST_CASE( ERCSingleGlobalLabels, ERC_REGRESSION_TEST_FIXTURE )
LOCALE_IO dummy;
// Check for Errors when using global labels
std::vector<std::pair<wxString, int>> tests = { { "issue13212", 3 } };
std::vector<std::pair<wxString, int>> tests = { { "issue13212", 3 },
{ "erc_label_test", 7 } };
for( const std::pair<wxString, int>& test : tests )
{
@ -108,9 +109,12 @@ BOOST_FIXTURE_TEST_CASE( ERCSingleGlobalLabels, ERC_REGRESSION_TEST_FIXTURE )
settings.m_ERCSeverities[ERCE_LIB_SYMBOL_MISMATCH] = RPT_SEVERITY_IGNORE;
// Configure the rules under test
settings.m_ERCSeverities[ERCE_GLOBLABEL_DANGLING] = RPT_SEVERITY_IGNORE;
settings.m_ERCSeverities[ERCE_LABEL_SINGLE_PIN] = RPT_SEVERITY_IGNORE;
settings.m_ERCSeverities[ERCE_SINGLE_GLOBAL_LABEL] = RPT_SEVERITY_ERROR;
// Silence dangling wire errors
settings.m_ERCSeverities[ERCE_UNCONNECTED_WIRE_ENDPOINT] = RPT_SEVERITY_IGNORE;
SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
m_schematic->ConnectionGraph()->Recalculate( sheets, true );
m_schematic->ConnectionGraph()->RunERC();