mirror of https://github.com/KLayout/klayout.git
WIP: some refactoring.
This commit is contained in:
parent
dda7ee8b60
commit
675a96eb9e
|
|
@ -194,16 +194,15 @@ void Device::add_others_terminals (unsigned int this_terminal, db::Device *other
|
|||
std::map<unsigned int, std::vector<OtherTerminalRef> >::const_iterator ot = other->m_reconnected_terminals.find (other_terminal);
|
||||
if (ot == other->m_reconnected_terminals.end ()) {
|
||||
|
||||
terminals.push_back (OtherTerminalRef (other->device_abstract (), other->position () - position (), other_terminal));
|
||||
terminals.push_back (OtherTerminalRef (other_abstracts ().size (), other_terminal));
|
||||
|
||||
} else {
|
||||
|
||||
size_t n = terminals.size ();
|
||||
terminals.insert (terminals.end (), ot->second.begin (), ot->second.end ());
|
||||
|
||||
db::DVector d = other->position () - position ();
|
||||
while (n < terminals.size ()) {
|
||||
terminals [n].offset += d;
|
||||
terminals [n].device_index += other_abstracts ().size ();
|
||||
++n;
|
||||
}
|
||||
|
||||
|
|
@ -218,7 +217,7 @@ void Device::init_terminal_routes ()
|
|||
|
||||
size_t n = device_class ()->terminal_definitions ().size ();
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
m_reconnected_terminals [i].push_back (OtherTerminalRef (device_abstract (), db::DVector (), i));
|
||||
m_reconnected_terminals [i].push_back (OtherTerminalRef (0, i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -285,12 +284,6 @@ void Device::translate_device_abstracts (const std::map<const DeviceAbstract *,
|
|||
for (std::vector<std::pair<const db::DeviceAbstract *, db::DVector> >::iterator a = m_other_abstracts.begin (); a != m_other_abstracts.end (); ++a) {
|
||||
a->first = map_da (map, a->first);
|
||||
}
|
||||
|
||||
for (std::map<unsigned int, std::vector<OtherTerminalRef> >::iterator t = m_reconnected_terminals.begin (); t != m_reconnected_terminals.end (); ++t) {
|
||||
for (std::vector<OtherTerminalRef>::iterator r = t->second.begin (); r != t->second.end (); ++r) {
|
||||
r->device_abstract = map_da (map, r->device_abstract);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,14 +60,13 @@ public:
|
|||
*/
|
||||
struct OtherTerminalRef
|
||||
{
|
||||
OtherTerminalRef (const db::DeviceAbstract *_device_abstract, const db::DVector &_offset, unsigned int _other_terminal_id)
|
||||
: device_abstract (_device_abstract), offset (_offset), other_terminal_id (_other_terminal_id)
|
||||
OtherTerminalRef (size_t _device_index, unsigned int _other_terminal_id)
|
||||
: device_index (_device_index), other_terminal_id (_other_terminal_id)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
const db::DeviceAbstract *device_abstract;
|
||||
db::DVector offset;
|
||||
size_t device_index;
|
||||
unsigned int other_terminal_id;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -530,9 +530,6 @@ LayoutToNetlistStandardReader::read_device (db::LayoutToNetlist *l2n, db::Circui
|
|||
double dbu = l2n->internal_layout ()->dbu ();
|
||||
db::VCplxTrans dbu_inv (1.0 / dbu);
|
||||
|
||||
std::map<std::pair<const db::DeviceAbstract *, db::Vector>, size_t> abstracts;
|
||||
abstracts [std::make_pair (dm, db::Vector ())] = 0;
|
||||
|
||||
size_t max_tid = 0;
|
||||
|
||||
while (br) {
|
||||
|
|
@ -559,7 +556,6 @@ LayoutToNetlistStandardReader::read_device (db::LayoutToNetlist *l2n, db::Circui
|
|||
|
||||
db::DeviceAbstract *da = device_model_by_name (l2n->netlist (), n);
|
||||
|
||||
abstracts [std::make_pair (da, db::Vector (dx, dy))] = device->other_abstracts ().size () + 1;
|
||||
device->other_abstracts ().push_back (std::make_pair (da, db::DVector (dbu * dx, dbu * dy)));
|
||||
|
||||
} else if (test (skeys::connect_key) || test (lkeys::connect_key)) {
|
||||
|
|
@ -581,10 +577,7 @@ LayoutToNetlistStandardReader::read_device (db::LayoutToNetlist *l2n, db::Circui
|
|||
size_t touter_id = terminal_id (dm->device_class (), touter);
|
||||
size_t tinner_id = terminal_id (dm->device_class (), tinner);
|
||||
|
||||
const db::DeviceAbstract *da = device_comp_index > 0 ? device->other_abstracts () [device_comp_index - 1].first : dm;
|
||||
db::DVector da_offset = device_comp_index > 0 ? device->other_abstracts () [device_comp_index - 1].second : db::DVector ();
|
||||
|
||||
device->reconnected_terminals () [touter_id].push_back (db::Device::OtherTerminalRef (da, da_offset, tinner_id));
|
||||
device->reconnected_terminals () [touter_id].push_back (db::Device::OtherTerminalRef (size_t (device_comp_index), tinner_id));
|
||||
|
||||
} else if (test (skeys::terminal_key) || test (lkeys::terminal_key)) {
|
||||
|
||||
|
|
@ -673,26 +666,20 @@ LayoutToNetlistStandardReader::read_device (db::LayoutToNetlist *l2n, db::Circui
|
|||
if (tr) {
|
||||
|
||||
for (std::vector<db::Device::OtherTerminalRef>::const_iterator i = tr->begin (); i != tr->end (); ++i) {
|
||||
|
||||
db::Vector offset = dbu_inv * i->offset;
|
||||
|
||||
std::map<std::pair<const db::DeviceAbstract *, db::Vector>, size_t>::const_iterator a = abstracts.find (std::make_pair (i->device_abstract, offset));
|
||||
if (a != abstracts.end () && a->second < insts.size ()) {
|
||||
Connections ref (net->cluster_id (), i->device_abstract->cluster_id_for_terminal (i->other_terminal_id));
|
||||
connections [insts [a->second]].push_back (ref);
|
||||
const db::DeviceAbstract *da = dm;
|
||||
if (i->device_index > 0) {
|
||||
da = device->other_abstracts () [i->device_index - 1].first;
|
||||
}
|
||||
|
||||
Connections ref (net->cluster_id (), da->cluster_id_for_terminal (i->other_terminal_id));
|
||||
connections [insts [i->device_index]].push_back (ref);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
std::map<std::pair<const db::DeviceAbstract *, db::Vector>, size_t>::const_iterator a = abstracts.find (std::make_pair (dm, db::Vector ()));
|
||||
if (a != abstracts.end () && a->second < insts.size ()) {
|
||||
Connections ref (net->cluster_id (), dm->cluster_id_for_terminal (tid));
|
||||
connections [insts [a->second]].push_back (ref);
|
||||
}
|
||||
Connections ref (net->cluster_id (), dm->cluster_id_for_terminal (tid));
|
||||
connections [insts [0]].push_back (ref);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -500,14 +500,10 @@ void std_writer_impl<Keys>::write (const db::LayoutToNetlist *l2n, const db::Dev
|
|||
tl_assert (device.device_abstract () != 0);
|
||||
*mp_stream << " " << tl::to_word_or_quoted_string (device.device_abstract ()->name ()) << endl;
|
||||
|
||||
std::map<std::pair<const db::DeviceAbstract *, db::Vector>, size_t> abstracts;
|
||||
abstracts.insert (std::make_pair (std::make_pair (device.device_abstract (), db::Vector ()), 0));
|
||||
|
||||
const std::vector<std::pair<const db::DeviceAbstract *, db::DVector> > &other_abstracts = device.other_abstracts ();
|
||||
for (std::vector<std::pair<const db::DeviceAbstract *, db::DVector> >::const_iterator a = other_abstracts.begin (); a != other_abstracts.end (); ++a) {
|
||||
|
||||
db::Vector pos = dbu_inv * a->second;
|
||||
abstracts.insert (std::make_pair (std::make_pair (a->first, pos), a - other_abstracts.begin () + 1));
|
||||
|
||||
*mp_stream << " " << Keys::device_key << "(" << tl::to_word_or_quoted_string (a->first->name ()) << " " << pos.x () << " " << pos.y () << ")" << endl;
|
||||
|
||||
|
|
@ -517,13 +513,7 @@ void std_writer_impl<Keys>::write (const db::LayoutToNetlist *l2n, const db::Dev
|
|||
for (std::map<unsigned int, std::vector<db::Device::OtherTerminalRef> >::const_iterator t = reconnected_terminals.begin (); t != reconnected_terminals.end (); ++t) {
|
||||
|
||||
for (std::vector<db::Device::OtherTerminalRef>::const_iterator c = t->second.begin (); c != t->second.end (); ++c) {
|
||||
|
||||
db::Vector pos = dbu_inv * c->offset;
|
||||
std::map<std::pair<const db::DeviceAbstract *, db::Vector>, size_t>::const_iterator a = abstracts.find (std::make_pair (c->device_abstract, pos));
|
||||
tl_assert (a != abstracts.end ());
|
||||
|
||||
*mp_stream << " " << Keys::connect_key << "(" << a->second << " " << tl::to_word_or_quoted_string (td [t->first].name ()) << " " << tl::to_word_or_quoted_string (td [c->other_terminal_id].name ()) << ")" << endl;
|
||||
|
||||
*mp_stream << " " << Keys::connect_key << "(" << c->device_index << " " << tl::to_word_or_quoted_string (td [t->first].name ()) << " " << tl::to_word_or_quoted_string (td [c->other_terminal_id].name ()) << ")" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue