2011-10-12 15:34:52 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-02-18 07:40:45 +00:00
|
|
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-09-25 19:09:57 +00:00
|
|
|
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
2016-02-18 07:40:45 +00:00
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-12 15:34:52 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
/**
|
2018-01-30 08:56:43 +00:00
|
|
|
* @file netlist_object.cpp
|
2011-10-07 14:41:30 +00:00
|
|
|
* @brief Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations)
|
|
|
|
*/
|
2009-07-12 15:29:42 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <macros.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <list>
|
2009-07-12 15:29:42 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_component.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <sch_connection.h>
|
2018-01-30 08:56:43 +00:00
|
|
|
#include <netlist_object.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2013-08-13 23:04:41 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#if defined(DEBUG)
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
#include <iostream>
|
2020-01-18 20:51:28 +00:00
|
|
|
const char* ShowType( NETLIST_ITEM aType )
|
2009-07-12 15:29:42 +00:00
|
|
|
{
|
|
|
|
const char* ret;
|
|
|
|
|
|
|
|
switch( aType )
|
|
|
|
{
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::SEGMENT:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "segment"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::BUS:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "bus"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::JUNCTION:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "junction"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::LABEL:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "label"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::HIERLABEL:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "hierlabel"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::GLOBLABEL:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "glabel"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::BUSLABELMEMBER:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "buslblmember"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::HIERBUSLABELMEMBER:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "hierbuslblmember"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "gbuslblmember"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "sbuslblmember"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::SHEETLABEL:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "sheetlabel"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::PINLABEL:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "pinlabel"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::PIN:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "pin"; break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::NOCONNECT:
|
2009-07-12 15:29:42 +00:00
|
|
|
ret = "noconnect"; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ret = "??"; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) const
|
2009-07-12 15:29:42 +00:00
|
|
|
{
|
2013-09-29 18:24:38 +00:00
|
|
|
wxString path = m_SheetPath.PathHumanReadable();
|
2009-07-12 15:29:42 +00:00
|
|
|
|
|
|
|
out << "<netItem ndx=\"" << ndx << '"' <<
|
|
|
|
" type=\"" << ShowType( m_Type ) << '"' <<
|
|
|
|
" netCode=\"" << GetNet() << '"' <<
|
2011-02-28 18:36:19 +00:00
|
|
|
" sheet=\"" << TO_UTF8( path ) << '"' <<
|
2009-07-12 15:29:42 +00:00
|
|
|
">\n";
|
|
|
|
|
|
|
|
out << " <start " << m_Start << "/> <end " << m_End << "/>\n";
|
|
|
|
|
2010-06-28 13:11:14 +00:00
|
|
|
if( !m_Label.IsEmpty() )
|
2010-06-24 18:31:43 +00:00
|
|
|
out << " <label>" << m_Label.mb_str() << "</label>\n";
|
2009-07-12 15:29:42 +00:00
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
out << " <sheetpath>" << m_SheetPath.PathHumanReadable().mb_str() << "</sheetpath>\n";
|
2010-08-03 05:11:05 +00:00
|
|
|
|
|
|
|
switch( m_Type )
|
|
|
|
{
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::PIN:
|
2011-12-14 17:25:42 +00:00
|
|
|
/* GetRef() needs to be const
|
2013-09-30 06:36:40 +00:00
|
|
|
out << " <refOfComp>" << GetComponentParent()->GetRef(&m_SheetPath).mb_str()
|
2011-10-07 14:41:30 +00:00
|
|
|
<< "</refOfComp>\n";
|
2011-12-14 17:25:42 +00:00
|
|
|
*/
|
2010-08-03 05:11:05 +00:00
|
|
|
|
|
|
|
if( m_Comp )
|
|
|
|
m_Comp->Show( 1, out );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-08-03 05:11:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// not all the m_Comp classes have working Show functions.
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* was segfault-ing
|
2009-07-12 15:29:42 +00:00
|
|
|
if( m_Comp )
|
2010-08-03 05:11:05 +00:00
|
|
|
m_Comp->Show( 1, out ); // labels may not have good Show() funcs?
|
2009-07-12 15:29:42 +00:00
|
|
|
else
|
|
|
|
out << " m_Comp==NULL\n";
|
2010-08-03 05:11:05 +00:00
|
|
|
*/
|
2009-07-12 15:29:42 +00:00
|
|
|
|
|
|
|
out << "</netItem>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
NETLIST_OBJECT::NETLIST_OBJECT()
|
|
|
|
{
|
2020-01-18 20:51:28 +00:00
|
|
|
m_Type = NETLIST_ITEM::ITEM_UNSPECIFIED; /* Type of this item (see NETLIST_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:
|
|
|
|
* Pointer to the hierarchy sheet that contains this
|
|
|
|
* SCH_SHEET_PIN For Pins: pointer to the component that
|
|
|
|
* contains this pin
|
|
|
|
*/
|
|
|
|
m_Flag = 0; /* flag used in calculations */
|
|
|
|
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 NETLIST_ITEM::BUSLABELMEMBER ( bus member created
|
|
|
|
* from the BUS label ) member number
|
|
|
|
*/
|
|
|
|
m_ConnectionType = NET_CONNECTION::UNCONNECTED;
|
|
|
|
m_ElectricalPinType =
|
|
|
|
ELECTRICAL_PINTYPE::PT_INPUT; /* Has meaning only for Pins: electrical type of the pin
|
|
|
|
* used to detect conflicts between pins in ERC
|
|
|
|
*/
|
|
|
|
m_netNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
|
|
|
|
* object used to give a name to the net
|
|
|
|
*/
|
2009-07-12 15:29:42 +00:00
|
|
|
}
|
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
// Copy constructor
|
|
|
|
NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource )
|
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
*this = aSource;
|
2009-07-12 15:29:42 +00:00
|
|
|
}
|
|
|
|
|
2010-06-23 17:00:12 +00:00
|
|
|
|
2009-07-12 15:29:42 +00:00
|
|
|
NETLIST_OBJECT::~NETLIST_OBJECT()
|
|
|
|
{
|
|
|
|
}
|
2010-08-03 02:13:33 +00:00
|
|
|
|
2015-06-07 18:18:45 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
// return true if the object is a label of any type
|
|
|
|
bool NETLIST_OBJECT::IsLabelType() const
|
|
|
|
{
|
2020-01-18 20:51:28 +00:00
|
|
|
return m_Type == NETLIST_ITEM::LABEL || m_Type == NETLIST_ITEM::GLOBLABEL
|
|
|
|
|| m_Type == NETLIST_ITEM::HIERLABEL || m_Type == NETLIST_ITEM::BUSLABELMEMBER
|
|
|
|
|| m_Type == NETLIST_ITEM::GLOBBUSLABELMEMBER
|
|
|
|
|| m_Type == NETLIST_ITEM::HIERBUSLABELMEMBER || m_Type == NETLIST_ITEM::PINLABEL;
|
2013-09-25 19:09:57 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
|
|
|
bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem )
|
|
|
|
{
|
|
|
|
if( aNetItem == this ) // Don't compare the same net list object.
|
|
|
|
return false;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
NETLIST_ITEM at = m_Type;
|
|
|
|
NETLIST_ITEM bt = aNetItem->m_Type;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( ( at == NETLIST_ITEM::HIERLABEL || at == NETLIST_ITEM::HIERBUSLABELMEMBER )
|
|
|
|
&& ( bt == NETLIST_ITEM::SHEETLABEL || bt == NETLIST_ITEM::SHEETBUSLABELMEMBER ) )
|
2011-10-07 14:41:30 +00:00
|
|
|
{
|
2013-09-29 18:24:38 +00:00
|
|
|
if( m_SheetPath == aNetItem->m_SheetPathInclude )
|
2011-10-07 14:41:30 +00:00
|
|
|
{
|
|
|
|
return true; //connected!
|
|
|
|
}
|
|
|
|
}
|
2020-01-18 20:51:28 +00:00
|
|
|
else if( ( at == NETLIST_ITEM::GLOBLABEL ) && ( bt == NETLIST_ITEM::GLOBLABEL ) )
|
2015-08-31 11:09:47 +00:00
|
|
|
{
|
|
|
|
if( m_Label == aNetItem->m_Label )
|
|
|
|
return true; //connected!
|
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
|
|
|
return false; //these two are unconnected
|
|
|
|
}
|
2011-10-12 15:34:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItems )
|
|
|
|
{
|
2019-03-11 21:32:05 +00:00
|
|
|
SCH_CONNECTION conn;
|
|
|
|
wxCHECK_RET( conn.IsBusLabel( m_Label ),
|
2011-10-12 15:34:52 +00:00
|
|
|
wxT( "<" ) + m_Label + wxT( "> is not a valid bus label." ) );
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_Type == NETLIST_ITEM::HIERLABEL )
|
|
|
|
m_Type = NETLIST_ITEM::HIERBUSLABELMEMBER;
|
|
|
|
else if( m_Type == NETLIST_ITEM::GLOBLABEL )
|
|
|
|
m_Type = NETLIST_ITEM::GLOBBUSLABELMEMBER;
|
|
|
|
else if( m_Type == NETLIST_ITEM::SHEETLABEL )
|
|
|
|
m_Type = NETLIST_ITEM::SHEETBUSLABELMEMBER;
|
|
|
|
else if( m_Type == NETLIST_ITEM::LABEL )
|
|
|
|
m_Type = NETLIST_ITEM::BUSLABELMEMBER;
|
2011-10-12 15:34:52 +00:00
|
|
|
else
|
|
|
|
wxCHECK_RET( false, wxT( "Net list object type is not valid." ) );
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
// NOTE: all netlist objects generated from a single bus definition need to have different
|
|
|
|
// member codes set. For bus vectors, the member code matches the vector index, but for
|
|
|
|
// bus groups (including with nested vectors) the code is something arbitrary.
|
|
|
|
long member_offset = 0;
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
auto alias = SCH_SCREEN::GetBusAlias( m_Label );
|
|
|
|
if( alias || conn.IsBusGroupLabel( m_Label ) )
|
2011-10-12 15:34:52 +00:00
|
|
|
{
|
2019-03-11 21:32:05 +00:00
|
|
|
wxString group_name;
|
|
|
|
bool self_set = false;
|
|
|
|
std::vector<wxString> bus_contents_vec;
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
if( alias )
|
|
|
|
{
|
2019-11-30 13:23:08 +00:00
|
|
|
for( const auto& member : alias->Members() )
|
|
|
|
bus_contents_vec.emplace_back( member );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCHECK_RET( conn.ParseBusGroup( m_Label, &group_name, bus_contents_vec ),
|
2019-04-15 19:52:49 +00:00
|
|
|
wxString::Format( _( "Failed to parse bus group %s" ), m_Label ) );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
// For named bus groups, like "USB{DP DM}"
|
|
|
|
auto group_prefix = ( group_name != "" ) ? ( group_name + "." ) : "";
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
std::list<wxString> bus_contents( bus_contents_vec.begin(),
|
|
|
|
bus_contents_vec.end() );
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-12-05 15:20:59 +00:00
|
|
|
for( const auto& bus_member : bus_contents )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
|
|
|
// Nested bus vector inside a bus group
|
|
|
|
if( conn.IsBusVectorLabel( bus_member ) )
|
|
|
|
{
|
|
|
|
wxString prefix;
|
2019-05-24 02:46:45 +00:00
|
|
|
std::vector<wxString> members;
|
2019-03-11 21:32:05 +00:00
|
|
|
long begin, end;
|
|
|
|
|
2019-05-24 02:46:45 +00:00
|
|
|
conn.ParseBusVector( bus_member, &prefix, members );
|
2019-03-11 21:32:05 +00:00
|
|
|
prefix = group_prefix + prefix;
|
2019-05-24 02:46:45 +00:00
|
|
|
begin = conn.VectorStart();
|
|
|
|
end = conn.VectorEnd();
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
if( !self_set )
|
|
|
|
{
|
2019-05-24 02:46:45 +00:00
|
|
|
m_Label = members[0];
|
2019-03-11 21:32:05 +00:00
|
|
|
m_Member = ( begin++ ) + ( member_offset++ );
|
|
|
|
|
|
|
|
self_set = true;
|
|
|
|
begin++;
|
|
|
|
}
|
|
|
|
|
|
|
|
fillBusVector( aNetListItems, prefix, begin, end, member_offset );
|
|
|
|
member_offset += std::abs( end - begin );
|
|
|
|
}
|
|
|
|
else if( auto nested_alias = SCH_SCREEN::GetBusAlias( bus_member ) )
|
|
|
|
{
|
|
|
|
// Nested alias inside a group
|
2019-12-05 15:20:59 +00:00
|
|
|
for( const auto& alias_member : nested_alias->Members() )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
|
|
|
bus_contents.push_back( alias_member );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !self_set )
|
|
|
|
{
|
|
|
|
m_Label = group_prefix + bus_member;
|
|
|
|
m_Member = member_offset++;
|
|
|
|
self_set = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto item = new NETLIST_OBJECT( *this );
|
|
|
|
item->m_Label = group_prefix + bus_member;
|
|
|
|
item->m_Member = member_offset++;
|
|
|
|
aNetListItems.push_back( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-12 15:34:52 +00:00
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Plain bus vector
|
|
|
|
wxString prefix;
|
2019-05-24 02:46:45 +00:00
|
|
|
std::vector<wxString> members;
|
2019-03-11 21:32:05 +00:00
|
|
|
long begin, end;
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-05-24 02:46:45 +00:00
|
|
|
conn.ParseBusVector( m_Label, &prefix, members );
|
|
|
|
begin = conn.VectorStart();
|
|
|
|
end = conn.VectorEnd();
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-05-24 02:46:45 +00:00
|
|
|
m_Label = members[0];
|
2019-03-11 21:32:05 +00:00
|
|
|
m_Member = begin;
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
fillBusVector( aNetListItems, prefix, begin + 1, end, 0 );
|
|
|
|
}
|
|
|
|
}
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
void NETLIST_OBJECT::fillBusVector( NETLIST_OBJECT_LIST& aNetListItems,
|
|
|
|
wxString aName, long aBegin, long aEnd, long aOffset )
|
|
|
|
{
|
|
|
|
for( long member = aBegin; member <= aEnd; member++ )
|
2011-10-12 15:34:52 +00:00
|
|
|
{
|
2019-03-11 21:32:05 +00:00
|
|
|
auto item = new NETLIST_OBJECT( *this );
|
2011-10-12 15:34:52 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
item->m_Label = aName;
|
|
|
|
item->m_Label << member;
|
2011-10-12 15:34:52 +00:00
|
|
|
item->m_Member = member;
|
|
|
|
|
|
|
|
aNetListItems.push_back( item );
|
|
|
|
}
|
|
|
|
}
|
2013-09-25 19:09:57 +00:00
|
|
|
|
2016-02-18 07:40:45 +00:00
|
|
|
|
|
|
|
bool NETLIST_OBJECT::IsLabelGlobal() const
|
|
|
|
{
|
|
|
|
// return true if the object is a global label
|
|
|
|
// * a actual global label
|
|
|
|
// * a pin label coming from a invisible power pin
|
2020-01-18 20:51:28 +00:00
|
|
|
return ( m_Type == NETLIST_ITEM::PINLABEL ) || ( m_Type == NETLIST_ITEM::GLOBLABEL )
|
|
|
|
|| ( m_Type == NETLIST_ITEM::GLOBBUSLABELMEMBER );
|
2016-02-18 07:40:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool NETLIST_OBJECT::IsLabelBusMemberType() const
|
|
|
|
{
|
|
|
|
// return true if the object is a bus label member build from a
|
|
|
|
// schematic bus label (like label[xx..yy)
|
|
|
|
// They are labels with very specific properties, especially for connection
|
|
|
|
// between them: 2 bus label members can be connected only
|
|
|
|
// if they have the same member value.
|
2020-01-18 20:51:28 +00:00
|
|
|
return ( m_Type == NETLIST_ITEM::SHEETBUSLABELMEMBER )
|
|
|
|
|| ( m_Type == NETLIST_ITEM::BUSLABELMEMBER )
|
|
|
|
|| ( m_Type == NETLIST_ITEM::HIERBUSLABELMEMBER )
|
|
|
|
|| ( m_Type == NETLIST_ITEM::GLOBBUSLABELMEMBER );
|
2016-02-18 07:40:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
/*
|
|
|
|
* return the net name of the item
|
|
|
|
*/
|
2020-02-15 17:55:18 +00:00
|
|
|
wxString NETLIST_OBJECT::GetNetName() const
|
2013-09-25 19:09:57 +00:00
|
|
|
{
|
|
|
|
if( m_netNameCandidate == NULL )
|
|
|
|
return wxEmptyString;
|
|
|
|
|
|
|
|
wxString netName;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_netNameCandidate->m_Type == NETLIST_ITEM::PIN )
|
2020-02-15 17:55:18 +00:00
|
|
|
return GetShortNetName();
|
2013-09-25 19:09:57 +00:00
|
|
|
|
|
|
|
if( !m_netNameCandidate->IsLabelGlobal() )
|
|
|
|
{
|
|
|
|
// usual net name, prefix it by the sheet path
|
2013-09-29 18:24:38 +00:00
|
|
|
netName = m_netNameCandidate->m_SheetPath.PathHumanReadable();
|
2013-09-25 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
netName += m_netNameCandidate->m_Label;
|
|
|
|
|
|
|
|
return netName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* return the short net name of the item i.e. the net name
|
|
|
|
* from the "best" label without any prefix.
|
|
|
|
* 2 different nets can have the same short name
|
|
|
|
*/
|
2020-02-15 17:55:18 +00:00
|
|
|
wxString NETLIST_OBJECT::GetShortNetName() const
|
2013-09-25 19:09:57 +00:00
|
|
|
{
|
|
|
|
if( m_netNameCandidate == NULL )
|
|
|
|
return wxEmptyString;
|
|
|
|
|
|
|
|
wxString netName;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( m_netNameCandidate->m_Type == NETLIST_ITEM::PIN )
|
2013-09-25 19:09:57 +00:00
|
|
|
{
|
2013-09-30 06:36:40 +00:00
|
|
|
SCH_COMPONENT* link = m_netNameCandidate->GetComponentParent();
|
2013-09-27 17:58:58 +00:00
|
|
|
if( link ) // Should be always true
|
2013-09-25 19:09:57 +00:00
|
|
|
{
|
2013-10-14 16:03:38 +00:00
|
|
|
netName = wxT("Net-(");
|
2016-02-15 20:17:51 +00:00
|
|
|
netName << link->GetRef( &m_netNameCandidate->m_SheetPath );
|
2017-08-10 15:00:28 +00:00
|
|
|
netName << wxT("-Pad") << m_netNameCandidate->m_PinNum << wxT(")");
|
2013-09-25 19:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
netName = m_netNameCandidate->m_Label;
|
|
|
|
|
|
|
|
return netName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set m_netNameCandidate to a connected item which will
|
|
|
|
* be used to calcule the net name of the item
|
|
|
|
* Obviously the candidate can be only a label
|
2016-02-18 07:40:45 +00:00
|
|
|
* If there is no label on the net, a pad name will be
|
2013-09-25 19:09:57 +00:00
|
|
|
* used to build a net name (something like Cmp<REF>_Pad<PAD_NAME>
|
|
|
|
* @param aCandidate = the connected item candidate
|
|
|
|
*/
|
|
|
|
void NETLIST_OBJECT::SetNetNameCandidate( NETLIST_OBJECT* aCandidate )
|
|
|
|
{
|
|
|
|
switch( aCandidate->m_Type )
|
|
|
|
{
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::HIERLABEL:
|
|
|
|
case NETLIST_ITEM::LABEL:
|
|
|
|
case NETLIST_ITEM::PINLABEL:
|
|
|
|
case NETLIST_ITEM::GLOBLABEL:
|
|
|
|
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
|
|
|
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
|
|
|
case NETLIST_ITEM::PIN:
|
|
|
|
m_netNameCandidate = aCandidate;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2013-09-25 19:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-17 09:11:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
const wxString NETLIST_OBJECT::GetPinNameText() const
|
|
|
|
{
|
|
|
|
wxString name;
|
2020-01-18 20:51:28 +00:00
|
|
|
// returns the pin name, for NETLIST_ITEM::PIN (usual pin) item.
|
|
|
|
if( m_Type == NETLIST_ITEM::PIN )
|
2019-11-17 09:11:29 +00:00
|
|
|
{
|
|
|
|
name = static_cast<LIB_PIN*>( m_Comp )->GetName();
|
|
|
|
|
|
|
|
if( name == "~" ) //empty name
|
|
|
|
name = wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|