diff --git a/src/db/db/dbNetlist.cc b/src/db/db/dbNetlist.cc index 0c2a134e3..39c04268d 100644 --- a/src/db/db/dbNetlist.cc +++ b/src/db/db/dbNetlist.cc @@ -955,4 +955,18 @@ void Netlist::remove_device_class (DeviceClass *device_class) m_device_classes.erase (device_class); } +void Netlist::purge_nets () +{ + for (circuit_iterator c = begin_circuits (); c != end_circuits (); ++c) { + c->purge_nets (); + } +} + +void Netlist::combine_devices () +{ + for (circuit_iterator c = begin_circuits (); c != end_circuits (); ++c) { + c->combine_devices (); + } +} + } diff --git a/src/db/db/dbNetlist.h b/src/db/db/dbNetlist.h index 7ba2ebc00..b3d911144 100644 --- a/src/db/db/dbNetlist.h +++ b/src/db/db/dbNetlist.h @@ -1573,6 +1573,21 @@ public: return m_device_classes.end (); } + /** + * @brief Purge unused nets + * + * This method will purge all nets which return "floating". + */ + void purge_nets (); + + /** + * @brief Combine devices + * + * This method will combine devices that can be combined according + * to their device classes "combine_devices" method. + */ + void combine_devices (); + private: circuit_list m_circuits; device_class_list m_device_classes; diff --git a/src/db/db/gsiDeclDbNetlist.cc b/src/db/db/gsiDeclDbNetlist.cc index 2ceef14cd..a9abc0c41 100644 --- a/src/db/db/gsiDeclDbNetlist.cc +++ b/src/db/db/gsiDeclDbNetlist.cc @@ -671,6 +671,18 @@ Class decl_dbCircuit ("db", "Circuit", gsi::method ("clear", &db::Circuit::clear, "@brief Clears the circuit\n" "This method removes all objects and clears the other attributes." + ) + + gsi::method ("combine_devices", &db::Circuit::combine_devices, + "@brief Combines devices where possible\n" + "This method will combine devices that can be combined according " + "to their device classes 'combine_devices' method.\n" + "For example, serial or parallel resistors can be combined into " + "a single resistor.\n" + ) + + gsi::method ("purge_nets", &db::Circuit::purge_nets, + "@brief Purges floating nets.\n" + "Floating nets can be created as effect of reconnections of devices or pins. " + "This method will eliminate all nets that make less than two connections." ), "@brief Circuits are the basic building blocks of the netlist\n" "A circuit has pins by which it can connect to the outside. Pins are " @@ -737,6 +749,18 @@ Class decl_dbNetlist ("db", "Netlist", ) + gsi::iterator ("each_device_class", (db::Netlist::device_class_iterator (db::Netlist::*) ()) &db::Netlist::begin_device_classes, (db::Netlist::device_class_iterator (db::Netlist::*) ()) &db::Netlist::end_device_classes, "@brief Iterates over the device classes of the netlist" + ) + + gsi::method ("combine_devices", &db::Netlist::combine_devices, + "@brief Combines devices where possible\n" + "This method will combine devices that can be combined according " + "to their device classes 'combine_devices' method.\n" + "For example, serial or parallel resistors can be combined into " + "a single resistor.\n" + ) + + gsi::method ("purge_nets", &db::Netlist::purge_nets, + "@brief Purges floating nets.\n" + "Floating nets can be created as effect of reconnections of devices or pins. " + "This method will eliminate all nets that make less than two connections." ), "@brief The netlist top-level class\n" "A netlist is a hierarchical structure of circuits. At least one circuit is the "