diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc index 0cb8fc40d..cbe6681f5 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc @@ -827,17 +827,19 @@ LEFImporter::read_macro (Layout &layout) layout.cell (ci).set_ghost_cell (true); } - db::Point origin; + db::Point vec; db::FTrans ft; if (! peek (";")) { - origin = get_point (1.0 / layout.dbu ()); + vec = get_point (1.0 / layout.dbu ()); ft = get_orient (true); } expect (";"); foreign_cell = &layout.cell (ci); - foreign_trans = (db::Trans (origin - db::Point ()) * db::Trans (ft)).inverted (); + // What is the definition of the FOREIGN transformation? + // Guessing: this transformation moves the lower-left origin to 0,0 + foreign_trans = db::Trans (db::Point () - vec) * db::Trans (ft); foreign_name = cn; } else if (test ("OBS")) { @@ -899,7 +901,7 @@ LEFImporter::read_macro (Layout &layout) cell.clear_insts (); - cell.insert (db::CellInstArray (db::CellInst (foreign_cell->cell_index ()), foreign_trans)); + cell.insert (db::CellInstArray (db::CellInst (foreign_cell->cell_index ()), db::Trans (db::Point () - origin) * foreign_trans)); m_macros_by_name.insert (std::make_pair (mn, std::make_pair (&cell, db::Trans ()))); } else { @@ -907,7 +909,7 @@ LEFImporter::read_macro (Layout &layout) // 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_macros_by_name.insert (std::make_pair (mn, std::make_pair (foreign_cell, db::Trans (db::Point () - origin) * foreign_trans))); } diff --git a/testdata/lefdef/foreigncell/au.oas.gz b/testdata/lefdef/foreigncell/au.oas.gz index 9c3843f9b..4aedac249 100644 Binary files a/testdata/lefdef/foreigncell/au.oas.gz and b/testdata/lefdef/foreigncell/au.oas.gz differ diff --git a/testdata/lefdef/foreigncell/au_always_foreign.oas.gz b/testdata/lefdef/foreigncell/au_always_foreign.oas.gz index 587178ba3..4aedac249 100644 Binary files a/testdata/lefdef/foreigncell/au_always_foreign.oas.gz and b/testdata/lefdef/foreigncell/au_always_foreign.oas.gz differ diff --git a/testdata/lefdef/foreigncell/au_default.oas.gz b/testdata/lefdef/foreigncell/au_default.oas.gz index bc6f4204d..6362bf9f1 100644 Binary files a/testdata/lefdef/foreigncell/au_default.oas.gz and b/testdata/lefdef/foreigncell/au_default.oas.gz differ diff --git a/testdata/lefdef/foreigncell/au_ignore_foreign.oas.gz b/testdata/lefdef/foreigncell/au_ignore_foreign.oas.gz index 44831e8e5..c9dd21723 100644 Binary files a/testdata/lefdef/foreigncell/au_ignore_foreign.oas.gz and b/testdata/lefdef/foreigncell/au_ignore_foreign.oas.gz differ diff --git a/testdata/lefdef/foreigncell/foreign.gds b/testdata/lefdef/foreigncell/foreign.gds index dce50b5e8..11d3f869e 100644 Binary files a/testdata/lefdef/foreigncell/foreign.gds and b/testdata/lefdef/foreigncell/foreign.gds differ diff --git a/testdata/lefdef/foreigncell/in.def b/testdata/lefdef/foreigncell/in.def index 04045ef5f..7cf1c70b3 100644 --- a/testdata/lefdef/foreigncell/in.def +++ b/testdata/lefdef/foreigncell/in.def @@ -9,7 +9,7 @@ DIEAREA ( 0 0 ) ( 1000 2000 ) ; COMPONENTS 3 ; - macro1 macro1 + PLACED ( 0 0 ) N ; - - macro2 macro2 + PLACED ( 0 500 ) N ; + - macro2 macro2 + PLACED ( 0 500 ) E ; - macro3 macro3 + PLACED ( 0 1000 ) N ; END COMPONENTS diff --git a/testdata/lefdef/foreigncell/in.lef b/testdata/lefdef/foreigncell/in.lef index d796cba46..99bd74c57 100644 --- a/testdata/lefdef/foreigncell/in.lef +++ b/testdata/lefdef/foreigncell/in.lef @@ -1,48 +1,21 @@ MACRO macro1 CLASS CORE ; - FOREIGN foreign1 0.5 -0.2 W ; - 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 + FOREIGN foreign1 0.13 0.5 W ; + ORIGIN 0.035 0.235 ; + SIZE 0.07 BY 0.47 ; END macro1 MACRO macro2 CLASS CORE ; - FOREIGN foreign2 -0.15 0.25 ; - 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 + FOREIGN foreign2 -0.15 0.25 ; + ORIGIN 0.235 0.035 ; + SIZE 0.47 BY 0.07 ; END macro2 MACRO macro3 CLASS CORE ; - FOREIGN macro3 ; - 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 + FOREIGN macro3 -1.0 1.0 ; + ORIGIN 0.0 0.0 ; + SIZE 1.0 BY 0.4 ; END macro3 diff --git a/testdata/lefdef/foreigncell/in2.lef b/testdata/lefdef/foreigncell/in2.lef index 3ff311146..7c9556cc7 100644 --- a/testdata/lefdef/foreigncell/in2.lef +++ b/testdata/lefdef/foreigncell/in2.lef @@ -1,46 +1,43 @@ MACRO macro1 CLASS CORE ; - ORIGIN 0.000 0.000 ; - SIZE 0.384 BY 0.480 ; + ORIGIN 0.035 0.235 ; + SIZE 0.07 BY 0.47 ; 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 ; + RECT -0.02 0 0.02 0.2 ; + RECT -0.03 -0.2 0.01 -0.1 ; + VIA 0.0 0.2 square ; + VIA 0.01 -0.2 square ; END END Z END macro1 MACRO macro2 CLASS CORE ; - FOREIGN foreign2 -0.15 0.25 ; - ORIGIN 0.000 0.000 ; - SIZE 0.384 BY 0.480 ; + FOREIGN foreign2 -0.15 0.25 ; + ORIGIN 0.235 0.035 ; + SIZE 0.47 BY 0.07 ; 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 ; + RECT 0 -0.02 -0.2 0.02 ; + RECT 0.2 -0.03 0.1 0.01 ; + VIA -0.2 0.0 square ; + VIA 0.2 0.01 square ; END END Z END macro2 MACRO macro3 CLASS CORE ; - FOREIGN macro3 ; - ORIGIN 0.000 0.000 ; - SIZE 0.384 BY 0.480 ; + FOREIGN macro3 -1.0 1.0 ; + ORIGIN 0.0 0.0 ; + SIZE 1.0 BY 1.0 ; 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 ; + RECT 0.2 0.2 0.3 0.5 ; END END Z END macro3