Fix hierarchical propagation for designs with unmatched hier ports

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8397
This commit is contained in:
Jon Evans 2021-05-10 17:54:09 -04:00
parent 7356f9568d
commit 55c1d814f9
7 changed files with 708 additions and 11 deletions

View File

@ -1365,6 +1365,9 @@ void CONNECTION_GRAPH::buildConnectionGraph()
if( !subgraph->m_dirty )
continue;
wxLogTrace( ConnTrace, "Processing %lu (%s) for propagation", subgraph->m_code,
subgraph->m_driver_connection->Name() );
// For subgraphs that are driven by a global (power port or label) and have more
// than one global driver, we need to seek out other subgraphs driven by the
// same name as the non-chosen driver and update them to match the chosen one.
@ -1423,6 +1426,9 @@ void CONNECTION_GRAPH::buildConnectionGraph()
for( CONNECTION_SUBGRAPH* subgraph : m_driver_subgraphs )
{
// All SGs should have been processed by propagateToNeighbors above
wxASSERT_MSG( !subgraph->m_dirty, "Subgraph not processed by propagateToNeighbors!" );
if( subgraph->m_bus_parents.size() < 2 )
continue;
@ -1789,21 +1795,22 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph )
if( conn->IsBus() )
propagate_bus_neighbors( aSubgraph );
// If we don't have any hier pins (i.e. no children), nothing to do
if( aSubgraph->m_hier_pins.empty() )
// If we have both ports and pins, skip processing as we'll be visited by a parent or child.
// If we only have one or the other, process (we can either go bottom-up or top-down depending
// on which subgraph comes up first)
if( !aSubgraph->m_hier_ports.empty() && !aSubgraph->m_hier_pins.empty() )
{
// If we also don't have any parents, we'll never be visited again
if( aSubgraph->m_hier_ports.empty() )
aSubgraph->m_dirty = false;
wxLogTrace( ConnTrace, "%lu (%s) has both hier ports and pins; deferring processing",
aSubgraph->m_code, conn->Name() );
return;
}
// If we do have hier ports, skip this subgraph as it will be visited by a parent
// TODO(JE) this will leave the subgraph dirty if there is no matching parent subgraph,
// which should be flagged as an ERC error
if( !aSubgraph->m_hier_ports.empty() )
else if( aSubgraph->m_hier_ports.empty() && aSubgraph->m_hier_pins.empty() )
{
wxLogTrace( ConnTrace, "%lu (%s) has no hier pins or ports; marking clean",
aSubgraph->m_code, conn->Name() );
aSubgraph->m_dirty = false;
return;
}
visited.insert( aSubgraph );

View File

@ -0,0 +1,48 @@
(kicad_sch (version 20210406) (generator eeschema)
(uuid 60c507a6-849f-4288-aba3-1905085b3f33)
(paper "A4")
(lib_symbols
)
(wire (pts (xy 127 88.9) (xy 139.7 88.9))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid 9f6e294c-594e-482a-bd29-59ac27289816)
)
(wire (pts (xy 203.2 88.9) (xy 190.5 88.9))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid bc9dbfdf-a984-42b8-a104-88448653a38c)
)
(hierarchical_label "SUB_INPUT" (shape input) (at 127 88.9 180)
(effects (font (size 1.27 1.27)) (justify right))
(uuid 68cc449a-24e7-4f61-9ffd-00b79f144118)
)
(hierarchical_label "SUB_OUTPUT" (shape output) (at 203.2 88.9 0)
(effects (font (size 1.27 1.27)) (justify left))
(uuid 64241e40-ccc2-4fea-8000-ffa243d18897)
)
(sheet (at 139.7 83.82) (size 50.8 10.16) (fields_autoplaced)
(stroke (width 0.0006) (type solid) (color 132 0 132 1))
(fill (color 255 255 255 0.0000))
(uuid d1e0bb44-07da-4574-92bf-3f9adc5e8751)
(property "Sheet name" "SubSubSheet" (id 0) (at 139.7 83.1843 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
)
(property "Sheet file" "subsubsheet.kicad_sch" (id 1) (at 139.7 94.4887 0)
(effects (font (size 1.27 1.27)) (justify left top))
)
(pin "SUBSUB_INPUT" input (at 139.7 88.9 180)
(effects (font (size 1.27 1.27)) (justify left))
(uuid 277a9f08-8815-4eb8-ba55-98f7eada92e5)
)
(pin "SUBSUB_OUTPUT" output (at 190.5 88.9 0)
(effects (font (size 1.27 1.27)) (justify right))
(uuid 611a4915-5afb-43f4-9ba3-5566f00e70ad)
)
)
)

View File

@ -0,0 +1,183 @@
(kicad_sch (version 20210406) (generator eeschema)
(uuid f1a8eb6a-461a-416e-b9ae-152bd21b2079)
(paper "A4")
(lib_symbols
(symbol "Device:R" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes)
(property "Reference" "R" (id 0) (at 2.032 0 90)
(effects (font (size 1.27 1.27)))
)
(property "Value" "R" (id 1) (at 0 0 90)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (id 2) (at -1.778 0 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "R res resistor" (id 4) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "Resistor" (id 5) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_fp_filters" "R_*" (id 6) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "R_0_1"
(rectangle (start -1.016 -2.54) (end 1.016 2.54)
(stroke (width 0.254)) (fill (type none))
)
)
(symbol "R_1_1"
(pin passive line (at 0 3.81 270) (length 1.27)
(name "~" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
(pin passive line (at 0 -3.81 90) (length 1.27)
(name "~" (effects (font (size 1.27 1.27))))
(number "2" (effects (font (size 1.27 1.27))))
)
)
)
(symbol "power:GND" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes)
(property "Reference" "#PWR" (id 0) (at 0 -6.35 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Value" "GND" (id 1) (at 0 -3.81 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (id 2) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "power-flag" (id 4) (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" (id 5) (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)) (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 127 88.9) (xy 132.08 88.9))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid aaaabe47-b7a6-4e66-92dc-696ff3ae62ce)
)
(wire (pts (xy 139.7 88.9) (xy 143.51 88.9))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid 7cd130fb-b637-4ed5-853c-146668691e13)
)
(wire (pts (xy 143.51 88.9) (xy 143.51 92.71))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid 7cd130fb-b637-4ed5-853c-146668691e13)
)
(wire (pts (xy 165.1 88.9) (xy 165.1 92.71))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid ebf21746-5a3f-45ac-bba8-bddd7adf4f4b)
)
(wire (pts (xy 168.91 88.9) (xy 165.1 88.9))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid 75ed1c8c-82f8-4094-b416-a19276508d2a)
)
(wire (pts (xy 181.61 88.9) (xy 176.53 88.9))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid a765ff7f-ced9-4aa9-b8ba-8448c3e1974c)
)
(hierarchical_label "SUBSUB_INPUT" (shape input) (at 127 88.9 180)
(effects (font (size 1.27 1.27)) (justify right))
(uuid 3d0f6256-cfd4-480d-91be-ab31f51a22ad)
)
(hierarchical_label "SUBSUB_OUTPUT" (shape output) (at 181.61 88.9 0)
(effects (font (size 1.27 1.27)) (justify left))
(uuid d69d78d7-eabd-46e1-a003-ce4aba0f199f)
)
(symbol (lib_id "power:GND") (at 143.51 92.71 0) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 285c0e97-7e2b-456e-b955-a3bac708cdc4)
(property "Reference" "#PWR?" (id 0) (at 143.51 99.06 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Value" "GND" (id 1) (at 143.51 97.79 0))
(property "Footprint" "" (id 2) (at 143.51 92.71 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 143.51 92.71 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid f78a2fc8-2d45-4b4d-abf1-6aed599cfda9))
)
(symbol (lib_id "power:GND") (at 165.1 92.71 0) (mirror y) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 5d60735e-17ab-412e-acd7-0b8752e14c64)
(property "Reference" "#PWR?" (id 0) (at 165.1 99.06 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Value" "GND" (id 1) (at 165.1 97.79 0))
(property "Footprint" "" (id 2) (at 165.1 92.71 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 165.1 92.71 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 2022cf98-e7c5-49a7-8c62-9369c3dca5d6))
)
(symbol (lib_id "Device:R") (at 135.89 88.9 90) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid d21dccc4-3b84-4309-8a03-49ef532d46d9)
(property "Reference" "R1" (id 0) (at 135.89 83.82 90))
(property "Value" "R" (id 1) (at 135.89 86.36 90))
(property "Footprint" "" (id 2) (at 135.89 90.678 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 135.89 88.9 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 367d77aa-21bf-4c2b-b34c-df83c840559a))
(pin "2" (uuid 4ca566eb-83dd-49e7-ab2f-f85f369b9947))
)
(symbol (lib_id "Device:R") (at 172.72 88.9 270) (mirror x) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 34621417-dac8-4a11-b54c-b5b5c180b754)
(property "Reference" "R2" (id 0) (at 172.72 83.82 90))
(property "Value" "R" (id 1) (at 172.72 86.36 90))
(property "Footprint" "" (id 2) (at 172.72 90.678 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 172.72 88.9 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid f0c5b7f5-6b9c-4936-8214-109b91f2fb67))
(pin "2" (uuid 266446ce-0adb-49fd-bb84-a5b23d2877c5))
)
)

View File

@ -0,0 +1,302 @@
{
"board": {
"layer_presets": []
},
"boards": [],
"cvpcb": {
"equivalence_files": []
},
"erc": {
"erc_exclusions": [],
"meta": {
"version": 0
},
"pin_map": [
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
2
],
[
0,
1,
0,
0,
0,
0,
1,
1,
2,
1,
1,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2
],
[
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
2
],
[
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
1,
2,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
0,
2,
1,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
],
"rule_severities": {
"bus_definition_conflict": "error",
"bus_label_syntax": "error",
"bus_to_bus_conflict": "error",
"bus_to_net_conflict": "error",
"different_unit_footprint": "error",
"different_unit_net": "error",
"duplicate_reference": "error",
"duplicate_sheet_names": "error",
"extra_units": "error",
"global_label_dangling": "warning",
"hier_label_mismatch": "error",
"label_dangling": "error",
"lib_symbol_issues": "warning",
"multiple_net_names": "warning",
"net_not_bus_member": "warning",
"no_connect_connected": "warning",
"no_connect_dangling": "warning",
"pin_not_connected": "error",
"pin_not_driven": "error",
"pin_to_pin": "warning",
"power_pin_not_driven": "error",
"similar_labels": "warning",
"unannotated": "error",
"unit_value_mismatch": "error",
"unresolved_variable": "error",
"wire_dangling": "error"
}
},
"libraries": {
"pinned_footprint_libs": [],
"pinned_symbol_libs": []
},
"meta": {
"filename": "8397_testcase.kicad_pro",
"version": 1
},
"net_settings": {
"classes": [
{
"bus_width": 12.0,
"clearance": 0.2,
"diff_pair_gap": 0.25,
"diff_pair_via_gap": 0.25,
"diff_pair_width": 0.2,
"line_style": 0,
"microvia_diameter": 0.3,
"microvia_drill": 0.1,
"name": "Default",
"pcb_color": "rgba(0, 0, 0, 0.000)",
"schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.25,
"via_diameter": 0.8,
"via_drill": 0.4,
"wire_width": 6.0
}
],
"meta": {
"version": 0
},
"net_colors": null
},
"pcbnew": {
"last_paths": {
"gencad": "",
"idf": "",
"netlist": "",
"specctra_dsn": "",
"step": "",
"vrml": ""
},
"page_layout_descr_file": ""
},
"schematic": {
"drawing": {
"default_bus_thickness": 12.0,
"default_junction_size": 40.0,
"default_line_thickness": 6.0,
"default_text_size": 50.0,
"default_wire_thickness": 6.0,
"field_names": [],
"intersheets_ref_own_page": false,
"intersheets_ref_prefix": "",
"intersheets_ref_short": false,
"intersheets_ref_show": false,
"intersheets_ref_suffix": "",
"junction_size_choice": 3,
"pin_symbol_size": 25.0,
"text_offset_ratio": 0.3
},
"legacy_lib_dir": "",
"legacy_lib_list": [],
"meta": {
"version": 0
},
"net_format_name": "KiCad",
"page_layout_descr_file": "",
"plot_directory": "",
"spice_adjust_passive_values": false,
"spice_external_command": "spice \"%I\"",
"subpart_first_id": 65,
"subpart_id_separator": 0
},
"sheets": [
[
"e602c70f-05a6-4a8d-b379-8e76c2586249",
""
],
[
"8b055b93-d115-4991-b853-dd747f0957ab",
"Subsheet1"
],
[
"d1e0bb44-07da-4574-92bf-3f9adc5e8751",
"SubSubSheet"
]
],
"text_variables": {}
}

View File

@ -0,0 +1,57 @@
(kicad_sch (version 20210406) (generator eeschema)
(uuid e602c70f-05a6-4a8d-b379-8e76c2586249)
(paper "A4")
(lib_symbols
)
(wire (pts (xy 139.7 76.2) (xy 152.4 76.2))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid 3074abfa-705b-40de-ba99-d14b5df48b71)
)
(hierarchical_label "INPUT" (shape input) (at 139.7 76.2 180)
(effects (font (size 1.27 1.27)) (justify right))
(uuid a4939eee-f4b6-4417-bfab-880e11b1d9c3)
)
(sheet (at 152.4 71.12) (size 25.4 10.16) (fields_autoplaced)
(stroke (width 0.0006) (type solid) (color 132 0 132 1))
(fill (color 255 255 255 0.0000))
(uuid 8b055b93-d115-4991-b853-dd747f0957ab)
(property "Sheet name" "Subsheet1" (id 0) (at 152.4 70.4843 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
)
(property "Sheet file" "subsheet.kicad_sch" (id 1) (at 152.4 81.7887 0)
(effects (font (size 1.27 1.27)) (justify left top))
)
(pin "SUB_INPUT" input (at 152.4 76.2 180)
(effects (font (size 1.27 1.27)) (justify left))
(uuid dbd0b769-7796-46eb-9458-f9c7cb70597c)
)
)
(sheet_instances
(path "/" (page "1"))
(path "/8b055b93-d115-4991-b853-dd747f0957ab" (page "2"))
(path "/8b055b93-d115-4991-b853-dd747f0957ab/d1e0bb44-07da-4574-92bf-3f9adc5e8751" (page "3"))
)
(symbol_instances
(path "/8b055b93-d115-4991-b853-dd747f0957ab/d1e0bb44-07da-4574-92bf-3f9adc5e8751/285c0e97-7e2b-456e-b955-a3bac708cdc4"
(reference "#PWR?") (unit 1) (value "GND") (footprint "")
)
(path "/8b055b93-d115-4991-b853-dd747f0957ab/d1e0bb44-07da-4574-92bf-3f9adc5e8751/5d60735e-17ab-412e-acd7-0b8752e14c64"
(reference "#PWR?") (unit 1) (value "GND") (footprint "")
)
(path "/8b055b93-d115-4991-b853-dd747f0957ab/d1e0bb44-07da-4574-92bf-3f9adc5e8751/d21dccc4-3b84-4309-8a03-49ef532d46d9"
(reference "R1") (unit 1) (value "R") (footprint "")
)
(path "/8b055b93-d115-4991-b853-dd747f0957ab/d1e0bb44-07da-4574-92bf-3f9adc5e8751/34621417-dac8-4a11-b54c-b5b5c180b754"
(reference "R2") (unit 1) (value "R") (footprint "")
)
)
)

View File

@ -0,0 +1,94 @@
(export (version "E")
(design
(source "/home/jon/work/kicad/qa/eeschema/data/netlists/top_level_hier_pins/top_level_hier_pins.kicad_sch")
(date "Mon 10 May 2021 17:51:31 EDT")
(tool "Eeschema (5.99.0-10539-g7356f9568d-dirty)")
(sheet (number "1") (name "/") (tstamps "/")
(title_block
(title)
(company)
(rev)
(date)
(source "top_level_hier_pins.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 "/Subsheet1/") (tstamps "/8b055b93-d115-4991-b853-dd747f0957ab/")
(title_block
(title)
(company)
(rev)
(date)
(source "subsheet.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 "/Subsheet1/SubSubSheet/") (tstamps "/8b055b93-d115-4991-b853-dd747f0957ab/d1e0bb44-07da-4574-92bf-3f9adc5e8751/")
(title_block
(title)
(company)
(rev)
(date)
(source "subsubsheet.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 "R1")
(value "R")
(datasheet "~")
(libsource (lib "Device") (part "R") (description "Resistor"))
(property (name "Sheetname") (value "SubSubSheet"))
(property (name "Sheetfile") (value "subsubsheet.kicad_sch"))
(sheetpath (names "/Subsheet1/SubSubSheet/") (tstamps "/8b055b93-d115-4991-b853-dd747f0957ab/d1e0bb44-07da-4574-92bf-3f9adc5e8751/"))
(tstamps "d21dccc4-3b84-4309-8a03-49ef532d46d9"))
(comp (ref "R2")
(value "R")
(datasheet "~")
(libsource (lib "Device") (part "R") (description "Resistor"))
(property (name "Sheetname") (value "SubSubSheet"))
(property (name "Sheetfile") (value "subsubsheet.kicad_sch"))
(sheetpath (names "/Subsheet1/SubSubSheet/") (tstamps "/8b055b93-d115-4991-b853-dd747f0957ab/d1e0bb44-07da-4574-92bf-3f9adc5e8751/"))
(tstamps "34621417-dac8-4a11-b54c-b5b5c180b754")))
(libparts
(libpart (lib "Device") (part "R")
(description "Resistor")
(docs "~")
(footprints
(fp "R_*"))
(fields
(field (name "Reference") "R")
(field (name "Value") "R")
(field (name "Datasheet") "~"))
(pins
(pin (num "1") (name "~") (type "passive"))
(pin (num "2") (name "~") (type "passive")))))
(libraries
(library (logical "Device")
(uri "/usr/local/share/kicad/library//Device.kicad_sym")))
(nets
(net (code "1") (name "/INPUT")
(node (ref "R1") (pin "1") (pintype "passive")))
(net (code "2") (name "/Subsheet1/SUB_OUTPUT")
(node (ref "R2") (pin "1") (pintype "passive")))
(net (code "3") (name "GND")
(node (ref "R1") (pin "2") (pintype "passive"))
(node (ref "R2") (pin "2") (pintype "passive")))))

View File

@ -290,4 +290,10 @@ BOOST_AUTO_TEST_CASE( GroupBusMatching )
}
BOOST_AUTO_TEST_CASE( TopLevelHierPins )
{
doNetlistTest( "top_level_hier_pins" );
}
BOOST_AUTO_TEST_SUITE_END()