From d4adb194e36e54b73ed9c93ba7fc1e465c447184 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 26 Sep 2018 20:49:04 +0200 Subject: [PATCH] Fixed #172 (DEF reader does not pull vias from LEF) --- src/ext/ext/extDEFImporter.cc | 13 +-------- src/ext/ext/extLEFDEFImporter.h | 18 ++++++++++++ src/ext/ext/extLEFImporter.cc | 7 +++-- src/ext/ext/extLEFImporter.h | 11 +++++++ src/ext/unit_tests/extLEFDEFImport.cc | 13 ++++++--- testdata/lefdef/issue-172.def | 16 +++++++++++ testdata/lefdef/issue-172.lef | 40 ++++++++++++++++++++++++++ testdata/lefdef/issue-172/au.oas.gz | Bin 0 -> 254 bytes testdata/lefdef/issue-172/in.def | 16 +++++++++++ testdata/lefdef/issue-172/in.lef | 40 ++++++++++++++++++++++++++ 10 files changed, 156 insertions(+), 18 deletions(-) create mode 100644 testdata/lefdef/issue-172.def create mode 100644 testdata/lefdef/issue-172.lef create mode 100644 testdata/lefdef/issue-172/au.oas.gz create mode 100644 testdata/lefdef/issue-172/in.def create mode 100644 testdata/lefdef/issue-172/in.lef diff --git a/src/ext/ext/extDEFImporter.cc b/src/ext/ext/extDEFImporter.cc index d80a7e91e..d06ab9ac6 100644 --- a/src/ext/ext/extDEFImporter.cc +++ b/src/ext/ext/extDEFImporter.cc @@ -70,17 +70,6 @@ DEFImporter::get_orient (bool optional) } } -/** - * @brief A structure describing a via - */ -struct ViaDesc -{ - ViaDesc () : cell (0) { } - - db::Cell *cell; - std::string m1, m2; -}; - void DEFImporter::read_polygon (db::Polygon &poly, double scale) { @@ -153,7 +142,7 @@ DEFImporter::do_read (db::Layout &layout) double dbu_mic = 1000.0; double scale = 1.0 / (dbu_mic * layout.dbu ()); std::map styles; - std::map via_desc; + std::map via_desc = m_lef_importer.vias (); std::map > regions; std::list groups; std::list > instances; diff --git a/src/ext/ext/extLEFDEFImporter.h b/src/ext/ext/extLEFDEFImporter.h index 013d44646..3f28ef4c6 100644 --- a/src/ext/ext/extLEFDEFImporter.h +++ b/src/ext/ext/extLEFDEFImporter.h @@ -534,6 +534,24 @@ private: const LEFDEFReaderOptions *mp_tech_comp; }; +/** + * @brief A structure describing a via + */ +struct EXT_PUBLIC ViaDesc +{ + ViaDesc () : cell (0) { } + + /** + * @brief The cell representing the via + */ + db::Cell *cell; + + /** + * @brief The names of bottom and top metal respectively + */ + std::string m1, m2; +}; + /** * @brief The LEF importer object */ diff --git a/src/ext/ext/extLEFImporter.cc b/src/ext/ext/extLEFImporter.cc index ff8592cca..1218de08c 100644 --- a/src/ext/ext/extLEFImporter.cc +++ b/src/ext/ext/extLEFImporter.cc @@ -459,6 +459,9 @@ LEFImporter::do_read (db::Layout &layout) std::string cellname = "VIA_" + n; db::Cell &cell = layout.cell (layout.add_cell (cellname.c_str ())); + ViaDesc &via_desc = m_vias[n]; + via_desc.cell = &cell; + while (test ("DEFAULT") || test ("TOPOFSTACKONLY")) ; test (";"); @@ -544,9 +547,9 @@ LEFImporter::do_read (db::Layout &layout) } else if (test ("LAYERS")) { - geometry[0].first = get (); + via_desc.m1 = geometry[0].first = get (); geometry[1].first = get (); - geometry[2].first = get (); + via_desc.m2 = geometry[2].first = get (); test (";"); diff --git a/src/ext/ext/extLEFImporter.h b/src/ext/ext/extLEFImporter.h index 5ca3406fd..17bec2c41 100644 --- a/src/ext/ext/extLEFImporter.h +++ b/src/ext/ext/extLEFImporter.h @@ -86,6 +86,16 @@ public: */ double layer_ext (const std::string &layer, double def_ext = 0.0) const; + /** + * @brief Gets a map of the vias defined in this LEF file + * + * The map maps the via name to the via description. + */ + const std::map &vias () const + { + return m_vias; + } + protected: void do_read (db::Layout &layout); @@ -95,6 +105,7 @@ private: std::map m_default_ext; std::map m_macros_by_name; std::map m_macro_bboxes_by_name; + std::map m_vias; std::vector get_iteration (db::Layout &layout); void read_geometries (db::Layout &layout, db::Cell &cell, LayerPurpose purpose, std::map *collect_bboxes = 0); diff --git a/src/ext/unit_tests/extLEFDEFImport.cc b/src/ext/unit_tests/extLEFDEFImport.cc index a43f3a526..469fdc04b 100644 --- a/src/ext/unit_tests/extLEFDEFImport.cc +++ b/src/ext/unit_tests/extLEFDEFImport.cc @@ -33,7 +33,7 @@ #include #include -static void run_test (tl::TestBase *_this, const char *lef_dir, const char *filename, const char *au) +static void run_test (tl::TestBase *_this, const char *lef_dir, const char *filename, const char *au, bool priv = true) { ext::LEFDEFReaderOptions tc; tc.set_via_geometry_datatype (0); @@ -63,7 +63,7 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file if (ex.test ("def:")) { - std::string fn (tl::testsrc_private ()); + std::string fn (priv ? tl::testsrc_private () : tl::testsrc ()); fn += "/testdata/lefdef/"; fn += lef_dir; fn += "/"; @@ -76,7 +76,7 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file } else if (ex.test ("lef:")) { - std::string fn (tl::testsrc_private ()); + std::string fn (priv ? tl::testsrc_private () : tl::testsrc ()); fn += "/testdata/lefdef/"; fn += lef_dir; fn += "/"; @@ -120,7 +120,7 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file if (au) { - std::string fn (tl::testsrc_private ()); + std::string fn (priv ? tl::testsrc_private () : tl::testsrc ()); fn += "/testdata/lefdef/"; fn += lef_dir; fn += "/"; @@ -235,3 +235,8 @@ TEST(19) run_test (_this, "def10", "def:in.def", "au.oas.gz"); } +TEST(20) +{ + run_test (_this, "issue-172", "lef:in.lef+def:in.def", "au.oas.gz", false); +} + diff --git a/testdata/lefdef/issue-172.def b/testdata/lefdef/issue-172.def new file mode 100644 index 000000000..a4311b4ae --- /dev/null +++ b/testdata/lefdef/issue-172.def @@ -0,0 +1,16 @@ +VERSION 5.6 ; +NAMESCASESENSITIVE ON ; +DIVIDERCHAR "/" ; +BUSBITCHARS "<>" ; +DESIGN SMALL ; +UNITS DISTANCE MICRONS 100 ; + +DIEAREA ( -30 -30 ) ( 1030 1030 ) ; + +NETS 1 ; +- TOP ++ ROUTED M1 ( 0 0 ) ( 1000 * ) M2_M1 + NEW M2 ( 1000 0 ) ( 1000 1000 ) ; +END NETS + +END DESIGN diff --git a/testdata/lefdef/issue-172.lef b/testdata/lefdef/issue-172.lef new file mode 100644 index 000000000..a0359f764 --- /dev/null +++ b/testdata/lefdef/issue-172.lef @@ -0,0 +1,40 @@ +VERSION 5.7 ; +NAMESCASESENSITIVE ON ; +BUSBITCHARS "[]" ; +DIVIDERCHAR "/" ; +UNITS + DATABASE MICRONS 1000 ; +END UNITS + +USEMINSPACING OBS ON ; +USEMINSPACING PIN OFF ; +CLEARANCEMEASURE EUCLIDEAN ; + +MANUFACTURINGGRID 0.05 ; + +LAYER M1 + TYPE ROUTING ; + DIRECTION HORIZONTAL ; + WIDTH 0.2 ; +END M1 + +LAYER V2 + TYPE CUT ; +END V2 + +LAYER M2 + TYPE ROUTING ; + DIRECTION VERTICAL ; + WIDTH 0.2 ; +END M2 + +VIA M2_M1 DEFAULT + LAYER M1 ; + RECT -0.300 -0.300 0.300 0.300 ; + LAYER V2 ; + RECT -0.200 -0.200 0.200 0.200 ; + LAYER M2 ; + RECT -0.300 -0.300 0.300 0.300 ; +END M2_M1 + +END LIBRARY diff --git a/testdata/lefdef/issue-172/au.oas.gz b/testdata/lefdef/issue-172/au.oas.gz new file mode 100644 index 0000000000000000000000000000000000000000..ce4faf59268c9141ddeee4f2fd1c7b491195a044 GIT binary patch literal 254 zcmV@0w@DQE=Jq6FgqCuj`Gg!wIDfj_9E6vQ#NPFS6Ggoctjn5K+>+2iX#c()k zdFIKL59CeV=!#4ebgg^3H&wWsMJiKMylMU_sAb|Qv>n}QYZph}mDa|`p6bd|*SDSS z!{Z#efb*>>$ra?*IMq_gQXnjTIhET2<>)8oyg=ONdrsqa6Rc@8MtnRp8RVY=KB9q< z5Ap?H8To+IB@?G#@ct%N-vXWz5G>Ut%)|+-`0r?W&+{SL^" ; +DESIGN SMALL ; +UNITS DISTANCE MICRONS 100 ; + +DIEAREA ( -30 -30 ) ( 1030 1030 ) ; + +NETS 1 ; +- TOP ++ ROUTED M1 ( 0 0 ) ( 1000 * ) M2_M1 + NEW M2 ( 1000 0 ) ( 1000 1000 ) ; +END NETS + +END DESIGN diff --git a/testdata/lefdef/issue-172/in.lef b/testdata/lefdef/issue-172/in.lef new file mode 100644 index 000000000..a0359f764 --- /dev/null +++ b/testdata/lefdef/issue-172/in.lef @@ -0,0 +1,40 @@ +VERSION 5.7 ; +NAMESCASESENSITIVE ON ; +BUSBITCHARS "[]" ; +DIVIDERCHAR "/" ; +UNITS + DATABASE MICRONS 1000 ; +END UNITS + +USEMINSPACING OBS ON ; +USEMINSPACING PIN OFF ; +CLEARANCEMEASURE EUCLIDEAN ; + +MANUFACTURINGGRID 0.05 ; + +LAYER M1 + TYPE ROUTING ; + DIRECTION HORIZONTAL ; + WIDTH 0.2 ; +END M1 + +LAYER V2 + TYPE CUT ; +END V2 + +LAYER M2 + TYPE ROUTING ; + DIRECTION VERTICAL ; + WIDTH 0.2 ; +END M2 + +VIA M2_M1 DEFAULT + LAYER M1 ; + RECT -0.300 -0.300 0.300 0.300 ; + LAYER V2 ; + RECT -0.200 -0.200 0.200 0.200 ; + LAYER M2 ; + RECT -0.300 -0.300 0.300 0.300 ; +END M2_M1 + +END LIBRARY