diff --git a/src/db/db/dbNetlist.cc b/src/db/db/dbNetlist.cc index 8305b9167..1e48924b3 100644 --- a/src/db/db/dbNetlist.cc +++ b/src/db/db/dbNetlist.cc @@ -145,11 +145,13 @@ const Pin *NetPinRef::pin (const db::Circuit *c) const // Net class implementation Net::Net () + : m_cluster_id (0) { // .. nothing yet .. } Net::Net (const Net &other) + : m_cluster_id (0) { operator= (other); } @@ -160,6 +162,7 @@ Net &Net::operator= (const Net &other) m_name = other.m_name; m_pins = other.m_pins; m_ports = other.m_ports; + m_cluster_id = other.m_cluster_id; } return *this; } @@ -169,6 +172,7 @@ void Net::clear () m_name.clear (); m_ports.clear (); m_pins.clear (); + m_cluster_id = 0; } void Net::set_name (const std::string &name) @@ -176,6 +180,11 @@ void Net::set_name (const std::string &name) m_name = name; } +void Net::set_cluster_id (size_t ci) +{ + m_cluster_id = ci; +} + void Net::add_pin (const NetPinRef &pin) { m_pins.push_back (pin); diff --git a/src/db/db/dbNetlist.h b/src/db/db/dbNetlist.h index c238fe9ce..0e67f02d4 100644 --- a/src/db/db/dbNetlist.h +++ b/src/db/db/dbNetlist.h @@ -409,6 +409,22 @@ public: return m_name; } + /** + * @brief Sets the cluster ID of this net + * + * The cluster ID links the net to a cluster from the + * hierarchical layout netlist extractor. + */ + void set_cluster_id (size_t ci); + + /** + * @brief Gets the cluster ID + */ + size_t cluster_id () const + { + return m_cluster_id; + } + /** * @brief Adds a pin to this net */ @@ -457,6 +473,7 @@ private: port_list m_ports; pin_list m_pins; std::string m_name; + size_t m_cluster_id; void translate_devices (const std::map &map); void translate_subcircuits (const std::map &map); diff --git a/src/db/unit_tests/dbNetlistTests.cc b/src/db/unit_tests/dbNetlistTests.cc index cc2653a15..86f870f55 100644 --- a/src/db/unit_tests/dbNetlistTests.cc +++ b/src/db/unit_tests/dbNetlistTests.cc @@ -320,3 +320,21 @@ TEST(5_SubCircuit) EXPECT_EQ (sc2.name (), "sc"); EXPECT_EQ (sc2.trans ().to_string (), "r0 *2.5 0,0"); } + +TEST(6_Net) +{ + db::Net n, n2; + + n.set_name ("n"); + EXPECT_EQ (n.name (), "n"); + n.set_cluster_id (17); + EXPECT_EQ (int (n.cluster_id ()), 17); + + n2 = n; + EXPECT_EQ (n2.name (), "n"); + EXPECT_EQ (int (n2.cluster_id ()), 17); + + n.clear (); + EXPECT_EQ (n.name (), ""); + EXPECT_EQ (int (n.cluster_id ()), 0); +}