mirror of https://github.com/KLayout/klayout.git
WIP: unit tests for GSI binding of Region#net
This commit is contained in:
parent
984c001f56
commit
83aaca4485
|
|
@ -1426,6 +1426,28 @@ nets_by_name (db::Circuit *circuit, const std::string &name_pattern)
|
|||
return res;
|
||||
}
|
||||
|
||||
static std::vector<db::Net *>
|
||||
nets_by_name_from_netlist (db::Netlist *netlist, const std::string &name_pattern)
|
||||
{
|
||||
std::vector<db::Net *> res;
|
||||
if (! netlist) {
|
||||
return res;
|
||||
}
|
||||
|
||||
tl::GlobPattern glob (name_pattern);
|
||||
glob.set_case_sensitive (netlist->is_case_sensitive ());
|
||||
for (auto c = netlist->begin_circuits (); c != netlist->end_circuits (); ++c) {
|
||||
for (auto n = c->begin_nets (); n != c->end_nets (); ++n) {
|
||||
db::Net *net = n.operator-> ();
|
||||
if (glob.match (net->name ())) {
|
||||
res.push_back (net);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static std::vector<const db::Net *>
|
||||
nets_by_name_const (const db::Circuit *circuit, const std::string &name_pattern)
|
||||
{
|
||||
|
|
@ -1448,6 +1470,28 @@ nets_by_name_const (const db::Circuit *circuit, const std::string &name_pattern)
|
|||
return res;
|
||||
}
|
||||
|
||||
static std::vector<const db::Net *>
|
||||
nets_by_name_const_from_netlist (const db::Netlist *netlist, const std::string &name_pattern)
|
||||
{
|
||||
std::vector<const db::Net *> res;
|
||||
if (! netlist) {
|
||||
return res;
|
||||
}
|
||||
|
||||
tl::GlobPattern glob (name_pattern);
|
||||
glob.set_case_sensitive (netlist->is_case_sensitive ());
|
||||
for (auto c = netlist->begin_circuits (); c != netlist->end_circuits (); ++c) {
|
||||
for (auto n = c->begin_nets (); n != c->end_nets (); ++n) {
|
||||
const db::Net *net = n.operator-> ();
|
||||
if (glob.match (net->name ())) {
|
||||
res.push_back (net);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Class<db::Circuit> decl_dbCircuit (decl_dbNetlistObject, "db", "Circuit",
|
||||
gsi::method_ext ("create_pin", &create_pin, gsi::arg ("name"),
|
||||
"@brief Creates a new \\Pin object inside the circuit\n"
|
||||
|
|
@ -1966,7 +2010,7 @@ Class<db::Netlist> decl_dbNetlist ("db", "Netlist",
|
|||
"@brief Gets the circuit object for a given cell index (const version).\n"
|
||||
"If the cell index is not valid or no circuit is registered with this index, nil is returned."
|
||||
"\n\n"
|
||||
"This constness variant has been introduced in version 0.26.8"
|
||||
"This constness variant has been introduced in version 0.26.8."
|
||||
) +
|
||||
gsi::method ("circuit_by_name", (db::Circuit *(db::Netlist::*) (const std::string &)) &db::Netlist::circuit_by_name, gsi::arg ("name"),
|
||||
"@brief Gets the circuit object for a given name.\n"
|
||||
|
|
@ -1976,7 +2020,7 @@ Class<db::Netlist> decl_dbNetlist ("db", "Netlist",
|
|||
"@brief Gets the circuit object for a given name (const version).\n"
|
||||
"If the name is not a valid circuit name, nil is returned."
|
||||
"\n\n"
|
||||
"This constness variant has been introduced in version 0.26.8"
|
||||
"This constness variant has been introduced in version 0.26.8."
|
||||
) +
|
||||
gsi::method_ext ("circuits_by_name", &circuits_by_name, gsi::arg ("name_pattern"),
|
||||
"@brief Gets the circuit objects for a given name filter.\n"
|
||||
|
|
@ -1988,7 +2032,19 @@ Class<db::Netlist> decl_dbNetlist ("db", "Netlist",
|
|||
"@brief Gets the circuit objects for a given name filter (const version).\n"
|
||||
"The name filter is a glob pattern. This method will return all \\Circuit objects matching the glob pattern.\n"
|
||||
"\n\n"
|
||||
"This constness variant has been introduced in version 0.26.8"
|
||||
"This constness variant has been introduced in version 0.26.8."
|
||||
) +
|
||||
gsi::method_ext ("nets_by_name", &nets_by_name_from_netlist, gsi::arg ("name_pattern"),
|
||||
"@brief Gets the net objects for a given name filter.\n"
|
||||
"The name filter is a glob pattern. This method will return all \\Net objects matching the glob pattern.\n"
|
||||
"\n"
|
||||
"This method has been introduced in version 0.28.4.\n"
|
||||
) +
|
||||
gsi::method_ext ("nets_by_name", &nets_by_name_const_from_netlist, gsi::arg ("name_pattern"),
|
||||
"@brief Gets the net objects for a given name filter (const version).\n"
|
||||
"The name filter is a glob pattern. This method will return all \\Net objects matching the glob pattern.\n"
|
||||
"\n\n"
|
||||
"This constness variant has been introduced in version 0.28.4."
|
||||
) +
|
||||
gsi::iterator ("each_circuit_top_down", (db::Netlist::top_down_circuit_iterator (db::Netlist::*) ()) &db::Netlist::begin_top_down, (db::Netlist::top_down_circuit_iterator (db::Netlist::*) ()) &db::Netlist::end_top_down,
|
||||
"@brief Iterates over the circuits top-down\n"
|
||||
|
|
@ -2000,7 +2056,7 @@ Class<db::Netlist> decl_dbNetlist ("db", "Netlist",
|
|||
"Iterating top-down means the parent circuits come before the child circuits. "
|
||||
"The first \\top_circuit_count circuits are top circuits - i.e. those which are not referenced by other circuits."
|
||||
"\n\n"
|
||||
"This constness variant has been introduced in version 0.26.8"
|
||||
"This constness variant has been introduced in version 0.26.8."
|
||||
) +
|
||||
gsi::iterator ("each_circuit_bottom_up", (db::Netlist::bottom_up_circuit_iterator (db::Netlist::*) ()) &db::Netlist::begin_bottom_up, (db::Netlist::bottom_up_circuit_iterator (db::Netlist::*) ()) &db::Netlist::end_bottom_up,
|
||||
"@brief Iterates over the circuits bottom-up\n"
|
||||
|
|
@ -2012,7 +2068,7 @@ Class<db::Netlist> decl_dbNetlist ("db", "Netlist",
|
|||
"Iterating bottom-up means the parent circuits come after the child circuits. "
|
||||
"This is the basically the reverse order as delivered by \\each_circuit_top_down."
|
||||
"\n\n"
|
||||
"This constness variant has been introduced in version 0.26.8"
|
||||
"This constness variant has been introduced in version 0.26.8."
|
||||
) +
|
||||
gsi::method ("top_circuit_count", &db::Netlist::top_circuit_count,
|
||||
"@brief Gets the number of top circuits.\n"
|
||||
|
|
@ -2025,7 +2081,7 @@ Class<db::Netlist> decl_dbNetlist ("db", "Netlist",
|
|||
gsi::iterator ("each_circuit", (db::Netlist::const_circuit_iterator (db::Netlist::*) () const) &db::Netlist::begin_circuits, (db::Netlist::const_circuit_iterator (db::Netlist::*) () const) &db::Netlist::end_circuits,
|
||||
"@brief Iterates over the circuits of the netlist (const version)"
|
||||
"\n\n"
|
||||
"This constness variant has been introduced in version 0.26.8"
|
||||
"This constness variant has been introduced in version 0.26.8."
|
||||
) +
|
||||
gsi::method_ext ("add", &gsi::add_device_class, gsi::arg ("device_class"),
|
||||
"@brief Adds the device class to the netlist\n"
|
||||
|
|
@ -2046,7 +2102,7 @@ Class<db::Netlist> decl_dbNetlist ("db", "Netlist",
|
|||
"@brief Gets the device class for a given name (const version).\n"
|
||||
"If the name is not a valid device class name, nil is returned."
|
||||
"\n\n"
|
||||
"This constness variant has been introduced in version 0.26.8"
|
||||
"This constness variant has been introduced in version 0.26.8."
|
||||
) +
|
||||
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"
|
||||
|
|
@ -2054,7 +2110,7 @@ Class<db::Netlist> decl_dbNetlist ("db", "Netlist",
|
|||
gsi::iterator ("each_device_class", (db::Netlist::const_device_class_iterator (db::Netlist::*) () const) &db::Netlist::begin_device_classes, (db::Netlist::const_device_class_iterator (db::Netlist::*) () const) &db::Netlist::end_device_classes,
|
||||
"@brief Iterates over the device classes of the netlist (const version)"
|
||||
"\n\n"
|
||||
"This constness variant has been introduced in version 0.26.8"
|
||||
"This constness variant has been introduced in version 0.26.8."
|
||||
) +
|
||||
gsi::method ("to_s", &db::Netlist::to_string,
|
||||
"@brief Converts the netlist to a string representation.\n"
|
||||
|
|
|
|||
|
|
@ -3040,7 +3040,7 @@ Class<db::Region> decl_Region (decl_dbShapeCollection, "db", "Region",
|
|||
"\n"
|
||||
"This method has been introduced in version 0.27.\n"
|
||||
) +
|
||||
gsi::method_ext ("nets", &nets, gsi::arg ("extracted"), gsi::arg ("net_prop_name", tl::Variant (), "nil"), gsi::arg ("net_filter"),
|
||||
gsi::method_ext ("nets", &nets, gsi::arg ("extracted"), gsi::arg ("net_prop_name", tl::Variant (), "nil"), gsi::arg ("net_filter", (const std::vector<const db::Net *> *) (0), "nil"),
|
||||
"@brief Pulls the net shapes from a LayoutToNetlist database\n"
|
||||
"This method will pull the net shapes from the LayoutToNetlist database, provided that this "
|
||||
"region was an input to the netlist extraction.\n"
|
||||
|
|
|
|||
|
|
@ -634,6 +634,58 @@ END
|
|||
|
||||
end
|
||||
|
||||
def test_15_BuildNetShapes
|
||||
|
||||
l2n = RBA::LayoutToNetlist::new
|
||||
|
||||
input = File.join($ut_testsrc, "testdata", "algo", "l2n_reader_in.txt")
|
||||
l2n.read(input)
|
||||
|
||||
# build_all_nets using Region#net
|
||||
|
||||
metal1 = l2n.layer_by_name("metal1")
|
||||
|
||||
metal1_all = metal1.nets(l2n)
|
||||
metal1_vdd = metal1.nets(l2n, nil, l2n.netlist.nets_by_name("VDD"))
|
||||
metal1_all_wp = metal1.nets(l2n, 1)
|
||||
|
||||
ly = RBA::Layout::new
|
||||
tc = ly.create_cell("TOP")
|
||||
metal1_all.insert_into(ly, tc.cell_index, ly.layer(1, 0))
|
||||
metal1_vdd.insert_into(ly, tc.cell_index, ly.layer(2, 0))
|
||||
metal1_all_wp.insert_into(ly, tc.cell_index, ly.layer(3, 0))
|
||||
|
||||
si = tc.begin_shapes_rec(ly.layer(1, 0))
|
||||
assert_equal(si.each.count, 111)
|
||||
|
||||
si = tc.begin_shapes_rec(ly.layer(1, 0))
|
||||
si.each do |i|
|
||||
assert_equal(i.shape.prop_id, 0)
|
||||
end
|
||||
|
||||
# VDD net is smaller
|
||||
si = tc.begin_shapes_rec(ly.layer(2, 0))
|
||||
assert_equal(si.each.count, 20)
|
||||
assert_equal(tc.dbbox(ly.layer(2, 0)).to_s, "(-0.18,2.42;23.94,3.18)")
|
||||
|
||||
si = tc.begin_shapes_rec(ly.layer(3, 0))
|
||||
assert_equal(si.each.count, 111)
|
||||
|
||||
# properties are net names + ID
|
||||
si = tc.begin_shapes_rec(ly.layer(3, 0))
|
||||
net_names = []
|
||||
si.each do |i|
|
||||
ly.properties(i.shape.prop_id).each do |k,v|
|
||||
if k == 1
|
||||
net_names << v[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assert_equal(net_names.sort.uniq.join(";"), "$10;$11;$12;$13;$14;$15;$16;$17;$18;$19;$20;$21;$22;$5;$6;$7;$8;$9;FB;OSC;VDD;VSS")
|
||||
|
||||
end
|
||||
|
||||
def test_20_Antenna
|
||||
|
||||
# --- simple antenna check
|
||||
|
|
|
|||
Loading…
Reference in New Issue