@JP,Attached you can find the patch file for the improvement of optional ERC's detecting local labels.
Short description:With this patch, there is an added extra check box inside ERC pop-up window, which by default is "un-checked".
This extra check box has a name "Check Unmatched Labels". When it is "un-checked", ERC's "Run" will just function as normal as it used to be, so to avoid un-wanted noises for some people who don't bother detecting; when it is "checked", ERC's "Run" will detect the "unmatched" local labels.
I also attached a new test schematic tar ball that can be used for testing the patch functions.
Thank you for all your valuable comments and insights.I would appreciate anyone could test this patch out and provide comments and inputs.
--JC On 09/14/2015 03:30 AM, jp charras wrote:
Le 14/09/2015 06:17, Joseph Chen a écrit :@Wayne and @JP, Could try ERC on this simple schematic file? Attached, you can find a test schematic file that has an unintended unmatched local labels, and current kicad ERC does not detect them. In the test schematic file, there is a mis-spelled local label on the right hand side. The local labels are constructed with an intention of using them to serve as ratnets, not just a convenient text. With this kind of mis-detected errors, the PCB will not have the intended ratnet at all and thus no copper track will be laid out, and thus the manufactured boards will be bad. --JoeThe test schematic looks good for a reader. You said: "The local labels are constructed with an intention of using them to serve as ratnets, not just a convenient text" But only the designer (you) knows that. Detecting mis-spelled local labels is not so easy, if you want to avoid noise. And if there is noise, this feature is useless. Many designers widely use a local label (and only one) to name a net for many reasons. This is not necessary a design error (in fact 99% of cases are not an error) Having said that, I think you could send us a patch, at least to try this feature, and see how useful it is in many different designs, and perhaps improve it to avoid noise. But keep in mind testing a patch and include it in a stable release are not the same thing.
diff --git a/eeschema/class_drc_erc_item.cpp b/eeschema/class_drc_erc_item.cpp
index 9071dc8..7a3e9de 100644
--- a/eeschema/class_drc_erc_item.cpp
+++ b/eeschema/class_drc_erc_item.cpp
@@ -54,6 +54,8 @@ wxString DRC_ITEM::GetErrorText() const
return wxString( _("A no connect symbol is connected to more than 1
pin"));
case ERCE_GLOBLABEL:
return wxString( _("Global label not connected to any other global
label") );
+ case ERCE_LABEL:
+ return wxString( _("Local label not connected to any other local label
of the same sheet") );
default:
return wxString( wxT("Unkown.") );
diff --git a/eeschema/class_netlist_object.cpp
b/eeschema/class_netlist_object.cpp
index 5d7ca6b..aaf6867 100644
--- a/eeschema/class_netlist_object.cpp
+++ b/eeschema/class_netlist_object.cpp
@@ -212,7 +212,7 @@ bool NETLIST_OBJECT::IsLabelType() const
|| m_Type == NET_PINLABEL;
}
-bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem )
+bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem, bool
checkUnmatchedLabel )
{
if( aNetItem == this ) // Don't compare the same net list object.
return false;
@@ -233,6 +233,20 @@ bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT*
aNetItem )
if( m_Label == aNetItem->m_Label )
return true; //connected!
}
+ else if( checkUnmatchedLabel )
+ {
+ if ( ( at == NET_LABEL ) &&
+ ( bt == NET_LABEL ) &&
+ ( m_SheetPath == aNetItem->m_SheetPath ) &&
+ ( m_Label == aNetItem->m_Label ) )
+ return true; //connected!
+ }
+ else if( !checkUnmatchedLabel )
+ {
+ if ( ( at == NET_LABEL ) ||
+ ( bt == NET_LABEL ) )
+ return true; //connected!
+ }
return false; //these two are unconnected
}
diff --git a/eeschema/class_netlist_object.h b/eeschema/class_netlist_object.h
index f97fe77..2c79741 100644
--- a/eeschema/class_netlist_object.h
+++ b/eeschema/class_netlist_object.h
@@ -206,10 +206,11 @@ public:
* connected to an associated hierarchical label or sheet label of \a
aNetItem.
*
* @param aNetItem A pointer to a NETLIST_OBJECT to test against.
+ * @param checkUnmatchedLabel A bool value to check unmatched label.
* @return A bool value of true if there is a connection with \a aNetItem
or false
* if no connection to \a aNetItem.
*/
- bool IsLabelConnected( NETLIST_OBJECT* aNetItem );
+ bool IsLabelConnected( NETLIST_OBJECT* aNetItem, bool checkUnmatchedLabel
);
/**
* Function IsLabelGlobal
diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp
index c6792ea..3419c3b 100644
--- a/eeschema/dialogs/dialog_erc.cpp
+++ b/eeschema/dialogs/dialog_erc.cpp
@@ -50,6 +50,7 @@
bool DIALOG_ERC::m_writeErcFile = false;
+bool DIALOG_ERC::m_checkUnmatchedLabel = false;
BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
@@ -86,6 +87,7 @@ void DIALOG_ERC::Init()
}
m_WriteResultOpt->SetValue( m_writeErcFile );
+ m_CheckUnmatchedLabelOpt->SetValue( m_checkUnmatchedLabel );
SCH_SCREENS screens;
updateMarkerCounts( &screens );
@@ -439,6 +441,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
}
m_writeErcFile = m_WriteResultOpt->GetValue();
+ m_checkUnmatchedLabel = m_CheckUnmatchedLabelOpt->GetValue();
// Build the whole sheet list in hierarchy (sheet, not screen)
SCH_SHEET_LIST sheets;
@@ -501,7 +504,6 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
case NET_SEGMENT:
case NET_BUS:
case NET_JUNCTION:
- case NET_LABEL:
case NET_BUSLABELMEMBER:
case NET_PINLABEL:
case NET_GLOBBUSLABELMEMBER:
@@ -512,11 +514,12 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
case NET_SHEETLABEL:
case NET_SHEETBUSLABELMEMBER:
case NET_GLOBLABEL:
+ case NET_LABEL:
// ERC problems when pin sheets do not match hierarchical labels.
// Each pin sheet must match a hierarchical label
// Each hierarchical label must match a pin sheet
- TestLabel( objectsConnectedList.get(), net, nextNet );
+ TestLabel( objectsConnectedList.get(), net, nextNet,
m_checkUnmatchedLabel );
break;
case NET_NOCONNECT:
diff --git a/eeschema/dialogs/dialog_erc.h b/eeschema/dialogs/dialog_erc.h
index e086166..3da4e7e 100644
--- a/eeschema/dialogs/dialog_erc.h
+++ b/eeschema/dialogs/dialog_erc.h
@@ -54,6 +54,7 @@ private:
bool m_initialized;
const SCH_MARKER* m_lastMarkerFound;
static bool m_writeErcFile;
+ static bool m_checkUnmatchedLabel;
public:
DIALOG_ERC( SCH_EDIT_FRAME* parent );
diff --git a/eeschema/dialogs/dialog_erc_base.cpp
b/eeschema/dialogs/dialog_erc_base.cpp
index fc37976..93c3ac9 100644
--- a/eeschema/dialogs/dialog_erc_base.cpp
+++ b/eeschema/dialogs/dialog_erc_base.cpp
@@ -58,6 +58,8 @@ DIALOG_ERC_BASE::DIALOG_ERC_BASE( wxWindow* parent,
wxWindowID id, const wxStrin
m_WriteResultOpt = new wxCheckBox( sdiagSizer->GetStaticBox(),
wxID_ANY, _("Create ERC file report"), wxDefaultPosition, wxDefaultSize, 0 );
sdiagSizer->Add( m_WriteResultOpt, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
+ m_CheckUnmatchedLabelOpt = new wxCheckBox( sdiagSizer->GetStaticBox(),
wxID_ANY, _("Check Unmatched Labels"), wxDefaultPosition, wxDefaultSize, 0 );
+ sdiagSizer->Add( m_CheckUnmatchedLabelOpt, 0, wxTOP|wxBOTTOM|wxRIGHT, 5
);
bupperSizer->Add( sdiagSizer, 0, wxEXPAND|wxTOP, 5 );
diff --git a/eeschema/dialogs/dialog_erc_base.fbp
b/eeschema/dialogs/dialog_erc_base.fbp
index 4d0702b..b67490c 100644
--- a/eeschema/dialogs/dialog_erc_base.fbp
+++ b/eeschema/dialogs/dialog_erc_base.fbp
@@ -857,6 +857,7 @@
<property
name="minimum_size"></property>
<property
name="moveable">1</property>
<property
name="name">m_WriteResultOpt</property>
+ <property
name="name">m_CheckUnmatchedLabelOpt</property>
<property
name="pane_border">1</property>
<property
name="pane_position"></property>
<property
name="pane_size"></property>
diff --git a/eeschema/dialogs/dialog_erc_base.h
b/eeschema/dialogs/dialog_erc_base.h
index 007f946..e9b57f2 100644
--- a/eeschema/dialogs/dialog_erc_base.h
+++ b/eeschema/dialogs/dialog_erc_base.h
@@ -57,6 +57,7 @@ class DIALOG_ERC_BASE : public DIALOG_SHIM
wxStaticText* m_LastErrCountText;
wxTextCtrl* m_LastErrCount;
wxCheckBox* m_WriteResultOpt;
+ wxCheckBox* m_CheckUnmatchedLabelOpt;
wxStaticText* m_titleMessages;
wxTextCtrl* m_MessagesList;
wxStaticText* m_textMarkers;
diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp
index 099249c..700a2ee 100644
--- a/eeschema/erc.cpp
+++ b/eeschema/erc.cpp
@@ -265,6 +265,15 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef,
NETLIST_OBJECT* aNetItemTst,
msg,
aNetItemRef->m_Start );
}
+ else if( (aNetItemRef->m_Type == NET_LABEL) )
+ {
+ msg.Printf( _( "Local label %s is not connected to any other local
label of the same sheet." ),
+ GetChars( aNetItemRef->m_Label ) );
+ marker->SetData( ERCE_LABEL,
+ aNetItemRef->m_Start,
+ msg,
+ aNetItemRef->m_Start );
+ }
else
{
msg.Printf( _( "Sheet label %s is not connected to a hierarchical
label." ),
@@ -582,7 +591,7 @@ bool WriteDiagnosticERC( const wxString& aFullFileName )
}
-void TestLabel( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned
aStartNet )
+void TestLabel( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned
aStartNet, bool checkUnmatchedLabel )
{
unsigned netItemTst = aStartNet;
int erc = 1;
@@ -607,11 +616,11 @@ void TestLabel( NETLIST_OBJECT_LIST* aList, unsigned
aNetItemRef, unsigned aStar
return;
}
- if( aList->GetItem( aNetItemRef )->IsLabelConnected( aList->GetItem(
netItemTst ) ) )
+ if( aList->GetItem( aNetItemRef )->IsLabelConnected( aList->GetItem(
netItemTst ), checkUnmatchedLabel ) )
erc = 0;
//same thing, different order.
- if( aList->GetItem( netItemTst )->IsLabelConnected( aList->GetItem(
aNetItemRef ) ) )
+ if( aList->GetItem( netItemTst )->IsLabelConnected( aList->GetItem(
aNetItemRef ), checkUnmatchedLabel ) )
erc = 0;
}
}
diff --git a/eeschema/erc.h b/eeschema/erc.h
index 708fb6a..72fa4f0 100644
--- a/eeschema/erc.h
+++ b/eeschema/erc.h
@@ -58,6 +58,7 @@ extern const wxString CommentERC_V[];
#define ERCE_HIERACHICAL_LABEL 6 // mismatch between hierarchical labels
and pins sheets
#define ERCE_NOCONNECT_CONNECTED 7 // a no connect symbol is connected to
more than 1 pin
#define ERCE_GLOBLABEL 8 // global label not connected to any
other global label
+#define ERCE_LABEL 9 // local label not connected to any
other local label of the same sheet
/* Minimal connection table */
#define NPI 4 // Net with Pin isolated, this pin has type Not Connected
and must be left N.C.
@@ -111,7 +112,7 @@ int CountPinsInNet( NETLIST_OBJECT_LIST* aList, unsigned
aNetStart );
* performs an ERC on a sheet labels to verify that it is connected to a
corresponding
* sub sheet global label.
*/
-extern void TestLabel( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef,
unsigned aStartNet );
+extern void TestLabel( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef,
unsigned aStartNet, bool checkUnmatchedLabel );
/**
* Function TestDuplicateSheetNames( )
kicad-unmatched-local-labels-schematic.tar.gz
Description: application/gzip
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

