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 <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 299 of file netlist_object.h.

Constructor & Destructor Documentation

◆ NETLIST_OBJECT_LIST()

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 311 of file netlist_object.h.

312  {
313  // Do not leave some members uninitialized:
314  m_lastNetCode = 0;
315  m_lastBusNetCode = 0;
316  }

References m_lastBusNetCode, and m_lastNetCode.

◆ ~NETLIST_OBJECT_LIST()

NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST ( )

Definition at line 40 of file netlist_object_list.cpp.

41 {
42  Clear();
43 }
void Clear()
Delete all objects in list and clear list.

References Clear().

Member Function Documentation

◆ BuildNetListInfo()

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 72 of file netlist_object_list.cpp.

73 {
74  SCH_SHEET_PATH* sheet;
75 
76  // Fill list with connected items from the flattened sheet list
77  for( unsigned i = 0; i < aSheets.size(); i++ )
78  {
79  sheet = &aSheets[i];
80 
81  for( SCH_ITEM* item = sheet->LastScreen()->GetDrawItems(); item; item = item->Next() )
82  {
83  item->GetNetListItem( *this, sheet );
84  }
85  }
86 
87  if( size() == 0 )
88  return false;
89 
90  // Sort objects by Sheet
92 
93  sheet = &(GetItem( 0 )->m_SheetPath);
95 
96  for( unsigned ii = 0, istart = 0; ii < size(); ii++ )
97  {
98  NETLIST_OBJECT* net_item = GetItem( ii );
99 
100  if( net_item->m_SheetPath != *sheet ) // Sheet change
101  {
102  sheet = &(net_item->m_SheetPath);
103  istart = ii;
104  }
105 
106  switch( net_item->m_Type )
107  {
109  wxMessageBox( wxT( "BuildNetListInfo() error" ) );
110  break;
111 
112  case NET_PIN:
113  case NET_PINLABEL:
114  case NET_SHEETLABEL:
115  case NET_NOCONNECT:
116  if( net_item->GetNet() != 0 )
117  break;
118 
119  case NET_SEGMENT:
120  // Test connections point to point type without bus.
121  if( net_item->GetNet() == 0 )
122  {
123  net_item->SetNet( m_lastNetCode );
124  m_lastNetCode++;
125  }
126 
127  pointToPointConnect( net_item, IS_WIRE, istart );
128  break;
129 
130  case NET_JUNCTION:
131  // Control of the junction outside BUS.
132  if( net_item->GetNet() == 0 )
133  {
134  net_item->SetNet( m_lastNetCode );
135  m_lastNetCode++;
136  }
137 
138  segmentToPointConnect( net_item, IS_WIRE, istart );
139 
140  // Control of the junction, on BUS.
141  if( net_item->m_BusNetCode == 0 )
142  {
143  net_item->m_BusNetCode = m_lastBusNetCode;
145  }
146 
147  segmentToPointConnect( net_item, IS_BUS, istart );
148  break;
149 
150  case NET_LABEL:
151  case NET_HIERLABEL:
152  case NET_GLOBLABEL:
153  // Test connections type junction without bus.
154  if( net_item->GetNet() == 0 )
155  {
156  net_item->SetNet( m_lastNetCode );
157  m_lastNetCode++;
158  }
159 
160  segmentToPointConnect( net_item, IS_WIRE, istart );
161  break;
162 
164  if( net_item->m_BusNetCode != 0 )
165  break;
166 
167  case NET_BUS:
168  // Control type connections point to point mode bus
169  if( net_item->m_BusNetCode == 0 )
170  {
171  net_item->m_BusNetCode = m_lastBusNetCode;
173  }
174 
175  pointToPointConnect( net_item, IS_BUS, istart );
176  break;
177 
178  case NET_BUSLABELMEMBER:
181  // Control connections similar has on BUS
182  if( net_item->GetNet() == 0 )
183  {
184  net_item->m_BusNetCode = m_lastBusNetCode;
186  }
187 
188  segmentToPointConnect( net_item, IS_BUS, istart );
189  break;
190  }
191  }
192 
193 #if defined(NETLIST_DEBUG) && defined(DEBUG)
194  std::cout << "\n\nafter sheet local\n\n";
195  DumpNetTable();
196 #endif
197 
198  // Updating the Bus Labels Netcode connected by Bus
200 
201  // Group objects by label.
202  for( unsigned ii = 0; ii < size(); ii++ )
203  {
204  switch( GetItem( ii )->m_Type )
205  {
206  case NET_PIN:
207  case NET_SHEETLABEL:
208  case NET_SEGMENT:
209  case NET_JUNCTION:
210  case NET_BUS:
211  case NET_NOCONNECT:
212  break;
213 
214  case NET_LABEL:
215  case NET_GLOBLABEL:
216  case NET_PINLABEL:
217  case NET_BUSLABELMEMBER:
219  labelConnect( GetItem( ii ) );
220  break;
221 
223  case NET_HIERLABEL:
225  break;
226 
228  break;
229  }
230  }
231 
232 #if defined(NETLIST_DEBUG) && defined(DEBUG)
233  std::cout << "\n\nafter sheet global\n\n";
234  DumpNetTable();
235 #endif
236 
237  // Connection between hierarchy sheets
238  for( unsigned ii = 0; ii < size(); ii++ )
239  {
240  if( GetItem( ii )->m_Type == NET_SHEETLABEL
241  || GetItem( ii )->m_Type == NET_SHEETBUSLABELMEMBER )
242  sheetLabelConnect( GetItem( ii ) );
243  }
244 
245  // Sort objects by NetCode
247 
248 #if defined(NETLIST_DEBUG) && defined(DEBUG)
249  std::cout << "\n\nafter qsort()\n";
250  DumpNetTable();
251 #endif
252 
253  // Compress numbers of Netcode having consecutive values.
254  int NetCode = 0;
255  m_lastNetCode = 0;
256 
257  for( unsigned ii = 0; ii < size(); ii++ )
258  {
259  if( GetItem( ii )->GetNet() != m_lastNetCode )
260  {
261  NetCode++;
262  m_lastNetCode = GetItem( ii )->GetNet();
263  }
264 
265  GetItem( ii )->SetNet( NetCode );
266  }
267 
268  // Set the minimal connection info:
270 
271  // find the best label object to give the best net name to each net
273 
274  return true;
275 }
void setUnconnectedFlag()
Set the m_FlagOfConnection member of items in list depending on the connection type: UNCONNECTED,...
void connectBusLabels()
Function connectBusLabels Propagate the net code (and create it, if not yet existing) between all bus...
SCH_ITEM * Next() const
Definition: sch_item.h:153
int GetNet() const
#define IS_BUS
SCH_SHEET_PATH m_SheetPath
void findBestNetNameForEachNet()
Function findBestNetNameForEachNet fill the .m_NetNameCandidate member of each item of aNetItemBuffer...
NETLIST_ITEM_T m_Type
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.
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_WIRE
Class SCH_SHEET_PATH.
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
size_t i
Definition: json11.cpp:597
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...
Definition: sch_item.h:114
SCH_SCREEN * LastScreen() const
Function LastScreen.
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:152

References connectBusLabels(), findBestNetNameForEachNet(), SCH_SCREEN::GetDrawItems(), GetItem(), NETLIST_OBJECT::GetNet(), i, 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(), SortListbyNetcode(), and SortListbySheet().

◆ Clear()

void NETLIST_OBJECT_LIST::Clear ( )

Delete all objects in list and clear list.

Definition at line 46 of file netlist_object_list.cpp.

47 {
48  NETLIST_OBJECTS::iterator iter;
49 
50  for( iter = begin(); iter != end(); iter++ )
51  {
52  NETLIST_OBJECT* item = *iter;
53  delete item;
54  }
55 
56  clear();
57 }

Referenced by ~NETLIST_OBJECT_LIST().

◆ connectBusLabels()

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 520 of file netlist_object_list.cpp.

521 {
522  // Propagate the net code between all bus label member objects connected by they name.
523  // If the net code is not yet existing, a new one is created
524  // Search is done in the entire list
525  for( unsigned ii = 0; ii < size(); ii++ )
526  {
527  NETLIST_OBJECT* Label = GetItem( ii );
528 
529  if( Label->IsLabelBusMemberType() )
530  {
531  if( Label->GetNet() == 0 )
532  {
533  // Not yet existiing net code: create a new one.
534  Label->SetNet( m_lastNetCode );
535  m_lastNetCode++;
536  }
537 
538  for( unsigned jj = ii + 1; jj < size(); jj++ )
539  {
540  NETLIST_OBJECT* LabelInTst = GetItem( jj );
541 
542  if( LabelInTst->IsLabelBusMemberType() )
543  {
544  if( LabelInTst->m_BusNetCode != Label->m_BusNetCode )
545  continue;
546 
547  if( LabelInTst->m_Member != Label->m_Member )
548  continue;
549 
550  if( LabelInTst->GetNet() == 0 )
551  // Append this object to the current net
552  LabelInTst->SetNet( Label->GetNet() );
553  else
554  // Merge the 2 net codes, they are connected.
555  propagateNetCode( LabelInTst->GetNet(), Label->GetNet(), IS_WIRE );
556  }
557  }
558  }
559  }
560 }
int GetNet() const
bool IsLabelBusMemberType() const
Function IsLabelBusMemberType.
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
#define IS_WIRE
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
void SetNet(int aNetCode)

References GetItem(), NETLIST_OBJECT::GetNet(), IS_WIRE, NETLIST_OBJECT::IsLabelBusMemberType(), NETLIST_OBJECT::m_BusNetCode, m_lastNetCode, NETLIST_OBJECT::m_Member, propagateNetCode(), and NETLIST_OBJECT::SetNet().

Referenced by BuildNetListInfo().

◆ CountPinsInNet()

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 550 of file erc.cpp.

551 {
552  int count = 0;
553  int curr_net = GetItemNet( aNetStart );
554 
555  /* Test pins connected to NetItemRef */
556  for( unsigned item = aNetStart; item < size(); item++ )
557  {
558  // We examine only a given net. We stop the search if the net changes
559  if( curr_net != GetItemNet( item ) ) // End of net
560  break;
561 
562  if( GetItemType( item ) == NET_PIN )
563  count++;
564  }
565 
566  return count;
567 }
int GetItemNet(unsigned aIdx) const
Acces to an item net code.
NETLIST_ITEM_T GetItemType(unsigned aIdx) const
Acces to an item type.

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

◆ findBestNetNameForEachNet()

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 344 of file netlist_object_list.cpp.

345 {
346  // Important note: NET_SHEETLABEL items of sheet items should *NOT* be considered,
347  // because they live in a sheet but their names are actually used in the subsheet.
348  // Moreover, in the parent sheet, the name of NET_SHEETLABEL can be not unique,
349  // ( for instance when 2 different sheets share the same schematic in complex hierarchies
350  // and 2 identical NET_SHEETLABEL labels can be connected to 2 different nets
351 
352  int netcode = 0; // current netcode for tested items
353  unsigned idxstart = 0; // index of the first item of this net
354  NETLIST_OBJECT* item;
355  NETLIST_OBJECT* candidate;
356 
357  // Pass 1: find the best name for labelled nets:
358  candidate = NULL;
359  for( unsigned ii = 0; ii <= size(); ii++ )
360  {
361  if( ii == size() ) // last item already tested
362  item = NULL;
363  else
364  item = GetItem( ii );
365 
366  if( !item || netcode != item->GetNet() ) // End of net found
367  {
368  if( candidate ) // One or more labels exists, find the best
369  {
370  for (unsigned jj = idxstart; jj < ii; jj++ )
371  GetItem( jj )->SetNetNameCandidate( candidate );
372  }
373 
374  if( item == NULL ) // End of list
375  break;
376 
377  // Prepare next net analysis:
378  netcode = item->GetNet();
379  candidate = NULL;
380  idxstart = ii;
381  }
382 
383  switch( item->m_Type )
384  {
385  case NET_HIERLABEL:
386  case NET_LABEL:
387  case NET_PINLABEL:
388  case NET_GLOBLABEL:
390  // A candidate is found: select the better between the previous and this one
391  if( candidate == NULL )
392  candidate = item;
393  else
394  {
395  if( evalLabelsPriority( item, candidate ) )
396  // item has a higher priority than candidate so update the best candidate
397  candidate = item;
398  }
399  break;
400 
401  default:
402  break;
403  }
404  }
405 
406  // Pass 2: find the best name for not labelled nets:
407  // The "default" net name is Net-<<Ref cmp>_Pad<num pad>>
408  // (see NETLIST_OBJECT::GetShortNetName())
409  // therefore the "best" is the short net name alphabetically classed first
410  // (to avoid net names changes when the net is not modified,
411  // even if components are moved or deleted and undelete or replaced, as long
412  // the reference is kept)
413 
414  // Build a list of items with no net names
415  NETLIST_OBJECTS list; // no ownership of elements being pointed at
416 
417  for( unsigned ii = 0; ii < size(); ii++ )
418  {
419  item = GetItem( ii );
420 
421  if( !item->HasNetNameCandidate() )
422  list.push_back( item );
423  }
424 
425  if( list.size() == 0 )
426  return;
427 
428  idxstart = 0;
429  candidate = NULL;
430  netcode = list[0]->GetNet();
431 
432  for( unsigned ii = 0; ii <= list.size(); ii++ )
433  {
434  if( ii < list.size() )
435  item = list[ii];
436  else
437  item = NULL;
438 
439  if( !item || netcode != item->GetNet() ) // End of net found
440  {
441  if( candidate )
442  {
443  for (unsigned jj = idxstart; jj < ii; jj++ )
444  {
445  NETLIST_OBJECT* obj = list[jj];
446  obj->SetNetNameCandidate( candidate );
447  }
448  }
449 
450  if( !item )
451  break;
452 
453  netcode = item->GetNet();
454  candidate = NULL;
455  idxstart = ii;
456  }
457 
458  // Examine all pins of the net to find the best candidate,
459  // i.e. the first net name candidate, by alphabetic order
460  // the net names are built by GetShortNetName
461  // (Net-<{reference}-Pad{pad number}> like Net-<U3-Pad5>
462  // Not named nets do not have usually a lot of members.
463  // Many have only 2 members(a pad and a non connection symbol)
464  if( item->m_Type == NET_PIN )
465  {
466  // A candidate is found, however components which are not in
467  // netlist are not candidate because some have their reference
468  // changed each time the netlist is built (power components)
469  // and anyway obviously they are not a good candidate
470  SCH_COMPONENT* link = item->GetComponentParent();
471 
472  if( link && link->IsInNetlist() )
473  {
474  // select the better between the previous and this one
475  item->SetNetNameCandidate( item ); // Needed to calculate GetShortNetName
476 
477  if( candidate == NULL )
478  candidate = item;
479  else
480  {
481  if( item->GetShortNetName().Cmp( candidate->GetShortNetName() ) < 0 )
482  candidate = item;
483  }
484  }
485  }
486  }
487 }
SCH_COMPONENT * GetComponentParent() const
For Pins (NET_PINS):
static bool evalLabelsPriority(const NETLIST_OBJECT *aLabel1, const NETLIST_OBJECT *aLabel2)
int GetNet() const
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
NETLIST_ITEM_T m_Type
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
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:73
wxString GetShortNetName(bool adoptTimestamp=false) const
Function GetShortNetName.
bool HasNetNameCandidate()

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, and NETLIST_OBJECT::SetNetNameCandidate().

Referenced by BuildNetListInfo().

◆ GetConnectionType()

NET_CONNECTION_T NETLIST_OBJECT_LIST::GetConnectionType ( unsigned  aIdx)
inline

Definition at line 354 of file netlist_object.h.

355  {
356  return GetItem( aIdx )->GetConnectionType();
357  }
NET_CONNECTION_T GetConnectionType() const
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.

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

Referenced by TestOthersItems().

◆ GetItem()

◆ GetItemNet()

int NETLIST_OBJECT_LIST::GetItemNet ( unsigned  aIdx) const
inline

Acces to an item net code.

Definition at line 349 of file netlist_object.h.

350  {
351  return GetItem( aIdx )->GetNet();
352  }
int GetNet() const
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.

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

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

◆ GetItemType()

NETLIST_ITEM_T NETLIST_OBJECT_LIST::GetItemType ( unsigned  aIdx) const
inline

Acces to an item type.

Definition at line 341 of file netlist_object.h.

342  {
343  return GetItem( aIdx )->m_Type;
344  }
NETLIST_ITEM_T m_Type
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.

References GetItem(), and NETLIST_OBJECT::m_Type.

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

◆ labelConnect()

void NETLIST_OBJECT_LIST::labelConnect ( NETLIST_OBJECT aLabelRef)
private

Definition at line 730 of file netlist_object_list.cpp.

731 {
732  if( aLabelRef->GetNet() == 0 )
733  return;
734 
735  for( unsigned i = 0; i < size(); i++ )
736  {
737  NETLIST_OBJECT* item = GetItem( i );
738 
739  if( item->GetNet() == aLabelRef->GetNet() )
740  continue;
741 
742  if( item->m_SheetPath != aLabelRef->m_SheetPath )
743  {
744  if( item->m_Type != NET_PINLABEL && item->m_Type != NET_GLOBLABEL
745  && item->m_Type != NET_GLOBBUSLABELMEMBER )
746  continue;
747 
748  if( (item->m_Type == NET_GLOBLABEL
749  || item->m_Type == NET_GLOBBUSLABELMEMBER)
750  && item->m_Type != aLabelRef->m_Type )
751  //global labels only connect other global labels.
752  continue;
753  }
754 
755  // NET_HIERLABEL are used to connect sheets.
756  // NET_LABEL are local to a sheet
757  // NET_GLOBLABEL are global.
758  // NET_PINLABEL is a kind of global label (generated by a power pin invisible)
759  if( item->IsLabelType() )
760  {
761  if( item->m_Label != aLabelRef->m_Label )
762  continue;
763 
764  if( item->GetNet() )
765  propagateNetCode( item->GetNet(), aLabelRef->GetNet(), IS_WIRE );
766  else
767  item->SetNet( aLabelRef->GetNet() );
768  }
769  }
770 }
int GetNet() const
SCH_SHEET_PATH m_SheetPath
bool IsLabelType() const
Function IsLabelType.
NETLIST_ITEM_T m_Type
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
#define IS_WIRE
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
size_t i
Definition: json11.cpp:597
void SetNet(int aNetCode)

References GetItem(), NETLIST_OBJECT::GetNet(), i, IS_WIRE, NETLIST_OBJECT::IsLabelType(), NETLIST_OBJECT::m_Label, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_Type, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_PINLABEL, propagateNetCode(), and NETLIST_OBJECT::SetNet().

Referenced by BuildNetListInfo().

◆ pointToPointConnect()

void NETLIST_OBJECT_LIST::pointToPointConnect ( NETLIST_OBJECT aRef,
bool  aIsBus,
int  start 
)
private

Definition at line 591 of file netlist_object_list.cpp.

592 {
593  int netCode;
594 
595  if( aIsBus == false ) // Objects other than BUS and BUSLABELS
596  {
597  netCode = aRef->GetNet();
598 
599  for( unsigned i = start; i < size(); i++ )
600  {
601  NETLIST_OBJECT* item = GetItem( i );
602 
603  if( item->m_SheetPath != aRef->m_SheetPath ) //used to be > (why?)
604  continue;
605 
606  switch( item->m_Type )
607  {
608  case NET_SEGMENT:
609  case NET_PIN:
610  case NET_LABEL:
611  case NET_HIERLABEL:
612  case NET_GLOBLABEL:
613  case NET_SHEETLABEL:
614  case NET_PINLABEL:
615  case NET_JUNCTION:
616  case NET_NOCONNECT:
617  if( aRef->m_Start == item->m_Start
618  || aRef->m_Start == item->m_End
619  || aRef->m_End == item->m_Start
620  || aRef->m_End == item->m_End )
621  {
622  if( item->GetNet() == 0 )
623  item->SetNet( netCode );
624  else
625  propagateNetCode( item->GetNet(), netCode, IS_WIRE );
626  }
627  break;
628 
629  case NET_BUS:
630  case NET_BUSLABELMEMBER:
635  break;
636  }
637  }
638  }
639  else // Object type BUS, BUSLABELS, and junctions.
640  {
641  netCode = aRef->m_BusNetCode;
642 
643  for( unsigned i = start; i < size(); i++ )
644  {
645  NETLIST_OBJECT* item = GetItem( i );
646 
647  if( item->m_SheetPath != aRef->m_SheetPath )
648  continue;
649 
650  switch( item->m_Type )
651  {
653  case NET_SEGMENT:
654  case NET_PIN:
655  case NET_LABEL:
656  case NET_HIERLABEL:
657  case NET_GLOBLABEL:
658  case NET_SHEETLABEL:
659  case NET_PINLABEL:
660  case NET_NOCONNECT:
661  break;
662 
663  case NET_BUS:
664  case NET_BUSLABELMEMBER:
668  case NET_JUNCTION:
669  if( aRef->m_Start == item->m_Start
670  || aRef->m_Start == item->m_End
671  || aRef->m_End == item->m_Start
672  || aRef->m_End == item->m_End )
673  {
674  if( item->m_BusNetCode == 0 )
675  item->m_BusNetCode = netCode;
676  else
677  propagateNetCode( item->m_BusNetCode, netCode, IS_BUS );
678  }
679  break;
680  }
681  }
682  }
683 }
int GetNet() const
#define IS_BUS
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
#define IS_WIRE
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
size_t i
Definition: json11.cpp:597
void SetNet(int aNetCode)

References GetItem(), NETLIST_OBJECT::GetNet(), i, 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(), and NETLIST_OBJECT::SetNet().

Referenced by BuildNetListInfo().

◆ propagateNetCode()

void NETLIST_OBJECT_LIST::propagateNetCode ( int  aOldNetCode,
int  aNewNetCode,
bool  aIsBus 
)
private

Definition at line 563 of file netlist_object_list.cpp.

564 {
565  if( aOldNetCode == aNewNetCode )
566  return;
567 
568  if( aIsBus == false ) // Propagate NetCode
569  {
570  for( unsigned jj = 0; jj < size(); jj++ )
571  {
572  NETLIST_OBJECT* object = GetItem( jj );
573 
574  if( object->GetNet() == aOldNetCode )
575  object->SetNet( aNewNetCode );
576  }
577  }
578  else // Propagate BusNetCode
579  {
580  for( unsigned jj = 0; jj < size(); jj++ )
581  {
582  NETLIST_OBJECT* object = GetItem( jj );
583 
584  if( object->m_BusNetCode == aOldNetCode )
585  object->m_BusNetCode = aNewNetCode;
586  }
587  }
588 }
int GetNet() const
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
void SetNet(int aNetCode)

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

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

◆ ResetConnectionsType()

void NETLIST_OBJECT_LIST::ResetConnectionsType ( )
inline

Reset the connection type of all items to UNCONNECTED type.

Definition at line 377 of file netlist_object.h.

378  {
379  for( unsigned ii = 0; ii < size(); ii++ )
381  }
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...

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

◆ segmentToPointConnect()

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 686 of file netlist_object_list.cpp.

688 {
689  for( unsigned i = aIdxStart; i < size(); i++ )
690  {
691  NETLIST_OBJECT* segment = GetItem( i );
692 
693  // if different sheets, obviously no physical connection between elements.
694  if( segment->m_SheetPath != aJonction->m_SheetPath )
695  continue;
696 
697  if( aIsBus == IS_WIRE )
698  {
699  if( segment->m_Type != NET_SEGMENT )
700  continue;
701  }
702  else
703  {
704  if( segment->m_Type != NET_BUS )
705  continue;
706  }
707 
708  if( IsPointOnSegment( segment->m_Start, segment->m_End, aJonction->m_Start ) )
709  {
710  // Propagation Netcode has all the objects of the same Netcode.
711  if( aIsBus == IS_WIRE )
712  {
713  if( segment->GetNet() )
714  propagateNetCode( segment->GetNet(), aJonction->GetNet(), aIsBus );
715  else
716  segment->SetNet( aJonction->GetNet() );
717  }
718  else
719  {
720  if( segment->m_BusNetCode )
721  propagateNetCode( segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
722  else
723  segment->m_BusNetCode = aJonction->m_BusNetCode;
724  }
725  }
726  }
727 }
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Function IsPointOnSegment.
Definition: trigo.cpp:40
int GetNet() const
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
#define IS_WIRE
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
size_t i
Definition: json11.cpp:597
void SetNet(int aNetCode)

References GetItem(), NETLIST_OBJECT::GetNet(), i, 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(), and NETLIST_OBJECT::SetNet().

Referenced by BuildNetListInfo().

◆ SetConnectionType()

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 366 of file netlist_object.h.

367  {
368  GetItem( aIdx )->SetConnectionType( aFlg );
369  }
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...

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

Referenced by TestOthersItems().

◆ setUnconnectedFlag()

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 773 of file netlist_object_list.cpp.

774 {
775  NETLIST_OBJECT* NetItemRef;
776  unsigned NetStart, NetEnd;
777  NET_CONNECTION_T StateFlag;
778 
779  NetStart = NetEnd = 0;
780  StateFlag = UNCONNECTED;
781  for( unsigned ii = 0; ii < size(); ii++ )
782  {
783  NetItemRef = GetItem( ii );
784  if( NetItemRef->m_Type == NET_NOCONNECT && StateFlag != PAD_CONNECT )
785  StateFlag = NOCONNECT_SYMBOL_PRESENT;
786 
787  // Analysis of current net.
788  unsigned idxtoTest = ii + 1;
789 
790  if( ( idxtoTest >= size() )
791  || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
792  {
793  // Net analysis to update m_ConnectionType
794  NetEnd = idxtoTest;
795 
796  /* set m_ConnectionType member to StateFlag for all items of
797  * this net: */
798  for( unsigned kk = NetStart; kk < NetEnd; kk++ )
799  GetItem( kk )->m_ConnectionType = StateFlag;
800 
801  if( idxtoTest >= size() )
802  return;
803 
804  // Start Analysis next Net
805  StateFlag = UNCONNECTED;
806  NetStart = idxtoTest;
807  continue;
808  }
809 
810  /* test the current item: if this is a pin and if the reference item
811  * is also a pin, then 2 pins are connected, so set StateFlag to
812  * PAD_CONNECT (can be already done) Of course, if the current
813  * item is a no connect symbol, set StateFlag to
814  * NOCONNECT_SYMBOL_PRESENT to inhibit error diags. However if
815  * StateFlag is already set to PAD_CONNECT this state is kept (the
816  * no connect symbol was surely an error and an ERC will report this)
817  */
818  for( ; ; idxtoTest++ )
819  {
820  if( ( idxtoTest >= size() )
821  || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
822  break;
823 
824  switch( GetItem( idxtoTest )->m_Type )
825  {
827  wxMessageBox( wxT( "BuildNetListBase() error" ) );
828  break;
829 
830  case NET_SEGMENT:
831  case NET_LABEL:
832  case NET_HIERLABEL:
833  case NET_GLOBLABEL:
834  case NET_SHEETLABEL:
835  case NET_PINLABEL:
836  case NET_BUS:
837  case NET_BUSLABELMEMBER:
841  case NET_JUNCTION:
842  break;
843 
844  case NET_PIN:
845  if( NetItemRef->m_Type == NET_PIN )
846  StateFlag = PAD_CONNECT;
847 
848  break;
849 
850  case NET_NOCONNECT:
851  if( StateFlag != PAD_CONNECT )
852  StateFlag = NOCONNECT_SYMBOL_PRESENT;
853 
854  break;
855  }
856  }
857  }
858 }
int GetNet() const
NET_CONNECTION_T
NET_CONNECTION_T m_ConnectionType
NETLIST_ITEM_T m_Type
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.

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, and UNCONNECTED.

Referenced by BuildNetListInfo().

◆ sheetLabelConnect()

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 490 of file netlist_object_list.cpp.

491 {
492  if( SheetLabel->GetNet() == 0 )
493  return;
494 
495  for( unsigned ii = 0; ii < size(); ii++ )
496  {
497  NETLIST_OBJECT* ObjetNet = GetItem( ii );
498 
499  if( ObjetNet->m_SheetPath != SheetLabel->m_SheetPathInclude )
500  continue; //use SheetInclude, not the sheet!!
501 
502  if( (ObjetNet->m_Type != NET_HIERLABEL ) && (ObjetNet->m_Type != NET_HIERBUSLABELMEMBER ) )
503  continue;
504 
505  if( ObjetNet->GetNet() == SheetLabel->GetNet() )
506  continue; //already connected.
507 
508  if( ObjetNet->m_Label != SheetLabel->m_Label )
509  continue; //different names.
510 
511  // Propagate Netcode having all the objects of the same Netcode.
512  if( ObjetNet->GetNet() )
513  propagateNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), IS_WIRE );
514  else
515  ObjetNet->SetNet( SheetLabel->GetNet() );
516  }
517 }
int GetNet() const
SCH_SHEET_PATH m_SheetPath
NETLIST_ITEM_T m_Type
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
#define IS_WIRE
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
void SetNet(int aNetCode)

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(), and NETLIST_OBJECT::SetNet().

Referenced by BuildNetListInfo().

◆ sortItemsbyNetcode()

static bool NETLIST_OBJECT_LIST::sortItemsbyNetcode ( const NETLIST_OBJECT Objet1,
const NETLIST_OBJECT Objet2 
)
inlinestaticprivate

Definition at line 450 of file netlist_object.h.

451  {
452  return Objet1->GetNet() < Objet2->GetNet();
453  }
int GetNet() const

References NETLIST_OBJECT::GetNet().

Referenced by SortListbyNetcode().

◆ sortItemsBySheet()

static bool NETLIST_OBJECT_LIST::sortItemsBySheet ( const NETLIST_OBJECT Objet1,
const NETLIST_OBJECT Objet2 
)
inlinestaticprivate

Definition at line 457 of file netlist_object.h.

458  {
459  return Objet1->m_SheetPath.Cmp( Objet2->m_SheetPath ) < 0;
460  }
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.

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

Referenced by SortListbySheet().

◆ SortListbyNetcode()

void NETLIST_OBJECT_LIST::SortListbyNetcode ( )

Definition at line 60 of file netlist_object_list.cpp.

61 {
62  sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsbyNetcode );
63 }
static bool sortItemsbyNetcode(const NETLIST_OBJECT *Objet1, const NETLIST_OBJECT *Objet2)

References sortItemsbyNetcode().

Referenced by BuildNetListInfo().

◆ SortListbySheet()

void NETLIST_OBJECT_LIST::SortListbySheet ( )

Definition at line 66 of file netlist_object_list.cpp.

67 {
68  sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsBySheet );
69 }
static bool sortItemsBySheet(const NETLIST_OBJECT *Objet1, const NETLIST_OBJECT *Objet2)

References sortItemsBySheet().

Referenced by BuildNetListInfo().

◆ TestforNonOrphanLabel()

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 another suitable label.

Definition at line 623 of file erc.cpp.

624 {
625  unsigned netItemTst = aStartNet;
626  int erc = 1;
627 
628  // Review the list of labels connected to NetItemRef:
629  for( ; ; netItemTst++ )
630  {
631  if( netItemTst == aNetItemRef )
632  continue;
633 
634  /* Is always in the same net? */
635  if( ( netItemTst == size() )
636  || ( GetItemNet( aNetItemRef ) != GetItemNet( netItemTst ) ) )
637  {
638  /* End Netcode found. */
639  if( erc )
640  {
641  /* Glabel or SheetLabel orphaned. */
642  Diagnose( GetItem( aNetItemRef ), NULL, -1, WAR );
643  }
644 
645  return;
646  }
647 
648  if( GetItem( aNetItemRef )->IsLabelConnected( GetItem( netItemTst ) ) )
649  erc = 0;
650 
651  //same thing, different order.
652  if( GetItem( netItemTst )->IsLabelConnected( GetItem( aNetItemRef ) ) )
653  erc = 0;
654  }
655 }
Definition: erc.h:43
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:341
int GetItemNet(unsigned aIdx) const
Acces to an item net code.
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.

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

◆ TestforSimilarLabels()

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 697 of file erc.cpp.

698 {
699  // Similar labels which are different when using case sensitive comparisons
700  // but are equal when using case insensitive comparisons
701 
702  // list of all labels (used the better item to build diag messages)
703  std::vector<NETLIST_OBJECT*> fullLabelList;
704  // list of all labels , each label appears only once (used to to detect similar labels)
705  std::set<NETLIST_OBJECT*, compare_labels> uniqueLabelList;
706  wxString msg;
707 
708  // Build a list of differents labels. If inside a given sheet there are
709  // more than one given label, only one label is stored.
710  // not also the sheet labels are not taken in account for 2 reasons:
711  // * they are in the root sheet but they are seen only from the child sheet
712  // * any mismatch between child sheet hierarchical labels and the sheet label
713  // already detected by ERC
714  for( unsigned netItem = 0; netItem < size(); ++netItem )
715  {
716  switch( GetItemType( netItem ) )
717  {
718  case NET_LABEL:
719  case NET_BUSLABELMEMBER:
720  case NET_PINLABEL:
722  case NET_HIERLABEL:
724  case NET_GLOBLABEL:
725  // add this label in lists
726  uniqueLabelList.insert( GetItem( netItem ) );
727  fullLabelList.push_back( GetItem( netItem ) );
728  break;
729 
730  case NET_SHEETLABEL:
732  default:
733  break;
734  }
735  }
736 
737  // build global labels and compare
738  std::set<NETLIST_OBJECT*, compare_label_names> loc_labelList;
739 
740  for( auto it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it )
741  {
742  if( (*it)->IsLabelGlobal() )
743  loc_labelList.insert( *it );
744  }
745 
746  // compare global labels (same label names appears only once in list)
747  for( auto it = loc_labelList.begin(); it != loc_labelList.end(); ++it )
748  {
749  auto it_aux = it;
750 
751  for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
752  {
753  if( (*it)->m_Label.CmpNoCase( (*it_aux)->m_Label ) == 0 )
754  {
755  // Create new marker for ERC.
756  int cntA = countIndenticalLabels( fullLabelList, *it );
757  int cntB = countIndenticalLabels( fullLabelList, *it_aux );
758 
759  if( cntA <= cntB )
760  SimilarLabelsDiagnose( (*it), (*it_aux) );
761  else
762  SimilarLabelsDiagnose( (*it_aux), (*it) );
763  }
764  }
765  }
766 
767  // Build paths list
768  std::set<NETLIST_OBJECT*, compare_paths> pathsList;
769 
770  for( auto it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it )
771  pathsList.insert( *it );
772 
773  // Examine each label inside a sheet path:
774  for( auto it = pathsList.begin(); it != pathsList.end(); ++it )
775  {
776  loc_labelList.clear();
777 
778  auto it_uniq = uniqueLabelList.begin();
779 
780  for( ; it_uniq != uniqueLabelList.end(); ++it_uniq )
781  {
782  if( ( *it )->m_SheetPath.Path() == ( *it_uniq )->m_SheetPath.Path() )
783  loc_labelList.insert( *it_uniq );
784  }
785 
786  // at this point, loc_labelList contains labels of the current sheet path.
787  // Detect similar labels (same label names appears only once in list)
788 
789  for( auto ref_it = loc_labelList.begin(); ref_it != loc_labelList.end(); ++ref_it )
790  {
791  NETLIST_OBJECT* ref_item = *ref_it;
792  auto it_aux = ref_it;
793 
794  for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
795  {
796  // global label versus global label was already examined.
797  // here, at least one label must be local
798  if( ref_item->IsLabelGlobal() && ( *it_aux )->IsLabelGlobal() )
799  continue;
800 
801  if( ref_item->m_Label.CmpNoCase( ( *it_aux )->m_Label ) == 0 )
802  {
803  // Create new marker for ERC.
804  int cntA = countIndenticalLabels( fullLabelList, ref_item );
805  int cntB = countIndenticalLabels( fullLabelList, *it_aux );
806 
807  if( cntA <= cntB )
808  SimilarLabelsDiagnose( ref_item, ( *it_aux ) );
809  else
810  SimilarLabelsDiagnose( ( *it_aux ), ref_item );
811  }
812  }
813  }
814  }
815 }
static int countIndenticalLabels(std::vector< NETLIST_OBJECT * > &aList, NETLIST_OBJECT *aRef)
Definition: erc.cpp:820
bool IsLabelGlobal() const
Function IsLabelGlobal.
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
NETLIST_ITEM_T GetItemType(unsigned aIdx) const
Acces to an item type.
static void SimilarLabelsDiagnose(NETLIST_OBJECT *aItemA, NETLIST_OBJECT *aItemB)
Definition: erc.cpp:845

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().

Member Data Documentation

◆ m_lastBusNetCode

int NETLIST_OBJECT_LIST::m_lastBusNetCode
private

Definition at line 302 of file netlist_object.h.

Referenced by BuildNetListInfo(), and NETLIST_OBJECT_LIST().

◆ m_lastNetCode

int NETLIST_OBJECT_LIST::m_lastNetCode
private

Definition at line 301 of file netlist_object.h.

Referenced by BuildNetListInfo(), connectBusLabels(), and NETLIST_OBJECT_LIST().


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