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 140 of file eeschema/netlist.cpp.

References Clear().

141 {
142  Clear();
143 }
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 199 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().

200 {
201  SCH_SHEET_PATH* sheet;
202 
203  // Fill list with connected items from the flattened sheet list
204  for( unsigned i = 0; i < aSheets.size(); i++ )
205  {
206  sheet = &aSheets[i];
207 
208  for( SCH_ITEM* item = sheet->LastScreen()->GetDrawItems(); item; item = item->Next() )
209  {
210  item->GetNetListItem( *this, sheet );
211  }
212  }
213 
214  if( size() == 0 )
215  return false;
216 
217  // Sort objects by Sheet
218  SortListbySheet();
219 
220  sheet = &(GetItem( 0 )->m_SheetPath);
222 
223  for( unsigned ii = 0, istart = 0; ii < size(); ii++ )
224  {
225  NETLIST_OBJECT* net_item = GetItem( ii );
226 
227  if( net_item->m_SheetPath != *sheet ) // Sheet change
228  {
229  sheet = &(net_item->m_SheetPath);
230  istart = ii;
231  }
232 
233  switch( net_item->m_Type )
234  {
236  wxMessageBox( wxT( "BuildNetListInfo() error" ) );
237  break;
238 
239  case NET_PIN:
240  case NET_PINLABEL:
241  case NET_SHEETLABEL:
242  case NET_NOCONNECT:
243  if( net_item->GetNet() != 0 )
244  break;
245 
246  case NET_SEGMENT:
247  // Test connections point to point type without bus.
248  if( net_item->GetNet() == 0 )
249  {
250  net_item->SetNet( m_lastNetCode );
251  m_lastNetCode++;
252  }
253 
254  pointToPointConnect( net_item, IS_WIRE, istart );
255  break;
256 
257  case NET_JUNCTION:
258  // Control of the junction outside BUS.
259  if( net_item->GetNet() == 0 )
260  {
261  net_item->SetNet( m_lastNetCode );
262  m_lastNetCode++;
263  }
264 
265  segmentToPointConnect( net_item, IS_WIRE, istart );
266 
267  // Control of the junction, on BUS.
268  if( net_item->m_BusNetCode == 0 )
269  {
270  net_item->m_BusNetCode = m_lastBusNetCode;
272  }
273 
274  segmentToPointConnect( net_item, IS_BUS, istart );
275  break;
276 
277  case NET_LABEL:
278  case NET_HIERLABEL:
279  case NET_GLOBLABEL:
280  // Test connections type junction without bus.
281  if( net_item->GetNet() == 0 )
282  {
283  net_item->SetNet( m_lastNetCode );
284  m_lastNetCode++;
285  }
286 
287  segmentToPointConnect( net_item, IS_WIRE, istart );
288  break;
289 
291  if( net_item->m_BusNetCode != 0 )
292  break;
293 
294  case NET_BUS:
295  // Control type connections point to point mode bus
296  if( net_item->m_BusNetCode == 0 )
297  {
298  net_item->m_BusNetCode = m_lastBusNetCode;
300  }
301 
302  pointToPointConnect( net_item, IS_BUS, istart );
303  break;
304 
305  case NET_BUSLABELMEMBER:
308  // Control connections similar has on BUS
309  if( net_item->GetNet() == 0 )
310  {
311  net_item->m_BusNetCode = m_lastBusNetCode;
313  }
314 
315  segmentToPointConnect( net_item, IS_BUS, istart );
316  break;
317  }
318  }
319 
320 #if defined(NETLIST_DEBUG) && defined(DEBUG)
321  std::cout << "\n\nafter sheet local\n\n";
322  DumpNetTable();
323 #endif
324 
325  // Updating the Bus Labels Netcode connected by Bus
327 
328  // Group objects by label.
329  for( unsigned ii = 0; ii < size(); ii++ )
330  {
331  switch( GetItem( ii )->m_Type )
332  {
333  case NET_PIN:
334  case NET_SHEETLABEL:
335  case NET_SEGMENT:
336  case NET_JUNCTION:
337  case NET_BUS:
338  case NET_NOCONNECT:
339  break;
340 
341  case NET_LABEL:
342  case NET_GLOBLABEL:
343  case NET_PINLABEL:
344  case NET_BUSLABELMEMBER:
346  labelConnect( GetItem( ii ) );
347  break;
348 
350  case NET_HIERLABEL:
352  break;
353 
355  break;
356  }
357  }
358 
359 #if defined(NETLIST_DEBUG) && defined(DEBUG)
360  std::cout << "\n\nafter sheet global\n\n";
361  DumpNetTable();
362 #endif
363 
364  // Connection between hierarchy sheets
365  for( unsigned ii = 0; ii < size(); ii++ )
366  {
367  if( GetItem( ii )->m_Type == NET_SHEETLABEL
368  || GetItem( ii )->m_Type == NET_SHEETBUSLABELMEMBER )
369  sheetLabelConnect( GetItem( ii ) );
370  }
371 
372  // Sort objects by NetCode
374 
375 #if defined(NETLIST_DEBUG) && defined(DEBUG)
376  std::cout << "\n\nafter qsort()\n";
377  DumpNetTable();
378 #endif
379 
380  // Compress numbers of Netcode having consecutive values.
381  int NetCode = 0;
382  m_lastNetCode = 0;
383 
384  for( unsigned ii = 0; ii < size(); ii++ )
385  {
386  if( GetItem( ii )->GetNet() != m_lastNetCode )
387  {
388  NetCode++;
389  m_lastNetCode = GetItem( ii )->GetNet();
390  }
391 
392  GetItem( ii )->SetNet( NetCode );
393  }
394 
395  // Set the minimal connection info:
397 
398  // find the best label object to give the best net name to each net
400 
401  return true;
402 }
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
Function GetDrawItems().
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 146 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().

147 {
148  NETLIST_OBJECTS::iterator iter;
149 
150  for( iter = begin(); iter != end(); iter++ )
151  {
152  NETLIST_OBJECT* item = *iter;
153  delete item;
154  }
155 
156  clear();
157 }
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 649 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().

650 {
651  // Propagate the net code between all bus label member objects connected by they name.
652  // If the net code is not yet existing, a new one is created
653  // Search is done in the entire list
654  for( unsigned ii = 0; ii < size(); ii++ )
655  {
656  NETLIST_OBJECT* Label = GetItem( ii );
657 
658  if( Label->IsLabelBusMemberType() )
659  {
660  if( Label->GetNet() == 0 )
661  {
662  // Not yet existiing net code: create a new one.
663  Label->SetNet( m_lastNetCode );
664  m_lastNetCode++;
665  }
666 
667  for( unsigned jj = ii + 1; jj < size(); jj++ )
668  {
669  NETLIST_OBJECT* LabelInTst = GetItem( jj );
670 
671  if( LabelInTst->IsLabelBusMemberType() )
672  {
673  if( LabelInTst->m_BusNetCode != Label->m_BusNetCode )
674  continue;
675 
676  if( LabelInTst->m_Member != Label->m_Member )
677  continue;
678 
679  if( LabelInTst->GetNet() == 0 )
680  // Append this object to the current net
681  LabelInTst->SetNet( Label->GetNet() );
682  else
683  // Merge the 2 net codes, they are connected.
684  propagateNetCode( LabelInTst->GetNet(), Label->GetNet(), IS_WIRE );
685  }
686  }
687  }
688  }
689 }
#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 506 of file erc.cpp.

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

507 {
508  int count = 0;
509  int curr_net = GetItemNet( aNetStart );
510 
511  /* Test pins connected to NetItemRef */
512  for( unsigned item = aNetStart; item < size(); item++ )
513  {
514  // We examine only a given net. We stop the search if the net changes
515  if( curr_net != GetItemNet( item ) ) // End of net
516  break;
517 
518  if( GetItemType( item ) == NET_PIN )
519  count++;
520  }
521 
522  return count;
523 }
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 471 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().

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

860 {
861  if( aLabelRef->GetNet() == 0 )
862  return;
863 
864  for( unsigned i = 0; i < size(); i++ )
865  {
866  NETLIST_OBJECT* item = GetItem( i );
867 
868  if( item->GetNet() == aLabelRef->GetNet() )
869  continue;
870 
871  if( item->m_SheetPath != aLabelRef->m_SheetPath )
872  {
873  if( item->m_Type != NET_PINLABEL && item->m_Type != NET_GLOBLABEL
874  && item->m_Type != NET_GLOBBUSLABELMEMBER )
875  continue;
876 
877  if( (item->m_Type == NET_GLOBLABEL
878  || item->m_Type == NET_GLOBBUSLABELMEMBER)
879  && item->m_Type != aLabelRef->m_Type )
880  //global labels only connect other global labels.
881  continue;
882  }
883 
884  // NET_HIERLABEL are used to connect sheets.
885  // NET_LABEL are local to a sheet
886  // NET_GLOBLABEL are global.
887  // NET_PINLABEL is a kind of global label (generated by a power pin invisible)
888  if( item->IsLabelType() )
889  {
890  if( item->m_Label != aLabelRef->m_Label )
891  continue;
892 
893  if( item->GetNet() )
894  propagateNetCode( item->GetNet(), aLabelRef->GetNet(), IS_WIRE );
895  else
896  item->SetNet( aLabelRef->GetNet() );
897  }
898  }
899 }
#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 720 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().

721 {
722  int netCode;
723 
724  if( aIsBus == false ) // Objects other than BUS and BUSLABELS
725  {
726  netCode = aRef->GetNet();
727 
728  for( unsigned i = start; i < size(); i++ )
729  {
730  NETLIST_OBJECT* item = GetItem( i );
731 
732  if( item->m_SheetPath != aRef->m_SheetPath ) //used to be > (why?)
733  continue;
734 
735  switch( item->m_Type )
736  {
737  case NET_SEGMENT:
738  case NET_PIN:
739  case NET_LABEL:
740  case NET_HIERLABEL:
741  case NET_GLOBLABEL:
742  case NET_SHEETLABEL:
743  case NET_PINLABEL:
744  case NET_JUNCTION:
745  case NET_NOCONNECT:
746  if( aRef->m_Start == item->m_Start
747  || aRef->m_Start == item->m_End
748  || aRef->m_End == item->m_Start
749  || aRef->m_End == item->m_End )
750  {
751  if( item->GetNet() == 0 )
752  item->SetNet( netCode );
753  else
754  propagateNetCode( item->GetNet(), netCode, IS_WIRE );
755  }
756  break;
757 
758  case NET_BUS:
759  case NET_BUSLABELMEMBER:
764  break;
765  }
766  }
767  }
768  else // Object type BUS, BUSLABELS, and junctions.
769  {
770  netCode = aRef->m_BusNetCode;
771 
772  for( unsigned i = start; i < size(); i++ )
773  {
774  NETLIST_OBJECT* item = GetItem( i );
775 
776  if( item->m_SheetPath != aRef->m_SheetPath )
777  continue;
778 
779  switch( item->m_Type )
780  {
782  case NET_SEGMENT:
783  case NET_PIN:
784  case NET_LABEL:
785  case NET_HIERLABEL:
786  case NET_GLOBLABEL:
787  case NET_SHEETLABEL:
788  case NET_PINLABEL:
789  case NET_NOCONNECT:
790  break;
791 
792  case NET_BUS:
793  case NET_BUSLABELMEMBER:
797  case NET_JUNCTION:
798  if( aRef->m_Start == item->m_Start
799  || aRef->m_Start == item->m_End
800  || aRef->m_End == item->m_Start
801  || aRef->m_End == item->m_End )
802  {
803  if( item->m_BusNetCode == 0 )
804  item->m_BusNetCode = netCode;
805  else
806  propagateNetCode( item->m_BusNetCode, netCode, IS_BUS );
807  }
808  break;
809  }
810  }
811  }
812 }
#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 692 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().

693 {
694  if( aOldNetCode == aNewNetCode )
695  return;
696 
697  if( aIsBus == false ) // Propagate NetCode
698  {
699  for( unsigned jj = 0; jj < size(); jj++ )
700  {
701  NETLIST_OBJECT* object = GetItem( jj );
702 
703  if( object->GetNet() == aOldNetCode )
704  object->SetNet( aNewNetCode );
705  }
706  }
707  else // Propagate BusNetCode
708  {
709  for( unsigned jj = 0; jj < size(); jj++ )
710  {
711  NETLIST_OBJECT* object = GetItem( jj );
712 
713  if( object->m_BusNetCode == aOldNetCode )
714  object->m_BusNetCode = aNewNetCode;
715  }
716  }
717 }
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 815 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().

817 {
818  for( unsigned i = aIdxStart; i < size(); i++ )
819  {
820  NETLIST_OBJECT* segment = GetItem( i );
821 
822  // if different sheets, obviously no physical connection between elements.
823  if( segment->m_SheetPath != aJonction->m_SheetPath )
824  continue;
825 
826  if( aIsBus == IS_WIRE )
827  {
828  if( segment->m_Type != NET_SEGMENT )
829  continue;
830  }
831  else
832  {
833  if( segment->m_Type != NET_BUS )
834  continue;
835  }
836 
837  if( IsPointOnSegment( segment->m_Start, segment->m_End, aJonction->m_Start ) )
838  {
839  // Propagation Netcode has all the objects of the same Netcode.
840  if( aIsBus == IS_WIRE )
841  {
842  if( segment->GetNet() )
843  propagateNetCode( segment->GetNet(), aJonction->GetNet(), aIsBus );
844  else
845  segment->SetNet( aJonction->GetNet() );
846  }
847  else
848  {
849  if( segment->m_BusNetCode )
850  propagateNetCode( segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
851  else
852  segment->m_BusNetCode = aJonction->m_BusNetCode;
853  }
854  }
855  }
856 }
#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 902 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().

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

620 {
621  if( SheetLabel->GetNet() == 0 )
622  return;
623 
624  for( unsigned ii = 0; ii < size(); ii++ )
625  {
626  NETLIST_OBJECT* ObjetNet = GetItem( ii );
627 
628  if( ObjetNet->m_SheetPath != SheetLabel->m_SheetPathInclude )
629  continue; //use SheetInclude, not the sheet!!
630 
631  if( (ObjetNet->m_Type != NET_HIERLABEL ) && (ObjetNet->m_Type != NET_HIERBUSLABELMEMBER ) )
632  continue;
633 
634  if( ObjetNet->GetNet() == SheetLabel->GetNet() )
635  continue; //already connected.
636 
637  if( ObjetNet->m_Label != SheetLabel->m_Label )
638  continue; //different names.
639 
640  // Propagate Netcode having all the objects of the same Netcode.
641  if( ObjetNet->GetNet() )
642  propagateNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), IS_WIRE );
643  else
644  ObjetNet->SetNet( SheetLabel->GetNet() );
645  }
646 }
#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 160 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().

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

Definition at line 166 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().

167 {
168  sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsBySheet );
169 }
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 584 of file erc.cpp.

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

585 {
586  unsigned netItemTst = aStartNet;
587  int erc = 1;
588 
589  // Review the list of labels connected to NetItemRef:
590  for( ; ; netItemTst++ )
591  {
592  if( netItemTst == aNetItemRef )
593  continue;
594 
595  /* Is always in the same net? */
596  if( ( netItemTst == size() )
597  || ( GetItemNet( aNetItemRef ) != GetItemNet( netItemTst ) ) )
598  {
599  /* End Netcode found. */
600  if( erc )
601  {
602  /* Glabel or SheetLabel orphaned. */
603  Diagnose( GetItem( aNetItemRef ), NULL, -1, WAR );
604  }
605 
606  return;
607  }
608 
609  if( GetItem( aNetItemRef )->IsLabelConnected( GetItem( netItemTst ) ) )
610  erc = 0;
611 
612  //same thing, different order.
613  if( GetItem( netItemTst )->IsLabelConnected( GetItem( aNetItemRef ) ) )
614  erc = 0;
615  }
616 }
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 658 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().

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

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: