23
23
static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus );
24
24
static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel );
25
static void ListeObjetConnection( SCH_SHEET_PATH* sheetlist,
26
NETLIST_OBJECT_LIST& aNetItemBuffer );
25
static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
26
NETLIST_OBJECT_LIST& aNetItemBuffer );
27
27
static int ConvertBusToMembers( NETLIST_OBJECT_LIST& aNetItemBuffer, NETLIST_OBJECT& ObjNet );
28
28
static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start );
29
29
static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, int IsBus, int start );
31
31
static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer );
32
32
static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer );
34
static void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer );
35
static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer );
34
37
// Sort functions used here:
35
38
static bool SortItemsbyNetcode( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 );
36
39
static bool SortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 );
38
42
static int FirstNumWireBus, LastNumWireBus, RootBusNameLength;
39
43
static int LastNetCode, LastBusNetCode;
291
295
/* Assignment of m_FlagOfConnection based connection or not. */
292
296
SetUnconnectedFlag( g_NetObjectslist );
298
/* find the best label object to give the best net name to each net */
299
FindBestNetNameForEachNet( g_NetObjectslist );
303
/** function FindBestNetNameForEachNet
304
* fill the .m_NetNameCandidate member of each item of aNetItemBuffer
305
* with a reference to the "best" NETLIST_OBJECT usable to give a name to the net
306
* If no suitable object found, .m_NetNameCandidate is filled with 0.
307
* The "best" NETLIST_OBJECT is a NETLIST_OBJECT that have the type label
308
* and by priority order:
309
* the label is global or local
310
* the label is in the first sheet in a hierarchy (the root sheet has the most priority)
313
void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
315
NETLIST_OBJECT_LIST candidates;
316
int netcode = 0; // current netcode for tested items
317
unsigned idxstart = 0; // index of the first item of this net
318
for( unsigned ii = 0; ii <= aNetItemBuffer.size(); ii++ )
320
NETLIST_OBJECT* item;
322
if( ii == aNetItemBuffer.size() ) // last item already found
325
item = aNetItemBuffer[ii];
326
if( netcode != item->GetNet() ) // End of net found
328
if( candidates.size() ) // O,e or more labels exists, find the best
330
NETLIST_OBJECT* bestlabel = FindBestNetName( candidates );
331
for (unsigned jj = idxstart; jj < ii; jj++ )
332
aNetItemBuffer[jj]->m_NetNameCandidate = bestlabel;
336
netcode = item->GetNet();
340
switch( item->m_Type )
345
candidates.push_back( item );
354
/** Function FindBestNetName
355
* @return a reference to the "best" label that can be used to give a name
357
* @param aLabelItemBuffer = list of NETLIST_OBJECT type labels candidates.
358
* labels are local labels, hierarchical labels or pin labels
359
* labels in included sheets have a lower priority than labels in the current sheet.
360
* so labels inside the root sheet have the highter priority.
361
* pin labels are global labels and have the highter priority
362
* local labels have the lower priority
363
* labels having the same priority are sorted by alphabetic order.
366
static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
368
if( aLabelItemBuffer.size() == 0 )
371
NETLIST_OBJECT*item = aLabelItemBuffer[0];
373
for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ )
375
NETLIST_OBJECT* candidate = aLabelItemBuffer[ii];
376
if( candidate->m_SheetList.Path().Length() < item->m_SheetList.Path().Length() )
381
switch ( item->m_Type )
384
if( candidate->m_Type == NET_PINLABEL )
386
else if( candidate->m_Type == NET_HIERLABEL )
388
if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
394
if( candidate->m_Type == NET_LABEL )
396
if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
404
if( candidate->m_Type != NET_PINLABEL )
406
if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
410
default: // Should not occur.
297
418
* Connect sheets by sheetLabels
318
439
if( ObjetNet->GetNet() == SheetLabel->GetNet() )
319
440
continue; //already connected.
321
wxASSERT( ObjetNet->m_Label );
322
wxASSERT( SheetLabel->m_Label );
323
if( ObjetNet->m_Label->CmpNoCase( *SheetLabel->m_Label ) != 0 )
442
if( ObjetNet->m_Label.CmpNoCase( SheetLabel->m_Label ) != 0 )
324
443
continue; //different names.
326
445
/* Propagate Netcode having all the objects of the same Netcode. */
534
652
case DRAW_SHEET_STRUCT_TYPE:
536
655
#define STRUCT ( (SCH_SHEET*) DrawList )
537
656
list = *sheetlist;
538
657
list.Push( STRUCT );
539
SheetLabel = STRUCT->m_Label;
540
for( ; SheetLabel != NULL; SheetLabel = SheetLabel->Next() )
658
SCH_SHEET* sheet = (SCH_SHEET*) DrawList;
660
BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() )
542
ii = IsBusLabel( SheetLabel->m_Text );
662
ii = IsBusLabel( label.m_Text );
543
663
new_item = new NETLIST_OBJECT();
544
664
new_item->m_SheetListInclude = *sheetlist;
545
new_item->m_Comp = SheetLabel;
665
new_item->m_Comp = &label;
546
666
new_item->m_SheetList = *sheetlist;
547
667
new_item->m_Link = DrawList;
548
668
new_item->m_Type = NET_SHEETLABEL;
549
new_item->m_ElectricalType = SheetLabel->m_Shape;
550
new_item->m_Label = &SheetLabel->m_Text;
669
new_item->m_ElectricalType = label.m_Shape;
670
new_item->m_Label = label.m_Text;
551
671
new_item->m_SheetListInclude = list;
552
new_item->m_Start = new_item->m_End = SheetLabel->m_Pos;
672
new_item->m_Start = new_item->m_End = label.m_Pos;
553
673
aNetItemBuffer.push_back( new_item );
707
828
BusLabel.m_Type = NET_BUSLABELMEMBER;
709
830
/* Conversion of BusLabel to the root Label name + the member id like mybus0, mybus1 ... */
710
BufLine = BusLabel.m_Label->Left( RootBusNameLength );
831
BufLine = BusLabel.m_Label.Left( RootBusNameLength );
712
833
BusMember = FirstNumWireBus;
713
834
BufLine << BusMember;
714
BusLabel.m_Label = new wxString( BufLine );
835
BusLabel.m_Label = BufLine;
716
837
BusLabel.m_Member = BusMember;
974
1095
|| ntype == NET_HIERBUSLABELMEMBER
975
1096
|| ntype == NET_PINLABEL )
977
if( g_NetObjectslist[i]->m_Label->CmpNoCase( *LabelRef->m_Label )
1098
if( g_NetObjectslist[i]->m_Label.CmpNoCase( LabelRef->m_Label ) != 0 )
981
1101
if( g_NetObjectslist[i]->GetNet() )
983
g_NetObjectslist[i]->GetNet(), LabelRef->GetNet(), 0 );
1102
PropageNetCode( g_NetObjectslist[i]->GetNet(), LabelRef->GetNet(), 0 );
985
1104
g_NetObjectslist[i]->SetNet( LabelRef->GetNet() );