From 2e92cc7958deb09862ef1daf674cb2f6734355f7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 2 Nov 2020 12:41:58 +0100 Subject: [PATCH] ERC: use separate tests for input pins and power input pins. Input pins can be driven by many pin types: output, passive, 3state, I/O But Power pins can be driven by only power output pins, and cannot use the same criteria in ERC tests. --- eeschema/erc.cpp | 43 +++++++++++++++++++++++++++++++++++++---- eeschema/erc_item.cpp | 6 ++++++ eeschema/erc_item.h | 1 + eeschema/erc_settings.h | 3 +++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index aaedaff46b..4d8f4891de 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -100,10 +100,23 @@ const wxString CommentERC_V[] = }; -// List of pin types that are considered drivers +// List of pin types that are considered drivers for usual input pins +// i.e. pin type = ELECTRICAL_PINTYPE::PT_INPUT, but not PT_POWER_IN +// that need only a PT_POWER_OUT pin type to be driven const std::set DrivingPinTypes = { ELECTRICAL_PINTYPE::PT_OUTPUT, + ELECTRICAL_PINTYPE::PT_POWER_OUT, + ELECTRICAL_PINTYPE::PT_PASSIVE, + ELECTRICAL_PINTYPE::PT_TRISTATE, + ELECTRICAL_PINTYPE::PT_BIDI + }; + +// List of pin types that are considered drivers for power pins +// In fact only a ELECTRICAL_PINTYPE::PT_POWER_OUT pin type can drive +// power input pins +const std::set DrivingPowerPinTypes = + { ELECTRICAL_PINTYPE::PT_POWER_OUT }; @@ -455,6 +468,20 @@ int ERC_TESTER::TestPinToPin() SCH_PIN* needsDriver = nullptr; bool hasDriver = false; + // We need different drivers for power nets and normal nets. + // A power net has at least one pin having the ELECTRICAL_PINTYPE::PT_POWER_IN + // and power nets can be driven only by ELECTRICAL_PINTYPE::PT_POWER_OUT pins + bool ispowerNet = false; + + for( SCH_PIN* refPin : pins ) + { + if( refPin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN ) + { + ispowerNet = true; + break; + } + } + for( SCH_PIN* refPin : pins ) { ELECTRICAL_PINTYPE refType = refPin->GetType(); @@ -469,7 +496,10 @@ int ERC_TESTER::TestPinToPin() needsDriver = refPin; } - hasDriver |= ( DrivingPinTypes.count( refType ) != 0 ); + if( ispowerNet ) + hasDriver |= ( DrivingPowerPinTypes.count( refType ) != 0 ); + else + hasDriver |= ( DrivingPinTypes.count( refType ) != 0 ); for( SCH_PIN* testPin : pins ) { @@ -487,7 +517,10 @@ int ERC_TESTER::TestPinToPin() ELECTRICAL_PINTYPE testType = testPin->GetType(); - hasDriver |= ( DrivingPinTypes.count( testType ) != 0 ); + if( ispowerNet ) + hasDriver |= ( DrivingPowerPinTypes.count( testType ) != 0 ); + else + hasDriver |= ( DrivingPinTypes.count( testType ) != 0 ); PIN_ERROR erc = settings.GetPinMapValue( refType, testType ); @@ -513,7 +546,9 @@ int ERC_TESTER::TestPinToPin() if( needsDriver && !hasDriver ) { - std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_PIN_NOT_DRIVEN ); + int err_code = ispowerNet ? ERCE_POWERPIN_NOT_DRIVEN : ERCE_PIN_NOT_DRIVEN; + std::shared_ptr ercItem = ERC_ITEM::Create( err_code ); + ercItem->SetItems( needsDriver ); SCH_MARKER* marker = new SCH_MARKER( ercItem, needsDriver->GetTransformedPosition() ); diff --git a/eeschema/erc_item.cpp b/eeschema/erc_item.cpp index 24469fa353..8cddfd4340 100644 --- a/eeschema/erc_item.cpp +++ b/eeschema/erc_item.cpp @@ -50,6 +50,10 @@ ERC_ITEM ERC_ITEM::pinNotDriven( ERCE_PIN_NOT_DRIVEN, _( "Input pin not driven by any Output pins" ), wxT( "pin_not_driven" ) ); +ERC_ITEM ERC_ITEM::powerpinNotDriven( ERCE_POWERPIN_NOT_DRIVEN, + _( "Input Power pin not driven by any Output Power pins" ), + wxT( "power_pin_not_driven" ) ); + ERC_ITEM ERC_ITEM::pinTableWarning( ERCE_PIN_TO_PIN_WARNING, _( "Conflict problem between pins" ), wxT( "pin_to_pin" ) ); @@ -130,6 +134,7 @@ std::vector> ERC_ITEM::allItemTypes( { ERC_ITEM::duplicateSheetName, ERC_ITEM::pinNotConnected, ERC_ITEM::pinNotDriven, + ERC_ITEM::powerpinNotDriven, ERC_ITEM::pinTableWarning, ERC_ITEM::hierLabelMismatch, ERC_ITEM::noConnectConnected, @@ -159,6 +164,7 @@ std::shared_ptr ERC_ITEM::Create( int aErrorCode ) case ERCE_DUPLICATE_SHEET_NAME: return std::make_shared( duplicateSheetName ); case ERCE_PIN_NOT_CONNECTED: return std::make_shared( pinNotConnected ); case ERCE_PIN_NOT_DRIVEN: return std::make_shared( pinNotDriven ); + case ERCE_POWERPIN_NOT_DRIVEN: return std::make_shared( powerpinNotDriven ); case ERCE_PIN_TO_PIN_WARNING: return std::make_shared( pinTableWarning ); case ERCE_PIN_TO_PIN_ERROR: return std::make_shared( pinTableError ); case ERCE_HIERACHICAL_LABEL: return std::make_shared( hierLabelMismatch ); diff --git a/eeschema/erc_item.h b/eeschema/erc_item.h index f5105308ee..f1434d9fd6 100644 --- a/eeschema/erc_item.h +++ b/eeschema/erc_item.h @@ -55,6 +55,7 @@ private: static ERC_ITEM duplicateSheetName; static ERC_ITEM pinNotConnected; static ERC_ITEM pinNotDriven; + static ERC_ITEM powerpinNotDriven; static ERC_ITEM pinTableWarning; static ERC_ITEM pinTableError; static ERC_ITEM hierLabelMismatch; diff --git a/eeschema/erc_settings.h b/eeschema/erc_settings.h index e21dd2bb41..24623d60ee 100644 --- a/eeschema/erc_settings.h +++ b/eeschema/erc_settings.h @@ -39,6 +39,9 @@ enum ERCE_T ERCE_DUPLICATE_SHEET_NAME = ERCE_FIRST, ///< Duplicate sheet names within a given sheet. ERCE_PIN_NOT_CONNECTED, ///< Pin not connected and not no connect symbol. ERCE_PIN_NOT_DRIVEN, ///< Pin connected to some others pins but no pin to drive it. + ///< pins to drive it can be output, passive, 3sttae, I/O + ERCE_POWERPIN_NOT_DRIVEN, ///< Power input pin connected to some others pins but no + ///< power out pin to drive it. 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.