![]() |
KiCad PCB EDA Suite
|
A subgraph is a set of items that are electrically connected on a single sheet. More...
#include <connection_graph.h>
Public Types | |
enum | PRIORITY { PRIORITY::INVALID = -1, PRIORITY::NONE = 0, PRIORITY::PIN, PRIORITY::SHEET_PIN, PRIORITY::HIER_LABEL, PRIORITY::LOCAL_LABEL, PRIORITY::POWER_PIN, PRIORITY::GLOBAL } |
Public Member Functions | |
CONNECTION_SUBGRAPH (CONNECTION_GRAPH *aGraph) | |
~CONNECTION_SUBGRAPH ()=default | |
bool | ResolveDrivers (bool aCheckMultipleDrivers=false) |
Determines which potential driver should drive the subgraph. More... | |
wxString | GetNetName () const |
Returns the fully-qualified net name for this subgraph (if one exists) More... | |
std::vector< SCH_ITEM * > | GetBusLabels () const |
Returns all the bus labels attached to this subgraph (if any) More... | |
const wxString & | GetNameForDriver (SCH_ITEM *aItem) |
Returns the candidate net name for a driver. More... | |
const wxString | GetNameForDriver (SCH_ITEM *aItem) const |
void | Absorb (CONNECTION_SUBGRAPH *aOther) |
Combines another subgraph on the same sheet into this one. More... | |
void | AddItem (SCH_ITEM *aItem) |
Adds a new item to the subgraph. More... | |
void | UpdateItemConnections () |
Updates all items to match the driver connection. More... | |
PRIORITY | GetDriverPriority () |
Static Public Member Functions | |
static PRIORITY | GetDriverPriority (SCH_ITEM *aDriver) |
Returns the priority (higher is more important) of a candidate driver. More... | |
Public Attributes | |
CONNECTION_GRAPH * | m_graph |
bool | m_dirty |
bool | m_absorbed |
True if this subgraph has been absorbed into another. No pointers here are safe if so! More... | |
CONNECTION_SUBGRAPH * | m_absorbed_by |
If this subgraph is absorbed, points to the absorbing (and valid) subgraph. More... | |
long | m_code |
bool | m_multiple_drivers |
True if this subgraph contains more than one driver that should be shorted together in the netlist. More... | |
bool | m_strong_driver |
True if the driver is "strong": a label or power object. More... | |
bool | m_local_driver |
True if the driver is a local (i.e. non-global) type. More... | |
SCH_ITEM * | m_no_connect |
No-connect item in graph, if any. More... | |
SCH_ITEM * | m_bus_entry |
Bus entry in graph, if any. More... | |
std::vector< SCH_ITEM * > | m_items |
std::vector< SCH_ITEM * > | m_drivers |
SCH_ITEM * | m_driver |
SCH_SHEET_PATH | m_sheet |
SCH_CONNECTION * | m_driver_connection |
Cache for driver connection. More... | |
std::unordered_map< std::shared_ptr< SCH_CONNECTION >, std::unordered_set< CONNECTION_SUBGRAPH * > > | m_bus_neighbors |
If a subgraph is a bus, this map contains links between the bus members and any local sheet neighbors with the same connection name. More... | |
std::unordered_map< std::shared_ptr< SCH_CONNECTION >, std::unordered_set< CONNECTION_SUBGRAPH * > > | m_bus_parents |
If this is a net, this vector contains links to any same-sheet buses that contain it. More... | |
std::vector< SCH_SHEET_PIN * > | m_hier_pins |
std::vector< SCH_HIERLABEL * > | m_hier_ports |
CONNECTION_SUBGRAPH * | m_hier_parent |
std::unordered_map< SCH_ITEM *, wxString > | m_driver_name_cache |
A cache of escaped netnames from schematic items. More... | |
SCH_ITEM * | m_first_driver |
Stores the primary driver for the multiple drivers ERC check. More... | |
SCH_ITEM * | m_second_driver |
Used for multiple drivers ERC message; stores the second possible driver (or nullptr) More... | |
Private Member Functions | |
wxString | driverName (SCH_ITEM *aItem) const |
A subgraph is a set of items that are electrically connected on a single sheet.
For example, a label connected to a wire and so on. A net is composed of one or more subgraphs.
A set of items that appears to be physically connected may actually be more than one subgraph, because some items don't connect electrically.
For example, multiple bus wires can come together at a junction but have different labels on each branch. Each label+wire branch is its own subgraph.
Definition at line 59 of file connection_graph.h.
|
strong |
Enumerator | |
---|---|
INVALID | |
NONE | |
PIN | |
SHEET_PIN | |
HIER_LABEL | |
LOCAL_LABEL | |
POWER_PIN | |
GLOBAL |
Definition at line 62 of file connection_graph.h.
|
inlineexplicit |
Definition at line 74 of file connection_graph.h.
|
default |
void CONNECTION_SUBGRAPH::Absorb | ( | CONNECTION_SUBGRAPH * | aOther | ) |
Combines another subgraph on the same sheet into this one.
Definition at line 321 of file connection_graph.cpp.
References AddItem(), SCH_ITEM::Connection(), m_absorbed, m_absorbed_by, m_bus_neighbors, m_bus_parents, m_code, m_dirty, m_driver, m_driver_connection, m_items, m_multiple_drivers, m_sheet, and SCH_CONNECTION::SetSubgraphCode().
void CONNECTION_SUBGRAPH::AddItem | ( | SCH_ITEM * | aItem | ) |
Adds a new item to the subgraph.
Definition at line 344 of file connection_graph.cpp.
References SCH_ITEM::Connection(), SCH_CONNECTION::IsDriver(), m_drivers, m_hier_pins, m_hier_ports, m_items, m_sheet, SCH_HIER_LABEL_T, SCH_SHEET_PIN_T, and EDA_ITEM::Type().
Referenced by Absorb(), and CONNECTION_GRAPH::buildConnectionGraph().
|
private |
Definition at line 267 of file connection_graph.cpp.
References CTX_NETNAME, EscapeString(), SCH_PIN::GetDefaultNetName(), m_no_connect, m_sheet, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_PIN_T, SCH_SHEET_PIN_T, and EDA_ITEM::Type().
Referenced by GetNameForDriver().
std::vector< SCH_ITEM * > CONNECTION_SUBGRAPH::GetBusLabels | ( | ) | const |
Returns all the bus labels attached to this subgraph (if any)
Definition at line 239 of file connection_graph.cpp.
References BUS, m_drivers, m_sheet, SCH_GLOBAL_LABEL_T, SCH_LABEL_T, and SCH_CONNECTION::Type().
|
static |
Returns the priority (higher is more important) of a candidate driver.
0: Invalid driver 1: Component pin 2: Hierarchical sheet pin 3: Hierarchical label 4: Local label 5: Power pin 6: Global label
aDriver | is the item to inspect |
Definition at line 385 of file connection_graph.cpp.
References GLOBAL, HIER_LABEL, LOCAL_LABEL, NONE, PIN, POWER_PIN, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_PIN_T, SCH_SHEET_PIN_T, SHEET_PIN, and EDA_ITEM::Type().
Referenced by CONNECTION_GRAPH::ercCheckNoConnects(), and SCHEMATIC::GetNetClassAssignmentCandidates().
|
inline |
Definition at line 143 of file connection_graph.h.
References m_driver, and NONE.
Referenced by SCH_EDITOR_CONTROL::AssignNetclass(), CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), inheritNetclass(), BACK_ANNOTATE::processNetNameChange(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().
const wxString & CONNECTION_SUBGRAPH::GetNameForDriver | ( | SCH_ITEM * | aItem | ) |
Returns the candidate net name for a driver.
Definition at line 297 of file connection_graph.cpp.
References driverName(), and m_driver_name_cache.
Referenced by CONNECTION_GRAPH::ercCheckMultipleDrivers(), CONNECTION_GRAPH::getDefaultConnection(), inheritNetclass(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().
const wxString CONNECTION_SUBGRAPH::GetNameForDriver | ( | SCH_ITEM * | aItem | ) | const |
Definition at line 310 of file connection_graph.cpp.
References driverName(), and m_driver_name_cache.
wxString CONNECTION_SUBGRAPH::GetNetName | ( | ) | const |
Returns the fully-qualified net name for this subgraph (if one exists)
Definition at line 221 of file connection_graph.cpp.
References SCH_ITEM::Connection(), m_dirty, m_driver, m_sheet, and SCH_CONNECTION::Name().
Referenced by CONNECTION_GRAPH::buildConnectionGraph().
bool CONNECTION_SUBGRAPH::ResolveDrivers | ( | bool | aCheckMultipleDrivers = false | ) |
Determines which potential driver should drive the subgraph.
If multiple possible drivers exist, picks one according to the priority. If multiple "winners" exist, returns false and sets m_driver to nullptr.
aCheckMultipleDrivers | controls whether the second driver should be captured for ERC |
Definition at line 63 of file connection_graph.cpp.
References SCH_CONNECTION::ClearDirty(), SCH_CONNECTION::ConfigureFromLabel(), SCH_ITEM::Connection(), GetDriverPriority(), GetNameForDriver(), SCH_TEXT::GetShape(), HIER_LABEL, INVALID, SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsSubsetOf(), m_driver, m_driver_connection, m_drivers, m_first_driver, m_items, m_local_driver, m_multiple_drivers, m_second_driver, m_sheet, m_strong_driver, PIN, POWER_PIN, PS_OUTPUT, SCH_CONNECTION::SetDriver(), and SHEET_PIN.
Referenced by CONNECTION_GRAPH::buildConnectionGraph().
void CONNECTION_SUBGRAPH::UpdateItemConnections | ( | ) |
Updates all items to match the driver connection.
Definition at line 358 of file connection_graph.cpp.
References SCH_CONNECTION::ClearDirty(), SCH_CONNECTION::Clone(), SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsNet(), m_driver, m_driver_connection, m_graph, m_items, and m_sheet.
Referenced by CONNECTION_GRAPH::buildConnectionGraph().
bool CONNECTION_SUBGRAPH::m_absorbed |
True if this subgraph has been absorbed into another. No pointers here are safe if so!
Definition at line 156 of file connection_graph.h.
Referenced by Absorb(), CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::FindSubgraphByName(), CONNECTION_GRAPH::GetSubgraphForItem(), and CONNECTION_GRAPH::propagateToNeighbors().
CONNECTION_SUBGRAPH* CONNECTION_SUBGRAPH::m_absorbed_by |
If this subgraph is absorbed, points to the absorbing (and valid) subgraph.
Definition at line 159 of file connection_graph.h.
Referenced by Absorb(), CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::GetSubgraphForItem(), and CONNECTION_GRAPH::propagateToNeighbors().
SCH_ITEM* CONNECTION_SUBGRAPH::m_bus_entry |
Bus entry in graph, if any.
Definition at line 180 of file connection_graph.h.
std::unordered_map< std::shared_ptr<SCH_CONNECTION>, std::unordered_set<CONNECTION_SUBGRAPH*> > CONNECTION_SUBGRAPH::m_bus_neighbors |
If a subgraph is a bus, this map contains links between the bus members and any local sheet neighbors with the same connection name.
For example, if this subgraph is a bus D[7..0], and on the same sheet there is a net with label D7, this map will contain an entry for the D7 bus member, and the vector will contain a pointer to the D7 net subgraph.
Definition at line 202 of file connection_graph.h.
Referenced by Absorb().
std::unordered_map< std::shared_ptr<SCH_CONNECTION>, std::unordered_set<CONNECTION_SUBGRAPH*> > CONNECTION_SUBGRAPH::m_bus_parents |
If this is a net, this vector contains links to any same-sheet buses that contain it.
The string key is the name of the connection that forms the link (which isn't necessarily the same as the name of the connection driving this subgraph)
Definition at line 210 of file connection_graph.h.
Referenced by Absorb().
long CONNECTION_SUBGRAPH::m_code |
Definition at line 161 of file connection_graph.h.
Referenced by Absorb(), CONNECTION_GRAPH::buildConnectionGraph(), and CONNECTION_GRAPH::propagateToNeighbors().
bool CONNECTION_SUBGRAPH::m_dirty |
Definition at line 153 of file connection_graph.h.
Referenced by Absorb(), CONNECTION_GRAPH::buildConnectionGraph(), GetNetName(), and CONNECTION_GRAPH::propagateToNeighbors().
SCH_ITEM* CONNECTION_SUBGRAPH::m_driver |
Definition at line 186 of file connection_graph.h.
Referenced by Absorb(), CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckFloatingWires(), GetDriverPriority(), GetNetName(), CONNECTION_GRAPH::propagateToNeighbors(), ResolveDrivers(), and UpdateItemConnections().
SCH_CONNECTION* CONNECTION_SUBGRAPH::m_driver_connection |
Cache for driver connection.
Definition at line 191 of file connection_graph.h.
Referenced by Absorb(), CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::FindSubgraphByName(), CONNECTION_GRAPH::propagateToNeighbors(), CONNECTION_GRAPH::recacheSubgraphName(), ResolveDrivers(), and UpdateItemConnections().
std::unordered_map<SCH_ITEM*, wxString> CONNECTION_SUBGRAPH::m_driver_name_cache |
A cache of escaped netnames from schematic items.
Definition at line 222 of file connection_graph.h.
Referenced by GetNameForDriver().
std::vector<SCH_ITEM*> CONNECTION_SUBGRAPH::m_drivers |
Definition at line 184 of file connection_graph.h.
Referenced by AddItem(), CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::ercCheckLabels(), GetBusLabels(), inheritNetclass(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().
SCH_ITEM* CONNECTION_SUBGRAPH::m_first_driver |
Stores the primary driver for the multiple drivers ERC check.
This is the chosen driver before subgraphs are absorbed (so m_driver may be different)
Definition at line 228 of file connection_graph.h.
Referenced by CONNECTION_GRAPH::ercCheckMultipleDrivers(), and ResolveDrivers().
CONNECTION_GRAPH* CONNECTION_SUBGRAPH::m_graph |
Definition at line 151 of file connection_graph.h.
Referenced by UpdateItemConnections().
CONNECTION_SUBGRAPH* CONNECTION_SUBGRAPH::m_hier_parent |
Definition at line 219 of file connection_graph.h.
Referenced by CONNECTION_GRAPH::ercCheckLabels(), and CONNECTION_GRAPH::propagateToNeighbors().
std::vector<SCH_SHEET_PIN*> CONNECTION_SUBGRAPH::m_hier_pins |
Definition at line 213 of file connection_graph.h.
Referenced by AddItem(), and CONNECTION_GRAPH::propagateToNeighbors().
std::vector<SCH_HIERLABEL*> CONNECTION_SUBGRAPH::m_hier_ports |
Definition at line 216 of file connection_graph.h.
Referenced by AddItem(), and CONNECTION_GRAPH::propagateToNeighbors().
std::vector<SCH_ITEM*> CONNECTION_SUBGRAPH::m_items |
Definition at line 182 of file connection_graph.h.
Referenced by Absorb(), AddItem(), NETLIST_EXPORTER_BASE::CreatePinList(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckFloatingWires(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckNoConnects(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), ResolveDrivers(), ERC_TESTER::TestMultUnitPinConflicts(), ERC_TESTER::TestPinToPin(), ERC_TESTER::TestSimilarLabels(), UpdateItemConnections(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().
bool CONNECTION_SUBGRAPH::m_local_driver |
True if the driver is a local (i.e. non-global) type.
Definition at line 174 of file connection_graph.h.
Referenced by ResolveDrivers().
bool CONNECTION_SUBGRAPH::m_multiple_drivers |
True if this subgraph contains more than one driver that should be shorted together in the netlist.
For example, two labels or two power ports.
Definition at line 168 of file connection_graph.h.
Referenced by Absorb(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().
SCH_ITEM* CONNECTION_SUBGRAPH::m_no_connect |
No-connect item in graph, if any.
Definition at line 177 of file connection_graph.h.
Referenced by CONNECTION_GRAPH::buildConnectionGraph(), NETLIST_EXPORTER_BASE::CreatePinList(), driverName(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckNoConnects(), and NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol().
SCH_ITEM* CONNECTION_SUBGRAPH::m_second_driver |
Used for multiple drivers ERC message; stores the second possible driver (or nullptr)
Definition at line 231 of file connection_graph.h.
Referenced by CONNECTION_GRAPH::ercCheckMultipleDrivers(), and ResolveDrivers().
SCH_SHEET_PATH CONNECTION_SUBGRAPH::m_sheet |
Definition at line 188 of file connection_graph.h.
Referenced by Absorb(), AddItem(), CONNECTION_GRAPH::buildConnectionGraph(), driverName(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckFloatingWires(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckMultipleDrivers(), CONNECTION_GRAPH::ercCheckNoConnects(), CONNECTION_GRAPH::FindSubgraphByName(), GetBusLabels(), CONNECTION_GRAPH::getDefaultConnection(), GetNetName(), CONNECTION_GRAPH::propagateToNeighbors(), ResolveDrivers(), ERC_TESTER::TestMultUnitPinConflicts(), ERC_TESTER::TestPinToPin(), ERC_TESTER::TestSimilarLabels(), and UpdateItemConnections().
bool CONNECTION_SUBGRAPH::m_strong_driver |
True if the driver is "strong": a label or power object.
Definition at line 171 of file connection_graph.h.
Referenced by CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().