void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL ) return; NETLIST_OBJECT* item = new NETLIST_OBJECT(); item->m_SheetPath = *aSheetPath; item->m_SheetPathInclude = *aSheetPath; item->m_Comp = (SCH_ITEM*) this; item->m_Type = NET_LABEL; if( GetLayer() == LAYER_GLOBLABEL ) item->m_Type = NET_GLOBLABEL; else if( GetLayer() == LAYER_HIERLABEL ) item->m_Type = NET_HIERLABEL; item->m_Label = m_Text; item->m_Start = item->m_End = GetTextPos(); aNetListItems.push_back( item ); // If a bus connects to label if( Connection( *aSheetPath )->IsBusLabel( m_Text ) ) { item->ConvertBusToNetListItems( aNetListItems ); } }
void SCH_NO_CONNECT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { NETLIST_OBJECT* item = new NETLIST_OBJECT(); item->m_SheetPath = *aSheetPath; item->m_SheetPathInclude = *aSheetPath; item->m_Comp = this; item->m_Type = NET_NOCONNECT; item->m_Start = item->m_End = m_pos; aNetListItems.push_back( item ); }
void SCH_JUNCTION::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { NETLIST_OBJECT* item = new NETLIST_OBJECT(); item->m_SheetPath = *aSheetPath; item->m_SheetPathInclude = *aSheetPath; item->m_Comp = (SCH_ITEM*) this; item->m_Type = NET_JUNCTION; item->m_Start = item->m_End = m_pos; aNetListItems.push_back( item ); }
void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { SCH_SHEET_PATH sheetPath = *aSheetPath; sheetPath.push_back( this ); for( size_t i = 0; i < m_pins.size(); i++ ) { NETLIST_OBJECT* item = new NETLIST_OBJECT(); item->m_SheetPathInclude = sheetPath; item->m_SheetPath = *aSheetPath; item->m_Comp = &m_pins[i]; item->m_Link = this; item->m_Type = NET_SHEETLABEL; item->m_Label = m_pins[i].GetText(); item->m_Start = item->m_End = m_pins[i].GetPosition(); aNetListItems.push_back( item ); if( IsBusLabel( m_pins[i].GetText() ) ) item->ConvertBusToNetListItems( aNetListItems ); } }
void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItems ) { wxCHECK_RET( IsBusLabel( m_Label ), wxT( "<" ) + m_Label + wxT( "> is not a valid bus label." ) ); if( m_Type == NET_HIERLABEL ) m_Type = NET_HIERBUSLABELMEMBER; else if( m_Type == NET_GLOBLABEL ) m_Type = NET_GLOBBUSLABELMEMBER; else if( m_Type == NET_SHEETLABEL ) m_Type = NET_SHEETBUSLABELMEMBER; else if( m_Type == NET_LABEL ) m_Type = NET_BUSLABELMEMBER; else wxCHECK_RET( false, wxT( "Net list object type is not valid." ) ); unsigned i; wxString tmp, busName, busNumber; long begin, end, member; busName = busLabelRe.GetMatch( m_Label, 1 ); busNumber = busLabelRe.GetMatch( m_Label, 2 ); /* Search for '[' because a bus label is like "busname[nn..mm]" */ i = busNumber.Find( '[' ); i++; while( i < busNumber.Len() && busNumber[i] != '.' ) { tmp.Append( busNumber[i] ); i++; } tmp.ToLong( &begin ); while( i < busNumber.Len() && busNumber[i] == '.' ) i++; tmp.Empty(); while( i < busNumber.Len() && busNumber[i] != ']' ) { tmp.Append( busNumber[i] ); i++; } tmp.ToLong( &end ); if( begin < 0 ) begin = 0; if( end < 0 ) end = 0; if( begin > end ) std::swap( begin, end ); member = begin; tmp = busName; tmp << member; m_Label = tmp; m_Member = member; for( member++; member <= end; member++ ) { NETLIST_OBJECT* item = new NETLIST_OBJECT( *this ); // Conversion of bus label to the root name + the current member id. tmp = busName; tmp << member; item->m_Label = tmp; item->m_Member = member; aNetListItems.push_back( item ); } }
/** * 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. */ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet() { int netcode = 0; // current netcode for tested items unsigned idxstart = 0; // index of the first item of this net NETLIST_OBJECT* item; NETLIST_OBJECT* candidate; // Pass 1: find the best name for labelled nets: item = NULL; candidate = NULL; for( unsigned ii = 0; ii <= size(); ii++ ) { if( ii == size() ) // last item already found netcode = -2; else item = GetItem( ii ); if( netcode != item->GetNet() ) // End of net found { if( candidate ) // One or more labels exists, find the best { for (unsigned jj = idxstart; jj < ii; jj++ ) GetItem( jj )->SetNetNameCandidate( candidate ); } if( netcode == -2 ) break; netcode = item->GetNet(); candidate = NULL; idxstart = ii; } switch( item->m_Type ) { case NET_HIERLABEL: case NET_LABEL: case NET_PINLABEL: case NET_GLOBLABEL: // A candidate is found: select the better between the previous // and this one if( candidate == NULL ) candidate = item; else { if( evalLabelsPriority( item, candidate ) ) // item has a highter priority than candidate // so update the best candidate candidate = item; } break; default: break; } } // Pass 2: find the best name for not labelled nets: // The "default" net name is Net-<<Ref cmp>_Pad<num pad>> // (see NETLIST_OBJECT::GetShortNetName()) // therefore the "best" is the short net name alphabetically classed first // (to avoid net names changes when the net is not modified, // even if components are moved or deleted and undelete or replaced, as long // the reference is kept) // Build the list of items with no net names NETLIST_OBJECT_LIST list; for( unsigned ii = 0; ii < size(); ii++ ) { item = GetItem( ii ); if( !item->HasNetNameCandidate() ) list.push_back( item ); } if( list.size() == 0 ) return; idxstart = 0; candidate = NULL; netcode = list.GetItemNet( 0 ); for( unsigned ii = 0; ii <= list.size(); ii++ ) { if( ii < list.size() ) item = list.GetItem( ii ); if( netcode != item->GetNet() || ii >= list.size() ) // End of net found { if( candidate ) { for (unsigned jj = idxstart; jj < ii; jj++ ) { NETLIST_OBJECT* obj = list.GetItem( jj ); obj->SetNetNameCandidate( candidate ); } } if( ii >= list.size() ) break; netcode = item->GetNet(); candidate = NULL; idxstart = ii; } // Examine all pins of the net to find the best candidate, // i.e. the first net name candidate, by alphabetic order // the net names are names bu_ilt by GetShortNetName // (Net-<{reference}-Pad{pad number}> like Net-<U3-Pad5> // Not named nets do not have usually a lot of members. // Many have only 2 members(a pad and a non connection symbol) if( item->m_Type == NET_PIN ) { // A candidate is found, however components which are not in // netlist are not candidate because some have their reference // changed each time the netlist is built (power components) // and anyway obviously they are not a good candidate SCH_COMPONENT* link = item->GetComponentParent(); if( link && link->IsInNetlist() ) { // select the better between the previous and this one item->SetNetNameCandidate( item ); // Needed to calculate GetShortNetName if( candidate == NULL ) candidate = item; else { if( item->GetShortNetName().Cmp( candidate->GetShortNetName() ) < 0 ) candidate = item; } } } } }