Add ERC check that a pin appears in only one net
Fixes: lp:1680638 * https://bugs.launchpad.net/kicad/+bug/1680638
This commit is contained in:
parent
89d350a7d2
commit
0a81782b5d
|
@ -47,6 +47,7 @@
|
|||
#include <sch_marker.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <lib_pin.h>
|
||||
#include <sch_component.h>
|
||||
|
||||
#include <dialog_erc.h>
|
||||
#include <erc.h>
|
||||
|
@ -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<wxString, wxString> 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;
|
||||
}
|
||||
|
|
|
@ -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" );
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue