Connectivity: just pick the most popular net to update conflicting clusters

CHANGED: when pad net assignments are changed in a conflicting way (i.e.,
         tracks exist that short out more than one net after the change,
         track nets will be updated to the net with the most pads).

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7929
This commit is contained in:
Jon Evans 2021-03-21 15:31:15 -04:00
parent 6997fec14f
commit 37242f67e0
3 changed files with 38 additions and 18 deletions

View File

@ -481,17 +481,19 @@ void CN_CONNECTIVITY_ALGO::propagateConnections( BOARD_COMMIT* aCommit )
{
for( const auto& cluster : m_connClusters )
{
if( cluster->IsConflicting() )
if( cluster->IsOrphaned() )
{
wxLogTrace( "CN", "Conflicting nets in cluster %p\n", cluster.get() );
}
else if( cluster->IsOrphaned() )
{
wxLogTrace( "CN", "Skipping orphaned cluster %p [net: %s]\n", cluster.get(),
wxLogTrace( "CN", "Skipping orphaned cluster %p [net: %s]", cluster.get(),
(const char*) cluster->OriginNetName().c_str() );
}
else if( cluster->HasValidNet() )
{
if( cluster->IsConflicting() )
{
wxLogTrace( "CN", "Conflicting nets in cluster %p; chose %d (%s)", cluster.get(),
cluster->OriginNet(), cluster->OriginNetName() );
}
// normal cluster: just propagate from the pads
int n_changed = 0;
@ -515,15 +517,15 @@ void CN_CONNECTIVITY_ALGO::propagateConnections( BOARD_COMMIT* aCommit )
if( n_changed )
{
wxLogTrace( "CN", "Cluster %p : net : %d %s\n", cluster.get(),
wxLogTrace( "CN", "Cluster %p : net : %d %s", cluster.get(),
cluster->OriginNet(), (const char*) cluster->OriginNetName().c_str() );
}
else
wxLogTrace( "CN", "Cluster %p : nothing to propagate\n", cluster.get() );
wxLogTrace( "CN", "Cluster %p : nothing to propagate", cluster.get() );
}
else
{
wxLogTrace( "CN", "Cluster %p : connected to unused net\n", cluster.get() );
wxLogTrace( "CN", "Cluster %p : connected to unused net", cluster.get() );
}
}
}

View File

@ -472,20 +472,37 @@ void CN_CLUSTER::Add( CN_ITEM* item )
{
m_items.push_back( item );
if( item->Net() <= 0 )
int netCode = item->Net();
if( netCode <= 0 )
return;
if( m_originNet <= 0 )
{
m_originNet = item->Net();
m_originNet = netCode;
}
if( item->Parent()->Type() == PCB_PAD_T )
{
if( !m_originPad )
if( m_netRanks.count( netCode ) )
{
m_originPad = item;
m_originNet = item->Net();
m_netRanks[netCode]++;
if( m_netRanks.count( m_originNet ) && m_netRanks[netCode] > m_netRanks[m_originNet] )
{
m_originPad = item;
m_originNet = netCode;
}
}
else
{
m_netRanks[netCode] = 1;
if( !m_originPad )
{
m_originPad = item;
m_originNet = netCode;
}
}
if( m_originPad && item->Net() != m_originNet )

View File

@ -451,10 +451,11 @@ private:
class CN_CLUSTER
{
private:
bool m_conflicting;
int m_originNet;
CN_ITEM* m_originPad;
std::vector<CN_ITEM*> m_items;
bool m_conflicting;
int m_originNet;
CN_ITEM* m_originPad;
std::vector<CN_ITEM*> m_items;
std::unordered_map<int, int> m_netRanks;
public:
CN_CLUSTER();