Do not propagate bus entries across buses and wires at the same point

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9678
This commit is contained in:
Jon Evans 2021-11-25 13:36:30 -05:00
parent aa5f496727
commit 08cb573e11
7 changed files with 650 additions and 27 deletions

View File

@ -580,7 +580,10 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
for( const auto& it : connection_map )
{
auto connection_vec = it.second;
const std::vector<SCH_ITEM*>& connection_vec = it.second;
// Pre-scan to see if we have a bus at this location
SCH_LINE* busLine = aSheet.LastScreen()->GetBus( it.first );
for( auto primary_it = connection_vec.begin(); primary_it != connection_vec.end(); primary_it++ )
{
@ -600,13 +603,10 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
// a segment at some point other than at one of the endpoints.
if( connection_vec.size() == 1 )
{
SCH_SCREEN* screen = aSheet.LastScreen();
SCH_LINE* bus = screen->GetBus( it.first );
if( bus )
if( busLine )
{
auto bus_entry = static_cast<SCH_BUS_WIRE_ENTRY*>( connected_item );
bus_entry->m_connected_bus_item = bus;
bus_entry->m_connected_bus_item = busLine;
}
}
}
@ -616,20 +616,17 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
{
if( connection_vec.size() < 2 )
{
SCH_SCREEN* screen = aSheet.LastScreen();
SCH_LINE* bus = screen->GetBus( it.first );
if( bus )
if( busLine )
{
auto bus_entry = static_cast<SCH_BUS_BUS_ENTRY*>( connected_item );
if( it.first == bus_entry->GetPosition() )
bus_entry->m_connected_bus_items[0] = bus;
bus_entry->m_connected_bus_items[0] = busLine;
else
bus_entry->m_connected_bus_items[1] = bus;
bus_entry->m_connected_bus_items[1] = busLine;
bus_entry->ConnectedItems( aSheet ).insert( bus );
bus->ConnectedItems( aSheet ).insert( bus_entry );
bus_entry->ConnectedItems( aSheet ).insert( busLine );
busLine->ConnectedItems( aSheet ).insert( bus_entry );
}
}
}
@ -637,33 +634,45 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
// Change junctions to be on bus junction layer if they are touching a bus
else if( connected_item->Type() == SCH_JUNCTION_T )
{
SCH_SCREEN* screen = aSheet.LastScreen();
SCH_LINE* bus = screen->GetBus( it.first );
connected_item->SetLayer( bus ? LAYER_BUS_JUNCTION : LAYER_JUNCTION );
connected_item->SetLayer( busLine ? LAYER_BUS_JUNCTION : LAYER_JUNCTION );
}
for( auto test_it = primary_it + 1; test_it != connection_vec.end(); test_it++ )
{
SCH_ITEM* test_item = *test_it;
bool bus_connection_ok = true;
SCH_ITEM* test_item = *test_it;
if( connected_item != test_item &&
connected_item->ConnectionPropagatesTo( test_item ) &&
test_item->ConnectionPropagatesTo( connected_item ) )
{
connected_item->ConnectedItems( aSheet ).insert( test_item );
test_item->ConnectedItems( aSheet ).insert( connected_item );
}
wxASSERT( test_item != connected_item );
// Set up the link between the bus entry net and the bus
if( connected_item->Type() == SCH_BUS_WIRE_ENTRY_T )
{
if( test_item->Connection( &aSheet )->IsBus() )
if( test_item->GetLayer() == LAYER_BUS )
{
auto bus_entry = static_cast<SCH_BUS_WIRE_ENTRY*>( connected_item );
bus_entry->m_connected_bus_item = test_item;
}
}
// Bus entries only connect to bus lines on the end that is touching a bus line.
// If the user has overlapped another net line with the endpoint of the bus entry
// where the entry connects to a bus, we don't want to short-circuit it.
if( connected_item->Type() == SCH_BUS_WIRE_ENTRY_T )
{
bus_connection_ok = !busLine || test_item->GetLayer() == LAYER_BUS;
}
else if( test_item->Type() == SCH_BUS_WIRE_ENTRY_T )
{
bus_connection_ok = !busLine || connected_item->GetLayer() == LAYER_BUS;
}
if( connected_item->ConnectionPropagatesTo( test_item ) &&
test_item->ConnectionPropagatesTo( connected_item ) &&
bus_connection_ok )
{
connected_item->ConnectedItems( aSheet ).insert( test_item );
test_item->ConnectedItems( aSheet ).insert( connected_item );
}
}
// If we got this far and did not find a connected bus item for a bus entry,

View File

@ -747,6 +747,19 @@ std::vector<wxPoint> SCH_LINE::GetConnectionPoints() const
}
bool SCH_LINE::ConnectionPropagatesTo( const EDA_ITEM* aItem ) const
{
switch( aItem->Type() )
{
case SCH_LINE_T:
return IsBus() == static_cast<const SCH_LINE*>( aItem )->IsBus();
default:
return true;
}
}
void SCH_LINE::GetSelectedPoints( std::vector< wxPoint >& aPoints ) const
{
if( m_flags & STARTPOINT )

View File

@ -204,6 +204,8 @@ public:
std::vector<wxPoint> GetConnectionPoints() const override;
bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
void GetSelectedPoints( std::vector< wxPoint >& aPoints ) const;
bool CanConnect( const SCH_ITEM* aItem ) const override;

View File

@ -0,0 +1,294 @@
{
"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_entry_needed": "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": "bus_entries.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": 2
},
"net_colors": null
},
"pcbnew": {
"last_paths": {
"gencad": "",
"idf": "",
"netlist": "",
"specctra_dsn": "",
"step": "",
"vrml": ""
},
"page_layout_descr_file": ""
},
"schematic": {
"annotate_start_num": 0,
"drawing": {
"default_line_thickness": 6.0,
"default_text_size": 50.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,
"label_size_ratio": 0.375,
"pin_symbol_size": 25.0,
"text_offset_ratio": 0.15
},
"legacy_lib_dir": "",
"legacy_lib_list": [],
"meta": {
"version": 1
},
"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": [
[
"a1545928-1195-40b9-b3c4-78f837012afb",
""
]
],
"text_variables": {}
}

View File

@ -0,0 +1,217 @@
(kicad_sch (version 20211123) (generator eeschema)
(uuid a1545928-1195-40b9-b3c4-78f837012afb)
(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) (type default) (color 0 0 0 0))
(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))))
)
)
)
)
(bus_entry (at 15.24 7.62) (size 2.54 2.54)
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 4079d7b6-51ac-457a-8ba0-f050459c02ae)
)
(bus_entry (at 15.24 10.16) (size 2.54 2.54)
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 594df785-4335-453a-99bb-0cbabee7fd30)
)
(wire (pts (xy 0 10.16) (xy 0 12.7))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 2420fd82-7ec8-4e8a-99d9-d1065447a473)
)
(bus (pts (xy 15.24 0) (xy 15.24 7.62))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 247ebffd-2cb6-4379-ba6e-21861fea3913)
)
(wire (pts (xy 15.24 10.16) (xy 17.78 10.16))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 30190cfc-8fbf-46fd-95a4-5122e4bb4e4e)
)
(polyline (pts (xy 15.24 13.208) (xy 15.24 14.478))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid 30b7020c-f507-4978-80ef-a01885207bf9)
)
(bus (pts (xy 15.24 10.16) (xy 15.24 12.7))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 852bdba0-191d-4cf7-8112-d38ea272dc0e)
)
(wire (pts (xy 7.62 12.7) (xy 17.78 12.7))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 862cc153-d56c-4521-9559-ded98a3f0886)
)
(polyline (pts (xy 12.446 7.62) (xy 14.732 9.652))
(stroke (width 0) (type solid) (color 0 0 0 0))
(uuid a070a78d-392b-4c1a-9c53-7a2b2e9876ae)
)
(bus (pts (xy 15.24 7.62) (xy 15.24 10.16))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid b3c854e3-d8a9-4dce-b2fb-f4d9951581cb)
)
(wire (pts (xy 30.48 10.16) (xy 30.48 12.7))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid bc2a6774-22ad-4979-adcc-c101f68ebb51)
)
(wire (pts (xy 17.78 10.16) (xy 22.86 10.16))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid d4b39316-cdc6-4ead-bc52-4d8cd7a58e30)
)
(wire (pts (xy 17.78 12.7) (xy 22.86 12.7))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid d5765701-87de-4b69-9a3c-eaf69dbc75db)
)
(wire (pts (xy 7.62 10.16) (xy 15.24 10.16))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid e1617978-7ca3-4b03-a971-9ee65d19a74f)
)
(text "15.24, 12.7" (at 12.7 15.24 0)
(effects (font (size 0.5 0.5)) (justify left bottom))
(uuid 6038a029-d664-449b-83bd-7e2c1db433d2)
)
(text "15.24, 10.16" (at 8.636 7.366 0)
(effects (font (size 0.5 0.5)) (justify left bottom))
(uuid b74401fc-c466-4275-8779-086b0b8fe238)
)
(text "15.24, 7.62" (at 16.51 7.366 0)
(effects (font (size 0.5 0.5)) (justify left bottom))
(uuid b75c0835-ec0a-4aa3-b572-565b7b47b307)
)
(label "D[0..1]" (at 15.24 0 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
(uuid 36210d52-4f9a-42bc-a022-019a63c67fc2)
)
(label "D0" (at 20.32 10.16 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
(uuid 47889ec9-bc02-4908-9b16-7e457845614d)
)
(label "D1" (at 20.32 12.7 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
(uuid b54a5438-a202-4984-a167-124d0d7d3cfc)
)
(symbol (lib_id "Device:R") (at 26.67 12.7 90) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 00fe1780-0118-47db-9c5a-2a5739784eed)
(property "Reference" "R4" (id 0) (at 26.67 16.51 90))
(property "Value" "R" (id 1) (at 26.67 19.05 90))
(property "Footprint" "" (id 2) (at 26.67 14.478 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 26.67 12.7 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 95c1908b-a23c-48fe-806f-00105cd475d2))
(pin "2" (uuid 68f3fd88-6778-4ccc-879b-c4a57737e292))
)
(symbol (lib_id "Device:R") (at 3.81 12.7 270) (mirror x) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 11215924-608f-4de9-be0c-99a34efe4e76)
(property "Reference" "R2" (id 0) (at 3.81 16.51 90))
(property "Value" "R" (id 1) (at 3.81 19.05 90))
(property "Footprint" "" (id 2) (at 3.81 14.478 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 3.81 12.7 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 5d1191ab-0581-4e49-b5e0-c2f4514b1a19))
(pin "2" (uuid 66da230a-16cc-41d0-8225-1f2ed1ae80c3))
)
(symbol (lib_id "Device:R") (at 3.81 10.16 270) (mirror x) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 13cc3ed0-5d6e-432e-a920-2485183a707f)
(property "Reference" "R1" (id 0) (at 3.81 3.81 90))
(property "Value" "R" (id 1) (at 3.81 6.35 90))
(property "Footprint" "" (id 2) (at 3.81 11.938 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 3.81 10.16 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 8051ceca-6044-4f1a-b5de-bf9bbf8bbab0))
(pin "2" (uuid 94bb63c4-d35e-4601-b883-f7f070257a08))
)
(symbol (lib_id "Device:R") (at 26.67 10.16 90) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 9421d8ab-ec24-4783-b746-a12fbd00100e)
(property "Reference" "R3" (id 0) (at 26.67 3.81 90))
(property "Value" "R" (id 1) (at 26.67 6.35 90))
(property "Footprint" "" (id 2) (at 26.67 11.938 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 26.67 10.16 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 15f86f86-6612-462a-a1d2-f730a8788a9a))
(pin "2" (uuid b4450c83-6da6-4393-a892-92bf8cbec8aa))
)
(sheet_instances
(path "/" (page "1"))
)
(symbol_instances
(path "/13cc3ed0-5d6e-432e-a920-2485183a707f"
(reference "R1") (unit 1) (value "R") (footprint "")
)
(path "/11215924-608f-4de9-be0c-99a34efe4e76"
(reference "R2") (unit 1) (value "R") (footprint "")
)
(path "/9421d8ab-ec24-4783-b746-a12fbd00100e"
(reference "R3") (unit 1) (value "R") (footprint "")
)
(path "/00fe1780-0118-47db-9c5a-2a5739784eed"
(reference "R4") (unit 1) (value "R") (footprint "")
)
)
)

View File

@ -0,0 +1,83 @@
(export (version "E")
(design
(source "/home/jon/work/kicad/qa/eeschema/data/netlists/bus_entries/bus_entries.kicad_sch")
(date "Thu 25 Nov 2021 01:34:33 PM EST")
(tool "Eeschema (6.0.0-rc1-154-gaa5f496727-dirty)")
(sheet (number "1") (name "/") (tstamps "/")
(title_block
(title)
(company)
(rev)
(date)
(source "bus_entries.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 ""))
(property (name "Sheetfile") (value "bus_entries.kicad_sch"))
(sheetpath (names "/") (tstamps "/"))
(tstamps "13cc3ed0-5d6e-432e-a920-2485183a707f"))
(comp (ref "R2")
(value "R")
(datasheet "~")
(libsource (lib "Device") (part "R") (description "Resistor"))
(property (name "Sheetname") (value ""))
(property (name "Sheetfile") (value "bus_entries.kicad_sch"))
(sheetpath (names "/") (tstamps "/"))
(tstamps "11215924-608f-4de9-be0c-99a34efe4e76"))
(comp (ref "R3")
(value "R")
(datasheet "~")
(libsource (lib "Device") (part "R") (description "Resistor"))
(property (name "Sheetname") (value ""))
(property (name "Sheetfile") (value "bus_entries.kicad_sch"))
(sheetpath (names "/") (tstamps "/"))
(tstamps "9421d8ab-ec24-4783-b746-a12fbd00100e"))
(comp (ref "R4")
(value "R")
(datasheet "~")
(libsource (lib "Device") (part "R") (description "Resistor"))
(property (name "Sheetname") (value ""))
(property (name "Sheetfile") (value "bus_entries.kicad_sch"))
(sheetpath (names "/") (tstamps "/"))
(tstamps "00fe1780-0118-47db-9c5a-2a5739784eed")))
(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/share/kicad-nightly/symbols/Device.kicad_sym")))
(nets
(net (code "1") (name "/D0")
(node (ref "R1") (pin "1") (pintype "passive"))
(node (ref "R3") (pin "1") (pintype "passive")))
(net (code "2") (name "/D1")
(node (ref "R2") (pin "1") (pintype "passive"))
(node (ref "R4") (pin "1") (pintype "passive")))
(net (code "4") (name "Net-(R1-Pad2)")
(node (ref "R1") (pin "2") (pintype "passive"))
(node (ref "R2") (pin "2") (pintype "passive")))
(net (code "5") (name "Net-(R3-Pad2)")
(node (ref "R3") (pin "2") (pintype "passive"))
(node (ref "R4") (pin "2") (pintype "passive")))))

View File

@ -296,4 +296,9 @@ BOOST_AUTO_TEST_CASE( TopLevelHierPins )
}
BOOST_AUTO_TEST_CASE( BusEntries )
{
doNetlistTest( "bus_entries" );
}
BOOST_AUTO_TEST_SUITE_END()