Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
aa9e61ed
Commit
aa9e61ed
authored
Jul 12, 2009
by
charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup about netlist, ERC and markers in eeschema ( work in progress )
parent
a97a2b4b
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
764 additions
and
774 deletions
+764
-774
about_kicad.cpp
common/about_kicad.cpp
+1
-1
CMakeLists.txt
eeschema/CMakeLists.txt
+1
-0
class_libentry.cpp
eeschema/class_libentry.cpp
+0
-4
class_netlist_object.cpp
eeschema/class_netlist_object.cpp
+149
-0
class_netlist_object.h
eeschema/class_netlist_object.h
+80
-0
erc.cpp
eeschema/erc.cpp
+52
-59
netform.cpp
eeschema/netform.cpp
+126
-146
netlist.cpp
eeschema/netlist.cpp
+347
-494
netlist.h
eeschema/netlist.h
+7
-66
netlist_control.cpp
eeschema/netlist_control.cpp
+0
-3
wxEeschemaStruct.h
include/wxEeschemaStruct.h
+1
-1
No files found.
common/about_kicad.cpp
View file @
aa9e61ed
...
...
@@ -8,7 +8,7 @@
#include "appl_wxstruct.h"
#define BUILD_VERSION "(200907
08
-unstable)"
#define BUILD_VERSION "(200907
12
-unstable)"
#ifdef HAVE_SVN_VERSION
...
...
eeschema/CMakeLists.txt
View file @
aa9e61ed
...
...
@@ -23,6 +23,7 @@ set(EESCHEMA_SRCS
class_libentry_fields.cpp
class_library.cpp
class_marker_sch.cpp
class_netlist_object.cpp
class_pin.cpp
class_sch_cmp_field.cpp
class_schematic_items.cpp
...
...
eeschema/class_libentry.cpp
View file @
aa9e61ed
...
...
@@ -675,10 +675,6 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
bBox
.
Merge
(
DrawEntry
->
GetBoundingBox
()
);
}
wxRect
r
=
bBox
;
wxLogDebug
(
wxT
(
"New boundary box = (%d, %d, %d, %d)"
),
r
.
GetLeft
(),
r
.
GetRight
(),
r
.
GetBottom
(),
r
.
GetTop
()
);
return
bBox
;
}
...
...
eeschema/class_netlist_object.cpp
0 → 100644
View file @
aa9e61ed
/*************************************************************************************/
/* Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations) */
/*************************************************************************************/
#include "fctsys.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_netlist_object.h"
#if defined(DEBUG)
#include <iostream>
const
char
*
ShowType
(
NetObjetType
aType
)
{
const
char
*
ret
;
switch
(
aType
)
{
case
NET_SEGMENT
:
ret
=
"segment"
;
break
;
case
NET_BUS
:
ret
=
"bus"
;
break
;
case
NET_JONCTION
:
ret
=
"junction"
;
break
;
case
NET_LABEL
:
ret
=
"label"
;
break
;
case
NET_HIERLABEL
:
ret
=
"hierlabel"
;
break
;
case
NET_GLOBLABEL
:
ret
=
"glabel"
;
break
;
case
NET_BUSLABELMEMBER
:
ret
=
"buslblmember"
;
break
;
case
NET_HIERBUSLABELMEMBER
:
ret
=
"hierbuslblmember"
;
break
;
case
NET_GLOBBUSLABELMEMBER
:
ret
=
"gbuslblmember"
;
break
;
case
NET_SHEETBUSLABELMEMBER
:
ret
=
"sbuslblmember"
;
break
;
case
NET_SHEETLABEL
:
ret
=
"sheetlabel"
;
break
;
case
NET_PINLABEL
:
ret
=
"pinlabel"
;
break
;
case
NET_PIN
:
ret
=
"pin"
;
break
;
case
NET_NOCONNECT
:
ret
=
"noconnect"
;
break
;
default:
ret
=
"??"
;
break
;
}
return
ret
;
}
void
NETLIST_OBJECT
::
Show
(
std
::
ostream
&
out
,
int
ndx
)
{
wxString
path
=
m_SheetList
.
PathHumanReadable
();
out
<<
"<netItem ndx=
\"
"
<<
ndx
<<
'"'
<<
" type=
\"
"
<<
ShowType
(
m_Type
)
<<
'"'
<<
" netCode=
\"
"
<<
GetNet
()
<<
'"'
<<
" sheet=
\"
"
<<
CONV_TO_UTF8
(
path
)
<<
'"'
<<
">
\n
"
;
out
<<
" <start "
<<
m_Start
<<
"/> <end "
<<
m_End
<<
"/>
\n
"
;
if
(
m_Label
)
out
<<
" <label>"
<<
m_Label
->
mb_str
()
<<
"</label>
\n
"
;
if
(
m_Comp
)
m_Comp
->
Show
(
1
,
out
);
else
out
<<
" m_Comp==NULL
\n
"
;
out
<<
"</netItem>
\n
"
;
}
#endif
NETLIST_OBJECT
::
NETLIST_OBJECT
()
{
m_Type
=
NET_ITEM_UNSPECIFIED
;
/* Type of this item (see NetObjetType enum) */
m_Comp
=
NULL
;
/* Pointer on the library item that created this net object (the parent)*/
m_Link
=
NULL
;
/* For Hierarchical_PIN_Sheet_Struct:
* Pointer to the hierarchy sheet that contains this Hierarchical_PIN_Sheet_Struct
* For Pins: pointer to the component that contains this pin
*/
m_Flag
=
0
;
/* flag used in calculations */
m_ElectricalType
=
0
;
/* Has meaning only for Pins and hierachical pins: electrical type */
m_NetCode
=
0
;
/* net code for all items except BUS labels because a BUS label has
* as many net codes as bus members
*/
m_BusNetCode
=
0
;
/* Used for BUS connections */
m_Member
=
0
;
/* for labels type NET_BUSLABELMEMBER ( bus member created from the BUS label )
* member number
*/
m_FlagOfConnection
=
UNCONNECTED
;
m_PinNum
=
0
;
/* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
m_Label
=
0
;
/* For all labels:pointer on the text label */
}
// Copy constructor
NETLIST_OBJECT
::
NETLIST_OBJECT
(
NETLIST_OBJECT
&
aSource
)
{
}
NETLIST_OBJECT
::~
NETLIST_OBJECT
()
{
/* NETLIST_OBJECT is owner of m_Label only if its type is
* NET_HIERBUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_SHEETBUSLABELMEMBER or NET_BUSLABELMEMBER
* So we must delete m_Label only for these cases
* ( see the note in ConvertBustToMembers)
*/
switch
(
m_Type
)
{
default
:
break
;
case
NET_HIERBUSLABELMEMBER
:
case
NET_GLOBBUSLABELMEMBER
:
case
NET_SHEETBUSLABELMEMBER
:
case
NET_BUSLABELMEMBER
:
SAFE_DELETE
(
m_Label
);
break
;
}
}
eeschema/class_netlist_object.h
0 → 100644
View file @
aa9e61ed
/*************************************************************************************/
/* Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations) */
/*************************************************************************************/
#ifndef _CLASS_NETLIST_OBJECT_H_
#define _CLASS_NETLIST_OBJECT_H_
/* Type of Net objects (wires, labels, pins...) */
enum
NetObjetType
{
NET_ITEM_UNSPECIFIED
,
// only for not yet initialized instances
NET_SEGMENT
,
// connection by wire
NET_BUS
,
// connection by bus
NET_JONCTION
,
// connection by junction: can connect to or more crossing wires
NET_LABEL
,
// this is a local label
NET_GLOBLABEL
,
// this is a global label that connect all others global label in whole hierrachy
NET_HIERLABEL
,
// element to indicate connection to a higher-level sheet
NET_SHEETLABEL
,
// element to indicate connection to a lower-level sheet.
NET_BUSLABELMEMBER
,
/* created when a bus label is found:
* the bus label (like DATA[0..7] is converted to n single labels like DATA0, DATA1 ...
*/
NET_GLOBBUSLABELMEMBER
,
// see NET_BUSLABELMEMBER, used when a global bus label is found
NET_HIERBUSLABELMEMBER
,
// see NET_BUSLABELMEMBER, used when a hierarchical bus label is found
NET_SHEETBUSLABELMEMBER
,
// see NET_BUSLABELMEMBER, used when a pin sheet label using bus notation is found
NET_PINLABEL
,
/* created when a pin is POWER (IN or OUT) with invisible attribute is found:
* these pins are equivalent to a global label and are automatically connected
*/
NET_PIN
,
// this is an usual pin
NET_NOCONNECT
// this is a no connect symbol
};
/* Values for .m_FlagOfConnection member */
enum
ConnectType
{
UNCONNECTED
=
0
,
/* Pin or Label not connected (error) */
NOCONNECT_SYMBOL_PRESENT
,
/* Pin not connected but have a NoConnect symbol on it (no error) */
PAD_CONNECT
/* Normal connection (no error) */
};
class
NETLIST_OBJECT
{
public
:
NetObjetType
m_Type
;
/* Type of this item (see NetObjetType enum) */
EDA_BaseStruct
*
m_Comp
;
/* Pointer on the library item that created this net object (the parent)*/
SCH_ITEM
*
m_Link
;
/* For Hierarchical_PIN_Sheet_Struct:
* Pointer to the hierarchy sheet that contains this Hierarchical_PIN_Sheet_Struct
* For Pins: pointer to the component that contains this pin
*/
int
m_Flag
;
/* flag used in calculations */
DrawSheetPath
m_SheetList
;
int
m_ElectricalType
;
/* Has meaning only for Pins and hierachical pins: electrical type */
private
:
int
m_NetCode
;
/* net code for all items except BUS labels because a BUS label has
* as many net codes as bus members
*/
public
:
int
m_BusNetCode
;
/* Used for BUS connections */
int
m_Member
;
/* for labels type NET_BUSLABELMEMBER ( bus member created from the BUS label )
* member number
*/
ConnectType
m_FlagOfConnection
;
DrawSheetPath
m_SheetListInclude
;
/* sheet that the hierarchal label connects to.*/
long
m_PinNum
;
/* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
const
wxString
*
m_Label
;
/* For all labels:pointer on the text label */
wxPoint
m_Start
;
// Position of object or for segments: starting point
wxPoint
m_End
;
// For segments (wire and busses): ending point
#if defined(DEBUG)
void
Show
(
std
::
ostream
&
out
,
int
ndx
);
#endif
NETLIST_OBJECT
();
NETLIST_OBJECT
(
NETLIST_OBJECT
&
aSource
);
// Copy constructor
~
NETLIST_OBJECT
();
void
SetNet
(
int
aNetCode
)
{
m_NetCode
=
aNetCode
;
}
int
GetNet
()
const
{
return
m_NetCode
;
}
};
#endif // _CLASS_NETLIST_OBJECT_H_
eeschema/erc.cpp
View file @
aa9e61ed
...
...
@@ -30,15 +30,15 @@
/* fonctions locales */
static
bool
WriteDiagnosticERC
(
const
wxString
&
FullFileName
);
static
void
Diagnose
(
WinEDA_DrawPanel
*
panel
,
ObjetNetListStruct
*
NetItemRef
,
ObjetNetListStruct
*
NetItemTst
,
int
MinConnexion
,
int
Diag
);
NETLIST_OBJECT
*
NetItemRef
,
NETLIST_OBJECT
*
NetItemTst
,
int
MinConnexion
,
int
Diag
);
static
void
TestOthersItems
(
WinEDA_DrawPanel
*
panel
,
ObjetNetListStruct
*
NetItemRef
,
ObjetNetListStruct
*
NetStart
,
unsigned
NetItemRef
,
unsigned
NetStart
,
int
*
NetNbItems
,
int
*
MinConnexion
);
static
void
TestLabel
(
WinEDA_DrawPanel
*
panel
,
ObjetNetListStruct
*
NetItemRef
,
ObjetNetListStruct
*
StartNet
);
unsigned
NetItemRef
,
unsigned
StartNet
);
/* Local variables */
int
WriteFichierERC
=
FALSE
;
...
...
@@ -166,7 +166,7 @@ static int MinimalReq[PIN_NMAX][PIN_NMAX] =
/**Function TestDuplicateSheetNames( )
/**
Function TestDuplicateSheetNames( )
* inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
*/
int
TestDuplicateSheetNames
(
)
...
...
@@ -217,10 +217,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
/**************************************************/
{
wxFileName
fn
;
ObjetNetListStruct
*
NetItemRef
;
ObjetNetListStruct
*
OldItem
;
ObjetNetListStruct
*
StartNet
;
ObjetNetListStruct
*
Lim
;
unsigned
NetItemRef
;
unsigned
OldItem
;
unsigned
StartNet
;
int
NetNbItems
,
MinConn
;
...
...
@@ -273,30 +272,28 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
m_Parent
->
BuildNetListBase
();
/* Analyse de la table des connexions : */
Lim
=
g_TabObjNet
+
g_NbrObjNet
;
/* Reset the flag m_FlagOfConnection, that will be used next, in calculations */
for
(
NetItemRef
=
g_TabObjNet
;
NetItemRef
<
Lim
;
NetItemRef
++
)
NetItemRef
->
m_FlagOfConnection
=
UNCONNECTED
;
for
(
unsigned
ii
=
0
;
ii
<
g_NetObjectslist
.
size
();
ii
++
)
g_NetObjectslist
[
ii
]
->
m_FlagOfConnection
=
UNCONNECTED
;
StartNet
=
OldItem
=
0
;
NetNbItems
=
0
;
MinConn
=
NOC
;
StartNet
=
OldItem
=
NetItemRef
=
g_TabObjNet
;
for
(
;
NetItemRef
<
Lim
;
NetItemRef
++
)
for
(
NetItemRef
=
0
;
NetItemRef
<
g_NetObjectslist
.
size
();
NetItemRef
++
)
{
/* Tst changement de net */
if
(
OldItem
->
GetNet
()
!=
NetItemRef
->
GetNet
()
)
if
(
g_NetObjectslist
[
OldItem
]
->
GetNet
()
!=
g_NetObjectslist
[
NetItemRef
]
->
GetNet
()
)
{
MinConn
=
NOC
;
NetNbItems
=
0
;
StartNet
=
NetItemRef
;
}
switch
(
NetItemRef
->
m_Type
)
switch
(
g_NetObjectslist
[
NetItemRef
]
->
m_Type
)
{
case
NET_ITEM_UNSPECIFIED
:
case
NET_SEGMENT
:
case
NET_BUS
:
case
NET_JONCTION
:
...
...
@@ -325,7 +322,8 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
// ERC problems when a noconnect symbol is connected to more than one pin.
MinConn
=
NET_NC
;
if
(
NetNbItems
!=
0
)
Diagnose
(
m_Parent
->
DrawPanel
,
NetItemRef
,
NULL
,
MinConn
,
UNC
);
Diagnose
(
m_Parent
->
DrawPanel
,
g_NetObjectslist
[
NetItemRef
],
NULL
,
MinConn
,
UNC
);
break
;
case
NET_PIN
:
...
...
@@ -339,8 +337,6 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
OldItem
=
NetItemRef
;
}
FreeTabNetList
(
g_TabObjNet
,
g_NbrObjNet
);
// Displays global results:
wxString
num
;
num
.
Printf
(
wxT
(
"%d"
),
g_EESchemaVar
.
NbErrorErc
);
...
...
@@ -383,8 +379,8 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
/********************************************************/
static
void
Diagnose
(
WinEDA_DrawPanel
*
aPanel
,
ObjetNetListStruct
*
aNetItemRef
,
ObjetNetListStruct
*
aNetItemTst
,
NETLIST_OBJECT
*
aNetItemRef
,
NETLIST_OBJECT
*
aNetItemTst
,
int
aMinConn
,
int
aDiag
)
/********************************************************/
...
...
@@ -515,8 +511,8 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
/********************************************************************/
static
void
TestOthersItems
(
WinEDA_DrawPanel
*
panel
,
ObjetNetListStruct
*
NetItemRef
,
ObjetNetListStruct
*
netstart
,
unsigned
NetItemRef
,
unsigned
netstart
,
int
*
NetNbItems
,
int
*
MinConnexion
)
/********************************************************************/
...
...
@@ -525,15 +521,13 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
* et les autres items du meme net
*/
{
ObjetNetListStruct
*
NetItemTst
;
ObjetNetListStruct
*
Lim
;
unsigned
NetItemTst
;
int
ref_elect_type
,
jj
,
erc
=
OK
,
local_minconn
;
/* Analyse de la table des connexions : */
Lim
=
g_TabObjNet
+
g_NbrObjNet
;
// pointe la fin de la liste
ref_elect_type
=
NetItemRef
->
m_ElectricalType
;
ref_elect_type
=
g_NetObjectslist
[
NetItemRef
]
->
m_ElectricalType
;
NetItemTst
=
netstart
;
local_minconn
=
NOC
;
...
...
@@ -545,49 +539,50 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
continue
;
/* We examine only a given net. We stop the search if the net changes */
if
(
(
NetItemTst
>=
Lim
)
// End of list
||
(
NetItemRef
->
GetNet
()
!=
NetItemTst
->
GetNet
()
)
)
// End of net
if
(
(
NetItemTst
>=
g_NetObjectslist
.
size
()
)
// End of list
||
(
g_NetObjectslist
[
NetItemRef
]
->
GetNet
()
!=
g_NetObjectslist
[
NetItemTst
]
->
GetNet
()
)
)
// End of net
{
/* Fin de netcode trouve: Tst connexion minimum */
if
(
(
*
MinConnexion
<
NET_NC
)
&&
(
local_minconn
<
NET_NC
)
)
/* Not connected or not driven pin */
{
bool
seterr
=
true
;
if
(
local_minconn
==
NOC
&&
NetItemRef
->
m_Type
==
NET_PIN
)
if
(
local_minconn
==
NOC
&&
g_NetObjectslist
[
NetItemRef
]
->
m_Type
==
NET_PIN
)
{
/* This pin is not connected: for multiple part per package, and duplicated pin,
* search for an other instance of this pin
* this will be flagged only is all instances of this pin are not connected
* TODO test also if instances connected are connected to the same net
*/
for
(
ObjetNetListStruct
*
duppin
=
g_TabObjNet
;
duppin
<
Lim
;
duppin
++
)
for
(
unsigned
duppin
=
0
;
duppin
<
g_NetObjectslist
.
size
()
;
duppin
++
)
{
if
(
duppin
->
m_Type
!=
NET_PIN
)
if
(
g_NetObjectslist
[
duppin
]
->
m_Type
!=
NET_PIN
)
continue
;
if
(
duppin
==
NetItemRef
)
continue
;
if
(
NetItemRef
->
m_PinNum
!=
duppin
->
m_PinNum
)
if
(
g_NetObjectslist
[
NetItemRef
]
->
m_PinNum
!=
g_NetObjectslist
[
duppin
]
->
m_PinNum
)
continue
;
if
(
(
(
SCH_COMPONENT
*
)
NetItemRef
->
m_Link
)
->
GetRef
(
&
NetItemRef
->
m_SheetList
)
!=
((
SCH_COMPONENT
*
)
duppin
->
m_Link
)
->
GetRef
(
&
duppin
->
m_SheetList
)
)
if
(
(
(
SCH_COMPONENT
*
)
g_NetObjectslist
[
NetItemRef
]
->
m_Link
)
->
GetRef
(
&
g_NetObjectslist
[
NetItemRef
]
->
m_SheetList
)
!=
((
SCH_COMPONENT
*
)
g_NetObjectslist
[
duppin
]
->
m_Link
)
->
GetRef
(
&
g_NetObjectslist
[
duppin
]
->
m_SheetList
)
)
continue
;
// Same component and same pin. Do dot create error for this pin
// if the other pin is connected (i.e. if duppin net has an other item)
if
(
(
duppin
>
g_TabObjNet
)
&&
(
duppin
->
GetNet
()
==
(
duppin
-
1
)
->
GetNet
()))
if
(
(
duppin
>
0
)
&&
(
g_NetObjectslist
[
duppin
]
->
GetNet
()
==
g_NetObjectslist
[
duppin
-
1
]
->
GetNet
()))
seterr
=
false
;
if
(
(
duppin
<
Lim
-
1
)
&&
(
duppin
->
GetNet
()
==
(
duppin
+
1
)
->
GetNet
())
)
if
(
(
duppin
<
g_NetObjectslist
.
size
()
-
1
)
&&
(
g_NetObjectslist
[
duppin
]
->
GetNet
()
==
g_NetObjectslist
[
duppin
+
1
]
->
GetNet
())
)
seterr
=
false
;
}
}
if
(
seterr
)
Diagnose
(
panel
,
NetItemRef
,
NULL
,
local_minconn
,
WAR
);
Diagnose
(
panel
,
g_NetObjectslist
[
NetItemRef
]
,
NULL
,
local_minconn
,
WAR
);
*
MinConnexion
=
DRV
;
// inhibition autres messages de ce type pour ce net
}
return
;
}
switch
(
NetItemTst
->
m_Type
)
switch
(
g_NetObjectslist
[
NetItemTst
]
->
m_Type
)
{
case
NET_ITEM_UNSPECIFIED
:
case
NET_SEGMENT
:
case
NET_BUS
:
case
NET_JONCTION
:
...
...
@@ -607,7 +602,7 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
break
;
case
NET_PIN
:
jj
=
NetItemTst
->
m_ElectricalType
;
jj
=
g_NetObjectslist
[
NetItemTst
]
->
m_ElectricalType
;
local_minconn
=
MAX
(
MinimalReq
[
ref_elect_type
][
jj
],
local_minconn
);
if
(
NetItemTst
<=
NetItemRef
)
...
...
@@ -619,10 +614,10 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
erc
=
DiagErc
[
ref_elect_type
][
jj
];
if
(
erc
!=
OK
)
{
if
(
NetItemTst
->
m_FlagOfConnection
==
0
)
if
(
g_NetObjectslist
[
NetItemTst
]
->
m_FlagOfConnection
==
0
)
{
Diagnose
(
panel
,
NetItemRef
,
NetItemTst
,
0
,
erc
);
NetItemTst
->
m_FlagOfConnection
=
NOCONNEC
T
;
Diagnose
(
panel
,
g_NetObjectslist
[
NetItemRef
],
g_NetObjectslist
[
NetItemTst
]
,
0
,
erc
);
g_NetObjectslist
[
NetItemTst
]
->
m_FlagOfConnection
=
NOCONNECT_SYMBOL_PRESEN
T
;
}
}
}
...
...
@@ -692,7 +687,7 @@ static bool WriteDiagnosticERC( const wxString& FullFileName )
}
static
bool
IsLabelsConnected
(
ObjetNetListStruct
*
a
,
ObjetNetListStruct
*
b
)
static
bool
IsLabelsConnected
(
NETLIST_OBJECT
*
a
,
NETLIST_OBJECT
*
b
)
{
int
at
=
a
->
m_Type
;
int
bt
=
b
->
m_Type
;
...
...
@@ -711,19 +706,17 @@ static bool IsLabelsConnected( ObjetNetListStruct* a, ObjetNetListStruct* b )
/***********************************************************************/
void
TestLabel
(
WinEDA_DrawPanel
*
panel
,
ObjetNetListStruct
*
NetItemRef
,
ObjetNetListStruct
*
StartNet
)
unsigned
NetItemRef
,
unsigned
StartNet
)
/***********************************************************************/
/* Routine controlant qu'un sheetLabel est bien connecte a un Glabel de la
* sous-feuille correspondante
*/
{
ObjetNetListStruct
*
NetItemTst
,
*
Lim
;
unsigned
NetItemTst
;
int
erc
=
1
;
/* Analyse de la table des connexions : */
Lim
=
g_TabObjNet
+
g_NbrObjNet
;
NetItemTst
=
StartNet
;
...
...
@@ -734,22 +727,22 @@ void TestLabel( WinEDA_DrawPanel* panel,
continue
;
/* Est - on toujours dans le meme net ? */
if
(
(
NetItemTst
==
Lim
)
||
(
NetItemRef
->
GetNet
()
!=
NetItemTst
->
GetNet
()
)
)
if
(
(
NetItemTst
==
g_NetObjectslist
.
size
()
)
||
(
g_NetObjectslist
[
NetItemRef
]
->
GetNet
()
!=
g_NetObjectslist
[
NetItemTst
]
->
GetNet
()
)
)
{
/* Fin de netcode trouve */
if
(
erc
)
{
/* GLabel ou SheetLabel orphelin */
Diagnose
(
panel
,
NetItemRef
,
NULL
,
-
1
,
WAR
);
Diagnose
(
panel
,
g_NetObjectslist
[
NetItemRef
]
,
NULL
,
-
1
,
WAR
);
}
return
;
}
if
(
IsLabelsConnected
(
NetItemRef
,
NetItemTst
)
)
if
(
IsLabelsConnected
(
g_NetObjectslist
[
NetItemRef
],
g_NetObjectslist
[
NetItemTst
]
)
)
erc
=
0
;
//same thing, different order.
if
(
IsLabelsConnected
(
NetItemTst
,
NetItemRef
)
)
if
(
IsLabelsConnected
(
g_NetObjectslist
[
NetItemTst
],
g_NetObjectslist
[
NetItemRef
]
)
)
erc
=
0
;
}
}
eeschema/netform.cpp
View file @
aa9e61ed
...
...
@@ -21,27 +21,26 @@ static void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wxString&
static
void
WriteNetListPCBNEW
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
bool
with_pcbnew
);
static
void
WriteNetListCADSTAR
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
);
static
void
WriteListOfNetsCADSTAR
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNe
t
);
static
void
WriteListOfNetsCADSTAR
(
FILE
*
f
,
NETLIST_OBJECT_LIST
&
aObjectsLis
t
);
static
void
WriteNetListPspice
(
WinEDA_SchematicFrame
*
frame
,
FILE
*
f
,
bool
use_netnames
);
static
void
WriteGENERICListOfNets
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNe
t
);
static
void
WriteGENERICListOfNets
(
FILE
*
f
,
NETLIST_OBJECT_LIST
&
aObjectsLis
t
);
static
void
AddPinToComponentPinList
(
SCH_COMPONENT
*
Component
,
DrawSheetPath
*
sheet
,
LibDrawPin
*
PinEntry
);
static
void
FindAllsInstancesOfComponent
(
SCH_COMPONENT
*
Component
,
EDA_LibComponentStruct
*
Entry
,
DrawSheetPath
*
Sheet_in
);
static
int
SortPinsByNum
(
ObjetNetListStruct
**
Pin1
,
ObjetNetListStruct
*
*
Pin2
);
static
void
EraseDuplicatePins
(
ObjetNetListStruct
**
TabPin
,
int
NbrPin
);
static
bool
SortPinsByNum
(
NETLIST_OBJECT
*
Pin1
,
NETLIST_OBJECT
*
Pin2
);
static
void
EraseDuplicatePins
(
NETLIST_OBJECT_LIST
&
aPinList
);
static
void
ClearUsedFlags
(
void
);
/* Local variables */
static
int
s_SortedPinCount
;
static
ObjetNetListStruct
**
s_SortedComponentPinList
;
static
NETLIST_OBJECT_LIST
s_SortedComponentPinList
;
// list of references a
r
ready found for multi part per packages components
// list of references a
l
ready found for multi part per packages components
// (used to avoid to used more than one time a component)
static
wxArrayString
s_ReferencesAlreadyFound
;
...
...
@@ -106,8 +105,6 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
* build its pin list s_SortedComponentPinList.
* The list is sorted by pin num
* A suitable component is a "new" real component (power symbols are not considered)
*
* alloc memory for s_SortedComponentPinList if s_SortedComponentPinList == NULL
* Must be deallocated by the user
*/
{
...
...
@@ -115,8 +112,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
EDA_LibComponentStruct
*
Entry
;
LibEDA_BaseStruct
*
DEntry
;
s_SortedPinCount
=
0
;
s_SortedComponentPinList
.
clear
();
for
(
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Next
()
)
{
if
(
DrawList
->
Type
()
!=
TYPE_SCH_COMPONENT
)
...
...
@@ -158,13 +154,6 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
}
}
/* Create the pin table for this component */
int
ii
=
sizeof
(
ObjetNetListStruct
*
)
*
MAXPIN
;
if
(
s_SortedComponentPinList
==
NULL
)
s_SortedComponentPinList
=
(
ObjetNetListStruct
**
)
MyMalloc
(
ii
);
memset
(
s_SortedComponentPinList
,
0
,
ii
);
DEntry
=
Entry
->
m_Drawings
;
if
(
Entry
->
m_UnitCount
<=
1
)
// One part per package
{
...
...
@@ -187,11 +176,10 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
FindAllsInstancesOfComponent
(
Component
,
Entry
,
sheet
);
/* Sort Pins in s_SortedComponentPinList by pin number */
qsort
(
s_SortedComponentPinList
,
s_SortedPinCount
,
sizeof
(
ObjetNetListStruct
*
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
SortPinsByNum
);
sort
(
s_SortedComponentPinList
.
begin
(),
s_SortedComponentPinList
.
end
(),
SortPinsByNum
);
/* Remove duplicate Pins in s_SortedComponentPinList */
EraseDuplicatePins
(
s_SortedComponentPinList
,
s_SortedPinCount
);
EraseDuplicatePins
(
s_SortedComponentPinList
);
return
Component
;
}
...
...
@@ -201,7 +189,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
/**************************************************************************************/
static
wxString
ReturnPinNetName
(
ObjetNetListStruct
*
Pin
,
static
wxString
ReturnPinNetName
(
NETLIST_OBJECT
*
Pin
,
const
wxString
&
DefaultFormatNetname
)
/**************************************************************************************/
...
...
@@ -221,30 +209,30 @@ static wxString ReturnPinNetName( ObjetNetListStruct* Pin,
}
else
{
int
jj
;
for
(
jj
=
0
;
jj
<
g_N
brObjNet
;
jj
++
)
unsigned
jj
;
for
(
jj
=
0
;
jj
<
g_N
etObjectslist
.
size
()
;
jj
++
)
{
if
(
g_
TabObjNet
[
jj
].
GetNet
()
!=
netcode
)
if
(
g_
NetObjectslist
[
jj
]
->
GetNet
()
!=
netcode
)
continue
;
if
(
(
g_
TabObjNet
[
jj
].
m_Type
!=
NET_HIERLABEL
)
&&
(
g_
TabObjNet
[
jj
].
m_Type
!=
NET_LABEL
)
&&
(
g_
TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
)
if
(
(
g_
NetObjectslist
[
jj
]
->
m_Type
!=
NET_HIERLABEL
)
&&
(
g_
NetObjectslist
[
jj
]
->
m_Type
!=
NET_LABEL
)
&&
(
g_
NetObjectslist
[
jj
]
->
m_Type
!=
NET_PINLABEL
)
)
continue
;
NetName
=
*
g_
TabObjNet
[
jj
].
m_Label
;
NetName
=
*
g_
NetObjectslist
[
jj
]
->
m_Label
;
break
;
}
if
(
!
NetName
.
IsEmpty
()
)
{
if
(
g_
TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
if
(
g_
NetObjectslist
[
jj
]
->
m_Type
!=
NET_PINLABEL
)
{
wxString
lnet
=
NetName
;
NetName
=
g_
TabObjNet
[
jj
].
m_SheetList
.
PathHumanReadable
();
NetName
=
g_
NetObjectslist
[
jj
]
->
m_SheetList
.
PathHumanReadable
();
// If sheet path is too long, use the time stamp name insteed
if
(
NetName
.
Length
()
>
32
)
NetName
=
g_
TabObjNet
[
jj
].
m_SheetList
.
Path
();
NetName
=
g_
NetObjectslist
[
jj
]
->
m_SheetList
.
Path
();
NetName
+=
lnet
;
}
}
...
...
@@ -271,7 +259,6 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
EDA_BaseStruct
*
SchItem
;
SCH_COMPONENT
*
Component
;
wxString
netname
;
int
ii
;
FILE
*
tmpfile
;
wxFileName
fn
=
FullFileName
;
...
...
@@ -324,9 +311,9 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
// Write pin list:
fprintf
(
tmpfile
,
"$BeginPinList
\n
"
);
for
(
ii
=
0
;
ii
<
s_SortedPinCount
;
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
s_SortedComponentPinList
.
size
()
;
ii
++
)
{
ObjetNetListStruct
*
Pin
=
s_SortedComponentPinList
[
ii
];
NETLIST_OBJECT
*
Pin
=
s_SortedComponentPinList
[
ii
];
if
(
!
Pin
)
continue
;
netname
=
ReturnPinNetName
(
Pin
,
wxT
(
"$-%.6d"
)
);
...
...
@@ -341,13 +328,10 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
}
}
MyFree
(
s_SortedComponentPinList
);
s_SortedComponentPinList
=
NULL
;
fprintf
(
tmpfile
,
"$EndComponentList
\n
"
);
fprintf
(
tmpfile
,
"
\n
$BeginNets
\n
"
);
WriteGENERICListOfNets
(
tmpfile
,
g_
TabObjNe
t
);
WriteGENERICListOfNets
(
tmpfile
,
g_
NetObjectslis
t
);
fprintf
(
tmpfile
,
"$EndNets
\n
"
);
fprintf
(
tmpfile
,
"
\n
$EndNetlist
\n
"
);
fclose
(
tmpfile
);
...
...
@@ -399,7 +383,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
DrawSheetPath
*
sheet
;
EDA_BaseStruct
*
DrawList
;
SCH_COMPONENT
*
Component
;
int
ii
,
nbitems
;
int
nbitems
;
wxString
text
;
wxArrayString
SpiceCommandAtBeginFile
,
SpiceCommandAtEndFile
;
wxString
msg
;
...
...
@@ -436,7 +420,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
/* Put the Y position as an ascii string, for sort by vertical position,
* using usual sort string by alphabetic value */
int
ypos
=
DRAWTEXT
->
m_Pos
.
y
;
for
(
ii
=
0
;
ii
<
BUFYPOS_LEN
;
ii
++
)
for
(
i
nt
i
i
=
0
;
ii
<
BUFYPOS_LEN
;
ii
++
)
{
bufnum
[
BUFYPOS_LEN
-
1
-
ii
]
=
(
ypos
&
63
)
+
' '
;
ypos
>>=
6
;
}
...
...
@@ -456,7 +440,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
if
(
nbitems
)
{
SpiceCommandAtBeginFile
.
Sort
();
for
(
ii
=
0
;
ii
<
nbitems
;
ii
++
)
for
(
i
nt
i
i
=
0
;
ii
<
nbitems
;
ii
++
)
{
SpiceCommandAtBeginFile
[
ii
].
Remove
(
0
,
BUFYPOS_LEN
);
SpiceCommandAtBeginFile
[
ii
].
Trim
(
TRUE
);
...
...
@@ -480,9 +464,9 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
fprintf
(
f
,
"%s "
,
CONV_TO_UTF8
(
Component
->
GetRef
(
sheet
)
)
);
// Write pin list:
for
(
ii
=
0
;
ii
<
s_SortedPinCount
;
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
s_SortedComponentPinList
.
size
()
;
ii
++
)
{
ObjetNetListStruct
*
Pin
=
s_SortedComponentPinList
[
ii
];
NETLIST_OBJECT
*
Pin
=
s_SortedComponentPinList
[
ii
];
if
(
!
Pin
)
continue
;
wxString
NetName
=
ReturnPinNetName
(
Pin
,
wxT
(
"N-%.6d"
)
);
...
...
@@ -504,8 +488,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
}
}
MyFree
(
s_SortedComponentPinList
);
s_SortedComponentPinList
=
NULL
;
s_SortedComponentPinList
.
clear
();
/* Print texts starting by [+]pspice , ou [+]gnucap */
nbitems
=
SpiceCommandAtEndFile
.
GetCount
();
...
...
@@ -513,7 +496,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
{
fprintf
(
f
,
"
\n
"
);
SpiceCommandAtEndFile
.
Sort
();
for
(
ii
=
0
;
ii
<
nbitems
;
ii
++
)
for
(
i
nt
i
i
=
0
;
ii
<
nbitems
;
ii
++
)
{
SpiceCommandAtEndFile
[
ii
].
Remove
(
0
,
+
BUFYPOS_LEN
);
SpiceCommandAtEndFile
[
ii
].
Trim
(
TRUE
);
...
...
@@ -542,7 +525,6 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
DrawSheetPath
*
sheet
;
EDA_BaseStruct
*
DrawList
;
SCH_COMPONENT
*
Component
;
int
ii
;
OBJ_CMP_TO_LIST
*
CmpList
=
NULL
;
int
CmpListCount
=
0
,
CmpListSize
=
1000
;
...
...
@@ -618,15 +600,16 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
fprintf
(
f
,
"
\n
"
);
// Write pin list:
for
(
ii
=
0
;
ii
<
s_SortedPinCount
;
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
s_SortedComponentPinList
.
size
()
;
ii
++
)
{
ObjetNetListStruct
*
Pin
=
s_SortedComponentPinList
[
ii
];
NETLIST_OBJECT
*
Pin
=
s_SortedComponentPinList
[
ii
];
if
(
!
Pin
)
continue
;
wxString
netname
=
ReturnPinNetName
(
Pin
,
wxT
(
"N-%.6d"
)
);
if
(
netname
.
IsEmpty
()
)
netname
=
wxT
(
"?"
);
netname
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
fprintf
(
f
,
" ( %4.4s %s )
\n
"
,
(
char
*
)
&
Pin
->
m_PinNum
,
CONV_TO_UTF8
(
netname
)
);
}
...
...
@@ -637,31 +620,29 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
fprintf
(
f
,
")
\n
*
\n
"
);
MyFree
(
s_SortedComponentPinList
);
s_SortedComponentPinList
=
NULL
;
s_SortedComponentPinList
.
clear
();
/* Write the allowed footprint list for each component */
if
(
with_pcbnew
&&
CmpList
)
{
fprintf
(
f
,
"{ Allowed footprints by component:
\n
"
);
EDA_LibComponentStruct
*
Entry
;
for
(
ii
=
0
;
ii
<
CmpListCount
;
ii
++
)
for
(
i
nt
i
i
=
0
;
ii
<
CmpListCount
;
ii
++
)
{
Component
=
CmpList
[
ii
].
m_RootCmp
;
Entry
=
FindLibPart
(
Component
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
//Line.Printf(_("%s"), CmpList[ii].m_Ref);
//Line.Replace( wxT( " " ), wxT( "_" ) );
unsigned
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
CmpList
[
ii
].
m_Reference
)
&&
CmpList
[
ii
].
m_Reference
[
i
];
i
++
)
for
(
unsigned
nn
=
0
;
nn
<
sizeof
(
CmpList
[
ii
].
m_Reference
)
&&
CmpList
[
ii
].
m_Reference
[
nn
];
nn
++
)
{
if
(
CmpList
[
ii
].
m_Reference
[
i
]
==
' '
)
CmpList
[
ii
].
m_Reference
[
i
]
=
'_'
;
if
(
CmpList
[
ii
].
m_Reference
[
nn
]
==
' '
)
CmpList
[
ii
].
m_Reference
[
nn
]
=
'_'
;
}
fprintf
(
f
,
"$component %s
\n
"
,
CmpList
[
ii
].
m_Reference
);
/* Write the footprint list */
for
(
unsigned
int
jj
=
0
;
jj
<
Entry
->
m_FootprintList
.
GetCount
();
jj
++
)
for
(
unsigned
jj
=
0
;
jj
<
Entry
->
m_FootprintList
.
GetCount
();
jj
++
)
{
fprintf
(
f
,
" %s
\n
"
,
CONV_TO_UTF8
(
Entry
->
m_FootprintList
[
jj
]
)
);
}
...
...
@@ -677,7 +658,7 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
if
(
with_pcbnew
)
{
fprintf
(
f
,
"{ Pin List by Nets
\n
"
);
WriteGENERICListOfNets
(
f
,
g_
TabObjNe
t
);
WriteGENERICListOfNets
(
f
,
g_
NetObjectslis
t
);
fprintf
(
f
,
"}
\n
"
);
fprintf
(
f
,
"#End
\n
"
);
}
...
...
@@ -691,38 +672,35 @@ static void AddPinToComponentPinList( SCH_COMPONENT* Component,
/* Add a new pin description in the pin list s_SortedComponentPinList
* a pin description is a pointer to the corresponding structure
* created by BuildNetList() in the table g_
TabObjNe
t
* created by BuildNetList() in the table g_
NetObjectslis
t
*/
{
int
ii
;
/* Search the PIN description for Pin in g_TabObjNet*/
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
/* Search the PIN description for Pin in g_NetObjectslist*/
for
(
unsigned
ii
=
0
;
ii
<
g_NetObjectslist
.
size
();
ii
++
)
{
if
(
g_
TabObjNet
[
ii
].
m_Type
!=
NET_PIN
)
if
(
g_
NetObjectslist
[
ii
]
->
m_Type
!=
NET_PIN
)
continue
;
if
(
g_
TabObjNet
[
ii
].
m_Link
!=
Component
)
if
(
g_
NetObjectslist
[
ii
]
->
m_Link
!=
Component
)
continue
;
if
(
g_
TabObjNet
[
ii
].
m_SheetList
!=
*
sheetlist
)
if
(
g_
NetObjectslist
[
ii
]
->
m_SheetList
!=
*
sheetlist
)
continue
;
if
(
g_
TabObjNet
[
ii
].
m_PinNum
!=
Pin
->
m_PinNum
)
if
(
g_
NetObjectslist
[
ii
]
->
m_PinNum
!=
Pin
->
m_PinNum
)
continue
;
s_SortedComponentPinList
.
push_back
(
g_NetObjectslist
[
ii
]);
if
(
s_SortedComponentPinList
.
size
()
>=
MAXPIN
)
{
s_SortedComponentPinList
[
s_SortedPinCount
]
=
&
g_TabObjNet
[
ii
];
s_SortedPinCount
++
;
if
(
s_SortedPinCount
>=
MAXPIN
)
{
/* Log message for Internal error */
DisplayError
(
NULL
,
wxT
(
"AddPinToComponentPinList err: MAXPIN reached"
)
);
return
;
}
/* Log message for Internal error */
DisplayError
(
NULL
,
wxT
(
"AddPinToComponentPinList err: MAXPIN reached"
)
);
return
;
}
}
}
/**********************************************************************/
static
void
EraseDuplicatePins
(
ObjetNetListStruct
**
TabPin
,
int
NbrPin
)
static
void
EraseDuplicatePins
(
NETLIST_OBJECT_LIST
&
aPinList
)
/**********************************************************************/
/*
...
...
@@ -734,11 +712,13 @@ static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin )
* in the list.
*/
{
for
(
int
ii
=
0
;
ii
<
NbrPin
-
1
;
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
aPinList
.
size
()
-
1
;
ii
++
)
{
if
(
TabPin
[
ii
]
==
NULL
)
if
(
aPinList
[
ii
]
==
NULL
)
continue
;
/* already deleted */
if
(
TabPin
[
ii
]
->
m_PinNum
!=
TabPin
[
ii
+
1
]
->
m_PinNum
)
if
(
aPinList
[
ii
+
1
]
==
NULL
)
continue
;
/* already tested and deleted */
if
(
aPinList
[
ii
]
->
m_PinNum
!=
aPinList
[
ii
+
1
]
->
m_PinNum
)
continue
;
/* Duplicated Pins
* remove duplicates. The priority is to keep connected pins and remove unconnected
...
...
@@ -746,23 +726,22 @@ static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin )
* to connect only one op amp to power
*/
int
idxref
=
ii
;
for
(
int
jj
=
ii
+
1
;
jj
<
NbrPin
;
jj
++
)
for
(
unsigned
jj
=
ii
+
1
;
jj
<
aPinList
.
size
()
;
jj
++
)
{
if
(
TabPin
[
idxref
]
->
m_PinNum
!=
TabPin
[
jj
]
->
m_PinNum
)
if
(
aPinList
[
idxref
]
->
m_PinNum
!=
aPinList
[
jj
]
->
m_PinNum
)
break
;
if
(
TabPin
[
idxref
]
->
GetNet
()
)
TabPin
[
jj
]
=
NULL
;
if
(
aPinList
[
idxref
]
->
m_FlagOfConnection
==
PAD_CONNECT
)
aPinList
[
jj
]
=
NULL
;
else
{
/* the refernce pin is not connected: remove this pin if the other pin is connected */
if
(
TabPin
[
jj
]
->
GetNet
()
)
{
/* the refer
e
nce pin is not connected: remove this pin if the other pin is connected */
if
(
aPinList
[
jj
]
->
m_FlagOfConnection
==
PAD_CONNECT
)
{
TabPin
[
idxref
]
=
NULL
;
aPinList
[
idxref
]
=
NULL
;
idxref
=
jj
;
}
else
// the 2 pins are not connected: remove the tested pin, and continue ...
TabPin
[
jj
]
=
NULL
;
aPinList
[
jj
]
=
NULL
;
}
}
}
}
...
...
@@ -825,34 +804,33 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
/**************************************************************************/
static
int
SortPinsByNum
(
ObjetNetListStruct
**
Pin1
,
ObjetNetListStruct
*
*
Pin2
)
static
bool
SortPinsByNum
(
NETLIST_OBJECT
*
Pin1
,
NETLIST_OBJECT
*
Pin2
)
/**************************************************************************/
/* Routine de comparaison pour le tri des pins par numero croissant
* du tableau des pins s_SortedComponentPinList par qsort()
*/
{
ObjetNetListStruct
*
Obj1
,
*
Obj2
;
int
Num1
,
Num2
;
char
Line
[
5
];
Obj1
=
*
Pin1
;
Obj2
=
*
Pin2
;
Num1
=
Obj1
->
m_PinNum
;
Num2
=
Obj2
->
m_PinNum
;
Line
[
4
]
=
0
;
memcpy
(
Line
,
&
Num1
,
4
);
Num1
=
atoi
(
Line
);
Num1
=
Pin1
->
m_PinNum
;
Num2
=
Pin2
->
m_PinNum
;
Line
[
4
]
=
0
;
memcpy
(
Line
,
&
Num1
,
4
);
Num1
=
atoi
(
Line
);
memcpy
(
Line
,
&
Num2
,
4
);
Num2
=
atoi
(
Line
);
return
Num1
-
Num2
;
return
Num1
<
Num2
;
}
/*************************************************************************/
static
void
WriteGENERICListOfNets
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNe
t
)
static
void
WriteGENERICListOfNets
(
FILE
*
f
,
NETLIST_OBJECT_LIST
&
aObjectsLis
t
)
/*************************************************************************/
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
* elements qui y sont connectes
*/
{
int
ii
,
jj
;
int
NetCode
,
LastNetCode
=
-
1
;
int
SameNetcodeCount
=
0
;
SCH_COMPONENT
*
Cmp
;
...
...
@@ -860,22 +838,23 @@ static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet )
wxString
NetcodeName
;
char
FirstItemInNet
[
1024
];
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
aObjectsList
.
size
()
;
ii
++
)
{
if
(
(
NetCode
=
ObjNet
[
ii
].
GetNet
()
)
!=
LastNetCode
)
// New net found, write net id;
if
(
(
NetCode
=
aObjectsList
[
ii
]
->
GetNet
()
)
!=
LastNetCode
)
// New net found, write net id;
{
SameNetcodeCount
=
0
;
// Items count for this net
NetName
.
Empty
();
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
)
// Find a label (if exists) for this net
unsigned
jj
;
for
(
jj
=
0
;
jj
<
aObjectsList
.
size
();
jj
++
)
// Find a label (if exists) for this net
{
if
(
ObjNet
[
jj
].
GetNet
()
!=
NetCode
)
if
(
aObjectsList
[
jj
]
->
GetNet
()
!=
NetCode
)
continue
;
if
(
(
ObjNet
[
jj
].
m_Type
!=
NET_HIERLABEL
)
&&
(
ObjNet
[
jj
].
m_Type
!=
NET_LABEL
)
&&
(
ObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
)
if
(
(
aObjectsList
[
jj
]
->
m_Type
!=
NET_HIERLABEL
)
&&
(
aObjectsList
[
jj
]
->
m_Type
!=
NET_LABEL
)
&&
(
aObjectsList
[
jj
]
->
m_Type
!=
NET_PINLABEL
)
)
continue
;
NetName
=
*
g_TabObjNet
[
jj
].
m_Label
;
NetName
=
*
aObjectsList
[
jj
]
->
m_Label
;
break
;
}
...
...
@@ -883,10 +862,10 @@ static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet )
NetcodeName
+=
wxT
(
"
\"
"
);
if
(
!
NetName
.
IsEmpty
()
)
{
if
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
if
(
aObjectsList
[
jj
]
->
m_Type
!=
NET_PINLABEL
)
{
// usual net name, prefix it by the sheet path
NetcodeName
+=
g_TabObjNet
[
jj
].
m_SheetList
.
PathHumanReadable
();
NetcodeName
+=
aObjectsList
[
jj
]
->
m_SheetList
.
PathHumanReadable
();
}
NetcodeName
+=
NetName
;
}
...
...
@@ -897,11 +876,11 @@ static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet )
LastNetCode
=
NetCode
;
}
if
(
ObjNet
[
ii
].
m_Type
!=
NET_PIN
)
if
(
aObjectsList
[
ii
]
->
m_Type
!=
NET_PIN
)
continue
;
Cmp
=
(
SCH_COMPONENT
*
)
ObjNet
[
ii
].
m_Link
;
CmpRef
=
Cmp
->
GetRef
(
&
ObjNet
[
ii
].
m_SheetList
);
//is this correct?
Cmp
=
(
SCH_COMPONENT
*
)
aObjectsList
[
ii
]
->
m_Link
;
CmpRef
=
Cmp
->
GetRef
(
&
aObjectsList
[
ii
]
->
m_SheetList
);
// Get the reference for thenetname and the main parent component
if
(
CmpRef
.
StartsWith
(
wxT
(
"#"
)
)
)
continue
;
// Pseudo component (Like Power symbol)
...
...
@@ -911,7 +890,7 @@ static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet )
* Print this connection, when a second item will be found */
{
sprintf
(
FirstItemInNet
,
" %s %.4s
\n
"
,
CONV_TO_UTF8
(
CmpRef
),
(
const
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
(
const
char
*
)
&
aObjectsList
[
ii
]
->
m_PinNum
);
}
if
(
SameNetcodeCount
==
2
)
// Second item for this net found, Print the Net name, and the first item
{
...
...
@@ -921,7 +900,7 @@ static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet )
if
(
SameNetcodeCount
>=
2
)
fprintf
(
f
,
" %s %.4s
\n
"
,
CONV_TO_UTF8
(
CmpRef
),
(
const
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
(
const
char
*
)
&
aObjectsList
[
ii
]
->
m_PinNum
);
}
}
...
...
@@ -1009,17 +988,16 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
fprintf
(
f
,
"
\n
"
);
MyFree
(
s_SortedComponentPinList
);
s_SortedComponentPinList
=
NULL
;
s_SortedComponentPinList
.
clear
();
WriteListOfNetsCADSTAR
(
f
,
g_
TabObjNe
t
);
WriteListOfNetsCADSTAR
(
f
,
g_
NetObjectslis
t
);
fprintf
(
f
,
"
\n
%sEND
\n
"
,
CONV_TO_UTF8
(
StartLine
)
);
}
/*************************************************************************/
static
void
WriteListOfNetsCADSTAR
(
FILE
*
f
,
ObjetNetListStruct
*
ObjNe
t
)
static
void
WriteListOfNetsCADSTAR
(
FILE
*
f
,
NETLIST_OBJECT_LIST
&
aObjectsLis
t
)
/*************************************************************************/
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
...
...
@@ -1033,43 +1011,44 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet )
wxString
InitNetDesc
=
StartLine
+
wxT
(
"ADD_TER"
);
wxString
StartNetDesc
=
StartLine
+
wxT
(
"TER"
);
wxString
NetcodeName
,
InitNetDescLine
;
int
ii
,
jj
,
print_ter
=
0
;
unsigned
ii
,
jj
;
int
print_ter
=
0
;
int
NetCode
,
LastNetCode
=
-
1
;
SCH_COMPONENT
*
Cmp
;
wxString
NetName
;
for
(
ii
=
0
;
ii
<
g_NbrObjNet
;
ii
++
)
ObjNet
[
ii
].
m_Flag
=
0
;
for
(
ii
=
0
;
ii
<
aObjectsList
.
size
()
;
ii
++
)
aObjectsList
[
ii
]
->
m_Flag
=
0
;
for
(
ii
=
0
;
ii
<
g_N
brObjNet
;
ii
++
)
for
(
ii
=
0
;
ii
<
g_N
etObjectslist
.
size
()
;
ii
++
)
{
// Get the NetName of the current net :
if
(
(
NetCode
=
ObjNet
[
ii
].
GetNet
()
)
!=
LastNetCode
)
if
(
(
NetCode
=
aObjectsList
[
ii
]
->
GetNet
()
)
!=
LastNetCode
)
{
NetName
.
Empty
();
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
)
for
(
jj
=
0
;
jj
<
aObjectsList
.
size
()
;
jj
++
)
{
if
(
ObjNet
[
jj
].
GetNet
()
!=
NetCode
)
if
(
aObjectsList
[
jj
]
->
GetNet
()
!=
NetCode
)
continue
;
if
(
(
ObjNet
[
jj
].
m_Type
!=
NET_HIERLABEL
)
&&
(
ObjNet
[
jj
].
m_Type
!=
NET_LABEL
)
&&
(
ObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
)
if
(
(
aObjectsList
[
jj
]
->
m_Type
!=
NET_HIERLABEL
)
&&
(
aObjectsList
[
jj
]
->
m_Type
!=
NET_LABEL
)
&&
(
aObjectsList
[
jj
]
->
m_Type
!=
NET_PINLABEL
)
)
continue
;
NetName
=
*
ObjNet
[
jj
].
m_Label
;
break
;
NetName
=
*
aObjectsList
[
jj
]
->
m_Label
;
break
;
}
NetcodeName
=
wxT
(
"
\"
"
);
if
(
!
NetName
.
IsEmpty
()
)
{
NetcodeName
+=
NetName
;
if
(
g_TabObjNet
[
jj
].
m_Type
!=
NET_PINLABEL
)
if
(
aObjectsList
[
jj
]
->
m_Type
!=
NET_PINLABEL
)
{
NetcodeName
=
g_TabObjNet
[
jj
].
m_SheetList
.
PathHumanReadable
()
NetcodeName
=
aObjectsList
[
jj
]
->
m_SheetList
.
PathHumanReadable
()
+
NetcodeName
;
//NetcodeName << wxT("_") <<
// g_
TabObjNe
t[jj].m_SheetList.PathHumanReadable();
// g_
NetObjectslis
t[jj].m_SheetList.PathHumanReadable();
}
}
else
// this net has no name: create a default name $<net number>
...
...
@@ -1080,14 +1059,14 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet )
}
if
(
ObjNet
[
ii
].
m_Type
!=
NET_PIN
)
if
(
aObjectsList
[
ii
]
->
m_Type
!=
NET_PIN
)
continue
;
if
(
ObjNet
[
ii
].
m_Flag
!=
0
)
if
(
aObjectsList
[
ii
]
->
m_Flag
!=
0
)
continue
;
Cmp
=
(
SCH_COMPONENT
*
)
ObjNet
[
ii
].
m_Link
;
wxString
refstr
=
Cmp
->
GetRef
(
&
(
ObjNet
[
ii
].
m_SheetList
)
);
Cmp
=
(
SCH_COMPONENT
*
)
aObjectsList
[
ii
]
->
m_Link
;
wxString
refstr
=
Cmp
->
GetRef
(
&
(
aObjectsList
[
ii
]
->
m_SheetList
)
);
if
(
refstr
[
0
]
==
'#'
)
continue
;
// Pseudo composant (symboles d'alims)
...
...
@@ -1097,7 +1076,8 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet )
{
char
buf
[
5
];
wxString
str_pinnum
;
strncpy
(
buf
,
(
char
*
)
&
ObjNet
[
ii
].
m_PinNum
,
4
);
buf
[
4
]
=
0
;
strncpy
(
buf
,
(
char
*
)
&
aObjectsList
[
ii
]
->
m_PinNum
,
4
);
buf
[
4
]
=
0
;
str_pinnum
=
CONV_FROM_UTF8
(
buf
);
InitNetDescLine
.
Printf
(
wxT
(
"
\n
%s %s %.4s %s"
),
InitNetDesc
.
GetData
(),
...
...
@@ -1112,36 +1092,36 @@ static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet )
fprintf
(
f
,
"%s %s %.4s
\n
"
,
CONV_TO_UTF8
(
StartNetDesc
),
CONV_TO_UTF8
(
refstr
),
(
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
(
char
*
)
&
aObjectsList
[
ii
]
->
m_PinNum
);
print_ter
++
;
break
;
default
:
fprintf
(
f
,
" %s %.4s
\n
"
,
CONV_TO_UTF8
(
refstr
),
(
char
*
)
&
ObjNet
[
ii
].
m_PinNum
);
(
char
*
)
&
aObjectsList
[
ii
]
->
m_PinNum
);
break
;
}
ObjNet
[
ii
].
m_Flag
=
1
;
aObjectsList
[
ii
]
->
m_Flag
=
1
;
// Recherche des pins redondantes et mise a 1 de m_Flag,
// pour ne pas generer plusieurs fois la connexion
for
(
jj
=
ii
+
1
;
jj
<
g_NbrObjNet
;
jj
++
)
for
(
jj
=
ii
+
1
;
jj
<
aObjectsList
.
size
()
;
jj
++
)
{
if
(
ObjNet
[
jj
].
GetNet
()
!=
NetCode
)
if
(
aObjectsList
[
jj
]
->
GetNet
()
!=
NetCode
)
break
;
if
(
ObjNet
[
jj
].
m_Type
!=
NET_PIN
)
if
(
aObjectsList
[
jj
]
->
m_Type
!=
NET_PIN
)
continue
;
SCH_COMPONENT
*
tstcmp
=
(
SCH_COMPONENT
*
)
ObjNet
[
jj
].
m_Link
;
wxString
p
=
Cmp
->
GetPath
(
&
(
ObjNet
[
ii
].
m_SheetList
)
);
wxString
tstp
=
tstcmp
->
GetPath
(
&
(
ObjNet
[
jj
].
m_SheetList
)
);
(
SCH_COMPONENT
*
)
aObjectsList
[
jj
]
->
m_Link
;
wxString
p
=
Cmp
->
GetPath
(
&
(
aObjectsList
[
ii
]
->
m_SheetList
)
);
wxString
tstp
=
tstcmp
->
GetPath
(
&
(
aObjectsList
[
jj
]
->
m_SheetList
)
);
if
(
p
.
Cmp
(
tstp
)
!=
0
)
continue
;
if
(
ObjNet
[
jj
].
m_PinNum
==
ObjNet
[
ii
].
m_PinNum
)
ObjNet
[
jj
].
m_Flag
=
1
;
if
(
aObjectsList
[
jj
]
->
m_PinNum
==
aObjectsList
[
ii
]
->
m_PinNum
)
aObjectsList
[
jj
]
->
m_Flag
=
1
;
}
}
}
eeschema/netlist.cpp
View file @
aa9e61ed
...
...
@@ -13,330 +13,203 @@
#include "netlist.h"
/* Definitions generales liees au calcul de netliste */
#include "protos.h"
int
g_NbrObjNet
;
ObjetNetListStruct
*
g_TabObjNet
=
NULL
;
#include "algorithm"
// Buffer to build the list of items used in netlist and erc calculations
NETLIST_OBJECT_LIST
g_NetObjectslist
;
//#define NETLIST_DEBUG
/* Routines locales */
static
void
PropageNetCode
(
int
OldNetCode
,
int
NewNetCode
,
int
IsBus
);
static
void
SheetLabelConnect
(
ObjetNetListStruct
*
SheetLabel
);
static
int
ListeObjetConnection
(
DrawSheetPath
*
sheetlist
,
ObjetNetListStruct
*
ObjNet
);
static
int
ConvertBusToMembers
(
ObjetNetListStruct
*
ObjNet
);
static
void
PointToPointConnect
(
ObjetNetListStruct
*
Ref
,
int
IsBus
,
static
void
SheetLabelConnect
(
NETLIST_OBJECT
*
SheetLabel
);
static
void
ListeObjetConnection
(
DrawSheetPath
*
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
(
ObjetNetListStruct
*
Jonction
,
int
IsBus
,
static
void
SegmentToPointConnect
(
NETLIST_OBJECT
*
Jonction
,
int
IsBus
,
int
start
);
static
void
LabelConnect
(
ObjetNetListStruct
*
Label
);
static
int
TriNetCode
(
const
void
*
o1
,
const
void
*
o2
);
static
void
ConnectBusLabels
(
ObjetNetListStruct
*
Label
,
int
NbItems
);
static
void
SetUnconnectedFlag
(
ObjetNetListStruct
*
ObjNet
,
int
NbItems
);
static
int
TriBySheet
(
const
void
*
o1
,
const
void
*
o2
);
static
void
LabelConnect
(
NETLIST_OBJECT
*
Label
);
static
void
ConnectBusLabels
(
NETLIST_OBJECT_LIST
&
aNetItemBuffer
);
static
void
SetUnconnectedFlag
(
NETLIST_OBJECT_LIST
&
aNetItemBuffer
);
// 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
);
/* Variable locales */
static
int
FirstNumWireBus
,
LastNumWireBus
,
RootBusNameLength
;
static
int
LastNetCode
,
LastBusNetCode
;
static
int
s_PassNumber
;
#if defined (DEBUG)
#include <iostream>
const
char
*
ShowType
(
NetObjetType
aType
)
{
const
char
*
ret
;
switch
(
aType
)
{
case
NET_SEGMENT
:
ret
=
"segment"
;
break
;
case
NET_BUS
:
ret
=
"bus"
;
break
;
case
NET_JONCTION
:
ret
=
"junction"
;
break
;
case
NET_LABEL
:
ret
=
"label"
;
break
;
case
NET_HIERLABEL
:
ret
=
"hierlabel"
;
break
;
case
NET_GLOBLABEL
:
ret
=
"glabel"
;
break
;
case
NET_BUSLABELMEMBER
:
ret
=
"buslblmember"
;
break
;
case
NET_HIERBUSLABELMEMBER
:
ret
=
"hierbuslblmember"
;
break
;
case
NET_GLOBBUSLABELMEMBER
:
ret
=
"gbuslblmember"
;
break
;
case
NET_SHEETBUSLABELMEMBER
:
ret
=
"sbuslblmember"
;
break
;
case
NET_SHEETLABEL
:
ret
=
"sheetlabel"
;
break
;
case
NET_PINLABEL
:
ret
=
"pinlabel"
;
break
;
case
NET_PIN
:
ret
=
"pin"
;
break
;
case
NET_NOCONNECT
:
ret
=
"noconnect"
;
break
;
default:
ret
=
"??"
;
break
;
}
return
ret
;
}
void
ObjetNetListStruct
::
Show
(
std
::
ostream
&
out
,
int
ndx
)
{
wxString
path
=
m_SheetList
.
PathHumanReadable
();
out
<<
"<netItem ndx=
\"
"
<<
ndx
<<
'"'
<<
" type=
\"
"
<<
ShowType
(
m_Type
)
<<
'"'
<<
" netCode=
\"
"
<<
GetNet
()
<<
'"'
<<
" sheet=
\"
"
<<
CONV_TO_UTF8
(
path
)
<<
'"'
<<
">
\n
"
;
out
<<
" <start "
<<
m_Start
<<
"/> <end "
<<
m_End
<<
"/>
\n
"
;
if
(
m_Label
)
out
<<
" <label>"
<<
m_Label
->
mb_str
()
<<
"</label>
\n
"
;
if
(
m_Comp
)
m_Comp
->
Show
(
1
,
out
);
else
out
<<
" m_Comp==NULL
\n
"
;
out
<<
"</netItem>
\n
"
;
}
#if defined(DEBUG)
void
dumpNetTable
()
{
for
(
int
i
=
0
;
i
<
g_NbrObjNet
;
++
i
)
for
(
unsigned
idx
=
0
;
idx
<
g_NetObjectslist
.
size
();
++
idx
)
{
g_
TabObjNet
[
i
].
Show
(
std
::
cout
,
i
);
g_
NetObjectslist
[
idx
]
->
Show
(
std
::
cout
,
idx
);
}
}
#endif
/***********************************************************************/
void
FreeTabNetList
(
ObjetNetListStruct
*
TabNetItems
,
int
NbrNetItems
)
/***********************************************************************/
/*********************************************************************/
void
FreeNetObjectsList
(
NETLIST_OBJECT_LIST
&
aNetObjectsBuffer
)
/*********************************************************************/
/*
* Routine de liberation memoire des tableaux utilises pour le calcul
* de la netliste
* TabNetItems = pointeur sur le tableau principal (liste des items )
* NbrNetItems = nombre d'elements
*/
{
int
i
;
/* Liberation memoire des strings du champ Label reserve par ConvertBusToMembers */
for
(
i
=
0
;
i
<
NbrNetItems
;
i
++
)
{
switch
(
TabNetItems
[
i
].
m_Type
)
{
case
NET_PIN
:
case
NET_SHEETLABEL
:
case
NET_SEGMENT
:
case
NET_JONCTION
:
case
NET_BUS
:
case
NET_LABEL
:
case
NET_HIERLABEL
:
case
NET_GLOBLABEL
:
case
NET_PINLABEL
:
case
NET_NOCONNECT
:
break
;
for
(
unsigned
i
=
0
;
i
<
aNetObjectsBuffer
.
size
();
i
++
)
delete
aNetObjectsBuffer
[
i
];
case
NET_HIERBUSLABELMEMBER
:
case
NET_GLOBBUSLABELMEMBER
:
case
NET_SHEETBUSLABELMEMBER
:
case
NET_BUSLABELMEMBER
:
SAFE_DELETE
(
TabNetItems
[
i
].
m_Label
);
//see the note in ConvertBustToMembers
break
;
}
}
MyFree
(
TabNetItems
);
aNetObjectsBuffer
.
clear
();
}
/*****************************************************/
void
*
WinEDA_SchematicFrame
::
BuildNetListBase
()
/*****************************************************/
/*****************************************************
*******************
/
void
WinEDA_SchematicFrame
::
BuildNetListBase
()
/*****************************************************
*******************
/
/* Routine qui construit le tableau des elements connectes du projet
* met a jour:
* g_
TabObjNe
t
* g_N
brObjNe
t
* g_
NetObjectslis
t
* g_N
etObjectslis
t
*/
{
int
NetNumber
;
int
i
,
istart
,
NetCode
;
int
i
,
NetCode
;
DrawSheetPath
*
sheet
;
wxString
msg
,
activity
;
wxBusyCursor
Busy
;
NetNumber
=
1
;
s_PassNumber
=
0
;
NetNumber
=
1
;
activity
=
_
(
"List"
);
SetStatusText
(
activity
);
FreeNetObjectsList
(
g_NetObjectslist
);
/* Build the sheet (not screen) list (flattened)*/
EDA_SheetList
SheetListList
;
i
=
0
;
/* first pass : count objects used in connectivty calculation */
g_NbrObjNet
=
0
;
g_TabObjNet
=
NULL
;
/* Init pour le 1er passage dans ListeObjetConnection */
/* count nelist items */
for
(
sheet
=
SheetListList
.
GetFirst
();
sheet
!=
NULL
;
sheet
=
SheetListList
.
GetNext
()
)
{
g_NbrObjNet
+=
ListeObjetConnection
(
sheet
,
NULL
);
}
if
(
g_NbrObjNet
==
0
)
{
DisplayError
(
this
,
_
(
"No component"
),
20
);
return
NULL
;
}
i
=
sizeof
(
ObjetNetListStruct
)
*
g_NbrObjNet
;
g_TabObjNet
=
(
ObjetNetListStruct
*
)
MyZMalloc
(
i
);
if
(
g_TabObjNet
==
NULL
)
return
NULL
;
/*
second pass: fill the fields of the structures used in connectiv
ty calculation */
/*
Fill g_NetObjectslist with items used in connectivi
ty calculation */
s_PassNumber
++
;
ObjetNetListStruct
*
tabObjNet
=
g_TabObjNet
;
sheet
=
SheetListList
.
GetFirst
();
for
(
;
sheet
!=
NULL
;
sheet
=
SheetListList
.
GetNext
()
)
{
int
icnt
=
ListeObjetConnection
(
sheet
,
tabObjNet
);
tabObjNet
+=
icnt
;
// tabObjNet points the first free location in g_TabObjNet
}
ListeObjetConnection
(
sheet
,
g_NetObjectslist
);
if
(
g_NetObjectslist
.
size
()
==
0
)
return
;
// no objects
activity
.
Empty
();
activity
<<
wxT
(
" "
)
<<
_
(
"NbItems"
)
<<
wxT
(
" "
)
<<
g_N
brObjNet
;
activity
<<
wxT
(
" "
)
<<
_
(
"NbItems"
)
<<
wxT
(
" "
)
<<
g_N
etObjectslist
.
size
()
;
SetStatusText
(
activity
);
/* Sort objects by Sheet */
qsort
(
g_TabObjNet
,
g_NbrObjNet
,
sizeof
(
ObjetNetListStruct
),
Tri
BySheet
);
sort
(
g_NetObjectslist
.
begin
(),
g_NetObjectslist
.
end
(),
SortItems
BySheet
);
activity
<<
wxT
(
"; "
)
<<
_
(
"Conn"
);
SetStatusText
(
activity
);
sheet
=
&
(
g_
TabObjNet
[
0
].
m_SheetList
);
sheet
=
&
(
g_
NetObjectslist
[
0
]
->
m_SheetList
);
LastNetCode
=
LastBusNetCode
=
1
;
for
(
i
=
istart
=
0
;
i
<
g_NbrObjNet
;
i
++
)
for
(
unsigned
i
=
0
,
istart
=
0
;
i
<
g_NetObjectslist
.
size
();
i
++
)
{
if
(
g_
TabObjNet
[
i
].
m_SheetList
!=
*
sheet
)
if
(
g_
NetObjectslist
[
i
]
->
m_SheetList
!=
*
sheet
)
{
sheet
=
&
(
g_TabObjNet
[
i
].
m_SheetList
);
istart
=
i
;
sheet
=
&
(
g_NetObjectslist
[
i
]
->
m_SheetList
);
}
switch
(
g_
TabObjNet
[
i
].
m_Type
)
switch
(
g_
NetObjectslist
[
i
]
->
m_Type
)
{
case
NET_ITEM_UNSPECIFIED
:
wxMessageBox
(
wxT
(
"BuildNetListBase() error"
));
break
;
case
NET_PIN
:
case
NET_PINLABEL
:
case
NET_SHEETLABEL
:
case
NET_NOCONNECT
:
if
(
g_
TabObjNet
[
i
].
GetNet
()
!=
0
)
if
(
g_
NetObjectslist
[
i
]
->
GetNet
()
!=
0
)
break
;
/* Deja connecte */
case
NET_SEGMENT
:
/* Controle des connexions type point a point ( Sans BUS ) */
if
(
g_
TabObjNet
[
i
].
GetNet
()
==
0
)
if
(
g_
NetObjectslist
[
i
]
->
GetNet
()
==
0
)
{
g_
TabObjNet
[
i
].
SetNet
(
LastNetCode
);
g_
NetObjectslist
[
i
]
->
SetNet
(
LastNetCode
);
LastNetCode
++
;
}
PointToPointConnect
(
g_
TabObjNet
+
i
,
0
,
istart
);
PointToPointConnect
(
g_
NetObjectslist
[
i
]
,
0
,
istart
);
break
;
case
NET_JONCTION
:
/* Controle des jonction , hors BUS */
if
(
g_
TabObjNet
[
i
].
GetNet
()
==
0
)
if
(
g_
NetObjectslist
[
i
]
->
GetNet
()
==
0
)
{
g_
TabObjNet
[
i
].
SetNet
(
LastNetCode
);
g_
NetObjectslist
[
i
]
->
SetNet
(
LastNetCode
);
LastNetCode
++
;
}
SegmentToPointConnect
(
g_
TabObjNet
+
i
,
0
,
istart
);
SegmentToPointConnect
(
g_
NetObjectslist
[
i
]
,
0
,
istart
);
/* Controle des jonction , sur BUS */
if
(
g_
TabObjNet
[
i
].
m_BusNetCode
==
0
)
if
(
g_
NetObjectslist
[
i
]
->
m_BusNetCode
==
0
)
{
g_
TabObjNet
[
i
].
m_BusNetCode
=
LastBusNetCode
;
g_
NetObjectslist
[
i
]
->
m_BusNetCode
=
LastBusNetCode
;
LastBusNetCode
++
;
}
SegmentToPointConnect
(
g_
TabObjNet
+
i
,
ISBUS
,
istart
);
SegmentToPointConnect
(
g_
NetObjectslist
[
i
]
,
ISBUS
,
istart
);
break
;
case
NET_LABEL
:
case
NET_HIERLABEL
:
case
NET_GLOBLABEL
:
/* Controle des connexions type jonction ( Sans BUS ) */
if
(
g_
TabObjNet
[
i
].
GetNet
()
==
0
)
if
(
g_
NetObjectslist
[
i
]
->
GetNet
()
==
0
)
{
g_
TabObjNet
[
i
].
SetNet
(
LastNetCode
);
g_
NetObjectslist
[
i
]
->
SetNet
(
LastNetCode
);
LastNetCode
++
;
}
SegmentToPointConnect
(
g_
TabObjNet
+
i
,
0
,
istart
);
SegmentToPointConnect
(
g_
NetObjectslist
[
i
]
,
0
,
istart
);
break
;
case
NET_SHEETBUSLABELMEMBER
:
if
(
g_
TabObjNet
[
i
].
m_BusNetCode
!=
0
)
if
(
g_
NetObjectslist
[
i
]
->
m_BusNetCode
!=
0
)
break
;
/* Deja connecte */
case
NET_BUS
:
/* Controle des connexions type point a point mode BUS */
if
(
g_
TabObjNet
[
i
].
m_BusNetCode
==
0
)
if
(
g_
NetObjectslist
[
i
]
->
m_BusNetCode
==
0
)
{
g_
TabObjNet
[
i
].
m_BusNetCode
=
LastBusNetCode
;
g_
NetObjectslist
[
i
]
->
m_BusNetCode
=
LastBusNetCode
;
LastBusNetCode
++
;
}
PointToPointConnect
(
g_
TabObjNet
+
i
,
ISBUS
,
istart
);
PointToPointConnect
(
g_
NetObjectslist
[
i
]
,
ISBUS
,
istart
);
break
;
case
NET_BUSLABELMEMBER
:
case
NET_HIERBUSLABELMEMBER
:
case
NET_GLOBBUSLABELMEMBER
:
/* Controle des connexions semblables a des sur BUS */
if
(
g_
TabObjNet
[
i
].
GetNet
()
==
0
)
if
(
g_
NetObjectslist
[
i
]
->
GetNet
()
==
0
)
{
g_
TabObjNet
[
i
].
m_BusNetCode
=
LastBusNetCode
;
g_
NetObjectslist
[
i
]
->
m_BusNetCode
=
LastBusNetCode
;
LastBusNetCode
++
;
}
SegmentToPointConnect
(
g_
TabObjNet
+
i
,
ISBUS
,
istart
);
SegmentToPointConnect
(
g_
NetObjectslist
[
i
]
,
ISBUS
,
istart
);
break
;
}
}
#if defined
(NETLIST_DEBUG) && defined
(DEBUG)
#if defined
(NETLIST_DEBUG) && defined
(DEBUG)
std
::
cout
<<
"
\n\n
after sheet local
\n\n
"
;
dumpNetTable
();
#endif
...
...
@@ -346,15 +219,15 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
SetStatusText
(
activity
);
/* Mise a jour des NetCodes des Bus Labels connectes par les Bus */
ConnectBusLabels
(
g_
TabObjNet
,
g_NbrObjNe
t
);
ConnectBusLabels
(
g_
NetObjectslis
t
);
activity
<<
wxT
(
"; "
)
<<
_
(
"Labels"
);
SetStatusText
(
activity
);
/* Connections des groupes d'objets par labels identiques */
for
(
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
g_NetObjectslist
.
size
()
;
i
++
)
{
switch
(
g_
TabObjNet
[
i
].
m_Type
)
switch
(
g_
NetObjectslist
[
i
]
->
m_Type
)
{
case
NET_PIN
:
case
NET_SHEETLABEL
:
...
...
@@ -369,17 +242,19 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
case
NET_PINLABEL
:
case
NET_BUSLABELMEMBER
:
case
NET_GLOBBUSLABELMEMBER
:
LabelConnect
(
g_
TabObjNet
+
i
);
LabelConnect
(
g_
NetObjectslist
[
i
]
);
break
;
case
NET_SHEETBUSLABELMEMBER
:
case
NET_HIERLABEL
:
case
NET_HIERBUSLABELMEMBER
:
break
;
case
NET_ITEM_UNSPECIFIED
:
break
;
}
}
#if defined
(NETLIST_DEBUG) && defined
(DEBUG)
#if defined
(NETLIST_DEBUG) && defined
(DEBUG)
std
::
cout
<<
"
\n\n
after sheet global
\n\n
"
;
dumpNetTable
();
#endif
...
...
@@ -391,18 +266,18 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
activity
<<
wxT
(
"; "
)
<<
_
(
"Hierar."
);
SetStatusText
(
activity
);
for
(
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
g_NetObjectslist
.
size
()
;
i
++
)
{
if
(
g_
TabObjNet
[
i
].
m_Type
==
NET_SHEETLABEL
||
g_
TabObjNet
[
i
].
m_Type
==
NET_SHEETBUSLABELMEMBER
)
SheetLabelConnect
(
g_
TabObjNet
+
i
);
if
(
g_
NetObjectslist
[
i
]
->
m_Type
==
NET_SHEETLABEL
||
g_
NetObjectslist
[
i
]
->
m_Type
==
NET_SHEETBUSLABELMEMBER
)
SheetLabelConnect
(
g_
NetObjectslist
[
i
]
);
}
/* Sort objects by NetCode */
qsort
(
g_TabObjNet
,
g_NbrObjNet
,
sizeof
(
ObjetNetListStruct
),
TriNetC
ode
);
sort
(
g_NetObjectslist
.
begin
(),
g_NetObjectslist
.
end
(),
SortItemsbyNetc
ode
);
#if defined
(NETLIST_DEBUG) && defined
(DEBUG)
#if defined
(NETLIST_DEBUG) && defined
(DEBUG)
std
::
cout
<<
"after qsort()
\n
"
;
dumpNetTable
();
#endif
...
...
@@ -414,34 +289,29 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
activity
<<
wxT
(
"; "
)
<<
_
(
"Sorting Nets"
);
SetStatusText
(
activity
);
LastNetCode
=
NetCode
=
0
;
for
(
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
g_NetObjectslist
.
size
()
;
i
++
)
{
if
(
g_
TabObjNet
[
i
].
GetNet
()
!=
LastNetCode
)
if
(
g_
NetObjectslist
[
i
]
->
GetNet
()
!=
LastNetCode
)
{
NetCode
++
;
LastNetCode
=
g_
TabObjNet
[
i
].
GetNet
();
LastNetCode
=
g_
NetObjectslist
[
i
]
->
GetNet
();
}
g_
TabObjNet
[
i
].
SetNet
(
NetCode
);
g_
NetObjectslist
[
i
]
->
SetNet
(
NetCode
);
}
activity
<<
wxT
(
" "
)
<<
_
(
"Done"
);
SetStatusText
(
activity
);
/* Affectation du m_FlagOfConnection en fonction de connection ou non */
SetUnconnectedFlag
(
g_TabObjNet
,
g_NbrObjNet
);
return
(
void
*
)
g_TabObjNet
;
SetUnconnectedFlag
(
g_NetObjectslist
);
}
/*************************************************************
* Routine qui connecte les sous feuilles par les sheetLabels *
**************************************************************/
static
void
SheetLabelConnect
(
ObjetNetListStruct
*
SheetLabel
)
static
void
SheetLabelConnect
(
NETLIST_OBJECT
*
SheetLabel
)
{
int
i
;
ObjetNetListStruct
*
ObjetNet
;
if
(
SheetLabel
->
GetNet
()
==
0
)
return
;
...
...
@@ -449,43 +319,46 @@ static void SheetLabelConnect( ObjetNetListStruct* SheetLabel )
/* Comparaison du SheetLabel avec les GLABELS de la sous feuille
* pour regroupement des NetCodes */
for
(
i
=
0
,
ObjetNet
=
g_TabObjNet
;
i
<
g_NbrObjNet
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
g_NetObjectslist
.
size
()
;
i
++
)
{
if
(
ObjetNet
[
i
].
m_SheetList
!=
SheetLabel
->
m_SheetListInclude
)
NETLIST_OBJECT
*
ObjetNet
=
g_NetObjectslist
[
i
];
if
(
ObjetNet
->
m_SheetList
!=
SheetLabel
->
m_SheetListInclude
)
continue
;
//use SheetInclude, not the sheet!!
if
(
(
ObjetNet
[
i
].
m_Type
!=
NET_HIERLABEL
)
&&
(
ObjetNet
[
i
].
m_Type
!=
NET_HIERBUSLABELMEMBER
)
)
if
(
(
ObjetNet
->
m_Type
!=
NET_HIERLABEL
)
&&
(
ObjetNet
->
m_Type
!=
NET_HIERBUSLABELMEMBER
)
)
continue
;
if
(
ObjetNet
[
i
].
GetNet
()
==
SheetLabel
->
GetNet
()
)
if
(
ObjetNet
->
GetNet
()
==
SheetLabel
->
GetNet
()
)
continue
;
//already connected.
if
(
ObjetNet
[
i
].
m_Label
->
CmpNoCase
(
*
SheetLabel
->
m_Label
)
!=
0
)
if
(
ObjetNet
->
m_Label
->
CmpNoCase
(
*
SheetLabel
->
m_Label
)
!=
0
)
continue
;
//different names.
/* Propagation du Netcode a tous les Objets de meme NetCode */
if
(
ObjetNet
[
i
].
GetNet
()
)
if
(
ObjetNet
->
GetNet
()
)
PropageNetCode
(
ObjetNet
[
i
].
GetNet
(),
SheetLabel
->
GetNet
(),
0
);
else
ObjetNet
[
i
].
SetNet
(
SheetLabel
->
GetNet
()
);
ObjetNet
->
SetNet
(
SheetLabel
->
GetNet
()
);
}
}
/**************************************************************************************/
static
int
ListeObjetConnection
(
DrawSheetPath
*
sheetlist
,
ObjetNetListStruct
*
ObjNet
)
static
void
ListeObjetConnection
(
DrawSheetPath
*
sheetlist
,
std
::
vector
<
NETLIST_OBJECT
*>&
aNetItemBuffer
)
/**************************************************************************************/
/** Function ListeObjetConnection
* Creates the list of objects related to connections (pins of components, wires, labels, junctions ...)
* @param sheetlist: pointer to a sheetlist.
* @param
ObjNet: if NULL, objects count else list to fill
* @param
aNetItemBuffer: a std::vector to store pointer on NETLIST_OBJECT created
*/
{
int
ii
,
NbrItem
=
0
;
EDA_BaseStruct
*
DrawList
;
SCH_COMPONENT
*
DrawLibItem
;
int
ii
;
SCH_ITEM
*
DrawList
;
NETLIST_OBJECT
*
new_item
;
SCH_COMPONENT
*
DrawLibItem
;
EDA_LibComponentStruct
*
Entry
;
LibEDA_BaseStruct
*
DEntry
;
Hierarchical_PIN_Sheet_Struct
*
SheetLabel
;
...
...
@@ -499,81 +372,80 @@ static int ListeObjetConnection( DrawSheetPath* sheetlist, ObjetNetListStruct* O
case
DRAW_SEGMENT_STRUCT_TYPE
:
#undef STRUCT
#define STRUCT ( (EDA_DrawLineStruct*) DrawList )
if
(
ObjNet
)
{
if
(
(
STRUCT
->
GetLayer
()
!=
LAYER_BUS
)
&&
(
STRUCT
->
GetLayer
()
!=
LAYER_WIRE
)
)
break
;
if
(
(
STRUCT
->
GetLayer
()
!=
LAYER_BUS
)
&&
(
STRUCT
->
GetLayer
()
!=
LAYER_WIRE
)
)
break
;
ObjNet
[
NbrItem
].
m_SheetList
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_SheetListInclude
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Comp
=
STRUCT
;
ObjNet
[
NbrItem
].
m_Start
=
STRUCT
->
m_Start
;
ObjNet
[
NbrItem
].
m_End
=
STRUCT
->
m_End
;
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
;
if
(
STRUCT
->
GetLayer
()
==
LAYER_BUS
)
{
ObjNet
[
NbrItem
].
m_Type
=
NET_BUS
;
}
else
/* Cas des WIRE */
{
ObjNet
[
NbrItem
].
m_Type
=
NET_SEGMENT
;
}
if
(
STRUCT
->
GetLayer
()
==
LAYER_BUS
)
{
new_item
->
m_Type
=
NET_BUS
;
}
NbrItem
++
;
else
/* Cas des WIRE */
{
new_item
->
m_Type
=
NET_SEGMENT
;
}
aNetItemBuffer
.
push_back
(
new_item
);
break
;
case
DRAW_JUNCTION_STRUCT_TYPE
:
#undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) DrawList )
if
(
ObjNet
)
{
ObjNet
[
NbrItem
].
m_SheetList
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_SheetListInclude
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Comp
=
STRUCT
;
ObjNet
[
NbrItem
].
m_Type
=
NET_JONCTION
;
ObjNet
[
NbrItem
].
m_Start
=
ObjNet
[
NbrItem
].
m_End
=
STRUCT
->
m_Pos
;
}
NbrItem
++
;
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
)
;
break
;
case
DRAW_NOCONNECT_STRUCT_TYPE
:
#undef STRUCT
#define STRUCT ( (DrawNoConnectStruct*) DrawList )
if
(
ObjNet
)
{
ObjNet
[
NbrItem
].
m_SheetList
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_SheetListInclude
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Comp
=
STRUCT
;
ObjNet
[
NbrItem
].
m_Type
=
NET_NOCONNECT
;
ObjNet
[
NbrItem
].
m_Start
=
ObjNet
[
NbrItem
].
m_End
=
STRUCT
->
m_Pos
;
}
NbrItem
++
;
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
)
;
break
;
case
TYPE_SCH_LABEL
:
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) DrawList )
ii
=
IsBusLabel
(
STRUCT
->
m_Text
);
if
(
ObjNet
)
{
ObjNet
[
NbrItem
].
m_SheetList
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_SheetListInclude
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Comp
=
STRUCT
;
ObjNet
[
NbrItem
].
m_Type
=
NET_LABEL
;
if
(
STRUCT
->
m_Layer
==
LAYER_GLOBLABEL
)
ObjNet
[
NbrItem
].
m_Type
=
NET_GLOBLABEL
;
if
(
STRUCT
->
m_Layer
==
LAYER_HIERLABEL
)
ObjNet
[
NbrItem
].
m_Type
=
NET_HIERLABEL
;
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
);
/* Si c'est un Bus, eclatement en Label */
if
(
ii
)
ConvertBusToMembers
(
aNetItemBuffer
,
*
new_item
);
ObjNet
[
NbrItem
].
m_Label
=
&
STRUCT
->
m_Text
;
ObjNet
[
NbrItem
].
m_Start
=
ObjNet
[
NbrItem
].
m_End
=
STRUCT
->
m_Pos
;
/* Si c'est un Bus, eclatement en Label */
if
(
ii
)
ConvertBusToMembers
(
ObjNet
+
NbrItem
);
}
NbrItem
+=
ii
+
1
;
break
;
case
TYPE_SCH_GLOBALLABEL
:
...
...
@@ -581,26 +453,26 @@ static int ListeObjetConnection( DrawSheetPath* sheetlist, ObjetNetListStruct* O
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) DrawList )
ii
=
IsBusLabel
(
STRUCT
->
m_Text
);
if
(
ObjNet
)
{
ObjNet
[
NbrItem
].
m_SheetList
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_SheetListInclude
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Comp
=
STRUCT
;
ObjNet
[
NbrItem
].
m_Type
=
NET_LABEL
;
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
)
//this is not the simplest way of doing it
ObjNet
[
NbrItem
].
m_Type
=
NET_GLOBLABEL
;
// (look at the case statement above).
if
(
STRUCT
->
m_Layer
==
LAYER_HIERLABEL
)
ObjNet
[
NbrItem
].
m_Type
=
NET_HIERLABEL
;
if
(
STRUCT
->
m_Layer
==
LAYER_GLOBLABEL
)
//this is not the simplest way of doing it
new_item
->
m_Type
=
NET_GLOBLABEL
;
// (look at the case statement above).
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
);
/* Si c'est un Bus, eclatement en Label */
if
(
ii
)
ConvertBusToMembers
(
aNetItemBuffer
,
*
new_item
);
ObjNet
[
NbrItem
].
m_Label
=
&
STRUCT
->
m_Text
;
ObjNet
[
NbrItem
].
m_Start
=
ObjNet
[
NbrItem
].
m_End
=
STRUCT
->
m_Pos
;
/* Si c'est un Bus, eclatement en Label */
if
(
ii
)
ConvertBusToMembers
(
ObjNet
+
NbrItem
);
}
NbrItem
+=
ii
+
1
;
break
;
case
TYPE_SCH_COMPONENT
:
...
...
@@ -631,37 +503,35 @@ static int ListeObjetConnection( DrawSheetPath* sheetlist, ObjetNetListStruct* O
wxPoint
pos2
=
TransformCoordinate
(
DrawLibItem
->
m_Transform
,
Pin
->
m_Pos
)
+
DrawLibItem
->
m_Pos
;
Pin
->
m_Pos
)
+
DrawLibItem
->
m_Pos
;
if
(
ObjNet
)
{
ObjNet
[
NbrItem
].
m_SheetListInclude
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Comp
=
DEntry
;
ObjNet
[
NbrItem
].
m_SheetList
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Type
=
NET_PIN
;
ObjNet
[
NbrItem
].
m_Link
=
DrawLibItem
;
ObjNet
[
NbrItem
].
m_ElectricalType
=
Pin
->
m_PinType
;
ObjNet
[
NbrItem
].
m_PinNum
=
Pin
->
m_PinNum
;
ObjNet
[
NbrItem
].
m_Label
=
&
Pin
->
m_PinName
;
ObjNet
[
NbrItem
].
m_Start
=
ObjNet
[
NbrItem
].
m_End
=
pos2
;
}
NbrItem
++
;
new_item
=
new
NETLIST_OBJECT
();
new_item
->
m_SheetListInclude
=
*
sheetlist
;
new_item
->
m_Comp
=
DEntry
;
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
);
if
(
(
(
int
)
Pin
->
m_PinType
==
(
int
)
PIN_POWER_IN
)
&&
(
Pin
->
m_Attributs
&
PINNOTDRAW
)
)
{
/* Il y a un PIN_LABEL Associe */
if
(
ObjNet
)
{
ObjNet
[
NbrItem
].
m_SheetListInclude
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Comp
=
NULL
;
ObjNet
[
NbrItem
].
m_SheetList
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Type
=
NET_PINLABEL
;
ObjNet
[
NbrItem
].
m_Label
=
&
Pin
->
m_PinName
;
ObjNet
[
NbrItem
].
m_Start
=
pos2
;
ObjNet
[
NbrItem
].
m_End
=
ObjNet
[
NbrItem
].
m_Start
;
}
NbrItem
++
;
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
);
}
}
...
...
@@ -681,26 +551,24 @@ static int ListeObjetConnection( DrawSheetPath* sheetlist, ObjetNetListStruct* O
list
.
Push
(
STRUCT
);
SheetLabel
=
STRUCT
->
m_Label
;
for
(
;
SheetLabel
!=
NULL
;
SheetLabel
=
SheetLabel
->
Next
()
)
SheetLabel
=
SheetLabel
->
Next
()
)
{
ii
=
IsBusLabel
(
SheetLabel
->
m_Text
);
if
(
ObjNet
)
{
ObjNet
[
NbrItem
].
m_SheetListInclude
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Comp
=
SheetLabel
;
ObjNet
[
NbrItem
].
m_SheetList
=
*
sheetlist
;
ObjNet
[
NbrItem
].
m_Link
=
DrawList
;
ObjNet
[
NbrItem
].
m_Type
=
NET_SHEETLABEL
;
ObjNet
[
NbrItem
].
m_ElectricalType
=
SheetLabel
->
m_Shape
;
ObjNet
[
NbrItem
].
m_Label
=
&
SheetLabel
->
m_Text
;
ObjNet
[
NbrItem
].
m_SheetListInclude
=
list
;
ObjNet
[
NbrItem
].
m_Start
=
ObjNet
[
NbrItem
].
m_End
=
SheetLabel
->
m_Pos
;
/* Si c'est un Bus, eclatement en Label */
if
(
ii
)
ConvertBusToMembers
(
ObjNet
+
NbrItem
);
}
NbrItem
+=
ii
+
1
;
new_item
=
new
NETLIST_OBJECT
();
new_item
->
m_SheetListInclude
=
*
sheetlist
;
new_item
->
m_Comp
=
SheetLabel
;
new_item
->
m_SheetList
=
*
sheetlist
;
new_item
->
m_Link
=
DrawList
;
new_item
->
m_Type
=
NET_SHEETLABEL
;
new_item
->
m_ElectricalType
=
SheetLabel
->
m_Shape
;
new_item
->
m_Label
=
&
SheetLabel
->
m_Text
;
new_item
->
m_SheetListInclude
=
list
;
new_item
->
m_Start
=
new_item
->
m_End
=
SheetLabel
->
m_Pos
;
aNetItemBuffer
.
push_back
(
new_item
);
/* Si c'est un Bus, eclatement en Label */
if
(
ii
)
ConvertBusToMembers
(
aNetItemBuffer
,
*
new_item
);
}
break
;
...
...
@@ -713,19 +581,17 @@ static int ListeObjetConnection( DrawSheetPath* sheetlist, ObjetNetListStruct* O
{
wxString
msg
;
msg
.
Printf
(
wxT
(
"Netlist: unexpected type struct %d"
),
DrawList
->
Type
()
);
DrawList
->
Type
()
);
DisplayError
(
NULL
,
msg
);
break
;
}
}
}
return
NbrItem
;
}
/************************************************************************/
static
void
ConnectBusLabels
(
ObjetNetListStruct
*
Label
,
int
NbItems
)
static
void
ConnectBusLabels
(
NETLIST_OBJECT_LIST
&
aNetItemBuffer
)
/************************************************************************/
/* Routine qui analyse les labels type xxBUSLABELMEMBER
...
...
@@ -735,12 +601,9 @@ static void ConnectBusLabels( ObjetNetListStruct* Label, int NbItems )
* Utilise et met a jour la variable LastNetCode
*/
{
ObjetNetListStruct
*
LabelInTst
,
*
Lim
;
Lim
=
Label
+
NbItems
;
for
(
;
Label
<
Lim
;
Label
++
)
for
(
unsigned
ii
=
0
;
ii
<
aNetItemBuffer
.
size
();
ii
++
)
{
NETLIST_OBJECT
*
Label
=
aNetItemBuffer
[
ii
];
if
(
(
Label
->
m_Type
==
NET_SHEETBUSLABELMEMBER
)
||
(
Label
->
m_Type
==
NET_BUSLABELMEMBER
)
||
(
Label
->
m_Type
==
NET_HIERBUSLABELMEMBER
)
)
...
...
@@ -751,8 +614,9 @@ static void ConnectBusLabels( ObjetNetListStruct* Label, int NbItems )
LastNetCode
++
;
}
for
(
LabelInTst
=
Label
+
1
;
LabelInTst
<
Lim
;
LabelInTst
++
)
for
(
unsigned
jj
=
ii
+
1
;
jj
<
aNetItemBuffer
.
size
();
jj
++
)
{
NETLIST_OBJECT
*
LabelInTst
=
aNetItemBuffer
[
jj
];
if
(
(
LabelInTst
->
m_Type
==
NET_SHEETBUSLABELMEMBER
)
||
(
LabelInTst
->
m_Type
==
NET_BUSLABELMEMBER
)
||
(
LabelInTst
->
m_Type
==
NET_HIERBUSLABELMEMBER
)
)
...
...
@@ -834,25 +698,21 @@ int IsBusLabel( const wxString& LabelDrawList )
EXCHG
(
FirstNumWireBus
,
LastNumWireBus
);
}
if
(
error
&&
(
s_PassNumber
==
0
)
)
{
wxString
msg
=
_
(
"Bad Bus Label: "
)
+
LabelDrawList
;
DisplayError
(
NULL
,
msg
);
}
return
LastNumWireBus
-
FirstNumWireBus
+
1
;
}
/***************************************************************/
static
int
ConvertBusToMembers
(
ObjetNetListStruct
*
BusLabel
)
static
int
ConvertBusToMembers
(
NETLIST_OBJECT_LIST
&
aNetItemBuffer
,
NETLIST_OBJECT
&
BusLabel
)
/***************************************************************/
/* Routine qui eclate un label type Bus en autant de Label qu'il contient de membres,
* et qui cree les structures avec le type NET_GLOBBUSLABELMEMBER, NET_BUSLABELMEMBER
* ou NET_SHEETBUSLABELMEMBER
* entree = pointeur sur l'
ObjetNetListStruct
initialise corresp au buslabel
* entree = pointeur sur l'
NETLIST_OBJECT
initialise corresp au buslabel
* suppose que FirstNumWireBus, LastNumWireBus et RootBusNameLength sont a jour
* modifie l'
ObjetNetListStruct
de base et remplit les suivants
* modifie l'
NETLIST_OBJECT
de base et remplit les suivants
* m_Label is a pointer to a new wxString
* m_Label must be deallocated by the user (only for a NET_GLOBBUSLABELMEMBER,
* NET_BUSLABELMEMBER or a NET_SHEETBUSLABELMEMBER object type)
...
...
@@ -861,37 +721,37 @@ static int ConvertBusToMembers( ObjetNetListStruct* BusLabel )
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
;
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
;
else
BusLabel
->
m_Type
=
NET_BUSLABELMEMBER
;
BusLabel
.
m_Type
=
NET_BUSLABELMEMBER
;
/* Convertion du BusLabel en la racine du Label + le numero du fil */
BufLine
=
BusLabel
->
m_Label
->
Left
(
RootBusNameLength
);
BufLine
=
BusLabel
.
m_Label
->
Left
(
RootBusNameLength
);
BusMember
=
FirstNumWireBus
;
BufLine
<<
BusMember
;
BusLabel
->
m_Label
=
new
wxString
(
BufLine
);
BusLabel
.
m_Label
=
new
wxString
(
BufLine
);
BusLabel
->
m_Member
=
BusMember
;
BusLabel
.
m_Member
=
BusMember
;
NumItem
=
1
;
for
(
BusMember
++
;
BusMember
<=
LastNumWireBus
;
BusMember
++
)
{
*
(
BusLabel
+
1
)
=
*
BusLabel
;
//copy constructor.
BusLabel
++
;
NETLIST_OBJECT
*
new_label
=
new
NETLIST_OBJECT
(
BusLabel
);
NumItem
++
;
/* Convertion du BusLabel en la racine du Label + le numero du fil */
BufLine
=
BusLabel
->
m_Label
->
Left
(
RootBusNameLength
);
BufLine
=
BusLabel
.
m_Label
->
Left
(
RootBusNameLength
);
BufLine
<<
BusMember
;
BusL
abel
->
m_Label
=
new
wxString
(
BufLine
);
new_l
abel
->
m_Label
=
new
wxString
(
BufLine
);
BusLabel
->
m_Member
=
BusMember
;
new_label
->
m_Member
=
BusMember
;
aNetItemBuffer
.
push_back
(
new_label
);
}
return
NumItem
;
...
...
@@ -909,19 +769,14 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus )
*/
{
int
jj
;
ObjetNetListStruct
*
Objet
=
g_TabObjNet
;
if
(
OldNetCode
==
NewNetCode
)
return
;
#if defined (NETLIST_DEBUG) && defined (DEBUG)
printf
(
"replacing net %d with %d
\n
"
,
OldNetCode
,
NewNetCode
);
#endif
if
(
IsBus
==
0
)
/* Propagation du NetCode */
{
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
,
Objet
++
)
for
(
unsigned
jj
=
0
;
jj
<
g_NetObjectslist
.
size
();
jj
++
)
{
NETLIST_OBJECT
*
Objet
=
g_NetObjectslist
[
jj
];
if
(
Objet
->
GetNet
()
==
OldNetCode
)
{
Objet
->
SetNet
(
NewNetCode
);
...
...
@@ -930,8 +785,9 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus )
}
else
/* Propagation du BusNetCode */
{
for
(
jj
=
0
;
jj
<
g_NbrObjNet
;
jj
++
,
Objet
++
)
for
(
unsigned
jj
=
0
;
jj
<
g_NetObjectslist
.
size
();
jj
++
)
{
NETLIST_OBJECT
*
Objet
=
g_NetObjectslist
[
jj
];
if
(
Objet
->
m_BusNetCode
==
OldNetCode
)
{
Objet
->
m_BusNetCode
=
NewNetCode
;
...
...
@@ -942,7 +798,7 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus )
/***************************************************************************/
static
void
PointToPointConnect
(
ObjetNetListStruct
*
Ref
,
int
IsBus
,
int
start
)
static
void
PointToPointConnect
(
NETLIST_OBJECT
*
Ref
,
int
IsBus
,
int
start
)
/***************************************************************************/
/* Routine qui verifie si l'element *Ref est connecte a
...
...
@@ -964,18 +820,18 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
* ( il ne peut y avoir connexion physique entre elements de differentes sheets)
*/
{
int
i
,
netCode
;
ObjetNetListStruct
*
netTable
=
g_TabObjNet
;
int
netCode
;
if
(
IsBus
==
0
)
/* Objets autres que BUS et BUSLABELS */
{
netCode
=
Ref
->
GetNet
();
for
(
i
=
start
;
i
<
g_NbrObjNet
;
i
++
)
for
(
unsigned
i
=
start
;
i
<
g_NetObjectslist
.
size
()
;
i
++
)
{
if
(
netTable
[
i
].
m_SheetList
!=
Ref
->
m_SheetList
)
//used to be > (why?)
NETLIST_OBJECT
*
item
=
g_NetObjectslist
[
i
];
if
(
item
->
m_SheetList
!=
Ref
->
m_SheetList
)
//used to be > (why?)
continue
;
switch
(
netTable
[
i
].
m_Type
)
switch
(
item
->
m_Type
)
{
case
NET_SEGMENT
:
case
NET_PIN
:
...
...
@@ -986,15 +842,15 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
case
NET_PINLABEL
:
case
NET_JONCTION
:
case
NET_NOCONNECT
:
if
(
Ref
->
m_Start
==
netTable
[
i
].
m_Start
||
Ref
->
m_Start
==
netTable
[
i
].
m_End
||
Ref
->
m_End
==
netTable
[
i
].
m_Start
||
Ref
->
m_End
==
netTable
[
i
].
m_End
)
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
)
{
if
(
netTable
[
i
].
GetNet
()
==
0
)
netTable
[
i
].
SetNet
(
netCode
);
if
(
item
->
GetNet
()
==
0
)
item
->
SetNet
(
netCode
);
else
PropageNetCode
(
netTable
[
i
].
GetNet
(),
netCode
,
0
);
PropageNetCode
(
item
->
GetNet
(),
netCode
,
0
);
}
break
;
...
...
@@ -1003,6 +859,7 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
case
NET_SHEETBUSLABELMEMBER
:
case
NET_HIERBUSLABELMEMBER
:
case
NET_GLOBBUSLABELMEMBER
:
case
NET_ITEM_UNSPECIFIED
:
break
;
}
}
...
...
@@ -1010,13 +867,15 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
else
/* Objets type BUS et BUSLABELS ( et JONCTIONS )*/
{
netCode
=
Ref
->
m_BusNetCode
;
for
(
i
=
start
;
i
<
g_NbrObjNet
;
i
++
)
for
(
unsigned
i
=
start
;
i
<
g_NetObjectslist
.
size
()
;
i
++
)
{
if
(
netTable
[
i
].
m_SheetList
!=
Ref
->
m_SheetList
)
NETLIST_OBJECT
*
item
=
g_NetObjectslist
[
i
];
if
(
item
->
m_SheetList
!=
Ref
->
m_SheetList
)
continue
;
switch
(
netTable
[
i
].
m_Type
)
switch
(
item
->
m_Type
)
{
case
NET_ITEM_UNSPECIFIED
:
case
NET_SEGMENT
:
case
NET_PIN
:
case
NET_LABEL
:
...
...
@@ -1033,15 +892,15 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
case
NET_HIERBUSLABELMEMBER
:
case
NET_GLOBBUSLABELMEMBER
:
case
NET_JONCTION
:
if
(
Ref
->
m_Start
==
netTable
[
i
].
m_Start
||
Ref
->
m_Start
==
netTable
[
i
].
m_End
||
Ref
->
m_End
==
netTable
[
i
].
m_Start
||
Ref
->
m_End
==
netTable
[
i
].
m_End
)
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
)
{
if
(
netTable
[
i
].
m_BusNetCode
==
0
)
netTable
[
i
].
m_BusNetCode
=
netCode
;
if
(
item
->
m_BusNetCode
==
0
)
item
->
m_BusNetCode
=
netCode
;
else
PropageNetCode
(
netTable
[
i
].
m_BusNetCode
,
netCode
,
1
);
PropageNetCode
(
item
->
m_BusNetCode
,
netCode
,
1
);
}
break
;
}
...
...
@@ -1051,7 +910,7 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
/**************************************************************/
static
void
SegmentToPointConnect
(
ObjetNetListStruct
*
Jonction
,
static
void
SegmentToPointConnect
(
NETLIST_OBJECT
*
Jonction
,
int
IsBus
,
int
start
)
/***************************************************************/
...
...
@@ -1065,45 +924,44 @@ static void SegmentToPointConnect( ObjetNetListStruct* Jonction,
* ( il ne peut y avoir connexion physique entre elements de differentes sheets)
*/
{
int
i
;
ObjetNetListStruct
*
Segment
=
g_TabObjNet
;
for
(
i
=
start
;
i
<
g_NbrObjNet
;
i
++
)
for
(
unsigned
i
=
start
;
i
<
g_NetObjectslist
.
size
();
i
++
)
{
if
(
Segment
[
i
].
m_SheetList
!=
Jonction
->
m_SheetList
)
NETLIST_OBJECT
*
Segment
=
g_NetObjectslist
[
i
];
if
(
Segment
->
m_SheetList
!=
Jonction
->
m_SheetList
)
continue
;
if
(
IsBus
==
0
)
{
if
(
Segment
[
i
].
m_Type
!=
NET_SEGMENT
)
if
(
Segment
->
m_Type
!=
NET_SEGMENT
)
continue
;
}
else
{
if
(
Segment
[
i
].
m_Type
!=
NET_BUS
)
if
(
Segment
->
m_Type
!=
NET_BUS
)
continue
;
}
if
(
SegmentIntersect
(
Segment
[
i
].
m_Start
.
x
,
Segment
[
i
].
m_Start
.
y
,
Segment
[
i
].
m_End
.
x
,
Segment
[
i
].
m_End
.
y
,
Jonction
->
m_Start
.
x
,
Jonction
->
m_Start
.
y
)
)
if
(
SegmentIntersect
(
Segment
->
m_Start
.
x
,
Segment
->
m_Start
.
y
,
Segment
->
m_End
.
x
,
Segment
->
m_End
.
y
,
Jonction
->
m_Start
.
x
,
Jonction
->
m_Start
.
y
)
)
{
/* Propagation du Netcode a tous les Objets de meme NetCode */
if
(
IsBus
==
0
)
{
if
(
Segment
[
i
].
GetNet
()
)
PropageNetCode
(
Segment
[
i
].
GetNet
(),
Jonction
->
GetNet
(),
IsBus
);
if
(
Segment
->
GetNet
()
)
PropageNetCode
(
Segment
->
GetNet
(),
Jonction
->
GetNet
(),
IsBus
);
else
Segment
[
i
].
SetNet
(
Jonction
->
GetNet
()
);
Segment
->
SetNet
(
Jonction
->
GetNet
()
);
}
else
{
if
(
Segment
[
i
].
m_BusNetCode
)
PropageNetCode
(
Segment
[
i
].
m_BusNetCode
,
Jonction
->
m_BusNetCode
,
IsBus
);
if
(
Segment
->
m_BusNetCode
)
PropageNetCode
(
Segment
->
m_BusNetCode
,
Jonction
->
m_BusNetCode
,
IsBus
);
else
Segment
[
i
].
m_BusNetCode
=
Jonction
->
m_BusNetCode
;
Segment
->
m_BusNetCode
=
Jonction
->
m_BusNetCode
;
}
}
}
...
...
@@ -1113,26 +971,24 @@ static void SegmentToPointConnect( ObjetNetListStruct* Jonction,
/*****************************************************************
* Function which connects the groups of object which have the same label
*******************************************************************/
static
void
LabelConnect
(
ObjetNetListStruct
*
LabelRef
)
void
LabelConnect
(
NETLIST_OBJECT
*
LabelRef
)
{
if
(
LabelRef
->
GetNet
()
==
0
)
return
;
ObjetNetListStruct
*
netTable
=
g_TabObjNet
;
for
(
int
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
g_NetObjectslist
.
size
();
i
++
)
{
if
(
netTable
[
i
].
GetNet
()
==
LabelRef
->
GetNet
()
)
if
(
g_NetObjectslist
[
i
]
->
GetNet
()
==
LabelRef
->
GetNet
()
)
continue
;
if
(
netTable
[
i
].
m_SheetList
!=
LabelRef
->
m_SheetList
)
if
(
g_NetObjectslist
[
i
]
->
m_SheetList
!=
LabelRef
->
m_SheetList
)
{
if
(
(
netTable
[
i
].
m_Type
!=
NET_PINLABEL
&&
netTable
[
i
].
m_Type
!=
NET_GLOBLABEL
&&
netTable
[
i
].
m_Type
!=
NET_GLOBBUSLABELMEMBER
)
)
if
(
(
g_NetObjectslist
[
i
]
->
m_Type
!=
NET_PINLABEL
&&
g_NetObjectslist
[
i
]
->
m_Type
!=
NET_GLOBLABEL
&&
g_NetObjectslist
[
i
]
->
m_Type
!=
NET_GLOBBUSLABELMEMBER
)
)
continue
;
if
(
(
netTable
[
i
].
m_Type
==
NET_GLOBLABEL
||
netTable
[
i
].
m_Type
==
NET_GLOBBUSLABELMEMBER
)
&&
netTable
[
i
].
m_Type
!=
LabelRef
->
m_Type
)
if
(
(
g_NetObjectslist
[
i
]
->
m_Type
==
NET_GLOBLABEL
||
g_NetObjectslist
[
i
]
->
m_Type
==
NET_GLOBBUSLABELMEMBER
)
&&
g_NetObjectslist
[
i
]
->
m_Type
!=
LabelRef
->
m_Type
)
//global labels only connect other global labels.
continue
;
}
...
...
@@ -1141,114 +997,111 @@ static void LabelConnect( ObjetNetListStruct* LabelRef )
//NET_HIERLABEL are used to connect sheets.
//NET_LABEL is sheet-local (***)
//NET_GLOBLABEL is global.
if
(
netTable
[
i
].
m_Type
==
NET_LABEL
||
netTable
[
i
].
m_Type
==
NET_GLOBLABEL
||
netTable
[
i
].
m_Type
==
NET_HIERLABEL
||
netTable
[
i
].
m_Type
==
NET_BUSLABELMEMBER
||
netTable
[
i
].
m_Type
==
NET_GLOBBUSLABELMEMBER
||
netTable
[
i
].
m_Type
==
NET_HIERBUSLABELMEMBER
||
netTable
[
i
].
m_Type
==
NET_PINLABEL
)
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
)
{
if
(
netTable
[
i
].
m_Label
->
CmpNoCase
(
*
LabelRef
->
m_Label
)
!=
0
)
if
(
g_NetObjectslist
[
i
]
->
m_Label
->
CmpNoCase
(
*
LabelRef
->
m_Label
)
!=
0
)
continue
;
// Propagation du Netcode a tous les Objets de meme NetCode
if
(
netTable
[
i
].
GetNet
()
)
PropageNetCode
(
netTable
[
i
].
GetNet
(),
LabelRef
->
GetNet
(),
0
);
if
(
g_NetObjectslist
[
i
]
->
GetNet
()
)
PropageNetCode
(
g_NetObjectslist
[
i
]
->
GetNet
(),
LabelRef
->
GetNet
(),
0
);
else
netTable
[
i
].
SetNet
(
LabelRef
->
GetNet
()
);
g_NetObjectslist
[
i
]
->
SetNet
(
LabelRef
->
GetNet
()
);
}
}
}
/****************************************************************************/
static
int
TriNetCode
(
const
void
*
o1
,
const
void
*
o
2
)
bool
SortItemsbyNetcode
(
const
NETLIST_OBJECT
*
Objet1
,
const
NETLIST_OBJECT
*
Objet
2
)
/****************************************************************************/
/* Routine de comparaison pour le tri par NetCode croissant
* du tableau des elements connectes ( TabPinSort ) par qsort()
*/
{
ObjetNetListStruct
*
Objet1
=
(
ObjetNetListStruct
*
)
o1
;
ObjetNetListStruct
*
Objet2
=
(
ObjetNetListStruct
*
)
o2
;
return
Objet1
->
GetNet
()
-
Objet2
->
GetNet
();
return
Objet1
->
GetNet
()
<
Objet2
->
GetNet
();
}
/*****************************************************************************/
static
int
TriBySheet
(
const
void
*
o1
,
const
void
*
o
2
)
/*****************************************************************************/
/*****************************************************************************
************
/
bool
SortItemsBySheet
(
const
NETLIST_OBJECT
*
Objet1
,
const
NETLIST_OBJECT
*
Objet
2
)
/*****************************************************************************
************
/
/* Routine de comparaison pour le tri par NumSheet
* du tableau des elements connectes ( TabPinSort ) par qsort() */
{
ObjetNetListStruct
*
Objet1
=
(
ObjetNetListStruct
*
)
o1
;
ObjetNetListStruct
*
Objet2
=
(
ObjetNetListStruct
*
)
o2
;
return
Objet1
->
m_SheetList
.
Cmp
(
Objet2
->
m_SheetList
);
return
Objet1
->
m_SheetList
.
Cmp
(
Objet2
->
m_SheetList
)
<
0
;
}
/**********************************************************************/
static
void
SetUnconnectedFlag
(
ObjetNetListStruct
*
ListObj
,
int
NbItems
)
static
void
SetUnconnectedFlag
(
NETLIST_OBJECT_LIST
&
aNetItemBuffer
)
/**********************************************************************/
/* Routine positionnant le membre .FlagNoConnect des elements de
* la liste des objets netliste, tries par ordre de NetCode
*/
{
ObjetNetListStruct
*
NetItemRef
,
*
NetItemTst
,
*
ItemPtr
;
ObjetNetListStruct
*
NetStart
,
*
NetEnd
,
*
Lim
;
int
Nb
;
NETLIST_OBJECT
*
NetItemRef
;
unsigned
NetStart
,
NetEnd
;
ConnectType
StateFlag
;
NetStart
=
NetEnd
=
ListObj
;
NetItemRef
=
NetStart
;
Nb
=
0
;
NetStart
=
NetEnd
=
0
;
StateFlag
=
UNCONNECTED
;
Lim
=
ListObj
+
NbItems
;
for
(
;
NetItemRef
<
Lim
;
NetItemRef
++
)
for
(
unsigned
ii
=
0
;
ii
<
aNetItemBuffer
.
size
();
ii
++
)
{
if
(
NetItemRef
->
m_Type
==
NET_NOCONNECT
)
if
(
StateFlag
!=
PAD_CONNECT
)
StateFlag
=
NOCONNEC
T
;
NetItemRef
=
aNetItemBuffer
[
ii
];
if
(
NetItemRef
->
m_Type
==
NET_NOCONNECT
&&
StateFlag
!=
PAD_CONNECT
)
StateFlag
=
NOCONNECT_SYMBOL_PRESEN
T
;
/* Analyse du net en cours */
NetItemTst
=
NetItemRef
+
1
;
unsigned
idxtoTest
=
ii
+
1
;
if
(
(
NetItemTst
>=
Lim
)
||
(
NetItemRef
->
GetNet
()
!=
NetItemTst
->
GetNet
()
)
)
if
(
(
idxtoTest
>=
aNetItemBuffer
.
size
()
)
||
(
NetItemRef
->
GetNet
()
!=
aNetItemBuffer
[
idxtoTest
]
->
GetNet
()
)
)
{
/* Net analyse: mise a jour de m_FlagOfConnection */
NetEnd
=
NetItemT
st
;
NetEnd
=
idxtoTe
st
;
for
(
ItemPtr
=
NetStart
;
ItemPtr
<
NetEnd
;
ItemPtr
++
)
{
ItemPtr
->
m_FlagOfConnection
=
StateFlag
;
}
/* set m_FlagOfConnection member to StateFlag for all items of this net: */
for
(
unsigned
kk
=
NetStart
;
kk
<
NetEnd
;
kk
++
)
aNetItemBuffer
[
kk
]
->
m_FlagOfConnection
=
StateFlag
;
if
(
NetItemTst
>=
Lim
)
if
(
idxtoTest
>=
aNetItemBuffer
.
size
()
)
return
;
/* Start Analys
e Nouveau
Net */
/* Start Analys
is next
Net */
StateFlag
=
UNCONNECTED
;
NetStart
=
NetItemT
st
;
NetStart
=
idxtoTe
st
;
continue
;
}
for
(
;
;
NetItemTst
++
)
/* 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
++
)
{
if
(
(
NetItemTst
>=
Lim
)
||
(
NetItemRef
->
GetNet
()
!=
NetItemTst
->
GetNet
()
)
)
if
(
(
idxtoTest
>=
aNetItemBuffer
.
size
()
)
||
(
NetItemRef
->
GetNet
()
!=
aNetItemBuffer
[
idxtoTest
]
->
GetNet
()
)
)
break
;
switch
(
NetItemTst
->
m_Type
)
switch
(
aNetItemBuffer
[
idxtoTest
]
->
m_Type
)
{
case
NET_ITEM_UNSPECIFIED
:
wxMessageBox
(
wxT
(
"BuildNetListBase() error"
));
break
;
case
NET_SEGMENT
:
case
NET_LABEL
:
case
NET_HIERLABEL
:
...
...
@@ -1270,7 +1123,7 @@ static void SetUnconnectedFlag( ObjetNetListStruct* ListObj, int NbItems )
case
NET_NOCONNECT
:
if
(
StateFlag
!=
PAD_CONNECT
)
StateFlag
=
NOCONNECT
;
StateFlag
=
NOCONNECT
_SYMBOL_PRESENT
;
break
;
}
}
...
...
eeschema/netlist.h
View file @
aa9e61ed
...
...
@@ -11,6 +11,8 @@
#define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins
#include "class_netlist_object.h"
/* Id to select netlist type */
enum
TypeNetForm
{
NET_TYPE_UNINIT
=
0
,
...
...
@@ -30,69 +32,6 @@ enum TypeNetForm {
/* Max pin number per component and footprint */
#define MAXPIN 5000
enum
NetObjetType
{
/* Type des objets de Net */
NET_SEGMENT
,
NET_BUS
,
NET_JONCTION
,
NET_LABEL
,
NET_GLOBLABEL
,
NET_HIERLABEL
,
//on a screen to indicate connection to a higher-level sheet
NET_SHEETLABEL
,
//on a drawscreen element to indicate connection to a lower-level sheet.
NET_BUSLABELMEMBER
,
NET_GLOBBUSLABELMEMBER
,
NET_HIERBUSLABELMEMBER
,
NET_SHEETBUSLABELMEMBER
,
NET_PINLABEL
,
NET_PIN
,
NET_NOCONNECT
};
enum
ConnectType
{
/* Valeur du Flag de connection */
UNCONNECTED
=
0
,
/* Pin ou Label non connecte */
NOCONNECT
,
/* Pin volontairement non connectee (Symb. NoConnect utilise) */
PAD_CONNECT
/* connexion normale */
};
/* Structure decrivant 1 element de connexion (pour netlist ) */
class
ObjetNetListStruct
{
public
:
NetObjetType
m_Type
;
// Type of this item (see NetObjetType enum)
EDA_BaseStruct
*
m_Comp
;
/* Pointer on the schematic item that created this net object (the parent)*/
void
*
m_Link
;
/* For Hierarchical_PIN_Sheet_Struct:
* Pointer to the hierarchy sheet that contains this Hierarchical_PIN_Sheet_Struct
* For Pins: pointer to the component that contains this pin
*/
int
m_Flag
;
/* flag used in calculations */
DrawSheetPath
m_SheetList
;
int
m_ElectricalType
;
/* Has meaning only for Pins and hierachical pins: electrical type */
private
:
int
m_NetCode
;
/* net code for all items except BUS labels because a BUS label has
* as many net codes as bus members
*/
public
:
int
m_BusNetCode
;
/* Used for BUS connections */
int
m_Member
;
/* for labels type NET_BUSLABELMEMBER ( bus member created from the BUS label )
* member number
*/
ConnectType
m_FlagOfConnection
;
DrawSheetPath
m_SheetListInclude
;
/* sheet that the hierarchal label connects to.*/
long
m_PinNum
;
/* numero de pin( 4 octets -> 4 codes ascii) */
const
wxString
*
m_Label
;
/* For all labels:pointer on the text label */
wxPoint
m_Start
,
m_End
;
#if defined(DEBUG)
void
Show
(
std
::
ostream
&
out
,
int
ndx
);
#endif
void
SetNet
(
int
aNetCode
)
{
m_NetCode
=
aNetCode
;
}
int
GetNet
()
const
{
return
m_NetCode
;
}
};
/* object used in annotation to handle a list of components in schematic
...
...
@@ -150,15 +89,17 @@ public:
/* Global Variables */
extern
int
g_NbrObjNet
;
extern
ObjetNetListStruct
*
g_TabObjNet
;
// Buffer to build the list of items used in netlist and erc calculations
typedef
std
::
vector
<
NETLIST_OBJECT
*>
NETLIST_OBJECT_LIST
;
extern
NETLIST_OBJECT_LIST
g_NetObjectslist
;
/* Prototypes: */
void
WriteNetList
(
WinEDA_SchematicFrame
*
frame
,
const
wxString
&
FileNameNL
,
bool
use_netnames
);
void
Free
TabNetList
(
ObjetNetListStruct
*
TabNetItems
,
int
NbrNetItems
);
void
Free
NetObjectsList
(
std
::
vector
<
NETLIST_OBJECT
*>&
aNetObjectslist
);
/** Function ReturnUserNetlistTypeName
* to retrieve user netlist type names
...
...
eeschema/netlist_control.cpp
View file @
aa9e61ed
...
...
@@ -28,8 +28,6 @@
#define CUSTOM_NETLIST_TITLE wxT( "CustomNetlistTitle" )
#define CUSTOM_NETLIST_COMMAND wxT( "CustomNetlistCommand" )
/* Loacl variable */
/****************************************************/
wxString
ReturnUserNetlistTypeName
(
bool
first_item
)
/****************************************************/
...
...
@@ -531,7 +529,6 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
break
;
}
FreeTabNetList
(
g_TabObjNet
,
g_NbrObjNet
);
m_Parent
->
m_NetlistFormat
=
netformat_tmp
;
WriteCurrentNetlistSetup
();
...
...
include/wxEeschemaStruct.h
View file @
aa9e61ed
...
...
@@ -166,7 +166,7 @@ public:
SCH_COMPONENT
*
LibItem
);
/* netlist generation */
void
*
BuildNetListBase
();
void
BuildNetListBase
();
/**
* Function DeleteAnnotation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment