mirror of https://github.com/KLayout/klayout.git
WIP: introduced Circuit::is_external_net
This commit is contained in:
parent
72a140957d
commit
f989a85642
|
|
@ -851,6 +851,21 @@ void Circuit::connect_pin (size_t pin_id, Net *net)
|
|||
}
|
||||
}
|
||||
|
||||
bool Circuit::is_external_net (const db::Net *net) const
|
||||
{
|
||||
if (!net || net->pin_count () == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (std::vector<Net::pin_iterator>::const_iterator p = m_pin_refs.begin (); p != m_pin_refs.end (); ++p) {
|
||||
if (*p != Net::pin_iterator () && (*p)->net () == net) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Circuit::purge_nets ()
|
||||
{
|
||||
std::vector<db::Net *> nets_to_be_purged;
|
||||
|
|
|
|||
|
|
@ -1518,6 +1518,13 @@ public:
|
|||
*/
|
||||
void connect_pin (size_t pin_id, Net *net);
|
||||
|
||||
/**
|
||||
* @brief Returns true, if the net is an external net
|
||||
*
|
||||
* External nets are net which are connected to an outgoing pin.
|
||||
*/
|
||||
bool is_external_net (const db::Net *net) const;
|
||||
|
||||
/**
|
||||
* @brief Purge unused nets
|
||||
*
|
||||
|
|
|
|||
|
|
@ -760,6 +760,10 @@ Class<db::Circuit> decl_dbCircuit ("db", "Circuit",
|
|||
"@brief Gets the cell index of the circuit\n"
|
||||
"See \\cell_index= for details.\n"
|
||||
) +
|
||||
gsi::method ("is_external_net?", &db::Circuit::is_external_net, gsi::arg ("net"),
|
||||
"@brief Returns true, if the given net is an external one.\n"
|
||||
"External nets are nets which are connected to an outgoing pin."
|
||||
) +
|
||||
gsi::method ("net_for_pin", (db::Net *(db::Circuit::*) (size_t)) &db::Circuit::net_for_pin, gsi::arg ("pin_id"),
|
||||
"@brief Gets the net object attached to a specific pin.\n"
|
||||
"This is the net object inside the circuit which attaches to the given outward-bound pin.\n"
|
||||
|
|
|
|||
|
|
@ -144,11 +144,7 @@ static void dump_recursive_nets_to_layout (const db::LayoutToNetlist &l2n, db::L
|
|||
for (db::Circuit::const_net_iterator n = c->begin_nets (); n != c->end_nets (); ++n) {
|
||||
|
||||
// only handle nets without outgoing pins - these are local
|
||||
bool is_local = true;
|
||||
for (db::Net::const_pin_iterator p = n->begin_pins (); p != n->end_pins () && is_local; ++p) {
|
||||
is_local = (p->subcircuit () != 0);
|
||||
}
|
||||
if (! is_local) {
|
||||
if (c->is_external_net (n.operator-> ())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -751,18 +751,21 @@ TEST(8_NetSubCircuitsEditing)
|
|||
n2->set_name ("n2");
|
||||
c.add_net (n2);
|
||||
|
||||
EXPECT_EQ (c.is_external_net (n1), false);
|
||||
c.connect_pin (0, n1);
|
||||
|
||||
EXPECT_EQ (n1->terminal_count (), size_t (0));
|
||||
EXPECT_EQ (n1->pin_count (), size_t (1));
|
||||
EXPECT_EQ (n1->is_floating (), true);
|
||||
EXPECT_EQ (n1->is_internal (), false);
|
||||
EXPECT_EQ (c.is_external_net (n1), true);
|
||||
|
||||
EXPECT_EQ (c.net_for_pin (0), n1);
|
||||
EXPECT_EQ (c.net_for_pin (1), 0);
|
||||
|
||||
sc1->connect_pin (0, n1);
|
||||
sc1->connect_pin (1, n2);
|
||||
EXPECT_EQ (c.is_external_net (n2), false);
|
||||
|
||||
EXPECT_EQ (n1->terminal_count (), size_t (0));
|
||||
EXPECT_EQ (n1->pin_count (), size_t (2));
|
||||
|
|
|
|||
|
|
@ -510,7 +510,9 @@ class DBNetlist_TestClass < TestBase
|
|||
c.each_net { |n| names << n.name }
|
||||
assert_equal(names, [ "NET1", "NET2" ])
|
||||
|
||||
assert_equal(c.is_external_net?(net1), false)
|
||||
c.connect_pin(pina1, net1)
|
||||
assert_equal(c.is_external_net?(net1), true)
|
||||
c.connect_pin(pinb1.id, net1)
|
||||
c.connect_pin(pina2, net2)
|
||||
c.connect_pin(pinb2.id, net2)
|
||||
|
|
|
|||
Loading…
Reference in New Issue