Fix connectivity regression

We have a break somewhere in the connectivity that doesn't fully process
connections but the current code seems to catch these by forcing a
top-down & bottom-up calculation

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14818
This commit is contained in:
Seth Hillbrand 2023-09-13 12:23:36 -07:00
parent 8db400500d
commit cb1231382f
5 changed files with 446 additions and 35 deletions

View File

@ -2200,47 +2200,93 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo
std::unordered_set<CONNECTION_SUBGRAPH*> visited;
std::unordered_set<SCH_CONNECTION*> stale_bus_members;
auto visit =
[&]( CONNECTION_SUBGRAPH* aParent )
auto visit =[&]( CONNECTION_SUBGRAPH* aParent )
{
for( SCH_SHEET_PIN* pin : aParent->m_hier_pins )
{
SCH_SHEET_PATH path = aParent->m_sheet;
path.push_back( pin->GetParent() );
auto it = m_sheet_to_subgraphs_map.find( path );
if( it == m_sheet_to_subgraphs_map.end() )
continue;
for( CONNECTION_SUBGRAPH* candidate : it->second )
{
for( SCH_SHEET_PIN* pin : aParent->m_hier_pins )
if( !candidate->m_strong_driver
|| candidate->m_hier_ports.empty()
|| visited.count( candidate ) )
{
SCH_SHEET_PATH path = aParent->m_sheet;
path.push_back( pin->GetParent() );
continue;
}
auto it = m_sheet_to_subgraphs_map.find( path );
if( it == m_sheet_to_subgraphs_map.end() )
continue;
for( CONNECTION_SUBGRAPH* candidate : it->second )
for( SCH_HIERLABEL* label : candidate->m_hier_ports )
{
if( candidate->GetNameForDriver( label ) == aParent->GetNameForDriver( pin ) )
{
if( !candidate->m_strong_driver
|| candidate->m_hier_ports.empty()
|| visited.count( candidate ) )
{
continue;
}
wxLogTrace( ConnTrace, wxS( "%lu: found child %lu (%s)" ), aParent->m_code,
candidate->m_code, candidate->m_driver_connection->Name() );
for( SCH_HIERLABEL* label : candidate->m_hier_ports )
{
if( candidate->GetNameForDriver( label ) == aParent->GetNameForDriver( pin ) )
{
wxLogTrace( ConnTrace, wxS( "%lu: found child %lu (%s)" ), aParent->m_code,
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 );
break;
}
}
search_list.push_back( candidate );
break;
}
}
};
}
}
auto propagate_bus_neighbors = [&]( CONNECTION_SUBGRAPH* aParentGraph ) {
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 )
{
for( const auto& kv : aParentGraph->m_bus_neighbors )
{
for( CONNECTION_SUBGRAPH* neighbor : kv.second )
@ -2358,9 +2404,8 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo
{
auto child = search_list[i];
visited.insert( child );
visit( child );
if( visited.insert( child ).second )
visit( child );
child->m_dirty = false;
}

View File

@ -0,0 +1,239 @@
(kicad_sch (version 20230121) (generator eeschema)
(uuid 11dcf1dc-4b8a-4487-8b76-ed0a16ad6b81)
(paper "A4")
(lib_symbols
(symbol "Connector:TestPoint" (pin_numbers hide) (pin_names (offset 0.762) hide) (in_bom yes) (on_board yes)
(property "Reference" "TP" (at 0 6.858 0)
(effects (font (size 1.27 1.27)))
)
(property "Value" "TestPoint" (at 0 5.08 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (at 5.08 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (at 5.08 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "test point tp" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "test point" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_fp_filters" "Pin* Test*" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "TestPoint_0_1"
(circle (center 0 3.302) (radius 0.762)
(stroke (width 0) (type default))
(fill (type none))
)
)
(symbol "TestPoint_1_1"
(pin passive line (at 0 0 90) (length 2.54)
(name "1" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
)
)
(symbol "power:GND" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes)
(property "Reference" "#PWR" (at 0 -6.35 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Value" "GND" (at 0 -3.81 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "global power" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "Power symbol creates a global label with name \"GND\" , ground" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "GND_0_1"
(polyline
(pts
(xy 0 0)
(xy 0 -1.27)
(xy 1.27 -1.27)
(xy 0 -2.54)
(xy -1.27 -1.27)
(xy 0 -1.27)
)
(stroke (width 0) (type default))
(fill (type none))
)
)
(symbol "GND_1_1"
(pin power_in line (at 0 0 270) (length 0) hide
(name "GND" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
)
)
)
(wire (pts (xy 85.09 77.47) (xy 96.52 77.47))
(stroke (width 0) (type default))
(uuid 05d48414-152f-43a1-85bc-957f34c4195b)
)
(wire (pts (xy 120.65 77.47) (xy 129.54 77.47))
(stroke (width 0) (type default))
(uuid 1c2c1f88-ead0-4a89-9983-b49ae2abcb2e)
)
(wire (pts (xy 163.83 77.47) (xy 163.83 82.55))
(stroke (width 0) (type default))
(uuid 33acfa37-d47d-4b28-8128-c01134bd3e85)
)
(wire (pts (xy 153.67 77.47) (xy 163.83 77.47))
(stroke (width 0) (type default))
(uuid 79f366fc-0142-4366-9c92-e5bbf2ddb85d)
)
(wire (pts (xy 52.07 73.66) (xy 52.07 77.47))
(stroke (width 0) (type default))
(uuid 7bde2af8-4923-4b3b-aae1-8d50aee3b44c)
)
(wire (pts (xy 60.96 77.47) (xy 52.07 77.47))
(stroke (width 0) (type default))
(uuid 7e6059c0-7d3a-4472-ac0a-8e90f65dee0c)
)
(symbol (lib_id "power:GND") (at 163.83 82.55 0) (unit 1)
(in_bom yes) (on_board yes) (dnp no) (fields_autoplaced)
(uuid 01911e18-8ac4-41c0-aab8-927296bbf562)
(property "Reference" "#PWR01" (at 163.83 88.9 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Value" "GND" (at 163.83 87.63 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (at 163.83 82.55 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (at 163.83 82.55 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid cfb4dbed-8d45-4890-9941-b3470214336c))
(instances
(project "issue14818"
(path "/11dcf1dc-4b8a-4487-8b76-ed0a16ad6b81"
(reference "#PWR01") (unit 1)
)
)
)
)
(symbol (lib_id "Connector:TestPoint") (at 52.07 73.66 0) (unit 1)
(in_bom yes) (on_board yes) (dnp no) (fields_autoplaced)
(uuid d6ec637f-094b-4766-99e5-8085aeaefe06)
(property "Reference" "TP1" (at 54.61 69.088 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "TestPoint" (at 54.61 71.628 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "" (at 57.15 73.66 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (at 57.15 73.66 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 8b46051e-0ee0-4b49-8c7c-662399dd6fb3))
(instances
(project "issue14818"
(path "/11dcf1dc-4b8a-4487-8b76-ed0a16ad6b81"
(reference "TP1") (unit 1)
)
)
)
)
(sheet (at 96.52 66.04) (size 24.13 22.86) (fields_autoplaced)
(stroke (width 0.1524) (type solid))
(fill (color 0 0 0 0.0000))
(uuid 5d032182-2307-426c-884a-f7857d5edd6d)
(property "Sheetname" "Sub2" (at 96.52 65.3284 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
)
(property "Sheetfile" "issue14818_sub.kicad_sch" (at 96.52 89.4846 0)
(effects (font (size 1.27 1.27)) (justify left top))
)
(pin "in" input (at 96.52 77.47 180)
(effects (font (size 1.27 1.27)) (justify left))
(uuid dea890b4-297b-4928-b630-a4d763d7d1b5)
)
(pin "out" input (at 120.65 77.47 0)
(effects (font (size 1.27 1.27)) (justify right))
(uuid 260d614f-e46d-45e0-8b30-4e325bafa902)
)
(instances
(project "issue14818"
(path "/11dcf1dc-4b8a-4487-8b76-ed0a16ad6b81" (page "3"))
)
)
)
(sheet (at 60.96 66.04) (size 24.13 22.86) (fields_autoplaced)
(stroke (width 0.1524) (type solid))
(fill (color 0 0 0 0.0000))
(uuid 6d698a38-2711-45a8-832d-31c10d1f3612)
(property "Sheetname" "Sub1" (at 60.96 65.3284 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
)
(property "Sheetfile" "issue14818_sub.kicad_sch" (at 60.96 89.4846 0)
(effects (font (size 1.27 1.27)) (justify left top))
)
(pin "in" input (at 60.96 77.47 180)
(effects (font (size 1.27 1.27)) (justify left))
(uuid 57c5a46a-7c01-4c5e-9177-f37ae4dc9b79)
)
(pin "out" input (at 85.09 77.47 0)
(effects (font (size 1.27 1.27)) (justify right))
(uuid 7838d527-1f3d-417e-9ace-85d9c9915519)
)
(instances
(project "issue14818"
(path "/11dcf1dc-4b8a-4487-8b76-ed0a16ad6b81" (page "2"))
)
)
)
(sheet (at 129.54 66.04) (size 24.13 22.86) (fields_autoplaced)
(stroke (width 0.1524) (type solid))
(fill (color 0 0 0 0.0000))
(uuid 885941f0-70fc-427a-93dc-14e6b4cfc471)
(property "Sheetname" "Sub3" (at 129.54 65.3284 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
)
(property "Sheetfile" "issue14818_sub.kicad_sch" (at 129.54 89.4846 0)
(effects (font (size 1.27 1.27)) (justify left top))
)
(pin "in" input (at 129.54 77.47 180)
(effects (font (size 1.27 1.27)) (justify left))
(uuid 5a6a4586-709f-4f59-a57f-14be30bd50f3)
)
(pin "out" input (at 153.67 77.47 0)
(effects (font (size 1.27 1.27)) (justify right))
(uuid a38e47d0-9e22-4eff-b63c-261086027da8)
)
(instances
(project "issue14818"
(path "/11dcf1dc-4b8a-4487-8b76-ed0a16ad6b81" (page "4"))
)
)
)
(sheet_instances
(path "/" (page "1"))
)
)

View File

@ -0,0 +1,98 @@
(export (version "E")
(design
(source "/home/seth/code/kicad/kicad-v7/qa/data/eeschema/netlists/issue14818/issue14818.kicad_sch")
(date "Wed 13 Sep 2023 10:28:36 AM PDT")
(tool "Eeschema 7.0.7-115-g658e127951-dirty")
(sheet (number "1") (name "/") (tstamps "/")
(title_block
(title)
(company)
(rev)
(date)
(source "issue14818.kicad_sch")
(comment (number "1") (value ""))
(comment (number "2") (value ""))
(comment (number "3") (value ""))
(comment (number "4") (value ""))
(comment (number "5") (value ""))
(comment (number "6") (value ""))
(comment (number "7") (value ""))
(comment (number "8") (value ""))
(comment (number "9") (value ""))))
(sheet (number "2") (name "/Sub1/") (tstamps "/6d698a38-2711-45a8-832d-31c10d1f3612/")
(title_block
(title)
(company)
(rev)
(date)
(source "issue14818_sub.kicad_sch")
(comment (number "1") (value ""))
(comment (number "2") (value ""))
(comment (number "3") (value ""))
(comment (number "4") (value ""))
(comment (number "5") (value ""))
(comment (number "6") (value ""))
(comment (number "7") (value ""))
(comment (number "8") (value ""))
(comment (number "9") (value ""))))
(sheet (number "3") (name "/Sub2/") (tstamps "/5d032182-2307-426c-884a-f7857d5edd6d/")
(title_block
(title)
(company)
(rev)
(date)
(source "issue14818_sub.kicad_sch")
(comment (number "1") (value ""))
(comment (number "2") (value ""))
(comment (number "3") (value ""))
(comment (number "4") (value ""))
(comment (number "5") (value ""))
(comment (number "6") (value ""))
(comment (number "7") (value ""))
(comment (number "8") (value ""))
(comment (number "9") (value ""))))
(sheet (number "4") (name "/Sub3/") (tstamps "/885941f0-70fc-427a-93dc-14e6b4cfc471/")
(title_block
(title)
(company)
(rev)
(date)
(source "issue14818_sub.kicad_sch")
(comment (number "1") (value ""))
(comment (number "2") (value ""))
(comment (number "3") (value ""))
(comment (number "4") (value ""))
(comment (number "5") (value ""))
(comment (number "6") (value ""))
(comment (number "7") (value ""))
(comment (number "8") (value ""))
(comment (number "9") (value "")))))
(components
(comp (ref "TP1")
(value "TestPoint")
(libsource (lib "Connector") (part "TestPoint") (description "test point"))
(property (name "Sheetname") (value ""))
(property (name "Sheetfile") (value "issue14818.kicad_sch"))
(property (name "ki_description") (value "test point"))
(property (name "ki_keywords") (value "test point tp"))
(sheetpath (names "/") (tstamps "/"))
(tstamps "d6ec637f-094b-4766-99e5-8085aeaefe06")))
(libparts
(libpart (lib "Connector") (part "TestPoint")
(description "test point")
(docs "~")
(footprints
(fp "Pin*")
(fp "Test*"))
(fields
(field (name "Reference") "TP")
(field (name "Value") "TestPoint")
(field (name "Datasheet") "~"))
(pins
(pin (num "1") (name "1") (type "passive")))))
(libraries
(library (logical "Connector")
(uri "/usr/local/share/kicad/symbols//Connector.kicad_sym")))
(nets
(net (code "1") (name "GND")
(node (ref "TP1") (pin "1") (pinfunction "1") (pintype "passive")))))

View File

@ -0,0 +1,24 @@
(kicad_sch (version 20230121) (generator eeschema)
(uuid db368772-2162-4af0-812f-02d65127f34b)
(paper "A4")
(lib_symbols
)
(wire (pts (xy 77.47 82.55) (xy 88.9 82.55))
(stroke (width 0) (type default))
(uuid af3971fe-9d70-4180-aec7-06849506172b)
)
(hierarchical_label "out" (shape input) (at 88.9 82.55 0) (fields_autoplaced)
(effects (font (size 1.27 1.27)) (justify left))
(uuid 6b540c7f-cd51-4ae0-9753-e62094939d20)
)
(hierarchical_label "in" (shape input) (at 77.47 82.55 180) (fields_autoplaced)
(effects (font (size 1.27 1.27)) (justify right))
(uuid fbac9619-48e4-4bb4-ae58-b737c341dfb7)
)
)

View File

@ -194,5 +194,10 @@ BOOST_AUTO_TEST_CASE( HierarchyAliases )
TestNetlist( "hierarchy_aliases" );
}
BOOST_AUTO_TEST_CASE( Issue14818 )
{
TestNetlist( "issue14818" );
}
BOOST_AUTO_TEST_SUITE_END()