KiCad PCB EDA Suite
NETLIST_OBJECT_LIST Class Reference

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 GetItemType (unsigned aIdx) const
 Acces to an item type. More...
 
int GetItemNet (unsigned aIdx) const
 Acces to an item net code. More...
 
NET_CONNECTION GetConnectionType (unsigned aIdx)
 
void SetConnectionType (unsigned aIdx, NET_CONNECTION aFlg=NET_CONNECTION::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 ()
 
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

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

43 {
44  Clear();
45 }
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 74 of file netlist_object_list.cpp.

75 {
76  SCH_SHEET_PATH* sheet;
77 
78  // Fill list with connected items from the flattened sheet list
79  for( unsigned i = 0; i < aSheets.size(); i++ )
80  {
81  sheet = &aSheets[i];
82 
83  for( auto item : sheet->LastScreen()->Items() )
84  item->GetNetListItem( *this, sheet );
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 NETLIST_ITEM::PIN:
116  if( net_item->GetNet() != 0 )
117  break;
118 
119  // Intentionally fall through if there is no net assigned
121 
123  // Test connections point to point type without bus.
124  if( net_item->GetNet() == 0 )
125  {
126  net_item->SetNet( m_lastNetCode );
127  m_lastNetCode++;
128  }
129 
130  pointToPointConnect( net_item, IS_WIRE, istart );
131  break;
132 
134  // Control of the junction outside BUS.
135  if( net_item->GetNet() == 0 )
136  {
137  net_item->SetNet( m_lastNetCode );
138  m_lastNetCode++;
139  }
140 
141  segmentToPointConnect( net_item, IS_WIRE, istart );
142 
143  // Control of the junction, on BUS.
144  if( net_item->m_BusNetCode == 0 )
145  {
146  net_item->m_BusNetCode = m_lastBusNetCode;
148  }
149 
150  segmentToPointConnect( net_item, IS_BUS, istart );
151  break;
152 
153  case NETLIST_ITEM::LABEL:
156  // Test connections type junction without bus.
157  if( net_item->GetNet() == 0 )
158  {
159  net_item->SetNet( m_lastNetCode );
160  m_lastNetCode++;
161  }
162 
163  segmentToPointConnect( net_item, IS_WIRE, istart );
164  break;
165 
167  if( net_item->m_BusNetCode != 0 )
168  break;
169 
170  // Intentionally fall through if there is no bus assigned
172 
173  case NETLIST_ITEM::BUS:
174  // Control type connections point to point mode bus
175  if( net_item->m_BusNetCode == 0 )
176  {
177  net_item->m_BusNetCode = m_lastBusNetCode;
179  }
180 
181  pointToPointConnect( net_item, IS_BUS, istart );
182  break;
183 
187  // Control connections similar has on BUS
188  if( net_item->GetNet() == 0 )
189  {
190  net_item->m_BusNetCode = m_lastBusNetCode;
192  }
193 
194  segmentToPointConnect( net_item, IS_BUS, istart );
195  break;
196  }
197  }
198 
199 #if defined(NETLIST_DEBUG) && defined(DEBUG)
200  std::cout << "\n\nafter sheet local\n\n";
201  DumpNetTable();
202 #endif
203 
204  // Updating the Bus Labels Netcode connected by Bus
206 
207  // Group objects by label.
208  for( unsigned ii = 0; ii < size(); ii++ )
209  {
210  switch( GetItem( ii )->m_Type )
211  {
212  case NETLIST_ITEM::PIN:
216  case NETLIST_ITEM::BUS:
218  break;
219 
220  case NETLIST_ITEM::LABEL:
225  labelConnect( GetItem( ii ) );
226  break;
227 
231  break;
232 
234  break;
235  }
236  }
237 
238 #if defined(NETLIST_DEBUG) && defined(DEBUG)
239  std::cout << "\n\nafter sheet global\n\n";
240  DumpNetTable();
241 #endif
242 
243  // Connection between hierarchy sheets
244  for( unsigned ii = 0; ii < size(); ii++ )
245  {
248  sheetLabelConnect( GetItem( ii ) );
249  }
250 
251  // Sort objects by NetCode
253 
254 #if defined(NETLIST_DEBUG) && defined(DEBUG)
255  std::cout << "\n\nafter qsort()\n";
256  DumpNetTable();
257 #endif
258 
259  // Compress numbers of Netcode having consecutive values.
260  int NetCode = 0;
261  m_lastNetCode = 0;
262 
263  for( unsigned ii = 0; ii < size(); ii++ )
264  {
265  if( GetItem( ii )->GetNet() != m_lastNetCode )
266  {
267  NetCode++;
268  m_lastNetCode = GetItem( ii )->GetNet();
269  }
270 
271  GetItem( ii )->SetNet( NetCode );
272  }
273 
274  // Set the minimal connection info:
276 
277  // find the best label object to give the best net name to each net
279 
280  return true;
281 }
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...
#define KI_FALLTHROUGH
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...
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
SCH_SHEET_PATH.
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
SCH_SCREEN * LastScreen()
Function LastScreen.
void SetNet(int aNetCode)
EE_RTREE & Items()
Definition: sch_screen.h:162
void pointToPointConnect(NETLIST_OBJECT *aRef, bool aIsBus, int start)
NETLIST_ITEM m_Type

References BUS, BUSLABELMEMBER, connectBusLabels(), findBestNetNameForEachNet(), GetItem(), NETLIST_OBJECT::GetNet(), GLOBBUSLABELMEMBER, GLOBLABEL, HIERBUSLABELMEMBER, HIERLABEL, IS_BUS, IS_WIRE, ITEM_UNSPECIFIED, SCH_SCREEN::Items(), JUNCTION, KI_FALLTHROUGH, LABEL, labelConnect(), SCH_SHEET_PATH::LastScreen(), NETLIST_OBJECT::m_BusNetCode, m_lastBusNetCode, m_lastNetCode, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_Type, NOCONNECT, PIN, PINLABEL, pointToPointConnect(), SEGMENT, segmentToPointConnect(), NETLIST_OBJECT::SetNet(), setUnconnectedFlag(), SHEETBUSLABELMEMBER, SHEETLABEL, sheetLabelConnect(), SortListbyNetcode(), and SortListbySheet().

◆ Clear()

void NETLIST_OBJECT_LIST::Clear ( )

Delete all objects in list and clear list.

Definition at line 48 of file netlist_object_list.cpp.

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

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

533 {
534  // Propagate the net code between all bus label member objects connected by they name.
535  // If the net code is not yet existing, a new one is created
536  // Search is done in the entire list
537  for( unsigned ii = 0; ii < size(); ii++ )
538  {
539  NETLIST_OBJECT* Label = GetItem( ii );
540 
541  if( Label->IsLabelBusMemberType() )
542  {
543  if( Label->GetNet() == 0 )
544  {
545  // Not yet existiing net code: create a new one.
546  Label->SetNet( m_lastNetCode );
547  m_lastNetCode++;
548  }
549 
550  for( unsigned jj = ii + 1; jj < size(); jj++ )
551  {
552  NETLIST_OBJECT* LabelInTst = GetItem( jj );
553 
554  if( LabelInTst->IsLabelBusMemberType() )
555  {
556  if( LabelInTst->m_BusNetCode != Label->m_BusNetCode )
557  continue;
558 
559  if( LabelInTst->m_Member != Label->m_Member )
560  continue;
561 
562  if( LabelInTst->GetNet() == 0 )
563  // Append this object to the current net
564  LabelInTst->SetNet( Label->GetNet() );
565  else
566  // Merge the 2 net codes, they are connected.
567  propagateNetCode( LabelInTst->GetNet(), Label->GetNet(), IS_WIRE );
568  }
569  }
570  }
571  }
572 }
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().

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

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

References evalLabelsPriority(), NETLIST_OBJECT::GetComponentParent(), GetItem(), NETLIST_OBJECT::GetNet(), NETLIST_OBJECT::GetShortNetName(), GLOBBUSLABELMEMBER, GLOBLABEL, NETLIST_OBJECT::HasNetNameCandidate(), HIERLABEL, SCH_COMPONENT::IsInNetlist(), LABEL, NETLIST_OBJECT::m_Type, NULL, PIN, PINLABEL, and NETLIST_OBJECT::SetNetNameCandidate().

Referenced by BuildNetListInfo().

◆ GetConnectionType()

NET_CONNECTION 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 GetConnectionType() const
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.

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

Referenced by ERC_TESTER::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 ERC_TESTER::TestOthersItems().

◆ GetItemType()

NETLIST_ITEM 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_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
NETLIST_ITEM m_Type

References GetItem(), and NETLIST_OBJECT::m_Type.

Referenced by TestforSimilarLabels(), and ERC_TESTER::TestOthersItems().

◆ labelConnect()

void NETLIST_OBJECT_LIST::labelConnect ( NETLIST_OBJECT aLabelRef)
private

Definition at line 742 of file netlist_object_list.cpp.

743 {
744  if( aLabelRef->GetNet() == 0 )
745  return;
746 
747  for( unsigned i = 0; i < size(); i++ )
748  {
749  NETLIST_OBJECT* item = GetItem( i );
750 
751  if( item->GetNet() == aLabelRef->GetNet() )
752  continue;
753 
754  if( item->m_SheetPath != aLabelRef->m_SheetPath )
755  {
758  continue;
759 
760  if( ( item->m_Type == NETLIST_ITEM::GLOBLABEL
762  && item->m_Type != aLabelRef->m_Type )
763  //global labels only connect other global labels.
764  continue;
765  }
766 
767  // NETLIST_ITEM::HIERLABEL are used to connect sheets.
768  // NETLIST_ITEM::LABEL are local to a sheet
769  // NETLIST_ITEM::GLOBLABEL are global.
770  // NETLIST_ITEM::PINLABEL is a kind of global label (generated by a power pin invisible)
771  if( item->IsLabelType() )
772  {
773  if( item->m_Label != aLabelRef->m_Label )
774  continue;
775 
776  if( item->GetNet() )
777  propagateNetCode( item->GetNet(), aLabelRef->GetNet(), IS_WIRE );
778  else
779  item->SetNet( aLabelRef->GetNet() );
780  }
781  }
782 }
int GetNet() const
SCH_SHEET_PATH m_SheetPath
bool IsLabelType() const
Function IsLabelType.
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)
NETLIST_ITEM m_Type

References GetItem(), NETLIST_OBJECT::GetNet(), GLOBBUSLABELMEMBER, GLOBLABEL, IS_WIRE, NETLIST_OBJECT::IsLabelType(), NETLIST_OBJECT::m_Label, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_Type, 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 603 of file netlist_object_list.cpp.

604 {
605  int netCode;
606 
607  if( aIsBus == false ) // Objects other than BUS and BUSLABELS
608  {
609  netCode = aRef->GetNet();
610 
611  for( unsigned i = start; i < size(); i++ )
612  {
613  NETLIST_OBJECT* item = GetItem( i );
614 
615  if( item->m_SheetPath != aRef->m_SheetPath ) //used to be > (why?)
616  continue;
617 
618  switch( item->m_Type )
619  {
621  case NETLIST_ITEM::PIN:
622  case NETLIST_ITEM::LABEL:
629  if( aRef->m_Start == item->m_Start
630  || aRef->m_Start == item->m_End
631  || aRef->m_End == item->m_Start
632  || aRef->m_End == item->m_End )
633  {
634  if( item->GetNet() == 0 )
635  item->SetNet( netCode );
636  else
637  propagateNetCode( item->GetNet(), netCode, IS_WIRE );
638  }
639  break;
640 
641  case NETLIST_ITEM::BUS:
647  break;
648  }
649  }
650  }
651  else // Object type BUS, BUSLABELS, and junctions.
652  {
653  netCode = aRef->m_BusNetCode;
654 
655  for( unsigned i = start; i < size(); i++ )
656  {
657  NETLIST_OBJECT* item = GetItem( i );
658 
659  if( item->m_SheetPath != aRef->m_SheetPath )
660  continue;
661 
662  switch( item->m_Type )
663  {
666  case NETLIST_ITEM::PIN:
667  case NETLIST_ITEM::LABEL:
673  break;
674 
675  case NETLIST_ITEM::BUS:
681  if( aRef->m_Start == item->m_Start
682  || aRef->m_Start == item->m_End
683  || aRef->m_End == item->m_Start
684  || aRef->m_End == item->m_End )
685  {
686  if( item->m_BusNetCode == 0 )
687  item->m_BusNetCode = netCode;
688  else
689  propagateNetCode( item->m_BusNetCode, netCode, IS_BUS );
690  }
691  break;
692  }
693  }
694  }
695 }
int GetNet() const
#define IS_BUS
SCH_SHEET_PATH m_SheetPath
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)
NETLIST_ITEM m_Type

References BUS, BUSLABELMEMBER, GetItem(), NETLIST_OBJECT::GetNet(), GLOBBUSLABELMEMBER, GLOBLABEL, HIERBUSLABELMEMBER, HIERLABEL, IS_BUS, IS_WIRE, ITEM_UNSPECIFIED, JUNCTION, LABEL, NETLIST_OBJECT::m_BusNetCode, NETLIST_OBJECT::m_End, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_Start, NETLIST_OBJECT::m_Type, NOCONNECT, PIN, PINLABEL, propagateNetCode(), SEGMENT, NETLIST_OBJECT::SetNet(), SHEETBUSLABELMEMBER, and SHEETLABEL.

Referenced by BuildNetListInfo().

◆ propagateNetCode()

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

Definition at line 575 of file netlist_object_list.cpp.

576 {
577  if( aOldNetCode == aNewNetCode )
578  return;
579 
580  if( aIsBus == false ) // Propagate NetCode
581  {
582  for( unsigned jj = 0; jj < size(); jj++ )
583  {
584  NETLIST_OBJECT* object = GetItem( jj );
585 
586  if( object->GetNet() == aOldNetCode )
587  object->SetNet( aNewNetCode );
588  }
589  }
590  else // Propagate BusNetCode
591  {
592  for( unsigned jj = 0; jj < size(); jj++ )
593  {
594  NETLIST_OBJECT* object = GetItem( jj );
595 
596  if( object->m_BusNetCode == aOldNetCode )
597  object->m_BusNetCode = aNewNetCode;
598  }
599  }
600 }
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  }
void SetConnectionType(NET_CONNECTION aFlg=NET_CONNECTION::UNCONNECTED)
Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT...
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.

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

700 {
701  for( unsigned i = aIdxStart; i < size(); i++ )
702  {
703  NETLIST_OBJECT* segment = GetItem( i );
704 
705  // if different sheets, obviously no physical connection between elements.
706  if( segment->m_SheetPath != aJonction->m_SheetPath )
707  continue;
708 
709  if( aIsBus == IS_WIRE )
710  {
711  if( segment->m_Type != NETLIST_ITEM::SEGMENT )
712  continue;
713  }
714  else
715  {
716  if( segment->m_Type != NETLIST_ITEM::BUS )
717  continue;
718  }
719 
720  if( IsPointOnSegment( segment->m_Start, segment->m_End, aJonction->m_Start ) )
721  {
722  // Propagation Netcode has all the objects of the same Netcode.
723  if( aIsBus == IS_WIRE )
724  {
725  if( segment->GetNet() )
726  propagateNetCode( segment->GetNet(), aJonction->GetNet(), aIsBus );
727  else
728  segment->SetNet( aJonction->GetNet() );
729  }
730  else
731  {
732  if( segment->m_BusNetCode )
733  propagateNetCode( segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
734  else
735  segment->m_BusNetCode = aJonction->m_BusNetCode;
736  }
737  }
738  }
739 }
int GetNet() const
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:42
SCH_SHEET_PATH m_SheetPath
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)
NETLIST_ITEM m_Type

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

Referenced by BuildNetListInfo().

◆ SetConnectionType()

void NETLIST_OBJECT_LIST::SetConnectionType ( unsigned  aIdx,
NET_CONNECTION  aFlg = NET_CONNECTION::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  }
void SetConnectionType(NET_CONNECTION aFlg=NET_CONNECTION::UNCONNECTED)
Set the item connection type: UNCONNECTED Pin or Label not connected (error) NOCONNECT_SYMBOL_PRESENT...
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.

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

Referenced by ERC_TESTER::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 785 of file netlist_object_list.cpp.

786 {
787  NETLIST_OBJECT* NetItemRef;
788  unsigned NetStart, NetEnd;
789  NET_CONNECTION StateFlag;
790 
791  NetStart = NetEnd = 0;
792  StateFlag = NET_CONNECTION::UNCONNECTED;
793  for( unsigned ii = 0; ii < size(); ii++ )
794  {
795  NetItemRef = GetItem( ii );
796  if( NetItemRef->m_Type == NETLIST_ITEM::NOCONNECT
797  && StateFlag != NET_CONNECTION::PAD_CONNECT )
799 
800  // Analysis of current net.
801  unsigned idxtoTest = ii + 1;
802 
803  if( ( idxtoTest >= size() )
804  || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
805  {
806  // Net analysis to update m_ConnectionType
807  NetEnd = idxtoTest;
808 
809  /* set m_ConnectionType member to StateFlag for all items of
810  * this net: */
811  for( unsigned kk = NetStart; kk < NetEnd; kk++ )
812  GetItem( kk )->m_ConnectionType = StateFlag;
813 
814  if( idxtoTest >= size() )
815  return;
816 
817  // Start Analysis next Net
818  StateFlag = NET_CONNECTION::UNCONNECTED;
819  NetStart = idxtoTest;
820  continue;
821  }
822 
823  /* test the current item: if this is a pin and if the reference item
824  * is also a pin, then 2 pins are connected, so set StateFlag to
825  * PAD_CONNECT (can be already done) Of course, if the current
826  * item is a no connect symbol, set StateFlag to
827  * NOCONNECT_SYMBOL_PRESENT to inhibit error diags. However if
828  * StateFlag is already set to PAD_CONNECT this state is kept (the
829  * no connect symbol was surely an error and an ERC will report this)
830  */
831  for( ; ; idxtoTest++ )
832  {
833  if( ( idxtoTest >= size() )
834  || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
835  break;
836 
837  switch( GetItem( idxtoTest )->m_Type )
838  {
840  wxMessageBox( wxT( "BuildNetListBase() error" ) );
841  break;
842 
844  case NETLIST_ITEM::LABEL:
849  case NETLIST_ITEM::BUS:
855  break;
856 
857  case NETLIST_ITEM::PIN:
858  if( NetItemRef->m_Type == NETLIST_ITEM::PIN )
859  StateFlag = NET_CONNECTION::PAD_CONNECT;
860 
861  break;
862 
864  if( StateFlag != NET_CONNECTION::PAD_CONNECT )
866 
867  break;
868  }
869  }
870  }
871 }
int GetNet() const
NET_CONNECTION
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
NET_CONNECTION m_ConnectionType
NETLIST_ITEM m_Type

References BUS, BUSLABELMEMBER, GetItem(), NETLIST_OBJECT::GetNet(), GLOBBUSLABELMEMBER, GLOBLABEL, HIERBUSLABELMEMBER, HIERLABEL, ITEM_UNSPECIFIED, JUNCTION, LABEL, NETLIST_OBJECT::m_ConnectionType, NETLIST_OBJECT::m_Type, NOCONNECT, NOCONNECT_SYMBOL_PRESENT, PAD_CONNECT, PIN, PINLABEL, SEGMENT, SHEETBUSLABELMEMBER, SHEETLABEL, 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 501 of file netlist_object_list.cpp.

502 {
503  if( SheetLabel->GetNet() == 0 )
504  return;
505 
506  for( unsigned ii = 0; ii < size(); ii++ )
507  {
508  NETLIST_OBJECT* ObjetNet = GetItem( ii );
509 
510  if( ObjetNet->m_SheetPath != SheetLabel->m_SheetPathInclude )
511  continue; //use SheetInclude, not the sheet!!
512 
513  if( ( ObjetNet->m_Type != NETLIST_ITEM::HIERLABEL )
514  && ( ObjetNet->m_Type != NETLIST_ITEM::HIERBUSLABELMEMBER ) )
515  continue;
516 
517  if( ObjetNet->GetNet() == SheetLabel->GetNet() )
518  continue; //already connected.
519 
520  if( ObjetNet->m_Label != SheetLabel->m_Label )
521  continue; //different names.
522 
523  // Propagate Netcode having all the objects of the same Netcode.
524  if( ObjetNet->GetNet() )
525  propagateNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), IS_WIRE );
526  else
527  ObjetNet->SetNet( SheetLabel->GetNet() );
528  }
529 }
int GetNet() const
SCH_SHEET_PATH m_SheetPath
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)
NETLIST_ITEM m_Type

References GetItem(), NETLIST_OBJECT::GetNet(), HIERBUSLABELMEMBER, HIERLABEL, IS_WIRE, NETLIST_OBJECT::m_Label, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_SheetPathInclude, NETLIST_OBJECT::m_Type, 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 432 of file netlist_object.h.

433  {
434  return Objet1->GetNet() < Objet2->GetNet();
435  }
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 439 of file netlist_object.h.

440  {
441  return Objet1->m_SheetPath.Cmp( Objet2->m_SheetPath ) < 0;
442  }
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 62 of file netlist_object_list.cpp.

63 {
64  sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsbyNetcode );
65 }
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 68 of file netlist_object_list.cpp.

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

References sortItemsBySheet().

Referenced by BuildNetListInfo().

◆ 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 567 of file eeschema/erc.cpp.

568 {
569  // Similar labels which are different when using case sensitive comparisons
570  // but are equal when using case insensitive comparisons
571 
572  // list of all labels (used the better item to build diag messages)
573  std::vector<NETLIST_OBJECT*> fullLabelList;
574  // list of all labels , each label appears only once (used to to detect similar labels)
575  std::set<NETLIST_OBJECT*, compare_labels> uniqueLabelList;
576  wxString msg;
577 
578  // Build a list of differents labels. If inside a given sheet there are
579  // more than one given label, only one label is stored.
580  // not also the sheet labels are not taken in account for 2 reasons:
581  // * they are in the root sheet but they are seen only from the child sheet
582  // * any mismatch between child sheet hierarchical labels and the sheet label
583  // already detected by ERC
584  for( unsigned netItem = 0; netItem < size(); ++netItem )
585  {
586  switch( GetItemType( netItem ) )
587  {
588  case NETLIST_ITEM::LABEL:
595  // add this label in lists
596  uniqueLabelList.insert( GetItem( netItem ) );
597  fullLabelList.push_back( GetItem( netItem ) );
598  break;
599 
602  default:
603  break;
604  }
605  }
606 
607  // build global labels and compare
608  std::set<NETLIST_OBJECT*, compare_label_names> loc_labelList;
609 
610  for( NETLIST_OBJECT* label : uniqueLabelList )
611  {
612  if( label->IsLabelGlobal() )
613  loc_labelList.insert( label );
614  }
615 
616  // compare global labels (same label names appears only once in list)
617  for( auto it = loc_labelList.begin(); it != loc_labelList.end(); ++it )
618  {
619  auto it_aux = it;
620 
621  for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
622  {
623  if( (*it)->m_Label.CmpNoCase( (*it_aux)->m_Label ) == 0 )
624  {
625  // Create new marker for ERC.
626  int cntA = countIndenticalLabels( fullLabelList, *it );
627  int cntB = countIndenticalLabels( fullLabelList, *it_aux );
628 
629  if( cntA <= cntB )
630  SimilarLabelsDiagnose( (*it), (*it_aux) );
631  else
632  SimilarLabelsDiagnose( (*it_aux), (*it) );
633  }
634  }
635  }
636 
637  // Build paths list
638  std::set<NETLIST_OBJECT*, compare_paths> pathsList;
639 
640  for( NETLIST_OBJECT* label : uniqueLabelList )
641  pathsList.insert( label );
642 
643  // Examine each label inside a sheet path:
644  for( NETLIST_OBJECT* candidate : pathsList )
645  {
646  loc_labelList.clear();
647 
648  for( NETLIST_OBJECT* uniqueLabel : uniqueLabelList)
649  {
650  if( candidate->m_SheetPath.Path() == uniqueLabel->m_SheetPath.Path() )
651  loc_labelList.insert( uniqueLabel );
652  }
653 
654  // at this point, loc_labelList contains labels of the current sheet path.
655  // Detect similar labels (same label names appears only once in list)
656 
657  for( auto ref_it = loc_labelList.begin(); ref_it != loc_labelList.end(); ++ref_it )
658  {
659  NETLIST_OBJECT* ref_item = *ref_it;
660  auto it_aux = ref_it;
661 
662  for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
663  {
664  // global label versus global label was already examined.
665  // here, at least one label must be local
666  if( ref_item->IsLabelGlobal() && ( *it_aux )->IsLabelGlobal() )
667  continue;
668 
669  if( ref_item->m_Label.CmpNoCase( ( *it_aux )->m_Label ) == 0 )
670  {
671  // Create new marker for ERC.
672  int cntA = countIndenticalLabels( fullLabelList, ref_item );
673  int cntB = countIndenticalLabels( fullLabelList, *it_aux );
674 
675  if( cntA <= cntB )
676  SimilarLabelsDiagnose( ref_item, ( *it_aux ) );
677  else
678  SimilarLabelsDiagnose( ( *it_aux ), ref_item );
679  }
680  }
681  }
682  }
683 }
static int countIndenticalLabels(std::vector< NETLIST_OBJECT * > &aList, NETLIST_OBJECT *aRef)
bool IsLabelGlobal() const
Function IsLabelGlobal.
NETLIST_ITEM GetItemType(unsigned aIdx) const
Acces to an item type.
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
static void SimilarLabelsDiagnose(NETLIST_OBJECT *aItemA, NETLIST_OBJECT *aItemB)

References BUSLABELMEMBER, countIndenticalLabels(), GetItem(), GetItemType(), GLOBBUSLABELMEMBER, GLOBLABEL, HIERBUSLABELMEMBER, HIERLABEL, NETLIST_OBJECT::IsLabelGlobal(), LABEL, NETLIST_OBJECT::m_Label, PINLABEL, SHEETBUSLABELMEMBER, 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: