| 66 | } |
| 67 | |
| 68 | std::pair<bool, db::InstElement> |
| 69 | SpecificInst::to_inst_element (const db::Layout &layout, const db::Cell &parent_cell) const |
| 70 | { |
| 71 | // first, we must find the cell by name |
| 72 | std::pair<bool, db::cell_index_type> ci = layout.cell_by_name (cell_name.c_str ()); |
| 73 | if (! ci.first) { |
| 74 | return std::make_pair(false, db::InstElement ()); |
| 75 | } |
| 76 | |
| 77 | db::cell_index_type cell_index = ci.second; |
| 78 | |
| 79 | for (db::Cell::const_iterator inst = parent_cell.begin (); ! inst.at_end (); ++inst) { |
| 80 | |
| 81 | // use fuzzy comparison to find the base instance |
| 82 | if (inst->cell_index () == cell_index && inst->complex_trans ().equal (trans)) { |
| 83 | |
| 84 | // if a matching instance is found, look for the matching array instance. |
| 85 | // HINT: this can be optimized somewhat by inverting the transformation to a array instance |
| 86 | // directly rather than iterating. |
| 87 | for (db::CellInstArray::iterator ainst = inst->begin (); ! ainst.at_end (); ++ainst) { |
| 88 | if (*ainst == array_trans) { |
| 89 | |
| 90 | // a matching instance/array instance is found: deliver this |
| 91 | db::InstElement el; |
| 92 | el.inst_ptr = *inst; |
| 93 | el.array_inst = ainst; |
| 94 | return std::make_pair (true, el); |
| 95 | |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | } |
| 100 | |
| 101 | } |
| 102 | |
| 103 | // nothing found. |
| 104 | return std::make_pair(false, db::InstElement ()); |
| 105 | } |
| 106 | |
| 107 | std::string |
| 108 | SpecificInst::trans_str () const |
no test coverage detected