Check for conflicts before promoting sheet pins to be strong drivers

Fixes https://gitlab.com/kicad/code/kicad/issues/4201
This commit is contained in:
Jon Evans 2020-04-19 18:20:51 -04:00
parent 7df3df3381
commit d7d1ea33ac
6 changed files with 452 additions and 5 deletions

View File

@ -956,7 +956,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
std::unordered_set<CONNECTION_SUBGRAPH*> invalidated_subgraphs;
for( CONNECTION_SUBGRAPH* subgraph : m_driver_subgraphs)
for( CONNECTION_SUBGRAPH* subgraph : m_driver_subgraphs )
{
if( subgraph->m_absorbed )
continue;
@ -1003,13 +1003,45 @@ void CONNECTION_GRAPH::buildConnectionGraph()
// If there is no conflict, promote sheet pins to be strong drivers so that they
// will be considered below for propagation/merging.
// It is possible for this to generate a conflict if the sheet pin has the same
// name as a global label on the same sheet, because global merging will then treat
// this subgraph as if it had a matching local label. So, for those cases, we
// don't apply this promotion
if( subgraph->m_driver->Type() == SCH_SHEET_PIN_T )
{
wxLogTrace( "CONN", "%ld (%s) weakly driven by unique sheet pin %s, promoting",
subgraph->m_code, name,
subgraph->m_driver->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
bool conflict = false;
wxString global_name = connection->Name( true );
size_t count = m_net_name_to_subgraphs_map.count( global_name );
subgraph->m_strong_driver = true;
if( count )
{
// A global will conflict if it is on the same sheet as this subgraph, since
// it would be connected by implicit local label linking
auto& candidates = m_net_name_to_subgraphs_map.at( global_name );
for( const auto& candidate : candidates )
{
if( candidate->m_sheet == sheet )
conflict = true;
}
}
if( conflict )
{
wxLogTrace( "CONN",
"%ld (%s) skipped for promotion due to potential conflict",
subgraph->m_code, name );
}
else
{
wxLogTrace( "CONN",
"%ld (%s) weakly driven by unique sheet pin %s, promoting",
subgraph->m_code, name,
subgraph->m_driver->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
subgraph->m_strong_driver = true;
}
}
}
}

View File

@ -0,0 +1,70 @@
EESchema Schematic File Version 5
EELAYER 33 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 2 3
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
Comment5 ""
Comment6 ""
Comment7 ""
Comment8 ""
Comment9 ""
$EndDescr
Connection ~ 4500 2400
Wire Wire Line
3800 2400 4500 2400
Wire Wire Line
3800 2800 4500 2800
Wire Wire Line
3800 3000 4800 3000
Wire Wire Line
4500 2400 4500 2450
Wire Wire Line
4500 2400 4800 2400
Wire Wire Line
4500 2800 4500 2750
Wire Wire Line
4800 2400 4800 2450
Wire Wire Line
4800 3000 4800 2750
Text HLabel 3800 2400 0 50 Input ~ 0
LIVE
Text HLabel 3800 2800 0 50 Input ~ 0
NEUTRAL
Text HLabel 3800 3000 0 50 Input ~ 0
LIVE_1
$Comp
L Device:R R1
U 1 1 5CC15F6F
P 4500 2600
AR Path="/5CC15EF9/5CC15F6F" Ref="R1" Part="1"
AR Path="/5CC165F1/5CC15F6F" Ref="R3" Part="1"
F 0 "R1" V 4580 2600 50 0000 C CNN
F 1 "R" V 4500 2600 50 0000 C CNN
F 2 "Resistor_SMD:R_0603_1608Metric" V 4430 2600 50 0001 C CNN
F 3 "~" H 4500 2600 50 0001 C CNN
1 4500 2600
1 0 0 -1
$EndComp
$Comp
L Device:R R2
U 1 1 5CE0545A
P 4800 2600
AR Path="/5CC15EF9/5CE0545A" Ref="R2" Part="1"
AR Path="/5CC165F1/5CE0545A" Ref="R4" Part="1"
F 0 "R2" V 4880 2600 50 0000 C CNN
F 1 "R" V 4800 2600 50 0000 C CNN
F 2 "Resistor_SMD:R_0603_1608Metric" V 4730 2600 50 0001 C CNN
F 3 "~" H 4800 2600 50 0001 C CNN
1 4800 2600
1 0 0 -1
$EndComp
$EndSCHEMATC

View File

@ -0,0 +1,44 @@
EESchema-LIBRARY Version 2.4
#encoding utf-8
#
# Connector_Conn_01x03_Male
#
DEF Connector_Conn_01x03_Male J 0 40 Y N 1 F N
F0 "J" 0 200 50 H V C CNN
F1 "Connector_Conn_01x03_Male" 0 -200 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "~" 0 0 50 H I C CNN
$FPLIST
Connector*:*_1x??_*
$ENDFPLIST
DRAW
S 34 -95 0 -105 1 1 6 F
S 34 5 0 -5 1 1 6 F
S 34 105 0 95 1 1 6 F
P 2 1 1 6 50 -100 34 -100 N
P 2 1 1 6 50 0 34 0 N
P 2 1 1 6 50 100 34 100 N
X Pin_1 1 200 100 150 L 50 50 1 1 P
X Pin_2 2 200 0 150 L 50 50 1 1 P
X Pin_3 3 200 -100 150 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Device_R
#
DEF Device_R R 0 0 N Y 1 F N
F0 "R" 80 0 50 V V C CNN
F1 "Device_R" 0 0 50 V V C CNN
F2 "" -70 0 50 V I C CNN
F3 "~" 0 0 50 H I C CNN
$FPLIST
R_*
$ENDFPLIST
DRAW
S -40 -100 40 100 0 1 10 N
X ~ 1 0 150 50 D 50 50 1 1 P
X ~ 2 0 -150 50 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
#End Library

View File

@ -0,0 +1,148 @@
(export (version "D")
(design
(source "/home/jon/work/kicad-master/qa/eeschema/data/netlists/test_global_promotion_2/test_global_promotion_2.sch")
(date "Sun 19 Apr 2020 18:19:54 EDT")
(tool "Eeschema (5.99.0-1348-g327eb1c7c-dirty)")
(sheet (number "1") (name "/") (tstamps "/")
(title_block
(title)
(company)
(rev)
(date)
(source "test_global_promotion_2.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 "/Sheet5CC15EF8/") (tstamps "/00000000-0000-0000-0000-00005cc15ef9/")
(title_block
(title)
(company)
(rev)
(date)
(source "subsheet.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 "/sheet5CC165F1/") (tstamps "/00000000-0000-0000-0000-00005cc165f1/")
(title_block
(title)
(company)
(rev)
(date)
(source "subsheet.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 "J1")
(value "Conn_01x03_Male")
(footprint "Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical")
(datasheet "~")
(libsource (lib "Connector") (part "Conn_01x03_Male") (description "Generic connector, single row, 01x03, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names "/") (tstamps "/"))
(tstamp "00000000-0000-0000-0000-00005ccf482d"))
(comp (ref "J2")
(value "Conn_01x03_Male")
(footprint "Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical")
(datasheet "~")
(libsource (lib "Connector") (part "Conn_01x03_Male") (description "Generic connector, single row, 01x03, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names "/") (tstamps "/"))
(tstamp "00000000-0000-0000-0000-00005cc1686d"))
(comp (ref "R1")
(value "R")
(footprint "Resistor_SMD:R_0603_1608Metric")
(datasheet "~")
(libsource (lib "Device") (part "R") (description "Resistor"))
(sheetpath (names "/Sheet5CC15EF8/") (tstamps "/00000000-0000-0000-0000-00005cc15ef9/"))
(tstamp "00000000-0000-0000-0000-00005cc15f6f"))
(comp (ref "R2")
(value "R")
(footprint "Resistor_SMD:R_0603_1608Metric")
(datasheet "~")
(libsource (lib "Device") (part "R") (description "Resistor"))
(sheetpath (names "/Sheet5CC15EF8/") (tstamps "/00000000-0000-0000-0000-00005cc15ef9/"))
(tstamp "00000000-0000-0000-0000-00005ce0545a"))
(comp (ref "R3")
(value "R")
(footprint "Resistor_SMD:R_0603_1608Metric")
(datasheet "~")
(libsource (lib "Device") (part "R") (description "Resistor"))
(sheetpath (names "/sheet5CC165F1/") (tstamps "/00000000-0000-0000-0000-00005cc165f1/"))
(tstamp "00000000-0000-0000-0000-00005cc15f6f"))
(comp (ref "R4")
(value "R")
(footprint "Resistor_SMD:R_0603_1608Metric")
(datasheet "~")
(libsource (lib "Device") (part "R") (description "Resistor"))
(sheetpath (names "/sheet5CC165F1/") (tstamps "/00000000-0000-0000-0000-00005cc165f1/"))
(tstamp "00000000-0000-0000-0000-00005ce0545a")))
(libparts
(libpart (lib "Connector") (part "Conn_01x03_Male")
(description "Generic connector, single row, 01x03, script generated (kicad-library-utils/schlib/autogen/connector/)")
(docs "~")
(footprints
(fp "Connector*:*_1x??_*"))
(fields
(field (name "Reference") "J")
(field (name "Value") "Conn_01x03_Male")
(field (name "Datasheet") "~"))
(pins
(pin (num "1") (name "Pin_1") (type "passive"))
(pin (num "2") (name "Pin_2") (type "passive"))
(pin (num "3") (name "Pin_3") (type "passive"))))
(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 "Connector")
(uri "/home/jon/kicad-library/kicad-symbols//Connector.lib"))
(library (logical "Device")
(uri "/home/jon/kicad-library/kicad-symbols//Device.lib")))
(nets
(net (code "1") (name "/LIVE")
(node (ref "J2") (pin "1") (pinfunction "Pin_1"))
(node (ref "R1") (pin "1"))
(node (ref "R2") (pin "1")))
(net (code "2") (name "/LIVE_1")
(node (ref "J1") (pin "2") (pinfunction "Pin_2"))
(node (ref "R4") (pin "2")))
(net (code "3") (name "/LIVE_2")
(node (ref "J2") (pin "2") (pinfunction "Pin_2"))
(node (ref "R3") (pin "1"))
(node (ref "R4") (pin "1")))
(net (code "4") (name "/NEUTRAL")
(node (ref "J2") (pin "3") (pinfunction "Pin_3"))
(node (ref "R1") (pin "2"))
(node (ref "R3") (pin "2")))
(net (code "5") (name "LIVE")
(node (ref "J1") (pin "1") (pinfunction "Pin_1"))
(node (ref "R2") (pin "2")))
(net (code "6") (name "Net-(J1-Pad3)")
(node (ref "J1") (pin "3") (pinfunction "Pin_3")))))

View File

@ -0,0 +1,59 @@
update=Sun 19 Apr 2020 18:19:54 EDT
version=1
last_client=eeschema
[general]
version=1
RootSch=
BoardNm=
[pcbnew]
version=1
LastNetListRead=
UseCmpFile=1
PadDrill=0.600000000000
PadDrillOvalY=0.600000000000
PadSizeH=1.500000000000
PadSizeV=1.500000000000
PcbTextSizeV=1.500000000000
PcbTextSizeH=1.500000000000
PcbTextThickness=0.300000000000
ModuleTextSizeV=1.000000000000
ModuleTextSizeH=1.000000000000
ModuleTextSizeThickness=0.150000000000
SolderMaskClearance=0.000000000000
SolderMaskMinWidth=0.000000000000
DrawSegmentWidth=0.200000000000
BoardOutlineThickness=0.100000000000
ModuleOutlineThickness=0.150000000000
CopperEdgeClearance=0.000000000000
[cvpcb]
version=1
NetIExt=net
[eeschema]
version=1
LibDir=
[eeschema/libraries]
[sheetnames]
1=00000000-0000-0000-0000-00005e9ccd14:
2=00000000-0000-0000-0000-00005cc15ef9:Sheet5CC15EF8
3=00000000-0000-0000-0000-00005cc165f1:sheet5CC165F1
[schematic_editor]
version=1
PageLayoutDescrFile=
PlotDirectoryName=
NetFmtName=Pcbnew
SpiceAjustPassiveValues=0
SubpartIdSeparator=0
SubpartFirstId=65
LabSize=50
TextOffsetRatio=0.3
LineThickness=6
BusThickness=12
WireThickness=6
JunctionSize=40
FieldNameTemplates=(templatefields)
ERC_TestSimilarLabels=1
ERC_CheckUniqueGlobalLabels=1
ERC_CheckBusDriverConflicts=1
ERC_CheckBusEntryConflicts=1
ERC_CheckBusToBusConflicts=1
ERC_CheckBusToNetConflicts=1

View File

@ -0,0 +1,94 @@
EESchema Schematic File Version 5
EELAYER 33 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 3
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
Comment5 ""
Comment6 ""
Comment7 ""
Comment8 ""
Comment9 ""
$EndDescr
Connection ~ 4550 3250
Wire Wire Line
3800 2300 5150 2300
Wire Wire Line
3850 3050 5000 3050
Wire Wire Line
3850 3150 4550 3150
Wire Wire Line
4550 3150 4550 3250
Wire Wire Line
4550 3250 4550 4250
Wire Wire Line
4550 3250 5300 3250
Wire Wire Line
4550 4250 5300 4250
Wire Wire Line
5000 3050 5000 3950
Wire Wire Line
5000 3950 5300 3950
Wire Wire Line
5150 2300 5150 4100
Wire Wire Line
5150 4100 5300 4100
Wire Wire Line
5250 2200 3800 2200
Wire Wire Line
5250 3100 5250 2200
Wire Wire Line
5300 2950 3850 2950
Wire Wire Line
5300 3100 5250 3100
Text GLabel 5250 2200 2 50 Input ~ 0
LIVE
$Comp
L Connector:Conn_01x03_Male J1
U 1 1 5CCF482D
P 3600 2300
F 0 "J1" H 3600 2500 50 0000 C CNN
F 1 "Conn_01x03_Male" H 3600 2100 50 0000 C CNN
F 2 "Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical" H 3600 2300 50 0001 C CNN
F 3 "~" H 3600 2300 50 0001 C CNN
1 3600 2300
1 0 0 -1
$EndComp
$Comp
L Connector:Conn_01x03_Male J2
U 1 1 5CC1686D
P 3650 3050
F 0 "J2" H 3650 3250 50 0000 C CNN
F 1 "Conn_01x03_Male" H 3650 2850 50 0000 C CNN
F 2 "Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical" H 3650 3050 50 0001 C CNN
F 3 "~" H 3650 3050 50 0001 C CNN
1 3650 3050
1 0 0 -1
$EndComp
$Sheet
S 5300 2800 1100 700
U 5CC15EF9
F0 "Sheet5CC15EF8" 50
F1 "subsheet.sch" 50
F2 "LIVE" I L 5300 2950 50
F3 "NEUTRAL" I L 5300 3250 50
F4 "LIVE_1" I L 5300 3100 50
$EndSheet
$Sheet
S 5300 3800 1100 700
U 5CC165F1
F0 "sheet5CC165F1" 50
F1 "subsheet.sch" 50
F2 "LIVE" I L 5300 3950 50
F3 "NEUTRAL" I L 5300 4250 50
F4 "LIVE_1" I L 5300 4100 50
$EndSheet
$EndSCHEMATC