kicad/eeschema/netlist.cpp

1227 lines
39 KiB
C++
Raw Normal View History

/*****************/
/* netlist.cpp */
/*****************/
2007-05-06 16:03:28 +00:00
#include "fctsys.h"
#include "common.h"
2007-05-06 16:03:28 +00:00
#include "program.h"
#include "general.h"
#include "netlist.h"
2007-05-06 16:03:28 +00:00
#include "protos.h"
#include "class_library.h"
#include "lib_pin.h"
2007-05-06 16:03:28 +00:00
#include "algorithm"
// Buffer to build the list of items used in netlist and erc calculations
NETLIST_OBJECT_LIST g_NetObjectslist;
//#define NETLIST_DEBUG
2007-05-06 16:03:28 +00:00
static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus );
static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel );
static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
NETLIST_OBJECT_LIST& aNetItemBuffer );
static int ConvertBusToMembers( NETLIST_OBJECT_LIST& aNetItemBuffer, NETLIST_OBJECT& ObjNet );
static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start );
static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, int IsBus, int start );
static void LabelConnect( NETLIST_OBJECT* Label );
static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer );
static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer );
static void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer );
static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer );
// Sort functions used here:
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
// Local variables
2007-05-06 16:03:28 +00:00
static int FirstNumWireBus, LastNumWireBus, RootBusNameLength;
static int LastNetCode, LastBusNetCode;
2007-09-21 04:40:12 +00:00
#if defined(DEBUG)
2007-09-21 04:40:12 +00:00
void dumpNetTable()
{
for( unsigned idx = 0; idx < g_NetObjectslist.size(); ++idx )
2007-09-21 04:40:12 +00:00
{
g_NetObjectslist[idx]->Show( std::cout, idx );
2007-09-21 04:40:12 +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
/*
* 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
*/
void FreeNetObjectsList( NETLIST_OBJECT_LIST& aNetObjectsBuffer )
2007-05-06 16:03:28 +00:00
{
for( unsigned i = 0; i < aNetObjectsBuffer.size(); i++ )
delete aNetObjectsBuffer[i];
2007-09-20 21:06:49 +00:00
aNetObjectsBuffer.clear();
2007-05-06 16:03:28 +00:00
}
2007-09-20 21:06:49 +00:00
/*
* Build net list connection table.
*
* Updates:
* g_NetObjectslist
2007-09-20 21:06:49 +00:00
*/
void WinEDA_SchematicFrame::BuildNetListBase()
2007-05-06 16:03:28 +00:00
{
int NetNumber;
int NetCode;
SCH_SHEET_PATH* sheet;
wxString msg, activity;
wxBusyCursor Busy;
2007-09-20 21:06:49 +00:00
NetNumber = 1;
2008-03-20 01:50:21 +00:00
activity = _( "Building net list:" );
SetStatusText( activity );
2007-09-20 21:06:49 +00:00
FreeNetObjectsList( g_NetObjectslist );
/* Build the sheet (not screen) list (flattened)*/
SCH_SHEET_LIST SheetListList;
2007-09-20 21:06:49 +00:00
/* Fill g_NetObjectslist with items used in connectivity calculation */
2007-09-20 21:06:49 +00:00
2008-03-20 01:50:21 +00:00
sheet = SheetListList.GetFirst();
for( ; sheet != NULL; sheet = SheetListList.GetNext() )
AddConnectedObjects( sheet, g_NetObjectslist );
if( g_NetObjectslist.size() == 0 )
return; // no objects
2007-09-20 21:06:49 +00:00
activity << wxT( " " ) << _( "net count =" ) << wxT( " " ) << g_NetObjectslist.size();
SetStatusText( activity );
2007-09-20 21:06:49 +00:00
/* Sort objects by Sheet */
2007-09-20 21:06:49 +00:00
sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsBySheet );
2007-09-20 21:06:49 +00:00
activity << wxT( ", " ) << _( "connections" ) << wxT( "..." );
SetStatusText( activity );
2007-09-20 21:06:49 +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
for( unsigned ii = 0, istart = 0; ii < g_NetObjectslist.size(); ii++ )
2007-09-20 21:06:49 +00:00
{
NETLIST_OBJECT* net_item = g_NetObjectslist[ii];
if( net_item->m_SheetList != *sheet ) // Sheet change
2007-09-20 21:06:49 +00:00
{
sheet = &(net_item->m_SheetList);
istart = ii;
2007-09-20 21:06:49 +00:00
}
switch( net_item->m_Type )
2007-09-20 21:06:49 +00:00
{
case NET_ITEM_UNSPECIFIED:
wxMessageBox( wxT( "BuildNetListBase() error" ) );
break;
2007-09-20 21:06:49 +00:00
case NET_PIN:
case NET_PINLABEL:
case NET_SHEETLABEL:
case NET_NOCONNECT:
if( net_item->GetNet() != 0 )
break;
2007-09-20 21:06:49 +00:00
case NET_SEGMENT:
/* Control connections point to point type without bus. */
if( net_item->GetNet() == 0 )
2007-09-20 21:06:49 +00:00
{
net_item->SetNet( LastNetCode );
2007-09-20 21:06:49 +00:00
LastNetCode++;
}
PointToPointConnect( net_item, 0, istart );
2007-09-20 21:06:49 +00:00
break;
case NET_JONCTION:
/* Control of the junction outside BUS. */
if( net_item->GetNet() == 0 )
2007-09-20 21:06:49 +00:00
{
net_item->SetNet( LastNetCode );
2007-09-20 21:06:49 +00:00
LastNetCode++;
}
SegmentToPointConnect( net_item, 0, istart );
2007-09-20 21:06:49 +00:00
/* Control of the junction, on BUS. */
if( net_item->m_BusNetCode == 0 )
2007-09-20 21:06:49 +00:00
{
net_item->m_BusNetCode = LastBusNetCode;
2007-09-20 21:06:49 +00:00
LastBusNetCode++;
}
SegmentToPointConnect( net_item, ISBUS, istart );
2007-09-20 21:06:49 +00:00
break;
case NET_LABEL:
case NET_HIERLABEL:
2008-03-20 01:50:21 +00:00
case NET_GLOBLABEL:
/* Control connections type junction without bus. */
if( net_item->GetNet() == 0 )
2007-09-20 21:06:49 +00:00
{
net_item->SetNet( LastNetCode );
2007-09-20 21:06:49 +00:00
LastNetCode++;
}
SegmentToPointConnect( net_item, 0, istart );
2007-09-20 21:06:49 +00:00
break;
case NET_SHEETBUSLABELMEMBER:
if( net_item->m_BusNetCode != 0 )
break;
2007-09-20 21:06:49 +00:00
case NET_BUS:
/* Control type connections point to point mode bus */
if( net_item->m_BusNetCode == 0 )
2007-09-20 21:06:49 +00:00
{
net_item->m_BusNetCode = LastBusNetCode;
2007-09-20 21:06:49 +00:00
LastBusNetCode++;
}
PointToPointConnect( net_item, ISBUS, istart );
2007-09-20 21:06:49 +00:00
break;
case NET_BUSLABELMEMBER:
case NET_HIERBUSLABELMEMBER:
2008-03-20 01:50:21 +00:00
case NET_GLOBBUSLABELMEMBER:
/* Control connections similar has on BUS */
if( net_item->GetNet() == 0 )
2007-09-20 21:06:49 +00:00
{
net_item->m_BusNetCode = LastBusNetCode;
2007-09-20 21:06:49 +00:00
LastBusNetCode++;
}
SegmentToPointConnect( net_item, ISBUS, istart );
2007-09-20 21:06:49 +00:00
break;
}
}
#if defined(NETLIST_DEBUG) && defined(DEBUG)
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
activity << _( "done" );
SetStatusText( activity );
2007-09-20 21:06:49 +00:00
/* Updating the Bus Labels Netcode connected by Bus */
ConnectBusLabels( g_NetObjectslist );
2007-09-20 21:06:49 +00:00
activity << wxT( ", " ) << _( "bus labels" ) << wxT( "..." );;
SetStatusText( activity );
2007-09-20 21:06:49 +00:00
/* Group objects by label. */
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
2007-09-20 21:06:49 +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:
case NET_JONCTION:
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:
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;
case NET_ITEM_UNSPECIFIED:
break;
2007-09-20 21:06:49 +00:00
}
}
#if defined(NETLIST_DEBUG) && defined(DEBUG)
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
activity << _( "done" );
SetStatusText( activity );
2007-09-20 21:06:49 +00:00
/* Connection hierarchy. */
activity << wxT( ", " ) << _( "hierarchy..." );
SetStatusText( activity );
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
2007-09-20 21:06:49 +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
/* Sort objects by NetCode */
sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsbyNetcode );
2007-09-20 21:06:49 +00:00
#if defined(NETLIST_DEBUG) && defined(DEBUG)
std::cout << "\n\nafter qsort()\n";
2007-09-21 04:40:12 +00:00
dumpNetTable();
2008-03-20 01:50:21 +00:00
#endif
activity << _( "done" );
SetStatusText( activity );
2007-09-20 21:06:49 +00:00
/* Compress numbers of Netcode having consecutive values. */
2007-09-20 21:06:49 +00:00
LastNetCode = NetCode = 0;
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
2007-09-20 21:06:49 +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++;
LastNetCode = g_NetObjectslist[ii]->GetNet();
2007-09-20 21:06:49 +00:00
}
g_NetObjectslist[ii]->SetNet( NetCode );
2007-09-20 21:06:49 +00:00
}
/* Assignment of m_FlagOfConnection based connection or not. */
SetUnconnectedFlag( g_NetObjectslist );
/* find the best label object to give the best net name to each net */
FindBestNetNameForEachNet( g_NetObjectslist );
}
/** 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 FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
{
NETLIST_OBJECT_LIST candidates;
int netcode = 0; // current netcode for tested items
unsigned idxstart = 0; // index of the first item of this net
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];
if( netcode != item->GetNet() ) // End of net found
{
if( candidates.size() ) // One or more labels exists, find the best
{
NETLIST_OBJECT* bestlabel = FindBestNetName( candidates );
for (unsigned jj = idxstart; jj < ii; jj++ )
aNetItemBuffer[jj]->m_NetNameCandidate = bestlabel;
}
if( netcode == -2 )
break;
netcode = item->GetNet();
candidates.clear();
idxstart = ii;
}
switch( item->m_Type )
{
case NET_HIERLABEL:
case NET_LABEL:
case NET_PINLABEL:
case NET_GLOBLABEL:
candidates.push_back( item );
break;
default:
break;
}
}
2007-05-06 16:03:28 +00:00
}
/** Function FindBestNetName
* @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.
* so labels inside the root sheet have the highter priority.
* pin labels are global labels and have the highter priority
* local labels have the lower priority
* labels having the same priority are sorted by alphabetic order.
*
*/
static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
{
if( aLabelItemBuffer.size() == 0 )
return NULL;
// Define a priority (from low to high) to sort labels:
// NET_PINLABEL and NET_GLOBLABEL are global labels
// and priority >= PRIO_MAX-1 is for global connections
// ( i.e. for labels that are not prefixed by a sheetpath)
#define PRIO_MAX 4
int priority_order[PRIO_MAX+1] =
{ NET_ITEM_UNSPECIFIED, NET_LABEL, NET_HIERLABEL, NET_PINLABEL, NET_GLOBLABEL };
NETLIST_OBJECT*item = aLabelItemBuffer[0];
// Calculate item priority (initial priority)
int item_priority = 0;
for( unsigned ii = 0; ii <= PRIO_MAX; ii++ )
{
if ( item->m_Type == priority_order[ii] )
{
item_priority = ii;
break;
}
}
for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ )
{
NETLIST_OBJECT* candidate = aLabelItemBuffer[ii];
// Calculate candidate priority
int candidate_priority = 0;
for( unsigned ii = 0; ii <= PRIO_MAX; ii++ )
{
if ( candidate->m_Type == priority_order[ii] )
{
candidate_priority = ii;
break;
}
}
if( candidate_priority > item_priority )
{
printf(" prio (%d %d) ", item_priority, candidate_priority );
item = candidate;
item_priority = candidate_priority;
}
else if( candidate_priority == item_priority )
{
// 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
// and for a given path lenght, by alphabetic order
if( ( item_priority < PRIO_MAX-1 ) && // Not a global label or pin label
candidate->m_SheetList.Path().Length() < item->m_SheetList.Path().Length() )
{
item = candidate;
printf(" path (pr %d) ", item_priority);
}
else if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
{
item = candidate;
printf(" alpha ");
}
}
}
return item;
}
2007-09-20 21:06:49 +00:00
/*
* Connect sheets by sheetLabels
*/
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;
/* 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
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
2007-09-20 21:06:49 +00:00
{
NETLIST_OBJECT* ObjetNet = g_NetObjectslist[ii];
if( ObjetNet->m_SheetList != SheetLabel->m_SheetListInclude )
continue; //use SheetInclude, not the sheet!!
2008-03-20 01:50:21 +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
if( ObjetNet->GetNet() == SheetLabel->GetNet() )
continue; //already connected.
2008-03-20 01:50:21 +00:00
if( ObjetNet->m_Label.CmpNoCase( SheetLabel->m_Label ) != 0 )
continue; //different names.
2007-09-20 21:06:49 +00:00
/* Propagate Netcode having all the objects of the same Netcode. */
if( ObjetNet->GetNet() )
PropageNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), 0 );
2007-09-20 21:06:49 +00:00
else
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
/** Function AddConnectedObjects
* Creates the list of objects related to connections (pins of components,
* wires, labels, junctions ...)
*
* @param sheetlist: pointer to a sheetlist.
* @param aNetItemBuffer: a std::vector to store pointer on NETLIST_OBJECT
* created
2007-09-20 21:06:49 +00:00
*/
static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
std::vector<NETLIST_OBJECT*>& aNetItemBuffer )
2007-05-06 16:03:28 +00:00
{
int ii;
SCH_ITEM* DrawList;
NETLIST_OBJECT* new_item;
SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry;
SCH_SHEET_PATH list;
2008-03-20 01:50:21 +00:00
DrawList = sheetlist->LastScreen()->EEDrawList;
for( ; DrawList; DrawList = DrawList->Next() )
2007-09-20 21:06:49 +00:00
{
switch( DrawList->Type() )
{
case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) DrawList )
if( (STRUCT->GetLayer() != LAYER_BUS)
&& (STRUCT->GetLayer() != LAYER_WIRE) )
break;
2007-09-20 21:06:49 +00:00
new_item = new NETLIST_OBJECT();
new_item->m_SheetList = *sheetlist;
new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = STRUCT;
new_item->m_Start = STRUCT->m_Start;
new_item->m_End = STRUCT->m_End;
2008-03-20 01:50:21 +00:00
if( STRUCT->GetLayer() == LAYER_BUS )
{
new_item->m_Type = NET_BUS;
2007-09-20 21:06:49 +00:00
}
else /* WIRE */
{
new_item->m_Type = NET_SEGMENT;
}
aNetItemBuffer.push_back( new_item );
2007-09-20 21:06:49 +00:00
break;
case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) DrawList )
new_item = new NETLIST_OBJECT();
new_item->m_SheetList = *sheetlist;
new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = STRUCT;
new_item->m_Type = NET_JONCTION;
new_item->m_Start = new_item->m_End = STRUCT->m_Pos;
aNetItemBuffer.push_back( new_item );
2007-09-20 21:06:49 +00:00
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (SCH_NO_CONNECT*) DrawList )
new_item = new NETLIST_OBJECT();
new_item->m_SheetList = *sheetlist;
new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = STRUCT;
new_item->m_Type = NET_NOCONNECT;
new_item->m_Start = new_item->m_End = STRUCT->m_Pos;
aNetItemBuffer.push_back( new_item );
2007-09-20 21:06:49 +00:00
break;
2008-03-20 01:50:21 +00:00
case TYPE_SCH_LABEL:
2007-09-20 21:06:49 +00:00
#undef STRUCT
2008-03-20 01:50:21 +00:00
#define STRUCT ( (SCH_LABEL*) DrawList )
2007-09-20 21:06:49 +00:00
ii = IsBusLabel( STRUCT->m_Text );
2008-03-20 01:50:21 +00:00
new_item = new NETLIST_OBJECT();
new_item->m_SheetList = *sheetlist;
new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = STRUCT;
new_item->m_Type = NET_LABEL;
if( STRUCT->m_Layer == LAYER_GLOBLABEL )
new_item->m_Type = NET_GLOBLABEL;
if( STRUCT->m_Layer == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL;
new_item->m_Label = STRUCT->m_Text;
new_item->m_Start = new_item->m_End = STRUCT->m_Pos;
aNetItemBuffer.push_back( new_item );
/* If a bus connects to label */
if( ii )
ConvertBusToMembers( aNetItemBuffer, *new_item );
2008-03-20 01:50:21 +00:00
2007-09-20 21:06:49 +00:00
break;
2008-03-20 01:50:21 +00:00
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
2007-09-20 21:06:49 +00:00
#undef STRUCT
2008-03-20 01:50:21 +00:00
#define STRUCT ( (SCH_LABEL*) DrawList )
2007-09-20 21:06:49 +00:00
ii = IsBusLabel( STRUCT->m_Text );
new_item = new NETLIST_OBJECT();
new_item->m_SheetList = *sheetlist;
new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = STRUCT;
new_item->m_Type = NET_LABEL;
2008-03-20 01:50:21 +00:00
// this is not the simplest way of doing it
// (look at the case statement above).
if( STRUCT->m_Layer == LAYER_GLOBLABEL )
new_item->m_Type = NET_GLOBLABEL;
if( STRUCT->m_Layer == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL;
new_item->m_Label = STRUCT->m_Text;
new_item->m_Start = new_item->m_End = STRUCT->m_Pos;
aNetItemBuffer.push_back( new_item );
/* If a bus connects to label */
if( ii )
ConvertBusToMembers( aNetItemBuffer, *new_item );
2008-03-20 01:50:21 +00:00
2007-09-20 21:06:49 +00:00
break;
2008-03-20 01:50:21 +00:00
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
2007-09-20 21:06:49 +00:00
if( Entry == NULL )
break;
2008-03-20 01:50:21 +00:00
for( LIB_PIN* pin = Entry->GetNextPin(); pin; pin = Entry->GetNextPin( pin ) )
2007-09-20 21:06:49 +00:00
{
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
2008-03-20 01:50:21 +00:00
if( pin->GetUnit() &&
( pin->GetUnit() != DrawLibItem->GetUnitSelection( sheetlist ) ) )
2007-09-20 21:06:49 +00:00
continue;
2008-03-20 01:50:21 +00:00
if( pin->GetConvert() && ( pin->GetConvert() != DrawLibItem->m_Convert ) )
2007-09-20 21:06:49 +00:00
continue;
wxPoint pos2 = DrawLibItem->m_Transform.TransformCoordinate( pin->m_Pos ) +
DrawLibItem->m_Pos;
2007-09-20 21:06:49 +00:00
new_item = new NETLIST_OBJECT();
new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = pin;
new_item->m_SheetList = *sheetlist;
new_item->m_Type = NET_PIN;
new_item->m_Link = DrawLibItem;
new_item->m_ElectricalType = pin->m_PinType;
new_item->m_PinNum = pin->m_PinNum;
new_item->m_Label = pin->m_PinName;
new_item->m_Start = new_item->m_End = pos2;
aNetItemBuffer.push_back( new_item );
2007-09-20 21:06:49 +00:00
if( ( (int) pin->m_PinType == (int) PIN_POWER_IN )
&& ( pin->m_Attributs & PINNOTDRAW ) )
2008-03-20 01:50:21 +00:00
{
/* There is an associated PIN_LABEL. */
new_item = new NETLIST_OBJECT();
new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = NULL;
new_item->m_SheetList = *sheetlist;
new_item->m_Type = NET_PINLABEL;
new_item->m_Label = pin->m_PinName;
new_item->m_Start = pos2;
new_item->m_End = new_item->m_Start;
aNetItemBuffer.push_back( new_item );
2007-09-20 21:06:49 +00:00
}
}
break;
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case TYPE_SCH_MARKER:
2008-03-20 01:50:21 +00:00
case TYPE_SCH_TEXT:
2007-09-20 21:06:49 +00:00
break;
case DRAW_SHEET_STRUCT_TYPE:
{
2007-09-20 21:06:49 +00:00
#undef STRUCT
#define STRUCT ( (SCH_SHEET*) DrawList )
2008-03-20 01:50:21 +00:00
list = *sheetlist;
list.Push( STRUCT );
SCH_SHEET* sheet = (SCH_SHEET*) DrawList;
BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() )
2007-09-20 21:06:49 +00:00
{
ii = IsBusLabel( label.m_Text );
new_item = new NETLIST_OBJECT();
new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = &label;
new_item->m_SheetList = *sheetlist;
new_item->m_Link = DrawList;
new_item->m_Type = NET_SHEETLABEL;
new_item->m_ElectricalType = label.m_Shape;
new_item->m_Label = label.m_Text;
new_item->m_SheetListInclude = list;
new_item->m_Start = new_item->m_End = label.m_Pos;
aNetItemBuffer.push_back( new_item );
if( ii )
ConvertBusToMembers( aNetItemBuffer, *new_item );
2007-09-20 21:06:49 +00:00
}
break;
}
2007-09-20 21:06:49 +00:00
2008-04-15 19:38:19 +00:00
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
2007-09-20 21:06:49 +00:00
default:
{
wxString msg;
2009-08-01 19:26:05 +00:00
msg.Printf( wxT( "Netlist: unexpected struct type %d" ),
DrawList->Type() );
2009-08-01 19:26:05 +00:00
wxMessageBox( msg );
2007-09-20 21:06:49 +00:00
break;
}
}
}
2007-05-06 16:03:28 +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
*/
static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
2007-05-06 16:03:28 +00:00
{
for( unsigned ii = 0; ii < aNetItemBuffer.size(); ii++ )
2007-09-20 21:06:49 +00:00
{
NETLIST_OBJECT* Label = aNetItemBuffer[ii];
2007-09-20 21:06:49 +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
for( unsigned jj = ii + 1; jj < aNetItemBuffer.size(); jj++ )
2007-09-20 21:06:49 +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)
|| (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
PropageNetCode( LabelInTst->GetNet(),
Label->GetNet(), 0 );
2007-09-20 21:06:49 +00:00
}
}
}
}
2007-05-06 16:03:28 +00:00
}
/* Check if the Label has a bus notation.
* Returns 0 if not
* Number of members if yes
* Updates FirstNumWireBus, LastNumWireBus and RootBusNameLength
2007-09-20 21:06:49 +00:00
*/
int IsBusLabel( const wxString& LabelDrawList )
2007-05-06 16:03:28 +00:00
{
2007-09-20 21:06:49 +00:00
unsigned Num;
int ii;
wxString BufLine;
long tmp;
bool error = FALSE;
/* Search for '[' because a bus label is like "busname[nn..mm]" */
ii = LabelDrawList.Find( '[' );
if( ii < 0 )
return 0;
2008-03-20 01:50:21 +00:00
2007-09-20 21:06:49 +00:00
Num = (unsigned) ii;
FirstNumWireBus = LastNumWireBus = 9;
RootBusNameLength = Num;
Num++;
while( LabelDrawList[Num] != '.' && Num < LabelDrawList.Len() )
{
BufLine.Append( LabelDrawList[Num] );
Num++;
}
if( !BufLine.ToLong( &tmp ) )
error = TRUE;
2008-03-20 01:50:21 +00:00
2007-09-20 21:06:49 +00:00
FirstNumWireBus = tmp;
while( LabelDrawList[Num] == '.' && Num < LabelDrawList.Len() )
Num++;
BufLine.Empty();
while( LabelDrawList[Num] != ']' && Num < LabelDrawList.Len() )
{
BufLine.Append( LabelDrawList[Num] );
Num++;
}
if( !BufLine.ToLong( &tmp ) )
error = TRUE;;
2007-09-20 21:06:49 +00:00
LastNumWireBus = tmp;
if( FirstNumWireBus < 0 )
FirstNumWireBus = 0;
if( LastNumWireBus < 0 )
LastNumWireBus = 0;
if( FirstNumWireBus > LastNumWireBus )
{
EXCHG( FirstNumWireBus, LastNumWireBus );
}
return LastNumWireBus - FirstNumWireBus + 1;
2007-05-06 16:03:28 +00:00
}
/*
* Routine which breaks a seal Bus type Label in as many members it contains,
* And creates structures with type NET_GLOBBUSLABELMEMBER, NET_BUSLABELMEMBER
* Or NET_SHEETBUSLABELMEMBER
* Entry = pointer to NETLIST_OBJECT initializes the corresp buslabel
* Assumes that FirstNumWireBus, LastNumWireBus and RootBusNameLength are up
* to date
* Amends NETLIST_OBJECT base and meets the following
* M_Label is a pointer to a new wxString
* M_Label must be deallocated by the user (only for a NET_GLOBBUSLABELMEMBER,
* NET_BUSLABELMEMBER gold NET_SHEETBUSLABELMEMBER object type)
*/
static int ConvertBusToMembers( NETLIST_OBJECT_LIST& aNetItemBuffer,
NETLIST_OBJECT& BusLabel )
2007-05-06 16:03:28 +00:00
{
2007-09-20 21:06:49 +00:00
int NumItem, BusMember;
wxString BufLine;
if( BusLabel.m_Type == NET_HIERLABEL )
BusLabel.m_Type = NET_HIERBUSLABELMEMBER;
else if( BusLabel.m_Type == NET_GLOBLABEL )
BusLabel.m_Type = NET_GLOBBUSLABELMEMBER;
else if( BusLabel.m_Type == NET_SHEETLABEL )
BusLabel.m_Type = NET_SHEETBUSLABELMEMBER;
2007-09-20 21:06:49 +00:00
else
BusLabel.m_Type = NET_BUSLABELMEMBER;
2007-09-20 21:06:49 +00:00
/* Conversion of BusLabel to the root Label name + the member id like mybus0, mybus1 ... */
BufLine = BusLabel.m_Label.Left( RootBusNameLength );
2008-03-20 01:50:21 +00:00
2007-09-20 21:06:49 +00:00
BusMember = FirstNumWireBus;
BufLine << BusMember;
BusLabel.m_Label = BufLine;
2007-09-20 21:06:49 +00:00
BusLabel.m_Member = BusMember;
2007-09-20 21:06:49 +00:00
NumItem = 1;
for( BusMember++; BusMember <= LastNumWireBus; BusMember++ )
{
NETLIST_OBJECT* new_label = new NETLIST_OBJECT( BusLabel );
2007-09-21 04:40:12 +00:00
NumItem++;
/* Conversion of BusLabel to the root name + the current member id.*/
BufLine = BusLabel.m_Label.Left( RootBusNameLength );
2007-09-20 21:06:49 +00:00
BufLine << BusMember;
new_label->m_Label = BufLine;
2007-09-20 21:06:49 +00:00
new_label->m_Member = BusMember;
aNetItemBuffer.push_back( new_label );
2007-09-20 21:06:49 +00:00
}
return NumItem;
2007-05-06 16:03:28 +00:00
}
2007-09-20 21:06:49 +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
* If IsBus != 0; is the member who is spreading BusNetCode
2007-09-20 21:06:49 +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;
if( IsBus == 0 ) /* Propagate NetCode */
2007-09-20 21:06:49 +00:00
{
for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
2007-09-20 21:06:49 +00:00
{
NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
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
}
}
}
else /* Propagate BusNetCode */
2007-09-20 21:06:49 +00:00
{
for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
2007-09-20 21:06:49 +00:00
{
NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
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
/*
* 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
*
* 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
*
* The Ref object must have a valid Netcode.
2008-03-20 01:50:21 +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
*/
static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
2007-05-06 16:03:28 +00:00
{
int netCode;
2007-09-20 21:06:49 +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();
for( unsigned i = start; i < g_NetObjectslist.size(); i++ )
2007-09-20 21:06:49 +00:00
{
NETLIST_OBJECT* item = g_NetObjectslist[i];
if( item->m_SheetList != Ref->m_SheetList ) //used to be > (why?)
continue;
2008-03-20 01:50:21 +00:00
switch( item->m_Type )
2007-09-20 21:06:49 +00:00
{
case NET_SEGMENT:
case NET_PIN:
case NET_LABEL:
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_JONCTION:
case NET_NOCONNECT:
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
{
if( item->GetNet() == 0 )
item->SetNet( netCode );
2007-09-20 21:06:49 +00:00
else
PropageNetCode( item->GetNet(), netCode, 0 );
2007-09-20 21:06:49 +00:00
}
break;
case NET_BUS:
case NET_BUSLABELMEMBER:
case NET_SHEETBUSLABELMEMBER:
case NET_HIERBUSLABELMEMBER:
2008-03-20 01:50:21 +00:00
case NET_GLOBBUSLABELMEMBER:
case NET_ITEM_UNSPECIFIED:
2007-09-20 21:06:49 +00:00
break;
}
}
}
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;
for( unsigned i = start; i<g_NetObjectslist.size(); i++ )
2007-09-20 21:06:49 +00:00
{
NETLIST_OBJECT* item = g_NetObjectslist[i];
if( item->m_SheetList != Ref->m_SheetList )
continue;
2007-09-20 21:06:49 +00:00
switch( item->m_Type )
2007-09-20 21:06:49 +00:00
{
case NET_ITEM_UNSPECIFIED:
2007-09-20 21:06:49 +00:00
case NET_SEGMENT:
case NET_PIN:
case NET_LABEL:
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:
case NET_HIERBUSLABELMEMBER:
2008-03-20 01:50:21 +00:00
case NET_GLOBBUSLABELMEMBER:
2007-09-20 21:06:49 +00:00
case NET_JONCTION:
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
{
if( item->m_BusNetCode == 0 )
item->m_BusNetCode = netCode;
2007-09-20 21:06:49 +00:00
else
PropageNetCode( item->m_BusNetCode, netCode, 1 );
2007-09-20 21:06:49 +00:00
}
break;
}
}
}
2007-05-06 16:03:28 +00:00
}
/*
* Search if a junction is connected to segments and propagate the junction Netcode
* to objects connected by the junction.
* The junction must have a valid Netcode
* 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
*/
static void SegmentToPointConnect( NETLIST_OBJECT* aJonction,
int aIsBus, int aIdxStart )
2007-05-06 16:03:28 +00:00
{
for( unsigned i = aIdxStart; i < g_NetObjectslist.size(); i++ )
2007-09-20 21:06:49 +00:00
{
NETLIST_OBJECT* Segment = g_NetObjectslist[i];
// if different sheets, no physical connection between elements is possible.
if( Segment->m_SheetList != aJonction->m_SheetList )
continue;
2007-09-20 21:06:49 +00:00
if( aIsBus == 0 )
2007-09-20 21:06:49 +00:00
{
if( Segment->m_Type != NET_SEGMENT )
2007-09-20 21:06:49 +00:00
continue;
}
else
{
if( Segment->m_Type != NET_BUS )
2007-09-20 21:06:49 +00:00
continue;
}
if( SegmentIntersect( Segment->m_Start, Segment->m_End, aJonction->m_Start ) )
2007-09-20 21:06:49 +00:00
{
/* Propagation Netcode has all the objects of the same Netcode. */
if( aIsBus == 0 )
2007-09-20 21:06:49 +00:00
{
if( Segment->GetNet() )
PropageNetCode( Segment->GetNet(),
aJonction->GetNet(), aIsBus );
2007-09-20 21:06:49 +00:00
else
Segment->SetNet( aJonction->GetNet() );
2007-09-20 21:06:49 +00:00
}
else
{
if( Segment->m_BusNetCode )
PropageNetCode( Segment->m_BusNetCode,
aJonction->m_BusNetCode, aIsBus );
2007-09-20 21:06:49 +00:00
else
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
*******************************************************************/
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;
for( unsigned i = 0; i < g_NetObjectslist.size(); i++ )
2007-09-20 21:06:49 +00:00
{
if( g_NetObjectslist[i]->GetNet() == LabelRef->GetNet() )
2007-09-20 21:06:49 +00:00
continue;
if( g_NetObjectslist[i]->m_SheetList != LabelRef->m_SheetList )
2007-09-20 21:06:49 +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;
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;
}
// 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)
NetObjetType ntype = g_NetObjectslist[i]->m_Type;
if( ntype == NET_LABEL
|| 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
{
if( g_NetObjectslist[i]->m_Label.CmpNoCase( LabelRef->m_Label ) != 0 )
2007-09-20 21:06:49 +00:00
continue;
if( g_NetObjectslist[i]->GetNet() )
PropageNetCode( g_NetObjectslist[i]->GetNet(), LabelRef->GetNet(), 0 );
2007-09-20 21:06:49 +00:00
else
g_NetObjectslist[i]->SetNet( LabelRef->GetNet() );
2007-09-20 21:06:49 +00:00
}
}
2007-05-06 16:03:28 +00:00
}
/* Comparison routine for sorting by increasing Netcode
* table of elements connected (TabPinSort) by qsort ()
2007-09-20 21:06:49 +00:00
*/
bool SortItemsbyNetcode( const NETLIST_OBJECT* Objet1,
const NETLIST_OBJECT* Objet2 )
2007-05-06 16:03:28 +00:00
{
return Objet1->GetNet() < Objet2->GetNet();
2007-05-06 16:03:28 +00:00
}
/* Comparison routine for sorting by NumSheet table of elements
* connected (TabPinSort) by qsort ()
*/
2007-05-06 16:03:28 +00:00
bool SortItemsBySheet( const NETLIST_OBJECT* Objet1,
const NETLIST_OBJECT* Objet2 )
2007-05-06 16:03:28 +00:00
{
return Objet1->m_SheetList.Cmp( Objet2->m_SheetList ) < 0;
2007-05-06 16:03:28 +00:00
}
/* Routine positioning member. FlagNoConnect ELEMENTS
* List of objects NetList, sorted by order of Netcode
2007-09-20 21:06:49 +00:00
*/
static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer )
2007-05-06 16:03:28 +00:00
{
NETLIST_OBJECT* NetItemRef;
unsigned NetStart, NetEnd;
ConnectType StateFlag;
2007-09-20 21:06:49 +00:00
NetStart = NetEnd = 0;
StateFlag = UNCONNECTED;
for( unsigned ii = 0; ii < aNetItemBuffer.size(); ii++ )
2007-09-20 21:06:49 +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
/* Analysis of current net. */
unsigned idxtoTest = ii + 1;
2007-09-20 21:06:49 +00:00
if( ( idxtoTest >= aNetItemBuffer.size() )
|| ( NetItemRef->GetNet() != aNetItemBuffer[idxtoTest]->GetNet() ) )
2008-03-20 01:50:21 +00:00
{
/* Net analysis to update m_FlagOfConnection */
NetEnd = idxtoTest;
2007-09-20 21:06:49 +00:00
/* set m_FlagOfConnection member to StateFlag for all items of
* this net: */
for( unsigned kk = NetStart; kk < NetEnd; kk++ )
aNetItemBuffer[kk]->m_FlagOfConnection = StateFlag;
2007-09-20 21:06:49 +00:00
if( idxtoTest >= aNetItemBuffer.size() )
2007-09-20 21:06:49 +00:00
return;
/* Start Analysis next Net */
StateFlag = UNCONNECTED;
NetStart = idxtoTest;
2007-09-20 21:06:49 +00:00
continue;
}
/* 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)
*/
for( ; ; idxtoTest++ )
2007-09-20 21:06:49 +00:00
{
if( ( idxtoTest >= aNetItemBuffer.size() )
|| ( NetItemRef->GetNet() != aNetItemBuffer[idxtoTest]->GetNet() ) )
2007-09-20 21:06:49 +00:00
break;
switch( aNetItemBuffer[idxtoTest]->m_Type )
2007-09-20 21:06:49 +00:00
{
case NET_ITEM_UNSPECIFIED:
wxMessageBox( wxT( "BuildNetListBase() error" ) );
break;
2007-09-20 21:06:49 +00:00
case NET_SEGMENT:
case NET_LABEL:
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:
case NET_HIERBUSLABELMEMBER:
2008-03-20 01:50:21 +00:00
case NET_GLOBBUSLABELMEMBER:
2007-09-20 21:06:49 +00:00
case NET_JONCTION:
break;
case NET_PIN:
if( NetItemRef->m_Type == NET_PIN )
2008-01-05 17:30:56 +00:00
StateFlag = PAD_CONNECT;
2007-09-20 21:06:49 +00:00
break;
case NET_NOCONNECT:
2008-01-05 17:30:56 +00:00
if( StateFlag != PAD_CONNECT )
StateFlag = NOCONNECT_SYMBOL_PRESENT;
2007-09-20 21:06:49 +00:00
break;
}
}
}
2007-05-06 16:03:28 +00:00
}