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
31ed2c28
Commit
31ed2c28
authored
Oct 12, 2011
by
Wayne Stambaugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor bus label parsing function into net list object.
parent
4e55b6be
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
178 additions
and
138 deletions
+178
-138
class_netlist_object.cpp
eeschema/class_netlist_object.cpp
+105
-3
class_netlist_object.h
eeschema/class_netlist_object.h
+69
-21
netlist.cpp
eeschema/netlist.cpp
+2
-95
protos.h
eeschema/protos.h
+0
-13
sch_sheet.cpp
eeschema/sch_sheet.cpp
+1
-4
sch_text.cpp
eeschema/sch_text.cpp
+1
-2
No files found.
eeschema/class_netlist_object.cpp
View file @
31ed2c28
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file class_netlist_object.cpp
* @brief Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations)
...
...
@@ -13,7 +38,7 @@
#if defined(DEBUG)
#include <iostream>
const
char
*
ShowType
(
N
etObjetType
aType
)
const
char
*
ShowType
(
N
ETLIST_ITEM_T
aType
)
{
const
char
*
ret
;
...
...
@@ -117,7 +142,7 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
NETLIST_OBJECT
::
NETLIST_OBJECT
()
{
m_Type
=
NET_ITEM_UNSPECIFIED
;
/* Type of this item (see N
etObjetType
enum) */
m_Type
=
NET_ITEM_UNSPECIFIED
;
/* Type of this item (see N
ETLIST_ITEM_T
enum) */
m_Comp
=
NULL
;
/* Pointer on the library item that created this net object
* (the parent)*/
m_Link
=
NULL
;
/* For SCH_SHEET_PIN:
...
...
@@ -126,7 +151,7 @@ NETLIST_OBJECT::NETLIST_OBJECT()
* contains this pin
*/
m_Flag
=
0
;
/* flag used in calculations */
m_ElectricalType
=
0
;
/* Has meaning only for Pins and hierachical pins: electrical
m_ElectricalType
=
0
;
/* Has meaning only for Pins and hiera
r
chical 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
...
...
@@ -174,3 +199,80 @@ bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem )
return
false
;
//these two are unconnected
}
void
NETLIST_OBJECT
::
ConvertBusToNetListItems
(
NETLIST_OBJECT_LIST
&
aNetListItems
)
{
wxCHECK_RET
(
IsBusLabel
(
m_Label
),
wxT
(
"<"
)
+
m_Label
+
wxT
(
"> is not a valid bus label."
)
);
if
(
m_Type
==
NET_HIERLABEL
)
m_Type
=
NET_HIERBUSLABELMEMBER
;
else
if
(
m_Type
==
NET_GLOBLABEL
)
m_Type
=
NET_GLOBBUSLABELMEMBER
;
else
if
(
m_Type
==
NET_SHEETLABEL
)
m_Type
=
NET_SHEETBUSLABELMEMBER
;
else
if
(
m_Type
==
NET_LABEL
)
m_Type
=
NET_BUSLABELMEMBER
;
else
wxCHECK_RET
(
false
,
wxT
(
"Net list object type is not valid."
)
);
unsigned
i
;
wxString
tmp
,
busName
;
long
begin
,
end
,
member
;
/* Search for '[' because a bus label is like "busname[nn..mm]" */
i
=
m_Label
.
Find
(
'['
);
busName
=
m_Label
.
Left
(
i
);
i
++
;
while
(
m_Label
[
i
]
!=
'.'
&&
i
<
m_Label
.
Len
()
)
{
tmp
.
Append
(
m_Label
[
i
]
);
i
++
;
}
tmp
.
ToLong
(
&
begin
);
while
(
m_Label
[
i
]
==
'.'
&&
i
<
m_Label
.
Len
()
)
i
++
;
tmp
.
Empty
();
while
(
m_Label
[
i
]
!=
']'
&&
i
<
m_Label
.
Len
()
)
{
tmp
.
Append
(
m_Label
[
i
]
);
i
++
;
}
tmp
.
ToLong
(
&
end
);
if
(
begin
<
0
)
begin
=
0
;
if
(
end
<
0
)
end
=
0
;
if
(
begin
>
end
)
EXCHG
(
begin
,
end
);
member
=
begin
;
tmp
=
busName
;
tmp
<<
member
;
m_Label
=
tmp
;
m_Member
=
member
;
for
(
member
++
;
member
<=
end
;
member
++
)
{
NETLIST_OBJECT
*
item
=
new
NETLIST_OBJECT
(
*
this
);
// Conversion of bus label to the root name + the current member id.
tmp
=
busName
;
tmp
<<
member
;
item
->
m_Label
=
tmp
;
item
->
m_Member
=
member
;
aNetListItems
.
push_back
(
item
);
}
}
eeschema/class_netlist_object.h
View file @
31ed2c28
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file class_netlist_object.h
* @brief Definition of the NETLIST_OBJECT class.
...
...
@@ -12,8 +37,15 @@
#include "lib_pin.h" // LIB_PIN::ReturnPinStringNum( m_PinNum )
class
NETLIST_OBJECT
;
// Buffer to build the list of items used in netlist and erc calculations
typedef
std
::
vector
<
NETLIST_OBJECT
*>
NETLIST_OBJECT_LIST
;
/* Type of Net objects (wires, labels, pins...) */
enum
N
etObjetType
{
enum
N
ETLIST_ITEM_T
{
NET_ITEM_UNSPECIFIED
,
// only for not yet initialized instances
NET_SEGMENT
,
// connection by wire
NET_BUS
,
// connection by bus
...
...
@@ -47,8 +79,9 @@ enum NetObjetType {
NET_NOCONNECT
// this is a no connect symbol
};
/* Values for .m_FlagOfConnection member */
enum
ConnectType
{
enum
NET_CONNECTION_T
{
UNCONNECTED
=
0
,
/* Pin or Label not connected (error) */
NOCONNECT_SYMBOL_PRESENT
,
/* Pin not connected but have a NoConnect
* symbol on it (no error) */
...
...
@@ -56,11 +89,24 @@ enum ConnectType {
};
/**
* Function IsBusLabel
* test if \a aLabel has a bus notation.
*
* @param aLabel A wxString object containing the label to test.
* @return true if text is a bus notation format otherwise false is returned.
*/
inline
bool
IsBusLabel
(
const
wxString
&
aLabel
)
{
/* Search for '[' because a bus label is like "busname[nn..mm]" */
return
aLabel
.
Find
(
'['
)
!=
wxNOT_FOUND
;
}
class
NETLIST_OBJECT
{
public
:
NetObjetType
m_Type
;
/* Type of item (see NetObjetType
* enum) */
NETLIST_ITEM_T
m_Type
;
/* Type of item (see NETLIST_ITEM_T enum) */
EDA_ITEM
*
m_Comp
;
/* Pointer on the library item that
* created this net object (the parent)
*/
...
...
@@ -81,20 +127,15 @@ private:
*/
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
int
m_Member
;
/* for labels type NET_BUSLABELMEMBER ( bus member
* created from the BUS label ) member number.
*/
ConnectType
m_FlagOfConnection
;
SCH_SHEET_PATH
m_SheetListInclude
;
/* sheet that the hierarchical label
* connects to.*/
long
m_PinNum
;
/* pin number ( 1 long = 4 bytes ->
* 4 ascii codes) */
NET_CONNECTION_T
m_FlagOfConnection
;
SCH_SHEET_PATH
m_SheetListInclude
;
/* sheet that the hierarchical label connects to.*/
long
m_PinNum
;
/* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
wxString
m_Label
;
/* Label text. */
wxPoint
m_Start
;
// Position of object or for segments:
// starting point
wxPoint
m_End
;
// For segments (wire and buses):
// ending point
wxPoint
m_Start
;
// Position of object or for segments: starting point
wxPoint
m_End
;
// For segments (wire and buses): ending point
NETLIST_OBJECT
*
m_NetNameCandidate
;
/* a pointer to a label connected to the net,
* that can be used to give a name to the net
* NULL if no usable label
...
...
@@ -120,7 +161,7 @@ public:
wxString
GetPinNumText
()
{
// hide the ugliness in here, but do it inline.
return
LIB_PIN
::
ReturnPinStringNum
(
m_PinNum
);
return
LIB_PIN
::
ReturnPinStringNum
(
m_PinNum
);
}
/**
...
...
@@ -133,11 +174,18 @@ public:
* if no connection to \a aNetItem.
*/
bool
IsLabelConnected
(
NETLIST_OBJECT
*
aNetItem
);
};
// Buffer to build the list of items used in netlist and erc calculations
typedef
std
::
vector
<
NETLIST_OBJECT
*>
NETLIST_OBJECT_LIST
;
/**
* Function ConvertBusToNetListItems
* breaks the text of a bus label type net list object into as many members as
* it contains and creates a #NETLIST_OBJECT for each label and adds it to \a
* aNetListItems.
*
* @param aNetListItems A reference to vector of #NETLIST_OBJECT pointers to add
* the bus label NETLIST_OBJECTs.
*/
void
ConvertBusToNetListItems
(
NETLIST_OBJECT_LIST
&
aNetListItems
);
};
#endif // _CLASS_NETLIST_OBJECT_H_
eeschema/netlist.cpp
View file @
31ed2c28
...
...
@@ -539,92 +539,6 @@ static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel )
}
/**
* Function ConvertBusToMembers
* breaks the text of a bus label type in as many members as it contains and
* creates a #NETLIST_OBJECT for each label.
*
* @param aNetListItems A reference to vector of #NETLIST_OBJECT pointers to add
* the bus label NETLIST_OBJECTs.
* @param aBusLabel A reference to the base bus label #NETLIST_OBJECT.
*/
void
ConvertBusToMembers
(
NETLIST_OBJECT_LIST
&
aNetListItems
,
NETLIST_OBJECT
&
aBusLabel
)
{
wxCHECK_RET
(
IsBusLabel
(
aBusLabel
.
m_Label
),
wxT
(
"<"
)
+
aBusLabel
.
m_Label
+
wxT
(
"> is not a valid bus label."
)
);
if
(
aBusLabel
.
m_Type
==
NET_HIERLABEL
)
aBusLabel
.
m_Type
=
NET_HIERBUSLABELMEMBER
;
else
if
(
aBusLabel
.
m_Type
==
NET_GLOBLABEL
)
aBusLabel
.
m_Type
=
NET_GLOBBUSLABELMEMBER
;
else
if
(
aBusLabel
.
m_Type
==
NET_SHEETLABEL
)
aBusLabel
.
m_Type
=
NET_SHEETBUSLABELMEMBER
;
else
if
(
aBusLabel
.
m_Type
==
NET_LABEL
)
aBusLabel
.
m_Type
=
NET_BUSLABELMEMBER
;
else
wxCHECK_RET
(
false
,
wxT
(
"Net object type is not valid."
)
);
unsigned
i
;
wxString
tmp
,
busName
;
long
begin
,
end
,
member
;
/* Search for '[' because a bus label is like "busname[nn..mm]" */
i
=
aBusLabel
.
m_Label
.
Find
(
'['
);
busName
=
aBusLabel
.
m_Label
.
Left
(
i
);
i
++
;
while
(
aBusLabel
.
m_Label
[
i
]
!=
'.'
&&
i
<
aBusLabel
.
m_Label
.
Len
()
)
{
tmp
.
Append
(
aBusLabel
.
m_Label
[
i
]
);
i
++
;
}
tmp
.
ToLong
(
&
begin
);
while
(
aBusLabel
.
m_Label
[
i
]
==
'.'
&&
i
<
aBusLabel
.
m_Label
.
Len
()
)
i
++
;
tmp
.
Empty
();
while
(
aBusLabel
.
m_Label
[
i
]
!=
']'
&&
i
<
aBusLabel
.
m_Label
.
Len
()
)
{
tmp
.
Append
(
aBusLabel
.
m_Label
[
i
]
);
i
++
;
}
tmp
.
ToLong
(
&
end
);
if
(
begin
<
0
)
begin
=
0
;
if
(
end
<
0
)
end
=
0
;
if
(
begin
>
end
)
EXCHG
(
begin
,
end
);
member
=
begin
;
tmp
=
busName
;
tmp
<<
member
;
aBusLabel
.
m_Label
=
tmp
;
aBusLabel
.
m_Member
=
member
;
for
(
member
++
;
member
<=
end
;
member
++
)
{
NETLIST_OBJECT
*
item
=
new
NETLIST_OBJECT
(
aBusLabel
);
/* Conversion of BusLabel to the root name + the current member id.*/
tmp
=
busName
;
tmp
<<
member
;
item
->
m_Label
=
tmp
;
item
->
m_Member
=
member
;
aNetListItems
.
push_back
(
item
);
}
}
/*
* Routine that analyzes the type labels xxBUSLABELMEMBER
* Propagate Netcode between the corresponding labels (ie when
...
...
@@ -672,13 +586,6 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
}
bool
IsBusLabel
(
const
wxString
&
aLabel
)
{
/* Search for '[' because a bus label is like "busname[nn..mm]" */
return
aLabel
.
Find
(
'['
)
!=
wxNOT_FOUND
;
}
/*
* PropageNetCode propagates Netcode NewNetCode on all elements
* belonging to the former Netcode OldNetCode
...
...
@@ -913,7 +820,7 @@ void LabelConnect( NETLIST_OBJECT* LabelRef )
// NET_LABEL is sheet-local (***)
// NET_GLOBLABEL is global.
// NET_PINLABEL is a kind of global label (generated by a power pin invisible)
N
etObjetType
ntype
=
g_NetObjectslist
[
i
]
->
m_Type
;
N
ETLIST_ITEM_T
ntype
=
g_NetObjectslist
[
i
]
->
m_Type
;
if
(
ntype
==
NET_LABEL
||
ntype
==
NET_GLOBLABEL
...
...
@@ -960,7 +867,7 @@ static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer )
{
NETLIST_OBJECT
*
NetItemRef
;
unsigned
NetStart
,
NetEnd
;
ConnectType
StateFlag
;
NET_CONNECTION_T
StateFlag
;
NetStart
=
NetEnd
=
0
;
StateFlag
=
UNCONNECTED
;
...
...
eeschema/protos.h
View file @
31ed2c28
...
...
@@ -58,19 +58,6 @@ void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, in
EDA_Colors
ReturnLayerColor
(
int
Layer
);
/***************/
/* NETLIST.CPP */
/***************/
/**
* Function IsBusLabel
* test if the \a aLabel has a bus notation.
*
* @param aLabel A wxString object containing the label to test.
* @return false if text is not a bus notattion otherwise true is returned.
*/
bool
IsBusLabel
(
const
wxString
&
aLabel
);
/***************/
/* PINEDIT.CPP */
/***************/
...
...
eeschema/sch_sheet.cpp
View file @
31ed2c28
...
...
@@ -47,9 +47,6 @@
#include "class_netlist_object.h"
extern
void
ConvertBusToMembers
(
NETLIST_OBJECT_LIST
&
aNetItemBuffer
,
NETLIST_OBJECT
&
aBusLabel
);
SCH_SHEET
::
SCH_SHEET
(
const
wxPoint
&
pos
)
:
SCH_ITEM
(
NULL
,
SCH_SHEET_T
)
{
...
...
@@ -1118,7 +1115,7 @@ void SCH_SHEET::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
aNetListItems
.
push_back
(
item
);
if
(
IsBusLabel
(
m_pins
[
i
].
m_Text
)
)
ConvertBusToMembers
(
aNetListItems
,
*
item
);
item
->
ConvertBusToNetListItems
(
aNetListItems
);
}
}
...
...
eeschema/sch_text.cpp
View file @
31ed2c28
...
...
@@ -45,7 +45,6 @@
extern
void
IncrementLabelMember
(
wxString
&
name
);
extern
void
ConvertBusToMembers
(
NETLIST_OBJECT_LIST
&
aNetItemBuffer
,
NETLIST_OBJECT
&
aBusLabel
);
/* Names of sheet label types. */
...
...
@@ -696,7 +695,7 @@ void SCH_TEXT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
/* If a bus connects to label */
if
(
IsBusLabel
(
m_Text
)
)
ConvertBusToMembers
(
aNetListItems
,
*
item
);
item
->
ConvertBusToNetListItems
(
aNetListItems
);
}
...
...
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