From fd63d1017fd7a517f67d8b8a028795301903df97 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 2 May 2020 09:30:17 +0200 Subject: [PATCH] Added tests for LEF/DEF mapfile, fixed a few bugs. --- .../lefdef/db_plugin/dbLEFDEFPlugin.cc | 2 +- .../lefdef/db_plugin/dbLEFImporter.cc | 8 ++--- .../lefdef/unit_tests/dbLEFDEFImportTests.cc | 24 +++++++++++-- testdata/lefdef/mapfile/au.oas.gz | Bin 0 -> 508 bytes testdata/lefdef/mapfile/in.def | 32 ++++++++++++++++++ testdata/lefdef/mapfile/in.lef | 19 +++++++++++ testdata/lefdef/mapfile/in_tech.lef | 27 +++++++++++++++ testdata/lefdef/mapfile/test.map | 18 ++++++++++ 8 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 testdata/lefdef/mapfile/au.oas.gz create mode 100644 testdata/lefdef/mapfile/in.def create mode 100644 testdata/lefdef/mapfile/in.lef create mode 100644 testdata/lefdef/mapfile/in_tech.lef create mode 100644 testdata/lefdef/mapfile/test.map diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc index 983a68596..2bd4466ae 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc @@ -128,7 +128,7 @@ private: } } - return tl::combine_path (m_stream.absolute_path (), fn); + return tl::combine_path (tl::dirname (m_stream.absolute_path ()), fn); } else { return fn; diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc index b537b532e..7bf3c307a 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc @@ -604,12 +604,12 @@ LEFImporter::read_layer (Layout & /*layout*/) } else if (test ("TYPE")) { - if (test ("ROUTING")) { + std::string type = get (); + + if (type == "ROUTING" || type == "MASTERSLICE") { m_routing_layers.insert (ln); - } else if (test ("CUT")) { + } else if (type == "CUT") { m_cut_layers.insert (ln); - } else { - get (); } expect (";"); diff --git a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc index f6f70c009..827377a2a 100644 --- a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc +++ b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc @@ -49,7 +49,7 @@ static db::LEFDEFReaderOptions default_options () return tc; } -static void run_test (tl::TestBase *_this, const char *lef_dir, const char *filename, const char *au, const db::LEFDEFReaderOptions &tc, bool priv = true) +static void run_test (tl::TestBase *_this, const char *lef_dir, const char *filename, const char *au, const db::LEFDEFReaderOptions &options, bool priv = true) { std::string fn_path (priv ? tl::testsrc_private () : tl::testsrc ()); fn_path += "/testdata/lefdef/"; @@ -61,7 +61,7 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file tl::Extractor ex (filename); - db::LEFDEFReaderState ld (&tc, layout); + db::LEFDEFReaderState ld (&options, layout); db::DEFImporter imp; @@ -103,6 +103,18 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file db::Reader reader (stream); reader.read (layout, db::LoadLayoutOptions ()); + } else if (ex.test("read:")) { + + std::string fn = fn_path, f; + ex.read_word_or_quoted (f); + fn += f; + + tl::InputStream stream (fn); + db::Reader reader (stream); + db::LoadLayoutOptions lo; + lo.set_options (options); + reader.read (layout, lo); + } else { break; @@ -361,3 +373,11 @@ TEST(110_lefpins) run_test (_this, "lefpins", "lef:in_tech.lef+lef:in.lef+def:in.def", "au_lefpins_mapped.oas.gz", options, false); } + +TEST(111_mapfile) +{ + db::LEFDEFReaderOptions options = default_options (); + options.set_map_file ("test.map"); + + run_test (_this, "mapfile", "read:in.def", "au.oas.gz", options, false); +} diff --git a/testdata/lefdef/mapfile/au.oas.gz b/testdata/lefdef/mapfile/au.oas.gz new file mode 100644 index 0000000000000000000000000000000000000000..629c7144bc827d1420891ebf3db05ad7bec45729 GIT binary patch literal 508 zcmVaT?9SNY0W+&HBN7@9_DkNq23#Ns*^) z*R|4DFJI3O_vuBKUdC1OSj|bUg*%Do29jnJMA`67e;9>*PfjB@7~n0O#DiQ0G8x2C ze#QBeVQgiR*Zol+Jr$ISlI9K61&OXEDz3=nc|lcC(nZFzCelO4M8y>u+yJ#AN}4xw zs@M}Ph^oEp;`(Tbs9Mg^PP}mYzU4?Pd?4bl3cv1;uY3<{_}~>ezKLS^2Z^OBO?mze zRwav>qbo`MV&+Pu4#qbILf4HWp&CaVbkaTthos?^;fn*RVypzXTPn yUJuB}`UyE_MOEqktZmc@$uU@R>kA^-c-k2&M0rm#P~QE|2jDl8kqyDK1ONa$2?68) literal 0 HcmV?d00001 diff --git a/testdata/lefdef/mapfile/in.def b/testdata/lefdef/mapfile/in.def new file mode 100644 index 000000000..f24be607b --- /dev/null +++ b/testdata/lefdef/mapfile/in.def @@ -0,0 +1,32 @@ + +VERSION 5.8 ; +DIVIDERCHAR "/" ; +BUSBITCHARS "[]" ; +DESIGN mapfile ; +UNITS DISTANCE MICRONS 1000 ; + +DIEAREA ( 0 0 ) ( 1000 2000 ) ; + +COMPONENTS 3 ; + - macro1 macro1 + PLACED ( 0 0 ) N ; +END COMPONENTS + +SPECIALNETS 1 ; +- VDD ( * VDD ) ++ ROUTED M1 50 + SHAPE STRIPE ( 500 0 ) ( 500 500 25 ) square ( 0 500 ) ++ USE POWER ; +END SPECIALNETS + +PINS 1 ; +- VDD + NET VDD + SPECIAL + DIRECTION INOUT + USE POWER + + LAYER M1 ( 0 0 ) ( 50 70 ) + ; +END PINS + +NETS 1 ; +- TOP ++ ROUTED M1 ( 100 700 ) ( 500 * ) ; +END NETS + +END DESIGN + diff --git a/testdata/lefdef/mapfile/in.lef b/testdata/lefdef/mapfile/in.lef new file mode 100644 index 000000000..38d550efa --- /dev/null +++ b/testdata/lefdef/mapfile/in.lef @@ -0,0 +1,19 @@ +MACRO macro1 + CLASS CORE ; + ORIGIN 0.035 0.235 ; + SIZE 0.07 BY 0.47 ; + PIN Z + PORT + LAYER M1 ; + 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 + OBS + LAYER M1 ; + RECT -0.035 -0.235 0.035 0.235 ; + END +END macro1 + diff --git a/testdata/lefdef/mapfile/in_tech.lef b/testdata/lefdef/mapfile/in_tech.lef new file mode 100644 index 000000000..83f711256 --- /dev/null +++ b/testdata/lefdef/mapfile/in_tech.lef @@ -0,0 +1,27 @@ +LAYER M0PO + TYPE MASTERSLICE ; + WIDTH 0.02 ; +END M0PO +LAYER VIA0 + TYPE CUT ; +END VIA0 +LAYER M1 + TYPE MASTERSLICE ; + WIDTH 0.025 ; +END M1 +LAYER VIA1 + TYPE CUT ; +END VIA1 +LAYER M2 + TYPE MASTERSLICE ; + WIDTH 0.03 ; +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 diff --git a/testdata/lefdef/mapfile/test.map b/testdata/lefdef/mapfile/test.map new file mode 100644 index 000000000..7a8609dad --- /dev/null +++ b/testdata/lefdef/mapfile/test.map @@ -0,0 +1,18 @@ +DIEAREA ALL 100 0 +M0PO LEFPIN,LEFOBS,PIN,NET,SPNET,VIA 10 0 +VIA0 LEFPIN,LEFOBS,VIA,PIN,NET,SPNET 11 0 +M1 LEFPIN 12 0 +M1 LEFOBS 12 1 +M1 PIN 12 2 +M1 NET 12 3 +M1 SPNET 12 4 +M1 VIA 12 5 +M1 FILLOPC 12 100 +M1 FILLOPC:MASK:1 12 101 +M1 FILLOPC:MASK:2 12 102 +M1 BLOCKAGEFILL 12 150 +M1 BLOCKAGE 12 151 +M1 FILL 12 152 +NAME M1/PIN 12 10 +VIA1 LEFPIN,LEFOBS,VIA,PIN,NET,SPNET 13 0 +M2 LEFPIN,LEFOBS,PIN,NET,SPNET,VIA 14 0