mirror of https://github.com/KLayout/klayout.git
WIP: netlist browser.
This commit is contained in:
parent
5b8a9cf49c
commit
969d4e80cd
|
|
@ -466,7 +466,7 @@ NetlistBrowserModel::data (const QModelIndex &index, int role) const
|
|||
return tl::to_qstring (circuit->name ());
|
||||
}
|
||||
|
||||
} else if (is_id_circuit_pin (id) || is_id_circuit_net_pin (id)) {
|
||||
} else if (is_id_circuit_pin (id) || is_id_circuit_net_pin (id) || is_id_circuit_subcircuit_pin (id)) {
|
||||
|
||||
db::Pin *pin = pin_from_id (id);
|
||||
if (pin) {
|
||||
|
|
@ -491,6 +491,16 @@ NetlistBrowserModel::data (const QModelIndex &index, int role) const
|
|||
return tl::to_qstring (device->expanded_name ());
|
||||
}
|
||||
|
||||
} else if (is_id_circuit_device_terminal (id)) {
|
||||
|
||||
db::Device *device = device_from_id (id);
|
||||
if (device && device->device_class ()) {
|
||||
size_t terminal = circuit_device_terminal_index_from_id (id);
|
||||
if (device->device_class ()->terminal_definitions ().size () > terminal) {
|
||||
return tl::to_qstring (device->device_class ()->terminal_definitions () [terminal].name ());
|
||||
}
|
||||
}
|
||||
|
||||
} else if (is_id_circuit_subcircuit (id)) {
|
||||
|
||||
db::SubCircuit *subcircuit = subcircuit_from_id (id);
|
||||
|
|
@ -515,7 +525,7 @@ NetlistBrowserModel::data (const QModelIndex &index, int role) const
|
|||
} else if (is_id_circuit_net_subcircuit_pin_others (id)) {
|
||||
|
||||
const db::NetSubcircuitPinRef *ref = net_pinref_from_id (id);
|
||||
size_t other_index = circuit_net_device_terminal_other_index_from_id (id);
|
||||
size_t other_index = circuit_net_subcircuit_pin_other_index_from_id (id);
|
||||
|
||||
if (ref && ref->pin () && ref->subcircuit () && ref->subcircuit ()->circuit_ref () && ref->subcircuit ()->circuit_ref ()->pin_by_id (other_index)) {
|
||||
|
||||
|
|
@ -930,8 +940,17 @@ NetlistBrowserModel::pin_from_id (void *id) const
|
|||
|
||||
} else {
|
||||
|
||||
db::Circuit *circuit = circuit_from_id (id);
|
||||
size_t index = circuit_pin_index_from_id (id);
|
||||
db::Circuit *circuit;
|
||||
size_t index;
|
||||
|
||||
if (is_id_circuit_subcircuit_pin (id)) {
|
||||
db::SubCircuit *subcircuit = subcircuit_from_id (id);
|
||||
circuit = subcircuit->circuit_ref ();
|
||||
index = circuit_subcircuit_pin_index_from_id (id);
|
||||
} else {
|
||||
circuit = circuit_from_id (id);
|
||||
index = circuit_pin_index_from_id (id);
|
||||
}
|
||||
|
||||
std::map<db::Circuit *, std::map<size_t, db::Pin *> >::iterator cc = m_pin_by_circuit_and_index.find (circuit);
|
||||
if (cc == m_pin_by_circuit_and_index.end ()) {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ TEST (1)
|
|||
EXPECT_EQ (model->hasChildren (inv2PinOutIndexNet), false);
|
||||
EXPECT_EQ (model->rowCount (inv2PinOutIndexNet), 0);
|
||||
|
||||
// NOUT net has 1 pin, 2 devices
|
||||
// NOUT net has 1 pin, 2 devices, 0 subcircuits
|
||||
QModelIndex inv2NOutIndex = model->index (7, 0, inv2Index);
|
||||
EXPECT_EQ (model->hasChildren (inv2NOutIndex), true);
|
||||
EXPECT_EQ (model->rowCount (inv2NOutIndex), 3);
|
||||
|
|
@ -105,7 +105,58 @@ TEST (1)
|
|||
EXPECT_EQ (model->hasChildren (inv2NOutDeviceIndex), true);
|
||||
EXPECT_EQ (model->rowCount (inv2NOutDeviceIndex), 3);
|
||||
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (0, 0, inv2NOutDeviceIndex), Qt::DisplayRole).toString ()), "S");
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (1, 0, inv2NOutDeviceIndex), Qt::DisplayRole).toString ()), "G");
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (2, 0, inv2NOutDeviceIndex), Qt::DisplayRole).toString ()), "D");
|
||||
|
||||
QModelIndex inv2NOutDeviceGateIndex = model->index (1, 0, inv2NOutDeviceIndex);
|
||||
EXPECT_EQ (model->hasChildren (inv2NOutDeviceGateIndex), false);
|
||||
EXPECT_EQ (model->rowCount (inv2NOutDeviceGateIndex), 0);
|
||||
|
||||
// FB net has 0 pin, 0 devices, 2 subcircuits
|
||||
QModelIndex ringoFbIndex = model->index (0, 0, ringoIndex);
|
||||
EXPECT_EQ (model->hasChildren (ringoFbIndex), true);
|
||||
EXPECT_EQ (model->rowCount (ringoFbIndex), 2);
|
||||
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (0, 0, ringoFbIndex), Qt::DisplayRole).toString ()), "$1");
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (1, 0, ringoFbIndex), Qt::DisplayRole).toString ()), "IN");
|
||||
|
||||
QModelIndex ringoFbSubcircuit2Index = model->index (1, 0, ringoFbIndex);
|
||||
EXPECT_EQ (model->hasChildren (ringoFbSubcircuit2Index), true);
|
||||
EXPECT_EQ (model->rowCount (ringoFbSubcircuit2Index), 5);
|
||||
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (0, 0, ringoFbSubcircuit2Index), Qt::DisplayRole).toString ()), "IN");
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (1, 0, ringoFbSubcircuit2Index), Qt::DisplayRole).toString ()), "$1");
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (2, 0, ringoFbSubcircuit2Index), Qt::DisplayRole).toString ()), "OUT");
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (3, 0, ringoFbSubcircuit2Index), Qt::DisplayRole).toString ()), "$3");
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (4, 0, ringoFbSubcircuit2Index), Qt::DisplayRole).toString ()), "$4");
|
||||
|
||||
QModelIndex ringoFbSubcircuit2InPinIndex = model->index (1, 0, ringoFbSubcircuit2Index);
|
||||
EXPECT_EQ (model->hasChildren (ringoFbSubcircuit2InPinIndex), false);
|
||||
EXPECT_EQ (model->rowCount (ringoFbSubcircuit2InPinIndex), 0);
|
||||
|
||||
// Subcircuit 1 of RINGO has 5 pins
|
||||
|
||||
QModelIndex ringoSubcircuit1Index = model->index (12, 0, ringoIndex);
|
||||
EXPECT_EQ (model->hasChildren (ringoSubcircuit1Index), true);
|
||||
EXPECT_EQ (model->rowCount (ringoSubcircuit1Index), 5);
|
||||
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (2, 0, ringoSubcircuit1Index), Qt::DisplayRole).toString ()), "OUT");
|
||||
|
||||
QModelIndex ringoSubcircuit1OutPinIndex = model->index (2, 0, ringoSubcircuit1Index);
|
||||
EXPECT_EQ (model->hasChildren (ringoSubcircuit1OutPinIndex), false);
|
||||
EXPECT_EQ (model->rowCount (ringoSubcircuit1OutPinIndex), 0);
|
||||
|
||||
// Device 1 of INV2 has 3 pins
|
||||
|
||||
QModelIndex inv2Device1Index = model->index (10, 0, inv2Index);
|
||||
EXPECT_EQ (model->hasChildren (inv2Device1Index), true);
|
||||
EXPECT_EQ (model->rowCount (inv2Device1Index), 3);
|
||||
|
||||
EXPECT_EQ (tl::to_string (model->data (model->index (1, 0, inv2Device1Index), Qt::DisplayRole).toString ()), "G");
|
||||
|
||||
QModelIndex inv2Device1GateIndex = model->index (1, 0, inv2Device1Index);
|
||||
EXPECT_EQ (model->hasChildren (inv2Device1GateIndex), false);
|
||||
EXPECT_EQ (model->rowCount (inv2Device1GateIndex), 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue