KiCad PCB EDA Suite
NETLIST_OBJECT_LIST Class Reference

Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected items in a full schematic hierarchy. More...

#include <class_netlist_object.h>

Inheritance diagram for NETLIST_OBJECT_LIST:

Public Member Functions

 NETLIST_OBJECT_LIST ()
 Constructor. More...
 
 ~NETLIST_OBJECT_LIST ()
 
bool BuildNetListInfo (SCH_SHEET_LIST &aSheets)
 Function BuildNetListInfo the master function of tgis class. More...
 
NETLIST_OBJECTGetItem (unsigned aIdx) const
 Acces to an item in list. More...
 
NETLIST_ITEM_T GetItemType (unsigned aIdx) const
 Acces to an item type. More...
 
int GetItemNet (unsigned aIdx) const
 Acces to an item net code. More...
 
NET_CONNECTION_T GetConnectionType (unsigned aIdx)
 
void SetConnectionType (unsigned aIdx, NET_CONNECTION_T aFlg=UNCONNECTED)
 Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT Pin not connected but have a NoConnect symbol on it (no error) PAD_CONNECT Normal connection (no error) More...
 
void Clear ()
 Delete all objects in list and clear list. More...
 
void ResetConnectionsType ()
 Reset the connection type of all items to UNCONNECTED type. More...
 
void SortListbyNetcode ()
 
void SortListbySheet ()
 
int CountPinsInNet (unsigned aNetStart)
 Counts number of pins connected on the same net. More...
 
void TestforNonOrphanLabel (unsigned aNetItemRef, unsigned aStartNet)
 Function TestforNonOrphanLabel Sheet labels are expected to be connected to a hierarchical label. More...
 
void TestforSimilarLabels ()
 Function TestforSimilarLabels detects labels which are different when using case sensitive comparisons but are equal when using case insensitive comparisons It can be due to a mistake from designer, so this kind of labels is reported by TestforSimilarLabels. More...
 

Private Member Functions

void propagateNetCode (int aOldNetCode, int aNewNetCode, bool aIsBus)
 
void labelConnect (NETLIST_OBJECT *aLabelRef)
 
void sheetLabelConnect (NETLIST_OBJECT *aSheetLabel)
 Propagate net codes from a parent sheet to an include sheet, from a pin sheet connection. More...
 
void pointToPointConnect (NETLIST_OBJECT *aRef, bool aIsBus, int start)
 
void segmentToPointConnect (NETLIST_OBJECT *aJonction, bool aIsBus, int aIdxStart)
 Search connections between a junction and segments Propagate the junction net code to objects connected by this junction. More...
 
void connectBusLabels ()
 Function connectBusLabels Propagate the net code (and create it, if not yet existing) between all bus label member objects connected by they name. More...
 
void setUnconnectedFlag ()
 Set the m_FlagOfConnection member of items in list depending on the connection type: UNCONNECTED, PAD_CONNECT or NOCONNECT_SYMBOL_PRESENT The list is expected sorted by order of net code, i.e. More...
 
void findBestNetNameForEachNet ()
 Function findBestNetNameForEachNet fill the .m_NetNameCandidate member of each item of aNetItemBuffer with a reference to the "best" NETLIST_OBJECT usable to give a name to the net If no suitable object found, .m_NetNameCandidate is filled with 0. More...
 

Static Private Member Functions

static bool sortItemsbyNetcode (const NETLIST_OBJECT *Objet1, const NETLIST_OBJECT *Objet2)
 
static bool sortItemsBySheet (const NETLIST_OBJECT *Objet1, const NETLIST_OBJECT *Objet2)
 

Private Attributes

int m_lastNetCode
 
int m_lastBusNetCode
 

Detailed Description

Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected items in a full schematic hierarchy.

It is helpful for netlist and ERC calculations.

Definition at line 284 of file class_netlist_object.h.

Constructor & Destructor Documentation

NETLIST_OBJECT_LIST::NETLIST_OBJECT_LIST ( )
inline

Constructor.

NETLIST_OBJECT_LIST handle a list of connected items. these NETLIST_OBJECT items are freeed by the destructor

Definition at line 296 of file class_netlist_object.h.

297  {
298  // Do not leave some members uninitialized:
299  m_lastNetCode = 0;
300  m_lastBusNetCode = 0;
301  }
NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST ( )

Definition at line 136 of file eeschema/netlist.cpp.

References Clear().

137 {
138  Clear();
139 }
void Clear()
Delete all objects in list and clear list.

Member Function Documentation

bool NETLIST_OBJECT_LIST::BuildNetListInfo ( SCH_SHEET_LIST aSheets)

Function BuildNetListInfo the master function of tgis class.

Build the list of connected objects (pins, labels ...) and all info to generate netlists or run ERC diags

Parameters
aSheets= the flattened sheet list
Returns
true if OK, false is not item found

Definition at line 195 of file eeschema/netlist.cpp.

References connectBusLabels(), findBestNetNameForEachNet(), SCH_SCREEN::GetDrawItems(), GetItem(), NETLIST_OBJECT::GetNet(), IS_BUS, IS_WIRE, labelConnect(), SCH_SHEET_PATH::LastScreen(), NETLIST_OBJECT::m_BusNetCode, m_lastBusNetCode, m_lastNetCode, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_Type, NET_BUS, NET_BUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_HIERBUSLABELMEMBER, NET_HIERLABEL, NET_ITEM_UNSPECIFIED, NET_JUNCTION, NET_LABEL, NET_NOCONNECT, NET_PIN, NET_PINLABEL, NET_SEGMENT, NET_SHEETBUSLABELMEMBER, NET_SHEETLABEL, SCH_ITEM::Next(), pointToPointConnect(), segmentToPointConnect(), NETLIST_OBJECT::SetNet(), setUnconnectedFlag(), sheetLabelConnect(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size(), SortListbyNetcode(), and SortListbySheet().

196 {
197  SCH_SHEET_PATH* sheet;
198 
199  // Fill list with connected items from the flattened sheet list
200  for( unsigned i = 0; i < aSheets.size(); i++ )
201  {
202  sheet = &aSheets[i];
203 
204  for( SCH_ITEM* item = sheet->LastScreen()->GetDrawItems(); item; item = item->Next() )
205  {
206  item->GetNetListItem( *this, sheet );
207  }
208  }
209 
210  if( size() == 0 )
211  return false;
212 
213  // Sort objects by Sheet
214  SortListbySheet();
215 
216  sheet = &(GetItem( 0 )->m_SheetPath);
218 
219  for( unsigned ii = 0, istart = 0; ii < size(); ii++ )
220  {
221  NETLIST_OBJECT* net_item = GetItem( ii );
222 
223  if( net_item->m_SheetPath != *sheet ) // Sheet change
224  {
225  sheet = &(net_item->m_SheetPath);
226  istart = ii;
227  }
228 
229  switch( net_item->m_Type )
230  {
232  wxMessageBox( wxT( "BuildNetListInfo() error" ) );
233  break;
234 
235  case NET_PIN:
236  case NET_PINLABEL:
237  case NET_SHEETLABEL:
238  case NET_NOCONNECT:
239  if( net_item->GetNet() != 0 )
240  break;
241 
242  case NET_SEGMENT:
243  // Test connections point to point type without bus.
244  if( net_item->GetNet() == 0 )
245  {
246  net_item->SetNet( m_lastNetCode );
247  m_lastNetCode++;
248  }
249 
250  pointToPointConnect( net_item, IS_WIRE, istart );
251  break;
252 
253  case NET_JUNCTION:
254  // Control of the junction outside BUS.
255  if( net_item->GetNet() == 0 )
256  {
257  net_item->SetNet( m_lastNetCode );
258  m_lastNetCode++;
259  }
260 
261  segmentToPointConnect( net_item, IS_WIRE, istart );
262 
263  // Control of the junction, on BUS.
264  if( net_item->m_BusNetCode == 0 )
265  {
266  net_item->m_BusNetCode = m_lastBusNetCode;
268  }
269 
270  segmentToPointConnect( net_item, IS_BUS, istart );
271  break;
272 
273  case NET_LABEL:
274  case NET_HIERLABEL:
275  case NET_GLOBLABEL:
276  // Test connections type junction without bus.
277  if( net_item->GetNet() == 0 )
278  {
279  net_item->SetNet( m_lastNetCode );
280  m_lastNetCode++;
281  }
282 
283  segmentToPointConnect( net_item, IS_WIRE, istart );
284  break;
285 
287  if( net_item->m_BusNetCode != 0 )
288  break;
289 
290  case NET_BUS:
291  // Control type connections point to point mode bus
292  if( net_item->m_BusNetCode == 0 )
293  {
294  net_item->m_BusNetCode = m_lastBusNetCode;
296  }
297 
298  pointToPointConnect( net_item, IS_BUS, istart );
299  break;
300 
301  case NET_BUSLABELMEMBER:
304  // Control connections similar has on BUS
305  if( net_item->GetNet() == 0 )
306  {
307  net_item->m_BusNetCode = m_lastBusNetCode;
309  }
310 
311  segmentToPointConnect( net_item, IS_BUS, istart );
312  break;
313  }
314  }
315 
316 #if defined(NETLIST_DEBUG) && defined(DEBUG)
317  std::cout << "\n\nafter sheet local\n\n";
318  DumpNetTable();
319 #endif
320 
321  // Updating the Bus Labels Netcode connected by Bus
323 
324  // Group objects by label.
325  for( unsigned ii = 0; ii < size(); ii++ )
326  {
327  switch( GetItem( ii )->m_Type )
328  {
329  case NET_PIN:
330  case NET_SHEETLABEL:
331  case NET_SEGMENT:
332  case NET_JUNCTION:
333  case NET_BUS:
334  case NET_NOCONNECT:
335  break;
336 
337  case NET_LABEL:
338  case NET_GLOBLABEL:
339  case NET_PINLABEL:
340  case NET_BUSLABELMEMBER:
342  labelConnect( GetItem( ii ) );
343  break;
344 
346  case NET_HIERLABEL:
348  break;
349 
351  break;
352  }
353  }
354 
355 #if defined(NETLIST_DEBUG) && defined(DEBUG)
356  std::cout << "\n\nafter sheet global\n\n";
357  DumpNetTable();
358 #endif
359 
360  // Connection between hierarchy sheets
361  for( unsigned ii = 0; ii < size(); ii++ )
362  {
363  if( GetItem( ii )->m_Type == NET_SHEETLABEL
364  || GetItem( ii )->m_Type == NET_SHEETBUSLABELMEMBER )
365  sheetLabelConnect( GetItem( ii ) );
366  }
367 
368  // Sort objects by NetCode
370 
371 #if defined(NETLIST_DEBUG) && defined(DEBUG)
372  std::cout << "\n\nafter qsort()\n";
373  DumpNetTable();
374 #endif
375 
376  // Compress numbers of Netcode having consecutive values.
377  int NetCode = 0;
378  m_lastNetCode = 0;
379 
380  for( unsigned ii = 0; ii < size(); ii++ )
381  {
382  if( GetItem( ii )->GetNet() != m_lastNetCode )
383  {
384  NetCode++;
385  m_lastNetCode = GetItem( ii )->GetNet();
386  }
387 
388  GetItem( ii )->SetNet( NetCode );
389  }
390 
391  // Set the minimal connection info:
393 
394  // find the best label object to give the best net name to each net
396 
397  return true;
398 }
void setUnconnectedFlag()
Set the m_FlagOfConnection member of items in list depending on the connection type: UNCONNECTED...
#define IS_WIRE
void connectBusLabels()
Function connectBusLabels Propagate the net code (and create it, if not yet existing) between all bus...
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
SCH_SHEET_PATH m_SheetPath
void findBestNetNameForEachNet()
Function findBestNetNameForEachNet fill the .m_NetNameCandidate member of each item of aNetItemBuffer...
SCH_SCREEN * LastScreen() const
Function LastScreen.
NETLIST_ITEM_T m_Type
void labelConnect(NETLIST_OBJECT *aLabelRef)
SCH_ITEM * Next() const
void sheetLabelConnect(NETLIST_OBJECT *aSheetLabel)
Propagate net codes from a parent sheet to an include sheet, from a pin sheet connection.
void segmentToPointConnect(NETLIST_OBJECT *aJonction, bool aIsBus, int aIdxStart)
Search connections between a junction and segments Propagate the junction net code to objects connect...
#define IS_BUS
Class SCH_SHEET_PATH.
SCH_ITEM * GetDrawItems() const
void SetNet(int aNetCode)
void pointToPointConnect(NETLIST_OBJECT *aRef, bool aIsBus, int start)
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void NETLIST_OBJECT_LIST::Clear ( )

Delete all objects in list and clear list.

Definition at line 142 of file eeschema/netlist.cpp.

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::begin(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::end().

Referenced by ~NETLIST_OBJECT_LIST().

143 {
144  NETLIST_OBJECTS::iterator iter;
145 
146  for( iter = begin(); iter != end(); iter++ )
147  {
148  NETLIST_OBJECT* item = *iter;
149  delete item;
150  }
151 
152  clear();
153 }
void NETLIST_OBJECT_LIST::connectBusLabels ( )
private

Function connectBusLabels Propagate the net code (and create it, if not yet existing) between all bus label member objects connected by they name.

Search is done in the entire list

Definition at line 645 of file eeschema/netlist.cpp.

References GetItem(), NETLIST_OBJECT::GetNet(), IS_WIRE, NETLIST_OBJECT::IsLabelBusMemberType(), NETLIST_OBJECT::m_BusNetCode, m_lastNetCode, NETLIST_OBJECT::m_Member, propagateNetCode(), NETLIST_OBJECT::SetNet(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size().

Referenced by BuildNetListInfo().

646 {
647  // Propagate the net code between all bus label member objects connected by they name.
648  // If the net code is not yet existing, a new one is created
649  // Search is done in the entire list
650  for( unsigned ii = 0; ii < size(); ii++ )
651  {
652  NETLIST_OBJECT* Label = GetItem( ii );
653 
654  if( Label->IsLabelBusMemberType() )
655  {
656  if( Label->GetNet() == 0 )
657  {
658  // Not yet existiing net code: create a new one.
659  Label->SetNet( m_lastNetCode );
660  m_lastNetCode++;
661  }
662 
663  for( unsigned jj = ii + 1; jj < size(); jj++ )
664  {
665  NETLIST_OBJECT* LabelInTst = GetItem( jj );
666 
667  if( LabelInTst->IsLabelBusMemberType() )
668  {
669  if( LabelInTst->m_BusNetCode != Label->m_BusNetCode )
670  continue;
671 
672  if( LabelInTst->m_Member != Label->m_Member )
673  continue;
674 
675  if( LabelInTst->GetNet() == 0 )
676  // Append this object to the current net
677  LabelInTst->SetNet( Label->GetNet() );
678  else
679  // Merge the 2 net codes, they are connected.
680  propagateNetCode( LabelInTst->GetNet(), Label->GetNet(), IS_WIRE );
681  }
682  }
683  }
684  }
685 }
#define IS_WIRE
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
bool IsLabelBusMemberType() const
Function IsLabelBusMemberType.
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
void SetNet(int aNetCode)
int NETLIST_OBJECT_LIST::CountPinsInNet ( unsigned  aNetStart)

Counts number of pins connected on the same net.

Used to count all pins connected to a no connect symbol

Returns
the pin count of the net starting at aNetStart
Parameters
aNetStart= index in list of net objects of the first item

Definition at line 498 of file erc.cpp.

References GetItemNet(), GetItemType(), and NET_PIN.

499 {
500  int count = 0;
501  int curr_net = GetItemNet( aNetStart );
502 
503  /* Test pins connected to NetItemRef */
504  for( unsigned item = aNetStart; item < size(); item++ )
505  {
506  // We examine only a given net. We stop the search if the net changes
507  if( curr_net != GetItemNet( item ) ) // End of net
508  break;
509 
510  if( GetItemType( item ) == NET_PIN )
511  count++;
512  }
513 
514  return count;
515 }
NETLIST_ITEM_T GetItemType(unsigned aIdx) const
Acces to an item type.
int GetItemNet(unsigned aIdx) const
Acces to an item net code.
void NETLIST_OBJECT_LIST::findBestNetNameForEachNet ( )
private

Function findBestNetNameForEachNet fill the .m_NetNameCandidate member of each item of aNetItemBuffer with a reference to the "best" NETLIST_OBJECT usable to give a name to the net If no suitable object found, .m_NetNameCandidate is filled with 0.

The "best" NETLIST_OBJECT is a NETLIST_OBJECT that have the type label and by priority order: the label is global or local the label is in the first sheet in a hierarchy (the root sheet has the most priority) alphabetic order.

Definition at line 467 of file eeschema/netlist.cpp.

References evalLabelsPriority(), NETLIST_OBJECT::GetComponentParent(), GetItem(), NETLIST_OBJECT::GetNet(), NETLIST_OBJECT::GetShortNetName(), NETLIST_OBJECT::HasNetNameCandidate(), SCH_COMPONENT::IsInNetlist(), NETLIST_OBJECT::m_Type, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_HIERLABEL, NET_LABEL, NET_PIN, NET_PINLABEL, NETLIST_OBJECT::SetNetNameCandidate(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size().

Referenced by BuildNetListInfo().

468 {
469  // Important note: NET_SHEETLABEL items of sheet items should *NOT* be considered,
470  // because they live in a sheet but their names are actually used in the subsheet.
471  // Moreover, in the parent sheet, the name of NET_SHEETLABEL can be not unique,
472  // ( for instance when 2 different sheets share the same schematic in complex hierarchies
473  // and 2 identical NET_SHEETLABEL labels can be connected to 2 different nets
474 
475  int netcode = 0; // current netcode for tested items
476  unsigned idxstart = 0; // index of the first item of this net
477  NETLIST_OBJECT* item;
478  NETLIST_OBJECT* candidate;
479 
480  // Pass 1: find the best name for labelled nets:
481  candidate = NULL;
482  for( unsigned ii = 0; ii <= size(); ii++ )
483  {
484  if( ii == size() ) // last item already tested
485  item = NULL;
486  else
487  item = GetItem( ii );
488 
489  if( !item || netcode != item->GetNet() ) // End of net found
490  {
491  if( candidate ) // One or more labels exists, find the best
492  {
493  for (unsigned jj = idxstart; jj < ii; jj++ )
494  GetItem( jj )->SetNetNameCandidate( candidate );
495  }
496 
497  if( item == NULL ) // End of list
498  break;
499 
500  // Prepare next net analysis:
501  netcode = item->GetNet();
502  candidate = NULL;
503  idxstart = ii;
504  }
505 
506  switch( item->m_Type )
507  {
508  case NET_HIERLABEL:
509  case NET_LABEL:
510  case NET_PINLABEL:
511  case NET_GLOBLABEL:
513  // A candidate is found: select the better between the previous
514  // and this one
515  if( candidate == NULL )
516  candidate = item;
517  else
518  {
519  if( evalLabelsPriority( item, candidate ) )
520  // item has a highter priority than candidate
521  // so update the best candidate
522  candidate = item;
523  }
524  break;
525 
526  default:
527  break;
528  }
529  }
530 
531  // Pass 2: find the best name for not labelled nets:
532  // The "default" net name is Net-<<Ref cmp>_Pad<num pad>>
533  // (see NETLIST_OBJECT::GetShortNetName())
534  // therefore the "best" is the short net name alphabetically classed first
535  // (to avoid net names changes when the net is not modified,
536  // even if components are moved or deleted and undelete or replaced, as long
537  // the reference is kept)
538 
539  // Build a list of items with no net names
540  NETLIST_OBJECTS list; // no ownership of elements being pointed at
541 
542  for( unsigned ii = 0; ii < size(); ii++ )
543  {
544  item = GetItem( ii );
545 
546  if( !item->HasNetNameCandidate() )
547  list.push_back( item );
548  }
549 
550  if( list.size() == 0 )
551  return;
552 
553  idxstart = 0;
554  candidate = NULL;
555  netcode = list[0]->GetNet();
556 
557  for( unsigned ii = 0; ii <= list.size(); ii++ )
558  {
559  if( ii < list.size() )
560  item = list[ii];
561  else
562  item = NULL;
563 
564  if( !item || netcode != item->GetNet() ) // End of net found
565  {
566  if( candidate )
567  {
568  for (unsigned jj = idxstart; jj < ii; jj++ )
569  {
570  NETLIST_OBJECT* obj = list[jj];
571  obj->SetNetNameCandidate( candidate );
572  }
573  }
574 
575  if( !item )
576  break;
577 
578  netcode = item->GetNet();
579  candidate = NULL;
580  idxstart = ii;
581  }
582 
583  // Examine all pins of the net to find the best candidate,
584  // i.e. the first net name candidate, by alphabetic order
585  // the net names are built by GetShortNetName
586  // (Net-<{reference}-Pad{pad number}> like Net-<U3-Pad5>
587  // Not named nets do not have usually a lot of members.
588  // Many have only 2 members(a pad and a non connection symbol)
589  if( item->m_Type == NET_PIN )
590  {
591  // A candidate is found, however components which are not in
592  // netlist are not candidate because some have their reference
593  // changed each time the netlist is built (power components)
594  // and anyway obviously they are not a good candidate
595  SCH_COMPONENT* link = item->GetComponentParent();
596 
597  if( link && link->IsInNetlist() )
598  {
599  // select the better between the previous and this one
600  item->SetNetNameCandidate( item ); // Needed to calculate GetShortNetName
601 
602  if( candidate == NULL )
603  candidate = item;
604  else
605  {
606  if( item->GetShortNetName().Cmp( candidate->GetShortNetName() ) < 0 )
607  candidate = item;
608  }
609  }
610  }
611  }
612 }
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
NETLIST_ITEM_T m_Type
std::vector< NETLIST_OBJECT * > NETLIST_OBJECTS
Type NETLIST_OBJECTS is a container referring to (not owning) NETLIST_OBJECTs, which are connected it...
bool IsInNetlist() const
SCH_COMPONENT * GetComponentParent() const
For Pins (NET_PINS):
void SetNetNameCandidate(NETLIST_OBJECT *aCandidate)
Set m_netNameCandidate to a connected item which will be used to calcule the net name of the item Obv...
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
wxString GetShortNetName(bool adoptTimestamp=false) const
Function GetShortNetName.
static bool evalLabelsPriority(const NETLIST_OBJECT *aLabel1, const NETLIST_OBJECT *aLabel2)
NET_CONNECTION_T NETLIST_OBJECT_LIST::GetConnectionType ( unsigned  aIdx)
inline

Definition at line 339 of file class_netlist_object.h.

References NETLIST_OBJECT::GetConnectionType(), and GetItem().

Referenced by TestOthersItems().

340  {
341  return GetItem( aIdx )->GetConnectionType();
342  }
NET_CONNECTION_T GetConnectionType() const
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
int NETLIST_OBJECT_LIST::GetItemNet ( unsigned  aIdx) const
inline

Acces to an item net code.

Definition at line 334 of file class_netlist_object.h.

References GetItem(), and NETLIST_OBJECT::GetNet().

Referenced by CountPinsInNet(), TestforNonOrphanLabel(), and TestOthersItems().

335  {
336  return GetItem( aIdx )->GetNet();
337  }
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
NETLIST_ITEM_T NETLIST_OBJECT_LIST::GetItemType ( unsigned  aIdx) const
inline

Acces to an item type.

Definition at line 326 of file class_netlist_object.h.

References GetItem(), and NETLIST_OBJECT::m_Type.

Referenced by CountPinsInNet(), TestforSimilarLabels(), and TestOthersItems().

327  {
328  return GetItem( aIdx )->m_Type;
329  }
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
NETLIST_ITEM_T m_Type
void NETLIST_OBJECT_LIST::labelConnect ( NETLIST_OBJECT aLabelRef)
private

Definition at line 855 of file eeschema/netlist.cpp.

References GetItem(), NETLIST_OBJECT::GetNet(), IS_WIRE, NETLIST_OBJECT::IsLabelType(), NETLIST_OBJECT::m_Label, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_Type, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_PINLABEL, propagateNetCode(), NETLIST_OBJECT::SetNet(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size().

Referenced by BuildNetListInfo().

856 {
857  if( aLabelRef->GetNet() == 0 )
858  return;
859 
860  for( unsigned i = 0; i < size(); i++ )
861  {
862  NETLIST_OBJECT* item = GetItem( i );
863 
864  if( item->GetNet() == aLabelRef->GetNet() )
865  continue;
866 
867  if( item->m_SheetPath != aLabelRef->m_SheetPath )
868  {
869  if( item->m_Type != NET_PINLABEL && item->m_Type != NET_GLOBLABEL
870  && item->m_Type != NET_GLOBBUSLABELMEMBER )
871  continue;
872 
873  if( (item->m_Type == NET_GLOBLABEL
874  || item->m_Type == NET_GLOBBUSLABELMEMBER)
875  && item->m_Type != aLabelRef->m_Type )
876  //global labels only connect other global labels.
877  continue;
878  }
879 
880  // NET_HIERLABEL are used to connect sheets.
881  // NET_LABEL are local to a sheet
882  // NET_GLOBLABEL are global.
883  // NET_PINLABEL is a kind of global label (generated by a power pin invisible)
884  if( item->IsLabelType() )
885  {
886  if( item->m_Label != aLabelRef->m_Label )
887  continue;
888 
889  if( item->GetNet() )
890  propagateNetCode( item->GetNet(), aLabelRef->GetNet(), IS_WIRE );
891  else
892  item->SetNet( aLabelRef->GetNet() );
893  }
894  }
895 }
#define IS_WIRE
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
bool IsLabelType() const
Function IsLabelType.
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
void SetNet(int aNetCode)
void NETLIST_OBJECT_LIST::pointToPointConnect ( NETLIST_OBJECT aRef,
bool  aIsBus,
int  start 
)
private

Definition at line 716 of file eeschema/netlist.cpp.

References GetItem(), NETLIST_OBJECT::GetNet(), IS_BUS, IS_WIRE, NETLIST_OBJECT::m_BusNetCode, NETLIST_OBJECT::m_End, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_Start, NETLIST_OBJECT::m_Type, NET_BUS, NET_BUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_HIERBUSLABELMEMBER, NET_HIERLABEL, NET_ITEM_UNSPECIFIED, NET_JUNCTION, NET_LABEL, NET_NOCONNECT, NET_PIN, NET_PINLABEL, NET_SEGMENT, NET_SHEETBUSLABELMEMBER, NET_SHEETLABEL, propagateNetCode(), NETLIST_OBJECT::SetNet(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size().

Referenced by BuildNetListInfo().

717 {
718  int netCode;
719 
720  if( aIsBus == false ) // Objects other than BUS and BUSLABELS
721  {
722  netCode = aRef->GetNet();
723 
724  for( unsigned i = start; i < size(); i++ )
725  {
726  NETLIST_OBJECT* item = GetItem( i );
727 
728  if( item->m_SheetPath != aRef->m_SheetPath ) //used to be > (why?)
729  continue;
730 
731  switch( item->m_Type )
732  {
733  case NET_SEGMENT:
734  case NET_PIN:
735  case NET_LABEL:
736  case NET_HIERLABEL:
737  case NET_GLOBLABEL:
738  case NET_SHEETLABEL:
739  case NET_PINLABEL:
740  case NET_JUNCTION:
741  case NET_NOCONNECT:
742  if( aRef->m_Start == item->m_Start
743  || aRef->m_Start == item->m_End
744  || aRef->m_End == item->m_Start
745  || aRef->m_End == item->m_End )
746  {
747  if( item->GetNet() == 0 )
748  item->SetNet( netCode );
749  else
750  propagateNetCode( item->GetNet(), netCode, IS_WIRE );
751  }
752  break;
753 
754  case NET_BUS:
755  case NET_BUSLABELMEMBER:
760  break;
761  }
762  }
763  }
764  else // Object type BUS, BUSLABELS, and junctions.
765  {
766  netCode = aRef->m_BusNetCode;
767 
768  for( unsigned i = start; i < size(); i++ )
769  {
770  NETLIST_OBJECT* item = GetItem( i );
771 
772  if( item->m_SheetPath != aRef->m_SheetPath )
773  continue;
774 
775  switch( item->m_Type )
776  {
778  case NET_SEGMENT:
779  case NET_PIN:
780  case NET_LABEL:
781  case NET_HIERLABEL:
782  case NET_GLOBLABEL:
783  case NET_SHEETLABEL:
784  case NET_PINLABEL:
785  case NET_NOCONNECT:
786  break;
787 
788  case NET_BUS:
789  case NET_BUSLABELMEMBER:
793  case NET_JUNCTION:
794  if( aRef->m_Start == item->m_Start
795  || aRef->m_Start == item->m_End
796  || aRef->m_End == item->m_Start
797  || aRef->m_End == item->m_End )
798  {
799  if( item->m_BusNetCode == 0 )
800  item->m_BusNetCode = netCode;
801  else
802  propagateNetCode( item->m_BusNetCode, netCode, IS_BUS );
803  }
804  break;
805  }
806  }
807  }
808 }
#define IS_WIRE
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
#define IS_BUS
void SetNet(int aNetCode)
void NETLIST_OBJECT_LIST::propagateNetCode ( int  aOldNetCode,
int  aNewNetCode,
bool  aIsBus 
)
private

Definition at line 688 of file eeschema/netlist.cpp.

References GetItem(), NETLIST_OBJECT::GetNet(), NETLIST_OBJECT::m_BusNetCode, NETLIST_OBJECT::SetNet(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size().

Referenced by connectBusLabels(), labelConnect(), pointToPointConnect(), segmentToPointConnect(), and sheetLabelConnect().

689 {
690  if( aOldNetCode == aNewNetCode )
691  return;
692 
693  if( aIsBus == false ) // Propagate NetCode
694  {
695  for( unsigned jj = 0; jj < size(); jj++ )
696  {
697  NETLIST_OBJECT* object = GetItem( jj );
698 
699  if( object->GetNet() == aOldNetCode )
700  object->SetNet( aNewNetCode );
701  }
702  }
703  else // Propagate BusNetCode
704  {
705  for( unsigned jj = 0; jj < size(); jj++ )
706  {
707  NETLIST_OBJECT* object = GetItem( jj );
708 
709  if( object->m_BusNetCode == aOldNetCode )
710  object->m_BusNetCode = aNewNetCode;
711  }
712  }
713 }
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
void SetNet(int aNetCode)
void NETLIST_OBJECT_LIST::ResetConnectionsType ( )
inline

Reset the connection type of all items to UNCONNECTED type.

Definition at line 362 of file class_netlist_object.h.

References GetItem(), NETLIST_OBJECT::SetConnectionType(), and UNCONNECTED.

363  {
364  for( unsigned ii = 0; ii < size(); ii++ )
366  }
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
void SetConnectionType(NET_CONNECTION_T aFlg=UNCONNECTED)
Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT...
void NETLIST_OBJECT_LIST::segmentToPointConnect ( NETLIST_OBJECT aJonction,
bool  aIsBus,
int  aIdxStart 
)
private

Search connections between a junction and segments Propagate the junction net code to objects connected by this junction.

The junction must have a valid net code The list of objects is expected sorted by sheets. Search is done from index aIdxStart to the last element of list

Definition at line 811 of file eeschema/netlist.cpp.

References GetItem(), NETLIST_OBJECT::GetNet(), IS_WIRE, IsPointOnSegment(), NETLIST_OBJECT::m_BusNetCode, NETLIST_OBJECT::m_End, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_Start, NETLIST_OBJECT::m_Type, NET_BUS, NET_SEGMENT, propagateNetCode(), NETLIST_OBJECT::SetNet(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size().

Referenced by BuildNetListInfo().

813 {
814  for( unsigned i = aIdxStart; i < size(); i++ )
815  {
816  NETLIST_OBJECT* segment = GetItem( i );
817 
818  // if different sheets, obviously no physical connection between elements.
819  if( segment->m_SheetPath != aJonction->m_SheetPath )
820  continue;
821 
822  if( aIsBus == IS_WIRE )
823  {
824  if( segment->m_Type != NET_SEGMENT )
825  continue;
826  }
827  else
828  {
829  if( segment->m_Type != NET_BUS )
830  continue;
831  }
832 
833  if( IsPointOnSegment( segment->m_Start, segment->m_End, aJonction->m_Start ) )
834  {
835  // Propagation Netcode has all the objects of the same Netcode.
836  if( aIsBus == IS_WIRE )
837  {
838  if( segment->GetNet() )
839  propagateNetCode( segment->GetNet(), aJonction->GetNet(), aIsBus );
840  else
841  segment->SetNet( aJonction->GetNet() );
842  }
843  else
844  {
845  if( segment->m_BusNetCode )
846  propagateNetCode( segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
847  else
848  segment->m_BusNetCode = aJonction->m_BusNetCode;
849  }
850  }
851  }
852 }
#define IS_WIRE
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Function IsPointOnSegment.
Definition: trigo.cpp:39
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
void SetNet(int aNetCode)
void NETLIST_OBJECT_LIST::SetConnectionType ( unsigned  aIdx,
NET_CONNECTION_T  aFlg = UNCONNECTED 
)
inline

Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT Pin not connected but have a NoConnect symbol on it (no error) PAD_CONNECT Normal connection (no error)

Definition at line 351 of file class_netlist_object.h.

References GetItem(), and NETLIST_OBJECT::SetConnectionType().

Referenced by TestOthersItems().

352  {
353  GetItem( aIdx )->SetConnectionType( aFlg );
354  }
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
void SetConnectionType(NET_CONNECTION_T aFlg=UNCONNECTED)
Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT...
void NETLIST_OBJECT_LIST::setUnconnectedFlag ( )
private

Set the m_FlagOfConnection member of items in list depending on the connection type: UNCONNECTED, PAD_CONNECT or NOCONNECT_SYMBOL_PRESENT The list is expected sorted by order of net code, i.e.

items having the same net code are grouped

Definition at line 898 of file eeschema/netlist.cpp.

References GetItem(), NETLIST_OBJECT::GetNet(), NETLIST_OBJECT::m_ConnectionType, NETLIST_OBJECT::m_Type, NET_BUS, NET_BUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_HIERBUSLABELMEMBER, NET_HIERLABEL, NET_ITEM_UNSPECIFIED, NET_JUNCTION, NET_LABEL, NET_NOCONNECT, NET_PIN, NET_PINLABEL, NET_SEGMENT, NET_SHEETBUSLABELMEMBER, NET_SHEETLABEL, NOCONNECT_SYMBOL_PRESENT, PAD_CONNECT, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size(), and UNCONNECTED.

Referenced by BuildNetListInfo().

899 {
900  NETLIST_OBJECT* NetItemRef;
901  unsigned NetStart, NetEnd;
902  NET_CONNECTION_T StateFlag;
903 
904  NetStart = NetEnd = 0;
905  StateFlag = UNCONNECTED;
906  for( unsigned ii = 0; ii < size(); ii++ )
907  {
908  NetItemRef = GetItem( ii );
909  if( NetItemRef->m_Type == NET_NOCONNECT && StateFlag != PAD_CONNECT )
910  StateFlag = NOCONNECT_SYMBOL_PRESENT;
911 
912  // Analysis of current net.
913  unsigned idxtoTest = ii + 1;
914 
915  if( ( idxtoTest >= size() )
916  || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
917  {
918  // Net analysis to update m_ConnectionType
919  NetEnd = idxtoTest;
920 
921  /* set m_ConnectionType member to StateFlag for all items of
922  * this net: */
923  for( unsigned kk = NetStart; kk < NetEnd; kk++ )
924  GetItem( kk )->m_ConnectionType = StateFlag;
925 
926  if( idxtoTest >= size() )
927  return;
928 
929  // Start Analysis next Net
930  StateFlag = UNCONNECTED;
931  NetStart = idxtoTest;
932  continue;
933  }
934 
935  /* test the current item: if this is a pin and if the reference item
936  * is also a pin, then 2 pins are connected, so set StateFlag to
937  * PAD_CONNECT (can be already done) Of course, if the current
938  * item is a no connect symbol, set StateFlag to
939  * NOCONNECT_SYMBOL_PRESENT to inhibit error diags. However if
940  * StateFlag is already set to PAD_CONNECT this state is kept (the
941  * no connect symbol was surely an error and an ERC will report this)
942  */
943  for( ; ; idxtoTest++ )
944  {
945  if( ( idxtoTest >= size() )
946  || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
947  break;
948 
949  switch( GetItem( idxtoTest )->m_Type )
950  {
952  wxMessageBox( wxT( "BuildNetListBase() error" ) );
953  break;
954 
955  case NET_SEGMENT:
956  case NET_LABEL:
957  case NET_HIERLABEL:
958  case NET_GLOBLABEL:
959  case NET_SHEETLABEL:
960  case NET_PINLABEL:
961  case NET_BUS:
962  case NET_BUSLABELMEMBER:
966  case NET_JUNCTION:
967  break;
968 
969  case NET_PIN:
970  if( NetItemRef->m_Type == NET_PIN )
971  StateFlag = PAD_CONNECT;
972 
973  break;
974 
975  case NET_NOCONNECT:
976  if( StateFlag != PAD_CONNECT )
977  StateFlag = NOCONNECT_SYMBOL_PRESENT;
978 
979  break;
980  }
981  }
982  }
983 }
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
NET_CONNECTION_T m_ConnectionType
NETLIST_ITEM_T m_Type
NET_CONNECTION_T
void NETLIST_OBJECT_LIST::sheetLabelConnect ( NETLIST_OBJECT aSheetLabel)
private

Propagate net codes from a parent sheet to an include sheet, from a pin sheet connection.

Definition at line 615 of file eeschema/netlist.cpp.

References GetItem(), NETLIST_OBJECT::GetNet(), IS_WIRE, NETLIST_OBJECT::m_Label, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_SheetPathInclude, NETLIST_OBJECT::m_Type, NET_HIERBUSLABELMEMBER, NET_HIERLABEL, propagateNetCode(), NETLIST_OBJECT::SetNet(), and MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::size().

Referenced by BuildNetListInfo().

616 {
617  if( SheetLabel->GetNet() == 0 )
618  return;
619 
620  for( unsigned ii = 0; ii < size(); ii++ )
621  {
622  NETLIST_OBJECT* ObjetNet = GetItem( ii );
623 
624  if( ObjetNet->m_SheetPath != SheetLabel->m_SheetPathInclude )
625  continue; //use SheetInclude, not the sheet!!
626 
627  if( (ObjetNet->m_Type != NET_HIERLABEL ) && (ObjetNet->m_Type != NET_HIERBUSLABELMEMBER ) )
628  continue;
629 
630  if( ObjetNet->GetNet() == SheetLabel->GetNet() )
631  continue; //already connected.
632 
633  if( ObjetNet->m_Label != SheetLabel->m_Label )
634  continue; //different names.
635 
636  // Propagate Netcode having all the objects of the same Netcode.
637  if( ObjetNet->GetNet() )
638  propagateNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), IS_WIRE );
639  else
640  ObjetNet->SetNet( SheetLabel->GetNet() );
641  }
642 }
#define IS_WIRE
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
void SetNet(int aNetCode)
static bool NETLIST_OBJECT_LIST::sortItemsbyNetcode ( const NETLIST_OBJECT Objet1,
const NETLIST_OBJECT Objet2 
)
inlinestaticprivate

Definition at line 435 of file class_netlist_object.h.

References NETLIST_OBJECT::GetNet().

Referenced by SortListbyNetcode().

436  {
437  return Objet1->GetNet() < Objet2->GetNet();
438  }
static bool NETLIST_OBJECT_LIST::sortItemsBySheet ( const NETLIST_OBJECT Objet1,
const NETLIST_OBJECT Objet2 
)
inlinestaticprivate

Definition at line 442 of file class_netlist_object.h.

References SCH_SHEET_PATH::Cmp(), and NETLIST_OBJECT::m_SheetPath.

Referenced by SortListbySheet().

443  {
444  return Objet1->m_SheetPath.Cmp( Objet2->m_SheetPath ) < 0;
445  }
SCH_SHEET_PATH m_SheetPath
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Function Cmp Compare if this is the same sheet path as aSheetPathToTest.
void NETLIST_OBJECT_LIST::SortListbyNetcode ( )

Definition at line 156 of file eeschema/netlist.cpp.

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::begin(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::end(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::sort(), and sortItemsbyNetcode().

Referenced by BuildNetListInfo().

157 {
158  sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsbyNetcode );
159 }
static bool sortItemsbyNetcode(const NETLIST_OBJECT *Objet1, const NETLIST_OBJECT *Objet2)
void NETLIST_OBJECT_LIST::SortListbySheet ( )

Definition at line 162 of file eeschema/netlist.cpp.

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::begin(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::end(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::sort(), and sortItemsBySheet().

Referenced by BuildNetListInfo().

163 {
164  sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsBySheet );
165 }
static bool sortItemsBySheet(const NETLIST_OBJECT *Objet1, const NETLIST_OBJECT *Objet2)
void NETLIST_OBJECT_LIST::TestforNonOrphanLabel ( unsigned  aNetItemRef,
unsigned  aStartNet 
)

Function TestforNonOrphanLabel Sheet labels are expected to be connected to a hierarchical label.

Hierarchical labels are expected to be connected to a sheet label. Global labels are expected to be not orphan (connected to at least one other global label. this function tests the connection to an other suitable label

Definition at line 576 of file erc.cpp.

References Diagnose(), GetItem(), GetItemNet(), and WAR.

577 {
578  unsigned netItemTst = aStartNet;
579  int erc = 1;
580 
581  // Review the list of labels connected to NetItemRef:
582  for( ; ; netItemTst++ )
583  {
584  if( netItemTst == aNetItemRef )
585  continue;
586 
587  /* Is always in the same net? */
588  if( ( netItemTst == size() )
589  || ( GetItemNet( aNetItemRef ) != GetItemNet( netItemTst ) ) )
590  {
591  /* End Netcode found. */
592  if( erc )
593  {
594  /* Glabel or SheetLabel orphaned. */
595  Diagnose( GetItem( aNetItemRef ), NULL, -1, WAR );
596  }
597 
598  return;
599  }
600 
601  if( GetItem( aNetItemRef )->IsLabelConnected( GetItem( netItemTst ) ) )
602  erc = 0;
603 
604  //same thing, different order.
605  if( GetItem( netItemTst )->IsLabelConnected( GetItem( aNetItemRef ) ) )
606  erc = 0;
607  }
608 }
Definition: erc.h:43
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
void Diagnose(NETLIST_OBJECT *aNetItemRef, NETLIST_OBJECT *aNetItemTst, int aMinConn, int aDiag)
Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef or between aNe...
Definition: erc.cpp:228
int GetItemNet(unsigned aIdx) const
Acces to an item net code.
void NETLIST_OBJECT_LIST::TestforSimilarLabels ( )

Function TestforSimilarLabels detects labels which are different when using case sensitive comparisons but are equal when using case insensitive comparisons It can be due to a mistake from designer, so this kind of labels is reported by TestforSimilarLabels.

Definition at line 650 of file erc.cpp.

References countIndenticalLabels(), GetItem(), GetItemType(), NETLIST_OBJECT::IsLabelGlobal(), NETLIST_OBJECT::m_Label, NET_BUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_HIERBUSLABELMEMBER, NET_HIERLABEL, NET_LABEL, NET_PINLABEL, NET_SHEETBUSLABELMEMBER, NET_SHEETLABEL, and SimilarLabelsDiagnose().

651 {
652  // Similar labels which are different when using case sensitive comparisons
653  // but are equal when using case insensitive comparisons
654 
655  // list of all labels (used the better item to build diag messages)
656  std::vector<NETLIST_OBJECT*> fullLabelList;
657  // list of all labels , each label appears only once (used to to detect similar labels)
658  std::set<NETLIST_OBJECT*, compare_labels> uniqueLabelList;
659  wxString msg;
660 
661  // Build a list of differents labels. If inside a given sheet there are
662  // more than one given label, only one label is stored.
663  // not also the sheet labels are not taken in account for 2 reasons:
664  // * they are in the root sheet but they are seen only from the child sheet
665  // * any mismatch between child sheet hierarchical labels and the sheet label
666  // already detected by ERC
667  for( unsigned netItem = 0; netItem < size(); ++netItem )
668  {
669  switch( GetItemType( netItem ) )
670  {
671  case NET_LABEL:
672  case NET_BUSLABELMEMBER:
673  case NET_PINLABEL:
675  case NET_HIERLABEL:
677  case NET_GLOBLABEL:
678  // add this label in lists
679  uniqueLabelList.insert( GetItem( netItem ) );
680  fullLabelList.push_back( GetItem( netItem ) );
681  break;
682 
683  case NET_SHEETLABEL:
685  default:
686  break;
687  }
688  }
689 
690  // build global labels and compare
691  std::set<NETLIST_OBJECT*, compare_label_names> loc_labelList;
692  std::set<NETLIST_OBJECT*>::const_iterator it;
693 
694  for( it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it )
695  {
696  if( (*it)->IsLabelGlobal() )
697  loc_labelList.insert( *it );
698  }
699 
700  // compare global labels (same label names appears only once in list)
701  for( it = loc_labelList.begin(); it != loc_labelList.end(); ++it )
702  {
703  std::set<NETLIST_OBJECT*>::const_iterator it_aux = it;
704 
705  for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
706  {
707  if( (*it)->m_Label.CmpNoCase( (*it_aux)->m_Label ) == 0 )
708  {
709  // Create new marker for ERC.
710  int cntA = countIndenticalLabels( fullLabelList, *it );
711  int cntB = countIndenticalLabels( fullLabelList, *it_aux );
712 
713  if( cntA <= cntB )
714  SimilarLabelsDiagnose( (*it), (*it_aux) );
715  else
716  SimilarLabelsDiagnose( (*it_aux), (*it) );
717  }
718  }
719  }
720 
721  // Build paths list
722  std::set<NETLIST_OBJECT*, compare_paths> pathsList;
723 
724  for( it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it )
725  pathsList.insert( *it );
726 
727  // Examine each label inside a sheet path:
728  for( it = pathsList.begin(); it != pathsList.end(); ++it )
729  {
730  loc_labelList.clear();
731 
732  std::set<NETLIST_OBJECT*>::const_iterator it_aux = uniqueLabelList.begin();
733 
734  for( ; it_aux != uniqueLabelList.end(); ++it_aux )
735  {
736  if( (*it)->m_SheetPath.Path() == (*it_aux)->m_SheetPath.Path() )
737  loc_labelList.insert( *it_aux );
738  }
739 
740  // at this point, loc_labelList contains labels of the current sheet path.
741  // Detect similar labels (same label names appears only once in list)
742  std::set<NETLIST_OBJECT*>::const_iterator ref_it;
743 
744  for( ref_it = loc_labelList.begin(); ref_it != loc_labelList.end(); ++ref_it )
745  {
746  NETLIST_OBJECT* ref_item = *ref_it;
747  it_aux = ref_it;
748 
749  for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
750  {
751  // global label versus global label was already examined.
752  // here, at least one label must be local
753  if( ref_item->IsLabelGlobal() && (*it_aux)->IsLabelGlobal() )
754  continue;
755 
756  if( ref_item->m_Label.CmpNoCase( (*it_aux)->m_Label ) == 0 )
757  {
758  // Create new marker for ERC.
759  int cntA = countIndenticalLabels( fullLabelList, ref_item );
760  int cntB = countIndenticalLabels( fullLabelList, *it_aux );
761 
762  if( cntA <= cntB )
763  SimilarLabelsDiagnose( ref_item, (*it_aux) );
764  else
765  SimilarLabelsDiagnose( (*it_aux), ref_item );
766  }
767  }
768  }
769  }
770 }
bool IsLabelGlobal() const
Function IsLabelGlobal.
NETLIST_ITEM_T GetItemType(unsigned aIdx) const
Acces to an item type.
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
static int countIndenticalLabels(std::vector< NETLIST_OBJECT * > &aList, NETLIST_OBJECT *aLabel)
Definition: erc.cpp:775
static void SimilarLabelsDiagnose(NETLIST_OBJECT *aItemA, NETLIST_OBJECT *aItemB)
Definition: erc.cpp:805

Member Data Documentation

int NETLIST_OBJECT_LIST::m_lastBusNetCode
private

Definition at line 287 of file class_netlist_object.h.

Referenced by BuildNetListInfo().

int NETLIST_OBJECT_LIST::m_lastNetCode
private

Definition at line 286 of file class_netlist_object.h.

Referenced by BuildNetListInfo(), and connectBusLabels().


The documentation for this class was generated from the following files: