Modified reader scheme for FOREIGNCELL

This commit is contained in:
Matthias Koefferlein 2020-04-24 23:21:27 +02:00
parent c7de542070
commit f6140055d6
15 changed files with 135 additions and 27 deletions

View File

@ -1839,10 +1839,15 @@ LayerPropertiesList::load (tl::XMLSource &stream, std::vector <lay::LayerPropert
lay::LayerPropertiesList properties_list;
layer_prop_list_structure.parse (stream, properties_list);
properties_lists.push_back (properties_list);
} catch (...) {
// "new" way
stream.reset ();
layer_prop_lists_structure.parse (stream, properties_lists);
} catch (tl::Exception &ex) {
try {
// "new" way
stream.reset ();
layer_prop_lists_structure.parse (stream, properties_lists);
} catch (tl::Exception &) {
// the first exception is likely to be the root cause, so let's rather throw this one
throw ex;
}
}
}

View File

@ -1145,7 +1145,7 @@ DEFImporter::read_components (std::list<std::pair<std::string, CellInstArray> >
std::string inst_name = get ();
std::string model = get ();
db::Cell *cell = m_lef_importer.macro_by_name (model);
std::pair<db::Cell *, db::Trans> ct = m_lef_importer.macro_by_name (model);
while (test ("+")) {
@ -1158,8 +1158,8 @@ DEFImporter::read_components (std::list<std::pair<std::string, CellInstArray> >
db::FTrans ft = get_orient (false /*mandatory*/);
db::Vector d = pt - m_lef_importer.macro_bbox_by_name (model).transformed (ft).lower_left ();
if (cell) {
db::CellInstArray inst (db::CellInst (cell->cell_index ()), db::Trans (ft.rot (), d));
if (ct.first) {
db::CellInstArray inst (db::CellInst (ct.first->cell_index ()), db::Trans (ft.rot (), d) * ct.second);
instances.push_back (std::make_pair (inst_name, inst));
} else {
warn (tl::to_string (tr ("Macro not found in LEF file: ")) + model);

View File

@ -105,14 +105,14 @@ LEFImporter::layer_width (const std::string &layer, const std::string &nondefaul
}
}
db::Cell *
std::pair<db::Cell *, db::Trans>
LEFImporter::macro_by_name (const std::string &name) const
{
std::map<std::string, db::Cell *>::const_iterator m = m_macros_by_name.find (name);
std::map<std::string, std::pair<db::Cell *, db::Trans> >::const_iterator m = m_macros_by_name.find (name);
if (m != m_macros_by_name.end ()) {
return m->second;
} else {
return 0;
return std::make_pair ((db::Cell *) 0, db::Trans ());
}
}
@ -726,9 +726,9 @@ LEFImporter::read_macro (Layout &layout)
std::string mn = get ();
set_cellname (mn);
db::Cell &cell = layout.cell (layout.add_cell (mn.c_str ()));
m_macros_by_name.insert (std::make_pair (mn, &cell));
db::Cell &cell = layout.cell (layout.add_cell ());
db::Cell *foreign_cell = 0;
db::Trans foreign_trans;
db::Point origin;
db::Vector size;
@ -811,13 +811,12 @@ LEFImporter::read_macro (Layout &layout)
} else if (test ("FOREIGN")) {
std::string cn = get ();
if (cn == mn) {
// rename out macro placeholder cell so we don't create a recursive hierarchy
layout.rename_cell (cell.cell_index (), ("LEF_" + mn).c_str ());
if (foreign_cell) {
error ("Duplicate FOREIGN definition");
}
std::string cn = get ();
db::cell_index_type ci;
std::pair<bool, db::cell_index_type> c = layout.cell_by_name (cn.c_str ());
if (c.first) {
@ -836,7 +835,8 @@ LEFImporter::read_macro (Layout &layout)
expect (";");
cell.insert (db::CellInstArray (db::CellInst (ci), (db::Trans (origin - db::Point ()) * db::Trans (ft)).inverted ()));
foreign_cell = &layout.cell (ci);
foreign_trans = (db::Trans (origin - db::Point ()) * db::Trans (ft)).inverted ();
} else if (test ("OBS")) {
@ -851,9 +851,26 @@ LEFImporter::read_macro (Layout &layout)
}
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Outline);
if (dl.first) {
cell.shapes (dl.second).insert (db::Box (-origin, -origin + size));
if (! foreign_cell) {
// actually implement the real cell
layout.rename_cell (cell.cell_index (), mn.c_str ());
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Outline);
if (dl.first) {
cell.shapes (dl.second).insert (db::Box (-origin, -origin + size));
}
m_macros_by_name.insert (std::make_pair (mn, std::make_pair (&cell, db::Trans ())));
} else {
// use FOREIGN cell instead of new one
layout.delete_cell (cell.cell_index ());
m_macros_by_name.insert (std::make_pair (mn, std::make_pair (foreign_cell, foreign_trans)));
}
m_macro_bboxes_by_name.insert (std::make_pair (mn, db::Box (-origin, -origin + size)));

View File

@ -63,7 +63,7 @@ public:
* Returns 0 if the name is not a valid macro name. Otherwise it returns the pointer
* to the corresponding db::Cell object.
*/
db::Cell *macro_by_name (const std::string &macro_name) const;
std::pair<db::Cell *, db::Trans> macro_by_name (const std::string &macro_name) const;
/**
* @brief Get the cell bbox for the given macro name
@ -125,7 +125,7 @@ private:
std::map<std::string, std::pair<double, double> > m_default_widths;
std::map<std::string, double> m_default_ext;
std::map<std::string, std::pair<double, double> > m_min_widths;
std::map<std::string, db::Cell *> m_macros_by_name;
std::map<std::string, std::pair<db::Cell *, db::Trans> > m_macros_by_name;
std::map<std::string, db::Box> m_macro_bboxes_by_name;
std::map<std::string, ViaDesc> m_vias;
std::set<std::string> m_routing_layers, m_cut_layers;

View File

@ -334,15 +334,18 @@ TEST(108_scanchain)
TEST(109_foreigncell)
{
run_test (_this, "foreigncell", "gds:foreign.gds+lef:in_tech.lef+lef:in.lef", "au.oas.gz", default_options (), false);
run_test (_this, "foreigncell", "gds:foreign.gds+lef:in_tech.lef+lef:in.lef+def:in.def", "au.oas.gz", default_options (), false);
}
TEST(110_lefpins)
{
db::LEFDEFReaderOptions options = default_options ();
options.set_produce_lef_pins (false);
run_test (_this, "foreigncell", "gds:foreign.gds+lef:in_tech.lef+lef:in.lef", "au_no_lefpins.oas.gz", options, false);
run_test (_this, "lefpins", "lef:in_tech.lef+lef:in.lef+def:in.def", "au_no_lefpins.oas.gz", options, false);
options.set_produce_lef_pins (true);
options.set_lef_pins_datatype (10);
options.set_lef_pins_suffix (".LEFPIN");
run_test (_this, "foreigncell", "gds:foreign.gds+lef:in_tech.lef+lef:in.lef", "au_lefpins_mapped.oas.gz", options, false);
run_test (_this, "lefpins", "lef:in_tech.lef+lef:in.lef+def:in.def", "au_lefpins_mapped.oas.gz", options, false);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

17
testdata/lefdef/foreigncell/in.def vendored Normal file
View File

@ -0,0 +1,17 @@
VERSION 5.8 ;
DIVIDERCHAR "/" ;
BUSBITCHARS "[]" ;
DESIGN foreigncells ;
UNITS DISTANCE MICRONS 1000 ;
DIEAREA ( 0 0 ) ( 1000 2000 ) ;
COMPONENTS 3 ;
- macro1 macro1 + PLACED ( 0 0 ) N ;
- macro2 macro2 + PLACED ( 0 500 ) N ;
- macro3 macro3 + PLACED ( 0 1000 ) N ;
END COMPONENTS
END DESIGN

Binary file not shown.

Binary file not shown.

15
testdata/lefdef/lefpins/in.def vendored Normal file
View File

@ -0,0 +1,15 @@
VERSION 5.8 ;
DIVIDERCHAR "/" ;
BUSBITCHARS "[]" ;
DESIGN foreigncells ;
UNITS DISTANCE MICRONS 1000 ;
DIEAREA ( 0 0 ) ( 1000 2000 ) ;
COMPONENTS 3 ;
- macro1 macro1 + PLACED ( 0 0 ) N ;
END COMPONENTS
END DESIGN

15
testdata/lefdef/lefpins/in.lef vendored Normal file
View File

@ -0,0 +1,15 @@
MACRO macro1
CLASS CORE ;
ORIGIN 0.000 0.000 ;
SIZE 0.384 BY 0.480 ;
PIN Z
PORT
LAYER M1 ;
RECT 0.306 0.357 0.318 0.403 ;
RECT 0.318 0.115 0.352 0.403 ;
VIA 0.336 0.167 square ;
VIA 0.336 0.351 square ;
END
END Z
END macro1

36
testdata/lefdef/lefpins/in_tech.lef vendored Normal file
View File

@ -0,0 +1,36 @@
LAYER OD
TYPE IMPLANT ;
END OD
LAYER VTS_N
TYPE IMPLANT ;
END VTS_N
LAYER VTS_P
TYPE IMPLANT ;
END VTS_P
LAYER M0OD
TYPE IMPLANT ;
END M0OD
LAYER M0PO
TYPE MASTERSLICE ;
END M0PO
LAYER VIA0
TYPE CUT ;
END VIA0
LAYER M1
TYPE MASTERSLICE ;
END M1
LAYER VIA1
TYPE CUT ;
END VIA1
LAYER M2
TYPE MASTERSLICE ;
END M2
VIA square
LAYER M0PO ;
RECT -0.006 -0.006 0.006 0.006 ;
LAYER VIA0 ;
RECT -0.006 -0.006 0.006 0.006 ;
LAYER M1 ;
RECT -0.006 -0.006 0.006 0.006 ;
END square