bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets ) { SCH_SHEET_PATH* sheet; // Fill list with connected items from the flattened sheet list for( unsigned i = 0; i < aSheets.size(); i++ ) { sheet = &aSheets[i]; for( SCH_ITEM* item = sheet->LastScreen()->GetDrawItems(); item; item = item->Next() ) { item->GetNetListItem( *this, sheet ); } } if( size() == 0 ) return false; // Sort objects by Sheet SortListbySheet(); sheet = &(GetItem( 0 )->m_SheetPath); m_lastNetCode = m_lastBusNetCode = 1; for( unsigned ii = 0, istart = 0; ii < size(); ii++ ) { NETLIST_OBJECT* net_item = GetItem( ii ); if( net_item->m_SheetPath != *sheet ) // Sheet change { sheet = &(net_item->m_SheetPath); istart = ii; } switch( net_item->m_Type ) { case NET_ITEM_UNSPECIFIED: wxMessageBox( wxT( "BuildNetListInfo() error" ) ); break; case NET_PIN: case NET_PINLABEL: case NET_SHEETLABEL: case NET_NOCONNECT: if( net_item->GetNet() != 0 ) break; case NET_SEGMENT: // Test connections point to point type without bus. if( net_item->GetNet() == 0 ) { net_item->SetNet( m_lastNetCode ); m_lastNetCode++; } pointToPointConnect( net_item, IS_WIRE, istart ); break; case NET_JUNCTION: // Control of the junction outside BUS. if( net_item->GetNet() == 0 ) { net_item->SetNet( m_lastNetCode ); m_lastNetCode++; } segmentToPointConnect( net_item, IS_WIRE, istart ); // Control of the junction, on BUS. if( net_item->m_BusNetCode == 0 ) { net_item->m_BusNetCode = m_lastBusNetCode; m_lastBusNetCode++; } segmentToPointConnect( net_item, IS_BUS, istart ); break; case NET_LABEL: case NET_HIERLABEL: case NET_GLOBLABEL: // Test connections type junction without bus. if( net_item->GetNet() == 0 ) { net_item->SetNet( m_lastNetCode ); m_lastNetCode++; } segmentToPointConnect( net_item, IS_WIRE, istart ); break; case NET_SHEETBUSLABELMEMBER: if( net_item->m_BusNetCode != 0 ) break; case NET_BUS: // Control type connections point to point mode bus if( net_item->m_BusNetCode == 0 ) { net_item->m_BusNetCode = m_lastBusNetCode; m_lastBusNetCode++; } pointToPointConnect( net_item, IS_BUS, istart ); break; case NET_BUSLABELMEMBER: case NET_HIERBUSLABELMEMBER: case NET_GLOBBUSLABELMEMBER: // Control connections similar has on BUS if( net_item->GetNet() == 0 ) { net_item->m_BusNetCode = m_lastBusNetCode; m_lastBusNetCode++; } segmentToPointConnect( net_item, IS_BUS, istart ); break; } } #if defined(NETLIST_DEBUG) && defined(DEBUG) std::cout << "\n\nafter sheet local\n\n"; DumpNetTable(); #endif // Updating the Bus Labels Netcode connected by Bus connectBusLabels(); // Group objects by label. for( unsigned ii = 0; ii < size(); ii++ ) { switch( GetItem( ii )->m_Type ) { case NET_PIN: case NET_SHEETLABEL: case NET_SEGMENT: case NET_JUNCTION: case NET_BUS: case NET_NOCONNECT: break; case NET_LABEL: case NET_GLOBLABEL: case NET_PINLABEL: case NET_BUSLABELMEMBER: case NET_GLOBBUSLABELMEMBER: labelConnect( GetItem( ii ) ); break; case NET_SHEETBUSLABELMEMBER: case NET_HIERLABEL: case NET_HIERBUSLABELMEMBER: break; case NET_ITEM_UNSPECIFIED: break; } } #if defined(NETLIST_DEBUG) && defined(DEBUG) std::cout << "\n\nafter sheet global\n\n"; DumpNetTable(); #endif // Connection between hierarchy sheets for( unsigned ii = 0; ii < size(); ii++ ) { if( GetItem( ii )->m_Type == NET_SHEETLABEL || GetItem( ii )->m_Type == NET_SHEETBUSLABELMEMBER ) sheetLabelConnect( GetItem( ii ) ); } // Sort objects by NetCode SortListbyNetcode(); #if defined(NETLIST_DEBUG) && defined(DEBUG) std::cout << "\n\nafter qsort()\n"; DumpNetTable(); #endif // Compress numbers of Netcode having consecutive values. int NetCode = 0; m_lastNetCode = 0; for( unsigned ii = 0; ii < size(); ii++ ) { if( GetItem( ii )->GetNet() != m_lastNetCode ) { NetCode++; m_lastNetCode = GetItem( ii )->GetNet(); } GetItem( ii )->SetNet( NetCode ); } // Set the minimal connection info: setUnconnectedFlag(); // find the best label object to give the best net name to each net findBestNetNameForEachNet(); return true; }