diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 4a257a443d..b0a80397a4 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -491,6 +492,12 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter ) unsigned nextItemIdx = lastItemIdx = 0; int MinConn = NOC; + /* Check that a pin appears in only one net. This check is necessary + * because multi-unit components that have shared pins can be wired to + * different nets. + */ + std::unordered_map pin_to_net_map; + /* The netlist generated by SCH_EDIT_FRAME::BuildNetListBase is sorted * by net number, which means we can group netlist items into ranges * that live in the same net. The range from nextItem to the current @@ -555,11 +562,38 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter ) break; case NET_PIN: + { + // Check if this pin has appeared before on a different net + if( item->m_Link ) + { + auto ref = item->GetComponentParent()->GetRef( &item->m_SheetPath ); + wxString pin_name = ref + "_" + item->m_PinNum; + + if( pin_to_net_map.count( pin_name ) == 0 ) + { + pin_to_net_map[pin_name] = item->GetNetName(); + } + else if( pin_to_net_map[pin_name] != item->GetNetName() ) + { + SCH_MARKER* marker = new SCH_MARKER(); + + marker->SetTimeStamp( GetNewTimeStamp() ); + marker->SetData( ERCE_DIFFERENT_UNIT_NET, item->m_Start, + wxString::Format( _( "Pin %s on %s is connected to both %s and %s" ), + item->m_PinNum, ref, pin_to_net_map[pin_name], item->GetNetName() ), + item->m_Start ); + marker->SetMarkerType( MARKER_BASE::MARKER_ERC ); + marker->SetErrorLevel( MARKER_BASE::MARKER_SEVERITY_ERROR ); + + item->m_SheetPath.LastScreen()->Append( marker ); + } + } // Look for ERC problems between pins: TestOthersItems( objectsConnectedList.get(), itemIdx, nextItemIdx, &MinConn ); break; } + } lastItemIdx = itemIdx; } diff --git a/eeschema/drc_erc_item.cpp b/eeschema/drc_erc_item.cpp index 15a893cca9..e62438d324 100644 --- a/eeschema/drc_erc_item.cpp +++ b/eeschema/drc_erc_item.cpp @@ -60,6 +60,8 @@ wxString DRC_ITEM::GetErrorText() const return wxString( _("Global labels are similar (lower/upper case difference only)") ); case ERCE_DIFFERENT_UNIT_FP: return wxString( _("Different footprint assigned in another unit of the same component") ); + case ERCE_DIFFERENT_UNIT_NET: + return wxString( _("Different net assigned to a shared pin in another unit of the same component" ) ); default: wxFAIL_MSG( "Missing ERC error description" ); diff --git a/eeschema/erc.h b/eeschema/erc.h index a50fa43273..c60859b609 100644 --- a/eeschema/erc.h +++ b/eeschema/erc.h @@ -62,6 +62,8 @@ extern const wxString CommentERC_V[]; #define ERCE_SIMILAR_GLBL_LABELS 10 // 2 labels are equal fir case insensitive comparisons #define ERCE_DIFFERENT_UNIT_FP 11 // different units of the same component have different // footprints assigned +#define ERCE_DIFFERENT_UNIT_NET 12 // a shared pin in a multi-unit component is connected + // to more than one net /* Minimal connection table */ #define NPI 4 // Net with Pin isolated, this pin has type Not Connected and must be left N.C.