Bug Fixes for new incremental connectivity

- Ensure that critical paths (ERC/netlister) are fully-rechecked
- Handle symbol/pin distinction in change markers
- Fully connect hierarchical pins in one pass descending

(cherry picked from commit 6e8a5acc66)
This commit is contained in:
Seth Hillbrand 2023-04-21 13:25:01 -07:00
parent 683abd2029
commit 050f47daf1
5 changed files with 56 additions and 84 deletions

View File

@ -404,11 +404,21 @@ void CONNECTION_SUBGRAPH::Absorb( CONNECTION_SUBGRAPH* aOther )
m_multiple_drivers |= aOther->m_multiple_drivers; m_multiple_drivers |= aOther->m_multiple_drivers;
std::function<void( CONNECTION_SUBGRAPH* )> set_absorbed_by =
[ & ]( CONNECTION_SUBGRAPH *child )
{
child->m_absorbed_by = this;
for( CONNECTION_SUBGRAPH* subchild : child->m_absorbed_subgraphs )
set_absorbed_by( subchild );
};
aOther->m_absorbed = true; aOther->m_absorbed = true;
aOther->m_dirty = false; aOther->m_dirty = false;
aOther->m_driver = nullptr; aOther->m_driver = nullptr;
aOther->m_driver_connection = nullptr; aOther->m_driver_connection = nullptr;
aOther->m_absorbed_by = this;
set_absorbed_by( aOther );
} }
@ -497,47 +507,33 @@ void CONNECTION_GRAPH::Merge( CONNECTION_GRAPH& aGraph )
aGraph.m_driver_subgraphs.end(), aGraph.m_driver_subgraphs.end(),
std::back_inserter( m_driver_subgraphs ) ); std::back_inserter( m_driver_subgraphs ) );
std::copy( aGraph.m_sheet_to_subgraphs_map.begin(),
aGraph.m_sheet_to_subgraphs_map.end(),
std::inserter( m_sheet_to_subgraphs_map,
m_sheet_to_subgraphs_map.begin() ) );
std::copy( aGraph.m_invisible_power_pins.begin(), std::copy( aGraph.m_invisible_power_pins.begin(),
aGraph.m_invisible_power_pins.end(), aGraph.m_invisible_power_pins.end(),
std::back_inserter( m_invisible_power_pins ) ); std::back_inserter( m_invisible_power_pins ) );
std::copy( aGraph.m_net_name_to_code_map.begin(), for( auto& [key, value] : aGraph.m_net_name_to_subgraphs_map )
aGraph.m_net_name_to_code_map.end(), m_net_name_to_subgraphs_map.insert_or_assign( key, value );
std::inserter( m_net_name_to_code_map,
m_net_name_to_code_map.begin() ) );
std::copy( aGraph.m_bus_name_to_code_map.begin(), for( auto& [key, value] : aGraph.m_sheet_to_subgraphs_map )
aGraph.m_bus_name_to_code_map.end(), m_sheet_to_subgraphs_map.insert_or_assign( key, value );
std::inserter( m_bus_name_to_code_map,
m_net_name_to_code_map.begin() ) );
std::copy( aGraph.m_net_code_to_subgraphs_map.begin(), for( auto& [key, value] : aGraph.m_net_name_to_code_map )
aGraph.m_net_code_to_subgraphs_map.end(), m_net_name_to_code_map.insert_or_assign( key, value );
std::inserter( m_net_code_to_subgraphs_map,
m_net_code_to_subgraphs_map.begin() ) );
std::copy( aGraph.m_net_name_to_subgraphs_map.begin(), for( auto& [key, value] : aGraph.m_bus_name_to_code_map )
aGraph.m_net_name_to_subgraphs_map.end(), m_bus_name_to_code_map.insert_or_assign( key, value );
std::inserter( m_net_name_to_subgraphs_map,
m_net_name_to_subgraphs_map.begin() ) );
std::copy( aGraph.m_item_to_subgraph_map.begin(), for( auto& [key, value] : aGraph.m_net_code_to_subgraphs_map )
aGraph.m_item_to_subgraph_map.end(), m_net_code_to_subgraphs_map.insert_or_assign( key, value );
std::inserter( m_item_to_subgraph_map,
m_item_to_subgraph_map.begin() ) );
std::copy( aGraph.m_local_label_cache.begin(), for( auto& [key, value] : aGraph.m_item_to_subgraph_map )
aGraph.m_local_label_cache.end(), m_item_to_subgraph_map.insert_or_assign( key, value );
std::inserter( m_local_label_cache, m_local_label_cache.begin() ) );
std::copy( aGraph.m_global_label_cache.begin(), for( auto& [key, value] : aGraph.m_local_label_cache )
aGraph.m_global_label_cache.end(), m_local_label_cache.insert_or_assign( key, value );
std::inserter( m_global_label_cache, m_global_label_cache.begin() ) );
for( auto& [key, value] : aGraph.m_global_label_cache )
m_global_label_cache.insert_or_assign( key, value );
m_last_bus_code = std::max( m_last_bus_code, aGraph.m_last_bus_code ); m_last_bus_code = std::max( m_last_bus_code, aGraph.m_last_bus_code );
m_last_net_code = std::max( m_last_net_code, aGraph.m_last_net_code ); m_last_net_code = std::max( m_last_net_code, aGraph.m_last_net_code );
@ -686,6 +682,8 @@ std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> CONNECTION_GRAPH::ExtractAffected
for( CONNECTION_SUBGRAPH* bus_sg : bus_it.second ) for( CONNECTION_SUBGRAPH* bus_sg : bus_it.second )
traverse_subgraph( bus_sg ); traverse_subgraph( bus_sg );
} }
alg::delete_matching( m_items, item );
} }
removeSubgraphs( subgraphs ); removeSubgraphs( subgraphs );
@ -2167,60 +2165,15 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo
candidate->m_code, candidate->m_driver_connection->Name() ); candidate->m_code, candidate->m_driver_connection->Name() );
candidate->m_hier_parent = aParent; candidate->m_hier_parent = aParent;
aParent->m_hier_children.insert( candidate );
search_list.push_back( candidate ); search_list.push_back( candidate );
break; break;
} }
} }
} }
} }
};
for( SCH_HIERLABEL* label : aParent->m_hier_ports )
{
SCH_SHEET_PATH path = aParent->m_sheet;
path.pop_back();
auto it = m_sheet_to_subgraphs_map.find( path );
if( it == m_sheet_to_subgraphs_map.end() )
continue;
for( CONNECTION_SUBGRAPH* candidate : it->second )
{
if( candidate->m_hier_pins.empty()
|| visited.count( candidate )
|| candidate->m_driver_connection->Type() != aParent->m_driver_connection->Type() )
{
continue;
}
const KIID& last_parent_uuid = aParent->m_sheet.Last()->m_Uuid;
for( SCH_SHEET_PIN* pin : candidate->m_hier_pins )
{
// If the last sheet UUIDs won't match, no need to check the full path
if( pin->GetParent()->m_Uuid != last_parent_uuid )
continue;
SCH_SHEET_PATH pin_path = path;
pin_path.push_back( pin->GetParent() );
if( pin_path != aParent->m_sheet )
continue;
if( aParent->GetNameForDriver( label ) == candidate->GetNameForDriver( pin ) )
{
wxLogTrace( ConnTrace, wxS( "%lu: found additional parent %lu (%s)" ),
aParent->m_code, candidate->m_code,
candidate->m_driver_connection->Name() );
aParent->m_hier_children.insert( candidate );
search_list.push_back( candidate );
break;
}
}
}
}
};
auto propagate_bus_neighbors = [&]( CONNECTION_SUBGRAPH* aParentGraph ) { auto propagate_bus_neighbors = [&]( CONNECTION_SUBGRAPH* aParentGraph ) {
for( const auto& kv : aParentGraph->m_bus_neighbors ) for( const auto& kv : aParentGraph->m_bus_neighbors )

View File

@ -883,6 +883,9 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
return; return;
} }
if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
RecalculateConnections( GLOBAL_CLEANUP );
NETLIST_EXPORTER_KICAD exporter( &Schematic() ); NETLIST_EXPORTER_KICAD exporter( &Schematic() );
STRING_FORMATTER formatter; STRING_FORMATTER formatter;

View File

@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <advanced_config.h>
#include <gestfich.h> #include <gestfich.h>
#include <sch_screen.h> #include <sch_screen.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
@ -460,9 +461,6 @@ void DIALOG_ERC::testErc()
SCHEMATIC* sch = &m_parent->Schematic(); SCHEMATIC* sch = &m_parent->Schematic();
// Build the whole sheet list in hierarchy (sheet, not screen)
sch->GetSheets().AnnotatePowerSymbols();
SCH_SCREENS screens( sch->Root() ); SCH_SCREENS screens( sch->Root() );
ERC_SETTINGS& settings = sch->ErcSettings(); ERC_SETTINGS& settings = sch->ErcSettings();
ERC_TESTER tester( sch ); ERC_TESTER tester( sch );
@ -483,7 +481,13 @@ void DIALOG_ERC::testErc()
// The connection graph has a whole set of ERC checks it can run // The connection graph has a whole set of ERC checks it can run
AdvancePhase( _( "Checking conflicts..." ) ); AdvancePhase( _( "Checking conflicts..." ) );
m_parent->RecalculateConnections( NO_CLEANUP );
// If we are using the new connectivity, make sure that we do a full-rebuild
if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
m_parent->RecalculateConnections( GLOBAL_CLEANUP );
else
m_parent->RecalculateConnections( NO_CLEANUP );
sch->ConnectionGraph()->RunERC(); sch->ConnectionGraph()->RunERC();
AdvancePhase( _( "Checking units..." ) ); AdvancePhase( _( "Checking units..." ) );

View File

@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <advanced_config.h>
#include <common.h> // for ProcessExecute #include <common.h> // for ProcessExecute
#include <string_utils.h> #include <string_utils.h>
#include <gestfich.h> #include <gestfich.h>
@ -52,6 +53,10 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
if( !ReadyToNetlist( _( "Exporting netlist requires a fully annotated schematic." ) ) ) if( !ReadyToNetlist( _( "Exporting netlist requires a fully annotated schematic." ) ) )
return false; return false;
// If we are using the new connectivity, make sure that we do a full-rebuild
if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
RecalculateConnections( GLOBAL_CLEANUP );
bool res = true; bool res = true;
bool executeCommandLine = false; bool executeCommandLine = false;

View File

@ -1515,6 +1515,13 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags )
} }
} }
if( SCH_SYMBOL* sym = dyn_cast<SCH_SYMBOL*>( item ) )
{
std::vector<SCH_PIN*> pins = sym->GetPins();
changed_items.insert( pins.begin(), pins.end() );
continue;
}
if( item->IsConnected( pt ) ) if( item->IsConnected( pt ) )
changed_items.insert( item ); changed_items.insert( item );
} }