mirror of https://github.com/KLayout/klayout.git
WIP: some more refactoring.
This commit is contained in:
parent
2171b98bd8
commit
f5071d3254
|
|
@ -435,14 +435,10 @@ static std::string net_name (const db::Net *net)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @@@ TODO: refactor. This is inefficient. Give an ID automatically.
|
static std::string device_name (const db::Device &device)
|
||||||
static std::string device_name (const db::Device &device, const db::Circuit &circuit)
|
|
||||||
{
|
{
|
||||||
if (device.name ().empty ()) {
|
if (device.name ().empty ()) {
|
||||||
int id = 1;
|
return "$" + tl::to_string (device.id ());
|
||||||
for (db::Circuit::const_device_iterator d = circuit.begin_devices (); d != circuit.end_devices () && d.operator-> () != &device; ++d, ++id)
|
|
||||||
;
|
|
||||||
return "$" + tl::to_string (id);
|
|
||||||
} else {
|
} else {
|
||||||
return device.name ();
|
return device.name ();
|
||||||
}
|
}
|
||||||
|
|
@ -461,14 +457,11 @@ static std::string subcircuit_name (const db::SubCircuit &subcircuit, const db::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @@@ TODO: refactor. This is inefficient. Give an ID automatically.
|
static std::string pin_name (const db::Pin &pin)
|
||||||
static std::string pin_name (const db::Pin &pin, const db::Circuit &circuit)
|
|
||||||
{
|
{
|
||||||
if (pin.name ().empty ()) {
|
if (pin.name ().empty ()) {
|
||||||
int id = 1;
|
// the pin ID is zero-based and essentially the index, so we add 1 to make it compliant with the other IDs
|
||||||
for (db::Circuit::const_pin_iterator p = circuit.begin_pins (); p != circuit.end_pins () && p.operator-> () != &pin; ++p, ++id)
|
return "$" + tl::to_string (pin.id () + 1);
|
||||||
;
|
|
||||||
return "$" + tl::to_string (id);
|
|
||||||
} else {
|
} else {
|
||||||
return pin.name ();
|
return pin.name ();
|
||||||
}
|
}
|
||||||
|
|
@ -521,7 +514,7 @@ static std::string netlist2string (const db::Netlist &nl)
|
||||||
if (! ps.empty ()) {
|
if (! ps.empty ()) {
|
||||||
ps += ",";
|
ps += ",";
|
||||||
}
|
}
|
||||||
ps += pin_name (*p, *c) + "=" + net_name (c->net_for_pin (p->id ()));
|
ps += pin_name (*p) + "=" + net_name (c->net_for_pin (p->id ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
res += std::string ("Circuit ") + c->name () + " (" + ps + "):\n";
|
res += std::string ("Circuit ") + c->name () + " (" + ps + "):\n";
|
||||||
|
|
@ -541,7 +534,7 @@ static std::string netlist2string (const db::Netlist &nl)
|
||||||
}
|
}
|
||||||
ts += t->name () + "=" + net_name (d->net_for_terminal (t->id ()));
|
ts += t->name () + "=" + net_name (d->net_for_terminal (t->id ()));
|
||||||
}
|
}
|
||||||
res += std::string (" D") + d->device_class ()->name () + " " + device_name (*d, *c) + " (" + ts + ")\n";
|
res += std::string (" D") + d->device_class ()->name () + " " + device_name (*d) + " (" + ts + ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (db::Circuit::const_sub_circuit_iterator sc = c->begin_sub_circuits (); sc != c->end_sub_circuits (); ++sc) {
|
for (db::Circuit::const_sub_circuit_iterator sc = c->begin_sub_circuits (); sc != c->end_sub_circuits (); ++sc) {
|
||||||
|
|
@ -552,7 +545,7 @@ static std::string netlist2string (const db::Netlist &nl)
|
||||||
ps += ",";
|
ps += ",";
|
||||||
}
|
}
|
||||||
const db::Pin &pin = *p;
|
const db::Pin &pin = *p;
|
||||||
ps += pin_name (pin, *subcircuit.circuit ()) + "=" + net_name (subcircuit.net_for_pin (pin.id ()));
|
ps += pin_name (pin) + "=" + net_name (subcircuit.net_for_pin (pin.id ()));
|
||||||
}
|
}
|
||||||
res += std::string (" X") + sc->circuit ()->name () + " " + subcircuit_name (*sc, *c) + " (" + ps + ")\n";
|
res += std::string (" X") + sc->circuit ()->name () + " " + subcircuit_name (*sc, *c) + " (" + ps + ")\n";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue