2011-10-11 13:38:13 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2011-10-12 14:03:43 +00:00
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-11 13:38:13 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
/**
|
|
|
|
* @file eeschema/netlist.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "general.h"
|
2009-11-04 20:46:53 +00:00
|
|
|
#include "netlist.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "protos.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_pin.h"
|
2011-01-12 21:47:54 +00:00
|
|
|
#include "sch_junction.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_component.h"
|
2010-12-21 15:13:09 +00:00
|
|
|
#include "sch_line.h"
|
|
|
|
#include "sch_no_connect.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_text.h"
|
|
|
|
#include "sch_sheet.h"
|
2009-07-12 15:29:42 +00:00
|
|
|
#include "algorithm"
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
// Buffer to build the list of items used in netlist and erc calculations
|
|
|
|
NETLIST_OBJECT_LIST g_NetObjectslist;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-08-03 05:11:05 +00:00
|
|
|
//#define NETLIST_DEBUG
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus );
|
2009-07-12 15:29:42 +00:00
|
|
|
static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel );
|
2010-04-06 14:09:52 +00:00
|
|
|
static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start );
|
|
|
|
static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, int IsBus, int start );
|
2009-07-12 15:29:42 +00:00
|
|
|
static void LabelConnect( NETLIST_OBJECT* Label );
|
|
|
|
static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer );
|
|
|
|
static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer );
|
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
static void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer );
|
|
|
|
static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer );
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
// Sort functions used here:
|
2010-04-06 14:09:52 +00:00
|
|
|
static bool SortItemsbyNetcode( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 );
|
|
|
|
static bool SortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
// Local variables
|
2007-05-06 16:03:28 +00:00
|
|
|
static int LastNetCode, LastBusNetCode;
|
2008-08-22 14:48:30 +00:00
|
|
|
|
2007-09-21 04:40:12 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#if defined(DEBUG)
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2007-09-21 04:40:12 +00:00
|
|
|
void dumpNetTable()
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
for( unsigned idx = 0; idx < g_NetObjectslist.size(); ++idx )
|
2007-09-21 04:40:12 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
g_NetObjectslist[idx]->Show( std::cout, idx );
|
2007-09-21 04:40:12 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-09-21 04:40:12 +00:00
|
|
|
#endif
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*
|
2009-11-04 20:46:53 +00:00
|
|
|
* Routine to free memory used to calculate the netlist TabNetItems = pointer
|
|
|
|
* to the main table (list items)
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
void FreeNetObjectsList( NETLIST_OBJECT_LIST& aNetObjectsBuffer )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
for( unsigned i = 0; i < aNetObjectsBuffer.size(); i++ )
|
|
|
|
delete aNetObjectsBuffer[i];
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
aNetObjectsBuffer.clear();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/*
|
|
|
|
* Build net list connection table.
|
|
|
|
*
|
|
|
|
* Updates:
|
|
|
|
* g_NetObjectslist
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::BuildNetListBase()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
int NetCode;
|
|
|
|
SCH_SHEET_PATH* sheet;
|
|
|
|
wxString msg, activity;
|
|
|
|
wxBusyCursor Busy;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
activity = _( "Building net list:" );
|
2008-08-22 14:48:30 +00:00
|
|
|
SetStatusText( activity );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
FreeNetObjectsList( g_NetObjectslist );
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/* Build the sheet (not screen) list (flattened)*/
|
2011-10-11 13:38:13 +00:00
|
|
|
SCH_SHEET_LIST sheets;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
/* Fill g_NetObjectslist with items used in connectivity calculation */
|
2011-10-11 13:38:13 +00:00
|
|
|
for( sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() )
|
2011-10-12 14:03:43 +00:00
|
|
|
{
|
|
|
|
for( SCH_ITEM* item = sheet->LastScreen()->GetDrawItems(); item; item = item->Next() )
|
|
|
|
{
|
|
|
|
item->GetNetListItem( g_NetObjectslist, sheet );
|
|
|
|
}
|
|
|
|
}
|
2009-07-12 15:29:42 +00:00
|
|
|
|
|
|
|
if( g_NetObjectslist.size() == 0 )
|
2009-11-04 20:46:53 +00:00
|
|
|
return; // no objects
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
activity << wxT( " " ) << _( "net count =" ) << wxT( " " ) << g_NetObjectslist.size();
|
2008-08-22 14:48:30 +00:00
|
|
|
SetStatusText( activity );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-05-15 11:20:19 +00:00
|
|
|
/* Sort objects by Sheet */
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsBySheet );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
activity << wxT( ", " ) << _( "connections" ) << wxT( "..." );
|
2008-08-22 14:48:30 +00:00
|
|
|
SetStatusText( activity );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
sheet = &(g_NetObjectslist[0]->m_SheetList);
|
2007-09-20 21:06:49 +00:00
|
|
|
LastNetCode = LastBusNetCode = 1;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
for( unsigned ii = 0, istart = 0; ii < g_NetObjectslist.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
NETLIST_OBJECT* net_item = g_NetObjectslist[ii];
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->m_SheetList != *sheet ) // Sheet change
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
sheet = &(net_item->m_SheetList);
|
2009-07-15 07:10:07 +00:00
|
|
|
istart = ii;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
switch( net_item->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2009-11-04 20:46:53 +00:00
|
|
|
wxMessageBox( wxT( "BuildNetListBase() error" ) );
|
2009-07-12 15:29:42 +00:00
|
|
|
break;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_PIN:
|
|
|
|
case NET_PINLABEL:
|
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_NOCONNECT:
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() != 0 )
|
2009-11-04 20:46:53 +00:00
|
|
|
break;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
case NET_SEGMENT:
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Control connections point to point type without bus. */
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
net_item->SetNet( LastNetCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
LastNetCode++;
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
PointToPointConnect( net_item, 0, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Control of the junction outside BUS. */
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
net_item->SetNet( LastNetCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
LastNetCode++;
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
SegmentToPointConnect( net_item, 0, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Control of the junction, on BUS. */
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->m_BusNetCode == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
net_item->m_BusNetCode = LastBusNetCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
LastBusNetCode++;
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
SegmentToPointConnect( net_item, ISBUS, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_LABEL:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Control connections type junction without bus. */
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
net_item->SetNet( LastNetCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
LastNetCode++;
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
SegmentToPointConnect( net_item, 0, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->m_BusNetCode != 0 )
|
2009-11-04 20:46:53 +00:00
|
|
|
break;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
case NET_BUS:
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Control type connections point to point mode bus */
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->m_BusNetCode == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
net_item->m_BusNetCode = LastBusNetCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
LastBusNetCode++;
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
PointToPointConnect( net_item, ISBUS, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_BUSLABELMEMBER:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Control connections similar has on BUS */
|
2009-07-15 07:10:07 +00:00
|
|
|
if( net_item->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
net_item->m_BusNetCode = LastBusNetCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
LastBusNetCode++;
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
SegmentToPointConnect( net_item, ISBUS, istart );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#if defined(NETLIST_DEBUG) && defined(DEBUG)
|
2008-02-12 21:12:46 +00:00
|
|
|
std::cout << "\n\nafter sheet local\n\n";
|
2007-09-21 04:40:12 +00:00
|
|
|
dumpNetTable();
|
2008-03-20 01:50:21 +00:00
|
|
|
#endif
|
2007-09-21 04:40:12 +00:00
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
activity << _( "done" );
|
2008-08-22 14:48:30 +00:00
|
|
|
SetStatusText( activity );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Updating the Bus Labels Netcode connected by Bus */
|
2009-07-12 15:29:42 +00:00
|
|
|
ConnectBusLabels( g_NetObjectslist );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2011-03-03 19:08:13 +00:00
|
|
|
activity << wxT( ", " ) << _( "bus labels" ) << wxT( "..." );
|
2008-08-22 14:48:30 +00:00
|
|
|
SetStatusText( activity );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Group objects by label. */
|
|
|
|
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
switch( g_NetObjectslist[ii]->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
case NET_PIN:
|
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_SEGMENT:
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_BUS:
|
|
|
|
case NET_NOCONNECT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_LABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_PINLABEL:
|
|
|
|
case NET_BUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2009-07-15 07:10:07 +00:00
|
|
|
LabelConnect( g_NetObjectslist[ii] );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_HIERLABEL:
|
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
|
|
|
break;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#if defined(NETLIST_DEBUG) && defined(DEBUG)
|
2008-02-12 21:12:46 +00:00
|
|
|
std::cout << "\n\nafter sheet global\n\n";
|
2007-09-21 04:40:12 +00:00
|
|
|
dumpNetTable();
|
2008-03-20 01:50:21 +00:00
|
|
|
#endif
|
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
activity << _( "done" );
|
2008-08-22 14:48:30 +00:00
|
|
|
SetStatusText( activity );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Connection hierarchy. */
|
2010-04-06 14:09:52 +00:00
|
|
|
activity << wxT( ", " ) << _( "hierarchy..." );
|
2008-08-22 14:48:30 +00:00
|
|
|
SetStatusText( activity );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
if( g_NetObjectslist[ii]->m_Type == NET_SHEETLABEL
|
|
|
|
|| g_NetObjectslist[ii]->m_Type == NET_SHEETBUSLABELMEMBER )
|
|
|
|
SheetLabelConnect( g_NetObjectslist[ii] );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2008-05-15 11:20:19 +00:00
|
|
|
/* Sort objects by NetCode */
|
2009-07-12 15:29:42 +00:00
|
|
|
sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsbyNetcode );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#if defined(NETLIST_DEBUG) && defined(DEBUG)
|
2010-08-03 05:11:05 +00:00
|
|
|
std::cout << "\n\nafter qsort()\n";
|
2007-09-21 04:40:12 +00:00
|
|
|
dumpNetTable();
|
2008-03-20 01:50:21 +00:00
|
|
|
#endif
|
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
activity << _( "done" );
|
2008-08-22 14:48:30 +00:00
|
|
|
SetStatusText( activity );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Compress numbers of Netcode having consecutive values. */
|
2007-09-20 21:06:49 +00:00
|
|
|
LastNetCode = NetCode = 0;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
if( g_NetObjectslist[ii]->GetNet() != LastNetCode )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
NetCode++;
|
2009-07-15 07:10:07 +00:00
|
|
|
LastNetCode = g_NetObjectslist[ii]->GetNet();
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
g_NetObjectslist[ii]->SetNet( NetCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Assignment of m_FlagOfConnection based connection or not. */
|
2009-07-12 15:29:42 +00:00
|
|
|
SetUnconnectedFlag( g_NetObjectslist );
|
2010-06-23 17:00:12 +00:00
|
|
|
|
|
|
|
/* find the best label object to give the best net name to each net */
|
|
|
|
FindBestNetNameForEachNet( g_NetObjectslist );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function FindBestNetNameForEachNet
|
2010-06-23 17:00:12 +00:00
|
|
|
* 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 FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
|
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
if( aNetItemBuffer.size() == 0 )
|
|
|
|
return; // Should not occur: if this function is called, obviously some items exist in list
|
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
NETLIST_OBJECT_LIST candidates;
|
|
|
|
int netcode = 0; // current netcode for tested items
|
|
|
|
unsigned idxstart = 0; // index of the first item of this net
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
for( unsigned ii = 0; ii <= aNetItemBuffer.size(); ii++ )
|
|
|
|
{
|
|
|
|
NETLIST_OBJECT* item;
|
|
|
|
|
|
|
|
if( ii == aNetItemBuffer.size() ) // last item already found
|
|
|
|
netcode = -2;
|
|
|
|
else
|
|
|
|
item = aNetItemBuffer[ii];
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
if( netcode != item->GetNet() ) // End of net found
|
|
|
|
{
|
2010-10-20 19:43:58 +00:00
|
|
|
if( candidates.size() ) // One or more labels exists, find the best
|
2010-06-23 17:00:12 +00:00
|
|
|
{
|
|
|
|
NETLIST_OBJECT* bestlabel = FindBestNetName( candidates );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
for (unsigned jj = idxstart; jj < ii; jj++ )
|
|
|
|
aNetItemBuffer[jj]->m_NetNameCandidate = bestlabel;
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
if( netcode == -2 )
|
|
|
|
break;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
netcode = item->GetNet();
|
|
|
|
candidates.clear();
|
|
|
|
idxstart = ii;
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
switch( item->m_Type )
|
|
|
|
{
|
|
|
|
case NET_HIERLABEL:
|
|
|
|
case NET_LABEL:
|
|
|
|
case NET_PINLABEL:
|
2010-07-14 13:24:36 +00:00
|
|
|
case NET_GLOBLABEL:
|
2010-06-23 17:00:12 +00:00
|
|
|
candidates.push_back( item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-10-12 14:03:43 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function FindBestNetName
|
2010-06-23 17:00:12 +00:00
|
|
|
* @return a reference to the "best" label that can be used to give a name
|
|
|
|
* to a net.
|
|
|
|
* @param aLabelItemBuffer = list of NETLIST_OBJECT type labels candidates.
|
|
|
|
* labels are local labels, hierarchical labels or pin labels
|
|
|
|
* labels in included sheets have a lower priority than labels in the current sheet.
|
2010-12-31 19:47:39 +00:00
|
|
|
* so labels inside the root sheet have the higher priority.
|
|
|
|
* pin labels are global labels and have the higher priority
|
2010-06-23 17:00:12 +00:00
|
|
|
* local labels have the lower priority
|
|
|
|
* labels having the same priority are sorted by alphabetic order.
|
2010-06-24 18:31:43 +00:00
|
|
|
*
|
2010-06-23 17:00:12 +00:00
|
|
|
*/
|
|
|
|
static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
|
|
|
|
{
|
|
|
|
if( aLabelItemBuffer.size() == 0 )
|
|
|
|
return NULL;
|
|
|
|
|
2010-11-08 14:27:02 +00:00
|
|
|
// Define a priority (from low to high) to sort labels:
|
|
|
|
// NET_PINLABEL and NET_GLOBLABEL are global labels
|
2010-11-13 18:56:07 +00:00
|
|
|
// and priority >= NET_PRIO_MAX-1 is for global connections
|
2010-11-08 14:27:02 +00:00
|
|
|
// ( i.e. for labels that are not prefixed by a sheetpath)
|
2010-11-13 18:56:07 +00:00
|
|
|
#define NET_PRIO_MAX 4
|
2011-10-07 14:41:30 +00:00
|
|
|
|
|
|
|
int priority_order[NET_PRIO_MAX+1] = {
|
|
|
|
NET_ITEM_UNSPECIFIED,
|
2011-10-11 20:23:56 +00:00
|
|
|
NET_LABEL,
|
|
|
|
NET_HIERLABEL,
|
2011-10-07 14:41:30 +00:00
|
|
|
NET_PINLABEL,
|
|
|
|
NET_GLOBLABEL };
|
2010-07-14 13:24:36 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
NETLIST_OBJECT*item = aLabelItemBuffer[0];
|
|
|
|
|
2010-11-08 14:27:02 +00:00
|
|
|
// Calculate item priority (initial priority)
|
2010-07-14 13:24:36 +00:00
|
|
|
int item_priority = 0;
|
2011-10-11 13:38:13 +00:00
|
|
|
|
2010-11-13 18:56:07 +00:00
|
|
|
for( unsigned ii = 0; ii <= NET_PRIO_MAX; ii++ )
|
2010-07-14 13:24:36 +00:00
|
|
|
{
|
|
|
|
if ( item->m_Type == priority_order[ii] )
|
|
|
|
{
|
|
|
|
item_priority = ii;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ )
|
|
|
|
{
|
|
|
|
NETLIST_OBJECT* candidate = aLabelItemBuffer[ii];
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-07-14 13:24:36 +00:00
|
|
|
// Calculate candidate priority
|
|
|
|
int candidate_priority = 0;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-11-13 18:56:07 +00:00
|
|
|
for( unsigned ii = 0; ii <= NET_PRIO_MAX; ii++ )
|
2010-06-23 17:00:12 +00:00
|
|
|
{
|
2010-07-14 13:24:36 +00:00
|
|
|
if ( candidate->m_Type == priority_order[ii] )
|
|
|
|
{
|
|
|
|
candidate_priority = ii;
|
2010-06-23 17:00:12 +00:00
|
|
|
break;
|
2010-07-14 13:24:36 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-11 13:38:13 +00:00
|
|
|
|
2010-07-14 13:24:36 +00:00
|
|
|
if( candidate_priority > item_priority )
|
2010-11-08 14:27:02 +00:00
|
|
|
{
|
2010-11-08 15:47:48 +00:00
|
|
|
item = candidate;
|
2010-11-08 14:27:02 +00:00
|
|
|
item_priority = candidate_priority;
|
|
|
|
}
|
2010-07-14 13:24:36 +00:00
|
|
|
else if( candidate_priority == item_priority )
|
|
|
|
{
|
2010-11-08 14:27:02 +00:00
|
|
|
// for global labels, we select the best candidate by alphabetic order
|
|
|
|
// because they have no sheetpath as prefix name
|
|
|
|
// for other labels, we select them before by sheet deep order
|
|
|
|
// because the actual name is /sheetpath/label
|
2010-11-08 15:47:48 +00:00
|
|
|
// and for a given path length, by alphabetic order
|
2010-11-12 16:36:43 +00:00
|
|
|
|
2010-11-13 18:56:07 +00:00
|
|
|
if( item_priority >= NET_PRIO_MAX-1 ) // global label or pin label
|
2010-11-08 15:47:48 +00:00
|
|
|
{ // selection by alphabetic order:
|
|
|
|
if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
|
|
|
|
item = candidate;
|
2010-11-08 14:27:02 +00:00
|
|
|
}
|
2010-11-08 15:47:48 +00:00
|
|
|
else // not global: names are prefixed by their sheetpath
|
2010-11-08 14:27:02 +00:00
|
|
|
{
|
2010-12-31 19:47:39 +00:00
|
|
|
// use name defined in higher hierarchical sheet
|
2010-11-08 15:47:48 +00:00
|
|
|
// (i.e. shorter path because paths are /<timestamp1>/<timestamp2>/...
|
|
|
|
// and timestamp = 8 letters.
|
|
|
|
if( candidate->m_SheetList.Path().Length() < item->m_SheetList.Path().Length() )
|
|
|
|
{
|
|
|
|
item = candidate;
|
|
|
|
}
|
|
|
|
else if( candidate->m_SheetList.Path().Length() == item->m_SheetList.Path().Length() )
|
|
|
|
{
|
|
|
|
// For labels on sheets having an equivalent deep in hierarchy, use
|
|
|
|
// alphabetic label name order:
|
|
|
|
if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
|
|
|
|
item = candidate;
|
|
|
|
}
|
2010-11-08 14:27:02 +00:00
|
|
|
}
|
2010-07-14 13:24:36 +00:00
|
|
|
}
|
2010-06-23 17:00:12 +00:00
|
|
|
}
|
2010-11-08 14:27:02 +00:00
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
return item;
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2011-10-11 13:38:13 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/*
|
|
|
|
* Connect sheets by sheetLabels
|
|
|
|
*/
|
2009-07-12 15:29:42 +00:00
|
|
|
static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
if( SheetLabel->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Calculate the number of nodes in the corresponding sheetlabel */
|
|
|
|
|
|
|
|
/* Comparison with SheetLabel GLABELS sub sheet to group Netcode */
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-15 07:10:07 +00:00
|
|
|
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-15 07:10:07 +00:00
|
|
|
NETLIST_OBJECT* ObjetNet = g_NetObjectslist[ii];
|
2011-10-11 13:38:13 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( ObjetNet->m_SheetList != SheetLabel->m_SheetListInclude )
|
2009-11-04 20:46:53 +00:00
|
|
|
continue; //use SheetInclude, not the sheet!!
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2011-10-11 13:38:13 +00:00
|
|
|
if( (ObjetNet->m_Type != NET_HIERLABEL ) && (ObjetNet->m_Type != NET_HIERBUSLABELMEMBER ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( ObjetNet->GetNet() == SheetLabel->GetNet() )
|
2009-11-04 20:46:53 +00:00
|
|
|
continue; //already connected.
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
if( ObjetNet->m_Label.CmpNoCase( SheetLabel->m_Label ) != 0 )
|
2009-11-04 20:46:53 +00:00
|
|
|
continue; //different names.
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Propagate Netcode having all the objects of the same Netcode. */
|
2009-07-12 15:29:42 +00:00
|
|
|
if( ObjetNet->GetNet() )
|
2009-07-15 07:10:07 +00:00
|
|
|
PropageNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), 0 );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2009-07-12 15:29:42 +00:00
|
|
|
ObjetNet->SetNet( SheetLabel->GetNet() );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/*
|
|
|
|
* Routine that analyzes the type labels xxBUSLABELMEMBER
|
|
|
|
* Propagate Netcode between the corresponding labels (ie when
|
|
|
|
* Their member number is the same) when they are connected
|
|
|
|
* Generally by their BusNetCode
|
|
|
|
* Uses and updates the variable LastNetCode
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
for( unsigned ii = 0; ii < aNetItemBuffer.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* Label = aNetItemBuffer[ii];
|
2011-10-07 14:41:30 +00:00
|
|
|
|
|
|
|
if( (Label->m_Type == NET_SHEETBUSLABELMEMBER)
|
|
|
|
|| (Label->m_Type == NET_BUSLABELMEMBER)
|
|
|
|
|| (Label->m_Type == NET_HIERBUSLABELMEMBER) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
if( Label->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
Label->SetNet( LastNetCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
LastNetCode++;
|
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
for( unsigned jj = ii + 1; jj < aNetItemBuffer.size(); jj++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* LabelInTst = aNetItemBuffer[jj];
|
2007-09-20 21:06:49 +00:00
|
|
|
if( (LabelInTst->m_Type == NET_SHEETBUSLABELMEMBER)
|
|
|
|
|| (LabelInTst->m_Type == NET_BUSLABELMEMBER)
|
2008-02-12 21:12:46 +00:00
|
|
|
|| (LabelInTst->m_Type == NET_HIERBUSLABELMEMBER) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
if( LabelInTst->m_BusNetCode != Label->m_BusNetCode )
|
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
if( LabelInTst->m_Member != Label->m_Member )
|
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
if( LabelInTst->GetNet() == 0 )
|
|
|
|
LabelInTst->SetNet( Label->GetNet() );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2011-10-07 14:41:30 +00:00
|
|
|
PropageNetCode( LabelInTst->GetNet(), Label->GetNet(), 0 );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-08-22 14:48:30 +00:00
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/*
|
|
|
|
* PropageNetCode propagates Netcode NewNetCode on all elements
|
|
|
|
* belonging to the former Netcode OldNetCode
|
|
|
|
* If IsBus == 0; Netcode is the member who is spreading
|
2010-05-08 10:54:41 +00:00
|
|
|
* If IsBus != 0; is the member who is spreading BusNetCode
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
if( OldNetCode == NewNetCode )
|
|
|
|
return;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( IsBus == 0 ) /* Propagate NetCode */
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
if( Objet->GetNet() == OldNetCode )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
Objet->SetNet( NewNetCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
else /* Propagate BusNetCode */
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
if( Objet->m_BusNetCode == OldNetCode )
|
|
|
|
{
|
|
|
|
Objet->m_BusNetCode = NewNetCode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/*
|
|
|
|
* Check if Ref element is connected to other elements of the list of objects
|
|
|
|
* in the schematic, by mode point
|
|
|
|
* A point (end superimposed)
|
2008-03-20 01:50:21 +00:00
|
|
|
*
|
2009-11-04 20:46:53 +00:00
|
|
|
* If IsBus:
|
|
|
|
* The connection involves elements such as bus
|
|
|
|
* (Or BUS or BUSLABEL JUNCTION)
|
|
|
|
* Otherwise
|
|
|
|
* The connection involves elements such as non-bus
|
|
|
|
* (Other than BUS or BUSLABEL)
|
2008-03-20 01:50:21 +00:00
|
|
|
*
|
2009-11-04 20:46:53 +00:00
|
|
|
* The Ref object must have a valid Netcode.
|
2008-03-20 01:50:21 +00:00
|
|
|
*
|
2009-11-04 20:46:53 +00:00
|
|
|
* The list of objects is SUPPOSED class by SheetPath Croissants,
|
|
|
|
* And research is done from the start element, 1st element
|
|
|
|
* Leaf schema
|
|
|
|
* (There can be no physical connection between elements of different sheets)
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
int netCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( IsBus == 0 ) /* Objects other than BUS and BUSLABELS. */
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
netCode = Ref->GetNet();
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
for( unsigned i = start; i < g_NetObjectslist.size(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* item = g_NetObjectslist[i];
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( item->m_SheetList != Ref->m_SheetList ) //used to be > (why?)
|
2008-02-12 21:12:46 +00:00
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
switch( item->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
case NET_SEGMENT:
|
|
|
|
case NET_PIN:
|
|
|
|
case NET_LABEL:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_PINLABEL:
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_NOCONNECT:
|
2009-07-12 15:29:42 +00:00
|
|
|
if( Ref->m_Start == item->m_Start
|
|
|
|
|| Ref->m_Start == item->m_End
|
|
|
|
|| Ref->m_End == item->m_Start
|
|
|
|
|| Ref->m_End == item->m_End )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( item->GetNet() == 0 )
|
|
|
|
item->SetNet( netCode );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2009-07-12 15:29:42 +00:00
|
|
|
PropageNetCode( item->GetNet(), netCode, 0 );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_BUS:
|
|
|
|
case NET_BUSLABELMEMBER:
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
else /* Object type BUS, BUSLABELS, and junctions. */
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2007-09-21 04:40:12 +00:00
|
|
|
netCode = Ref->m_BusNetCode;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
for( unsigned i = start; i<g_NetObjectslist.size(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* item = g_NetObjectslist[i];
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( item->m_SheetList != Ref->m_SheetList )
|
2008-02-12 21:12:46 +00:00
|
|
|
continue;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
switch( item->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SEGMENT:
|
|
|
|
case NET_PIN:
|
|
|
|
case NET_LABEL:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_PINLABEL:
|
|
|
|
case NET_NOCONNECT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_BUS:
|
|
|
|
case NET_BUSLABELMEMBER:
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
|
|
|
if( Ref->m_Start == item->m_Start
|
|
|
|
|| Ref->m_Start == item->m_End
|
|
|
|
|| Ref->m_End == item->m_Start
|
|
|
|
|| Ref->m_End == item->m_End )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( item->m_BusNetCode == 0 )
|
|
|
|
item->m_BusNetCode = netCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2009-07-12 15:29:42 +00:00
|
|
|
PropageNetCode( item->m_BusNetCode, netCode, 1 );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-11-07 20:06:07 +00:00
|
|
|
* Search if a junction is connected to segments and propagate the junction Netcode
|
|
|
|
* to objects connected by the junction.
|
2009-11-04 20:46:53 +00:00
|
|
|
* The junction must have a valid Netcode
|
2010-11-07 20:06:07 +00:00
|
|
|
* The list of objects is expected sorted by sheets.
|
|
|
|
* Search is done from index aIdxStart to the last element of g_NetObjectslist
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2011-10-07 14:41:30 +00:00
|
|
|
static void SegmentToPointConnect( NETLIST_OBJECT* aJonction, int aIsBus, int aIdxStart )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-11-07 20:06:07 +00:00
|
|
|
for( unsigned i = aIdxStart; i < g_NetObjectslist.size(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* Segment = g_NetObjectslist[i];
|
|
|
|
|
2010-11-07 20:06:07 +00:00
|
|
|
// if different sheets, no physical connection between elements is possible.
|
|
|
|
if( Segment->m_SheetList != aJonction->m_SheetList )
|
2008-02-12 21:12:46 +00:00
|
|
|
continue;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2010-11-07 20:06:07 +00:00
|
|
|
if( aIsBus == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( Segment->m_Type != NET_SEGMENT )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( Segment->m_Type != NET_BUS )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-11-07 20:06:07 +00:00
|
|
|
if( SegmentIntersect( Segment->m_Start, Segment->m_End, aJonction->m_Start ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Propagation Netcode has all the objects of the same Netcode. */
|
2010-11-07 20:06:07 +00:00
|
|
|
if( aIsBus == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( Segment->GetNet() )
|
2011-10-07 14:41:30 +00:00
|
|
|
PropageNetCode( Segment->GetNet(), aJonction->GetNet(), aIsBus );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2010-11-07 20:06:07 +00:00
|
|
|
Segment->SetNet( aJonction->GetNet() );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( Segment->m_BusNetCode )
|
2011-10-07 14:41:30 +00:00
|
|
|
PropageNetCode( Segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2010-11-07 20:06:07 +00:00
|
|
|
Segment->m_BusNetCode = aJonction->m_BusNetCode;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************
|
2007-09-21 04:40:12 +00:00
|
|
|
* Function which connects the groups of object which have the same label
|
2007-09-20 21:06:49 +00:00
|
|
|
*******************************************************************/
|
2009-07-12 15:29:42 +00:00
|
|
|
void LabelConnect( NETLIST_OBJECT* LabelRef )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
if( LabelRef->GetNet() == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
for( unsigned i = 0; i < g_NetObjectslist.size(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( g_NetObjectslist[i]->GetNet() == LabelRef->GetNet() )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( g_NetObjectslist[i]->m_SheetList != LabelRef->m_SheetList )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( (g_NetObjectslist[i]->m_Type != NET_PINLABEL
|
|
|
|
&& g_NetObjectslist[i]->m_Type != NET_GLOBLABEL
|
|
|
|
&& g_NetObjectslist[i]->m_Type != NET_GLOBBUSLABELMEMBER) )
|
2008-03-20 01:50:21 +00:00
|
|
|
continue;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( (g_NetObjectslist[i]->m_Type == NET_GLOBLABEL
|
|
|
|
|| g_NetObjectslist[i]->m_Type == NET_GLOBBUSLABELMEMBER)
|
|
|
|
&& g_NetObjectslist[i]->m_Type != LabelRef->m_Type )
|
2008-03-20 01:50:21 +00:00
|
|
|
//global labels only connect other global labels.
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
2008-08-22 14:48:30 +00:00
|
|
|
|
2010-11-08 14:27:02 +00:00
|
|
|
// regular labels are sheet-local;
|
|
|
|
// NET_HIERLABEL are used to connect sheets.
|
|
|
|
// NET_LABEL is sheet-local (***)
|
|
|
|
// NET_GLOBLABEL is global.
|
|
|
|
// NET_PINLABEL is a kind of global label (generated by a power pin invisible)
|
2011-10-12 15:34:52 +00:00
|
|
|
NETLIST_ITEM_T ntype = g_NetObjectslist[i]->m_Type;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( ntype == NET_LABEL
|
2011-10-07 14:41:30 +00:00
|
|
|
|| ntype == NET_GLOBLABEL
|
|
|
|
|| ntype == NET_HIERLABEL
|
|
|
|
|| ntype == NET_BUSLABELMEMBER
|
|
|
|
|| ntype == NET_GLOBBUSLABELMEMBER
|
|
|
|
|| ntype == NET_HIERBUSLABELMEMBER
|
|
|
|
|| ntype == NET_PINLABEL )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
if( g_NetObjectslist[i]->m_Label.CmpNoCase( LabelRef->m_Label ) != 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
2008-08-22 14:48:30 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( g_NetObjectslist[i]->GetNet() )
|
2010-06-24 18:31:43 +00:00
|
|
|
PropageNetCode( g_NetObjectslist[i]->GetNet(), LabelRef->GetNet(), 0 );
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2009-07-12 15:29:42 +00:00
|
|
|
g_NetObjectslist[i]->SetNet( LabelRef->GetNet() );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-08-22 14:48:30 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Comparison routine for sorting by increasing Netcode
|
|
|
|
* table of elements connected (TabPinSort) by qsort ()
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2011-10-11 13:38:13 +00:00
|
|
|
bool SortItemsbyNetcode( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
return Objet1->GetNet() < Objet2->GetNet();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-08-22 14:48:30 +00:00
|
|
|
|
2011-02-09 12:06:42 +00:00
|
|
|
/* Comparison routine for sorting items by Sheet Number ( used by qsort )
|
2009-11-04 20:46:53 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-10-11 13:38:13 +00:00
|
|
|
bool SortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
return Objet1->m_SheetList.Cmp( Objet2->m_SheetList ) < 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-08-22 14:48:30 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Routine positioning member. FlagNoConnect ELEMENTS
|
|
|
|
* List of objects NetList, sorted by order of Netcode
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT* NetItemRef;
|
|
|
|
unsigned NetStart, NetEnd;
|
2011-10-12 15:34:52 +00:00
|
|
|
NET_CONNECTION_T StateFlag;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
NetStart = NetEnd = 0;
|
2008-12-10 16:49:53 +00:00
|
|
|
StateFlag = UNCONNECTED;
|
2009-07-12 15:29:42 +00:00
|
|
|
for( unsigned ii = 0; ii < aNetItemBuffer.size(); ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
NetItemRef = aNetItemBuffer[ii];
|
|
|
|
if( NetItemRef->m_Type == NET_NOCONNECT && StateFlag != PAD_CONNECT )
|
|
|
|
StateFlag = NOCONNECT_SYMBOL_PRESENT;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Analysis of current net. */
|
2009-07-12 15:29:42 +00:00
|
|
|
unsigned idxtoTest = ii + 1;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( ( idxtoTest >= aNetItemBuffer.size() )
|
|
|
|
|| ( NetItemRef->GetNet() != aNetItemBuffer[idxtoTest]->GetNet() ) )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Net analysis to update m_FlagOfConnection */
|
2009-07-12 15:29:42 +00:00
|
|
|
NetEnd = idxtoTest;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* set m_FlagOfConnection member to StateFlag for all items of
|
|
|
|
* this net: */
|
2009-07-12 15:29:42 +00:00
|
|
|
for( unsigned kk = NetStart; kk < NetEnd; kk++ )
|
|
|
|
aNetItemBuffer[kk]->m_FlagOfConnection = StateFlag;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
if( idxtoTest >= aNetItemBuffer.size() )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
/* Start Analysis next Net */
|
2008-12-10 16:49:53 +00:00
|
|
|
StateFlag = UNCONNECTED;
|
2009-07-12 15:29:42 +00:00
|
|
|
NetStart = idxtoTest;
|
2007-09-20 21:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* test the current item: if this is a pin and if the reference item
|
|
|
|
* is also a pin, then 2 pins are connected, so set StateFlag to
|
|
|
|
* PAD_CONNECT (can be already done) Of course, if the current
|
|
|
|
* item is a no connect symbol, set StateFlag to
|
|
|
|
* NOCONNECT_SYMBOL_PRESENT to inhibit error diags. However if
|
|
|
|
* StateFlag is already set to PAD_CONNECT this state is kept (the
|
|
|
|
* no connect symbol was surely an error and an ERC will report this)
|
2009-07-12 15:29:42 +00:00
|
|
|
*/
|
|
|
|
for( ; ; idxtoTest++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
if( ( idxtoTest >= aNetItemBuffer.size() )
|
|
|
|
|| ( NetItemRef->GetNet() != aNetItemBuffer[idxtoTest]->GetNet() ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
switch( aNetItemBuffer[idxtoTest]->m_Type )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-07-12 15:29:42 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
2009-11-04 20:46:53 +00:00
|
|
|
wxMessageBox( wxT( "BuildNetListBase() error" ) );
|
2009-07-12 15:29:42 +00:00
|
|
|
break;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SEGMENT:
|
|
|
|
case NET_LABEL:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERLABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBLABEL:
|
2007-09-20 21:06:49 +00:00
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_PINLABEL:
|
|
|
|
case NET_BUS:
|
|
|
|
case NET_BUSLABELMEMBER:
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
2008-02-12 21:12:46 +00:00
|
|
|
case NET_HIERBUSLABELMEMBER:
|
2008-03-20 01:50:21 +00:00
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_PIN:
|
|
|
|
if( NetItemRef->m_Type == NET_PIN )
|
2008-01-05 17:30:56 +00:00
|
|
|
StateFlag = PAD_CONNECT;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_NOCONNECT:
|
2008-01-05 17:30:56 +00:00
|
|
|
if( StateFlag != PAD_CONNECT )
|
2009-07-12 15:29:42 +00:00
|
|
|
StateFlag = NOCONNECT_SYMBOL_PRESENT;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|