2011-10-12 15:34:52 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
/**
|
|
|
|
* @file class_netlist_object.h
|
|
|
|
* @brief Definition of the NETLIST_OBJECT class.
|
|
|
|
*/
|
2009-07-12 15:29:42 +00:00
|
|
|
|
|
|
|
#ifndef _CLASS_NETLIST_OBJECT_H_
|
|
|
|
#define _CLASS_NETLIST_OBJECT_H_
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_sheet_path.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <lib_pin.h> // LIB_PIN::ReturnPinStringNum( m_PinNum )
|
2010-08-03 02:13:33 +00:00
|
|
|
|
|
|
|
|
2011-10-12 15:34:52 +00:00
|
|
|
class NETLIST_OBJECT;
|
|
|
|
|
|
|
|
|
|
|
|
// Buffer to build the list of items used in netlist and erc calculations
|
|
|
|
typedef std::vector <NETLIST_OBJECT*> NETLIST_OBJECT_LIST;
|
|
|
|
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
/* Type of Net objects (wires, labels, pins...) */
|
2011-10-12 15:34:52 +00:00
|
|
|
enum NETLIST_ITEM_T {
|
2009-07-12 15:29:42 +00:00
|
|
|
NET_ITEM_UNSPECIFIED, // only for not yet initialized instances
|
|
|
|
NET_SEGMENT, // connection by wire
|
|
|
|
NET_BUS, // connection by bus
|
2011-10-07 14:41:30 +00:00
|
|
|
NET_JUNCTION, // connection by junction: can connect to
|
2009-12-02 21:44:03 +00:00
|
|
|
// or more crossing wires
|
2009-07-12 15:29:42 +00:00
|
|
|
NET_LABEL, // this is a local label
|
2009-12-02 21:44:03 +00:00
|
|
|
NET_GLOBLABEL, // this is a global label that connect all
|
|
|
|
// others global label in whole hierarchy
|
|
|
|
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
|
|
|
|
*/
|
2009-07-12 15:29:42 +00:00
|
|
|
NET_PIN, // this is an usual pin
|
|
|
|
NET_NOCONNECT // this is a no connect symbol
|
|
|
|
};
|
|
|
|
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
/* Values for .m_FlagOfConnection member */
|
2011-10-12 15:34:52 +00:00
|
|
|
enum NET_CONNECTION_T {
|
2009-12-02 21:44:03 +00:00
|
|
|
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) */
|
2009-07-12 15:29:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-10-12 15:34:52 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2013-08-13 23:04:41 +00:00
|
|
|
extern bool IsBusLabel( const wxString& aLabel );
|
2011-10-12 15:34:52 +00:00
|
|
|
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
class NETLIST_OBJECT
|
|
|
|
{
|
|
|
|
public:
|
2011-10-12 15:34:52 +00:00
|
|
|
NETLIST_ITEM_T m_Type; /* Type of item (see NETLIST_ITEM_T enum) */
|
2011-10-07 14:41:30 +00:00
|
|
|
EDA_ITEM* m_Comp; /* Pointer on the library item that
|
2009-12-02 21:44:03 +00:00
|
|
|
* created this net object (the parent)
|
|
|
|
*/
|
|
|
|
SCH_ITEM* m_Link; /* For SCH_SHEET_PIN:
|
|
|
|
* Pointer to the hierarchy sheet that
|
|
|
|
* contains this SCH_SHEET_PIN
|
|
|
|
* For Pins: pointer to the component
|
|
|
|
* that contains this pin
|
|
|
|
*/
|
2010-06-23 17:00:12 +00:00
|
|
|
int m_Flag; /* flag used in calculations */
|
|
|
|
SCH_SHEET_PATH m_SheetList;
|
|
|
|
int m_ElectricalType; /* Has meaning only for Pins and
|
2009-12-02 21:44:03 +00:00
|
|
|
* hierarchical pins: electrical type */
|
2009-07-12 15:29:42 +00:00
|
|
|
private:
|
2010-06-23 17:00:12 +00:00
|
|
|
int m_NetCode; /* net code for all items except BUS
|
2009-12-02 21:44:03 +00:00
|
|
|
* labels because a BUS label has
|
|
|
|
* as many net codes as bus members
|
2009-07-12 15:29:42 +00:00
|
|
|
*/
|
|
|
|
public:
|
2010-06-23 17:00:12 +00:00
|
|
|
int m_BusNetCode; /* Used for BUS connections */
|
2011-10-12 15:34:52 +00:00
|
|
|
int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member
|
|
|
|
* created from the BUS label ) member number.
|
2009-12-02 21:44:03 +00:00
|
|
|
*/
|
2011-10-12 15:34:52 +00:00
|
|
|
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) */
|
2010-06-24 18:31:43 +00:00
|
|
|
wxString m_Label; /* Label text. */
|
2011-10-12 15:34:52 +00:00
|
|
|
wxPoint m_Start; // Position of object or for segments: starting point
|
|
|
|
wxPoint m_End; // For segments (wire and buses): ending point
|
2010-06-23 17:00:12 +00:00
|
|
|
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
|
|
|
|
*/
|
2009-07-12 15:29:42 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
2011-12-14 17:25:42 +00:00
|
|
|
void Show( std::ostream& out, int ndx ) const; // override
|
2009-07-12 15:29:42 +00:00
|
|
|
#endif
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT();
|
|
|
|
NETLIST_OBJECT( NETLIST_OBJECT& aSource ); // Copy constructor
|
|
|
|
|
|
|
|
~NETLIST_OBJECT();
|
|
|
|
|
|
|
|
void SetNet( int aNetCode ) { m_NetCode = aNetCode; }
|
|
|
|
int GetNet() const { return m_NetCode; }
|
2010-08-03 02:13:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetPinNum
|
|
|
|
* returns a pin number in wxString form. Pin numbers are not always
|
2011-10-07 14:41:30 +00:00
|
|
|
* numbers. \"A23\" would be a valid pin number.
|
2010-08-03 02:13:33 +00:00
|
|
|
*/
|
|
|
|
wxString GetPinNumText()
|
|
|
|
{
|
|
|
|
// hide the ugliness in here, but do it inline.
|
2011-10-12 15:34:52 +00:00
|
|
|
return LIB_PIN::ReturnPinStringNum( m_PinNum );
|
2010-08-03 02:13:33 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsLabelConnected
|
|
|
|
* tests if the net list object is a hierarchical label or sheet label and is
|
|
|
|
* connected to an associated hierarchical label or sheet label of \a aNetItem.
|
|
|
|
*
|
|
|
|
* @param aNetItem A pointer to a NETLIST_OBJECT to test against.
|
|
|
|
* @return A bool value of true if there is a connection with \a aNetItem or false
|
|
|
|
* if no connection to \a aNetItem.
|
|
|
|
*/
|
|
|
|
bool IsLabelConnected( NETLIST_OBJECT* aNetItem );
|
|
|
|
|
2011-10-12 15:34:52 +00:00
|
|
|
/**
|
|
|
|
* 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 );
|
|
|
|
};
|
2010-12-31 19:47:39 +00:00
|
|
|
|
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#endif // _CLASS_NETLIST_OBJECT_H_
|