diff --git a/src/plugins/streamers/lstream/db_plugin/lstrReader.cc b/src/plugins/streamers/lstream/db_plugin/lstrReader.cc index b4dd906da..c28e677e8 100644 --- a/src/plugins/streamers/lstream/db_plugin/lstrReader.cc +++ b/src/plugins/streamers/lstream/db_plugin/lstrReader.cc @@ -354,7 +354,7 @@ make_regular_array (stream::repetition::Repetition::Reader repetition, db::regul Reader::Reader (tl::InputStream &s) : m_stream (&s), m_source (s.source ()), m_progress (tl::to_string (tr ("Reading LStream file"))), - m_library_index (0), mp_layout (0), mp_cell (0), m_layout_view_id (0) + m_library_index (0), mp_cell (0), mp_layout (0), m_layout_view_id (0) { m_progress.set_format (tl::to_string (tr ("%.0f MB"))); m_progress.set_unit (1024 * 1024); @@ -423,6 +423,9 @@ Reader::do_read (db::Layout &layout) } catch (lstr::CoordinateOverflowException &ex) { // this adds source information error (ex.msg ()); + } catch (kj::Exception &ex) { + // this adds source information + error (ex.getDescription ().cStr ()); } } diff --git a/src/plugins/streamers/lstream/db_plugin/lstrWriter.cc b/src/plugins/streamers/lstream/db_plugin/lstrWriter.cc index 2c7c3da05..e4951130c 100644 --- a/src/plugins/streamers/lstream/db_plugin/lstrWriter.cc +++ b/src/plugins/streamers/lstream/db_plugin/lstrWriter.cc @@ -437,6 +437,21 @@ Writer::collect_property_ids (std::vector &prop_ids, std } } +namespace +{ + +struct ComparePropertyNameIdByValue +{ + bool operator() (db::property_names_id_type a, db::property_names_id_type b) const + { + const tl::Variant &na = db::property_name (a); + const tl::Variant &nb = db::property_name (b); + return na.less (nb); + } +}; + +} + /** * @brief Gets the LStream property set Id from a KLayout properties Id * @@ -463,8 +478,13 @@ Writer::make_property_id (db::properties_id_type id, std::vector ps_sorted; for (auto i = ps.begin (); i != ps.end (); ++i) { - make_property_name_id_from_id (i->first, prop_names); + ps_sorted.insert (i->first); + } + + for (auto i = ps_sorted.begin (); i != ps_sorted.end (); ++i) { + make_property_name_id_from_id (*i, prop_names); } return ls_id; @@ -684,7 +704,6 @@ Writer::make_layer_table (stream::library::LayerTable::Builder layers) for (auto l = m_layers_to_write.begin (); l != m_layers_to_write.end (); ++l) { - auto li = l->first; auto lp = l->second; // NOTE: currently, the purpose is always DRAWING @@ -876,11 +895,11 @@ Writer::write_cell (db::cell_index_type ci, kj::BufferedOutputStream &os) int view_index = 0; if (needs_layout_view) { tl_assert (m_layout_view_id >= 0); - cell.getViewIds ().set (view_index++, m_layout_view_id); + cell.getViewIds ().set (view_index++, (unsigned int) m_layout_view_id); } if (needs_meta_data_view) { tl_assert (m_meta_data_view_id >= 0); - cell.getViewIds ().set (view_index++, m_meta_data_view_id); + cell.getViewIds ().set (view_index++, (unsigned int) m_meta_data_view_id); } writePackedMessage (os, message); diff --git a/src/plugins/streamers/lstream/db_plugin/lstrWriter.h b/src/plugins/streamers/lstream/db_plugin/lstrWriter.h index 1236b3187..f771380c1 100644 --- a/src/plugins/streamers/lstream/db_plugin/lstrWriter.h +++ b/src/plugins/streamers/lstream/db_plugin/lstrWriter.h @@ -78,8 +78,8 @@ private: bool m_permissive; db::Layout *mp_layout; std::string m_cellname; - unsigned int m_layout_view_id; - unsigned int m_meta_data_view_id; + int m_layout_view_id; + int m_meta_data_view_id; std::map m_ls_lib_ids; std::vector > m_layers_to_write; std::set m_cells_to_write; diff --git a/src/plugins/streamers/lstream/unit_tests/dbLStreamReaderTests.cc b/src/plugins/streamers/lstream/unit_tests/dbLStreamReaderTests.cc index d0cac4c41..6515b7fa0 100644 --- a/src/plugins/streamers/lstream/unit_tests/dbLStreamReaderTests.cc +++ b/src/plugins/streamers/lstream/unit_tests/dbLStreamReaderTests.cc @@ -20,8 +20,7 @@ */ -#if 0 // @@@ -#include "dbMALYReader.h" +#include "lstrReader.h" #include "dbLayoutDiff.h" #include "dbWriter.h" #include "dbTestSupport.h" @@ -29,37 +28,16 @@ #include -static void run_test (tl::TestBase *_this, const std::string &base, const char *file, const char *file_au, const char *map = 0, double dbu = 0.001) +static void run_test (tl::TestBase *_this, const std::string &base, const char *file, const char *file_au) { - db::MALYReaderOptions *opt = new db::MALYReaderOptions(); - opt->dbu = dbu; - - db::LayerMap lm; - if (map) { - unsigned int ln = 0; - tl::Extractor ex (map); - while (! ex.at_end ()) { - std::string n; - int l; - ex.read_word_or_quoted (n); - ex.test (":"); - ex.read (l); - ex.test (","); - lm.map (n, ln++, db::LayerProperties (l, 0)); - } - opt->layer_map = lm; - opt->create_other_layers = true; - } - db::LoadLayoutOptions options; - options.set_options (opt); db::Manager m (false); db::Layout layout (&m); { std::string fn (base); - fn += "/maly/"; + fn += "/lstream/"; fn += file; tl::InputStream stream (fn); db::Reader reader (stream); @@ -67,82 +45,89 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char * } std::string fn_au (base); - fn_au += "/maly/"; + fn_au += "/lstream/"; fn_au += file_au; db::compare_layouts (_this, layout, fn_au, db::WriteOAS); } -TEST(1_Basic) +TEST(basic) { - std::string fn (tl::testdata ()); - fn += "/maly/MALY_test1.maly"; - - tl::InputStream stream (fn); - db::MALYReader reader (stream); - - db::MALYData data = reader.read_maly_file (); - - EXPECT_EQ (data.to_string (), - "Mask A\n" - " Size 127000\n" - " Title \"\" m90 0,-50 1,1,1 [Standard]\n" - " Title \"MaskA1\" m90 50,50 1,1,1 [Standard]\n" - " Title \"WITH \"QUOTES\"\" r270 -50,0 1,1,1 [Standard]\n" - " Ref A1.oas{CHIP_A}(1) (0,0;10,10) m90 *1 20,0\n" - " Ref A2.oas{CHIP_A}(2) ename(e001) dname(d001) (0,0;50,50) m90 *0.8 20,0 [2x5,1x2]\n" - " Ref B3.oas{CHIP_A}(2) (0,0;12,12) m90 *1 20,0" - ) + run_test (_this, tl::testdata (), "basic.lstr", "basic_au.oas"); } -static std::string run_test_with_error (tl::TestBase * /*_this*/, const std::string &file) +TEST(boxes) { - std::string fn (tl::testdata ()); - fn += "/maly/"; - fn += file; - - tl::InputStream stream (fn); - db::MALYReader reader (stream); - - try { - reader.read_maly_file (); - tl_assert (false); - } catch (tl::Exception &ex) { - tl::error << ex.msg (); - return ex.msg (); - } + run_test (_this, tl::testdata (), "boxes.lstr", "boxes_au.oas"); } -TEST(2_Errors) +TEST(cells) { - EXPECT_EQ (run_test_with_error (_this, "MALY_test2a.maly").find ("Line break inside quoted string (line=17,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2b.maly").find ("/*...*/ comment not closed (line=43,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2c.maly").find ("Expected value STANDARD or NATIVE for FONT (line=7,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2d.maly").find ("Unknown base specification: NOVALIDBASE (line=8,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2e.maly").find ("Expected end of text here: NOVALIDKEY .. (line=15,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2f.maly").find ("Expected 'Y' or 'NONE' for MIRROR spec (line=15,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2g.maly").find ("Expected end of text here: UNEXPECTED (line=20,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2h.maly").find ("Expected value Y or NONE for MASKMIRROR (line=23,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2i.maly").find ("Expected end of text here: UNEXPECTED (line=29,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2j.maly").find ("Expected end of text here: NOVALIDKEY .. (line=30,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2k.maly").find ("Expected a real number here: SCALE 0.80 .. (line=31,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2l.maly").find ("Expected 'PARAMETER' here: CMASK (line=19,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2m.maly").find ("Expected 'CMASK' here: TITLE (line=18,"), size_t (0)); - EXPECT_EQ (run_test_with_error (_this, "MALY_test2n.maly").find ("Header expected ('BEGIN MALY') (line=2, "), size_t (0)); + run_test (_this, tl::testdata (), "cells.lstr", "cells_au.oas"); } -TEST(10_BasicLayout) +TEST(cells_with_instances) { - run_test (_this, tl::testdata (), "MALY_test10.maly", "maly_test10_au.oas"); - run_test (_this, tl::testdata (), "MALY_test10.maly", "maly_test10_lm_au.oas", "A: 10, B: 11, C: 12, D: 13"); - run_test (_this, tl::testdata (), "MALY_test10.maly", "maly_test10_dbu10nm_au.oas", 0, 0.01); + run_test (_this, tl::testdata (), "cells_with_instances.lstr", "cells_with_instances_au.oas"); } -TEST(11_Titles) +TEST(edge_pairs) { - run_test (_this, tl::testdata (), "MALY_test11.maly", "maly_test11_au.oas"); + run_test (_this, tl::testdata (), "edge_pairs.lstr", "edge_pairs_au.oas"); } -#endif -// @@@ +TEST(edges) +{ + run_test (_this, tl::testdata (), "edges.lstr", "edges_au.oas"); +} + +TEST(ghost_cells) +{ + run_test (_this, tl::testdata (), "ghost_cells.lstr", "ghost_cells_au.oas"); +} + +TEST(meta_data) +{ + run_test (_this, tl::testdata (), "meta_data.lstr", "meta_data_au.oas"); +} + +TEST(paths) +{ + run_test (_this, tl::testdata (), "paths.lstr", "paths_au.oas"); +} + +TEST(pcells) +{ + run_test (_this, tl::testdata (), "pcells.lstr", "pcells_au.oas"); +} + +TEST(points) +{ + run_test (_this, tl::testdata (), "points.lstr", "points_au.oas"); +} + +TEST(polygons) +{ + run_test (_this, tl::testdata (), "polygons.lstr", "polygons_au.oas"); +} + +TEST(properties) +{ + run_test (_this, tl::testdata (), "properties.lstr", "properties_au.oas"); +} + +TEST(simple_polygons) +{ + run_test (_this, tl::testdata (), "simple_polygons.lstr", "simple_polygons_au.oas"); +} + +TEST(texts) +{ + run_test (_this, tl::testdata (), "texts.lstr", "texts_au.oas"); +} + +TEST(variants) +{ + run_test (_this, tl::testdata (), "variants.lstr", "variants_au.oas"); +} diff --git a/src/plugins/streamers/lstream/unit_tests/unit_tests.pro b/src/plugins/streamers/lstream/unit_tests/unit_tests.pro index 3d993288f..8e83c6e61 100644 --- a/src/plugins/streamers/lstream/unit_tests/unit_tests.pro +++ b/src/plugins/streamers/lstream/unit_tests/unit_tests.pro @@ -9,7 +9,7 @@ include($$PWD/../../../../lib_ut.pri) SOURCES = \ dbLStreamReaderTests.cc -INCLUDEPATH += $$LAY_INC $$TL_INC $$DB_INC $$GSI_INC $$PWD/../db_plugin $$PWD/../../../common +INCLUDEPATH += $$LAY_INC $$TL_INC $$DB_INC $$GSI_INC $$PWD/../db_plugin $$PWD/../../../common $$PWD/../db_plugin/capnp DEPENDPATH += $$LAY_INC $$TL_INC $$DB_INC $$GSI_INC $$PWD/../db_plugin $$PWD/../../../common LIBS += -L$$DESTDIR_UT -lklayout_db -lklayout_tl -lklayout_gsi diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc index 292326925..5ed3f5ed5 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc @@ -3309,6 +3309,46 @@ OASISWriter::write_shapes (const db::LayerProperties &lprops, const db::Shapes & break; + case db::Shape::EdgePair: + + if (shape->has_prop_id ()) { + db::EdgePairWithProperties edge_pair = *shape->basic_ptr (db::EdgePairWithProperties::tag ()); + db::EdgeWithProperties e1 (edge_pair.first (), edge_pair.properties_id ()); + db::EdgeWithProperties e2 (edge_pair.second (), edge_pair.properties_id ()); + db::Disp tr; + e1.reduce (tr); + edge_with_properties_compressor.add (e1, tr.disp ()); + e2.reduce (tr); + edge_with_properties_compressor.add (e2, tr.disp ()); + } else { + db::EdgePair edge_pair = *shape->basic_ptr (db::EdgePair::tag ()); + db::Disp tr; + edge_pair.first ().reduce (tr); + edge_compressor.add (edge_pair.first (), tr.disp ()); + edge_pair.second ().reduce (tr); + edge_compressor.add (edge_pair.second (), tr.disp ()); + } + + break; + + case db::Shape::Point: + + if (shape->has_prop_id ()) { + db::PointWithProperties point = *shape->basic_ptr (db::PointWithProperties::tag ()); + db::EdgeWithProperties e (db::Edge (point, point), point.properties_id ()); + db::Disp tr; + e.reduce (tr); + edge_with_properties_compressor.add (e, tr.disp ()); + } else { + db::Point point = *shape->basic_ptr (db::Point::tag ()); + db::Disp tr; + db::Edge e (point, point); + e.reduce (tr); + edge_compressor.add (e, tr.disp ()); + } + + break; + case db::Shape::Path: if (shape->has_prop_id ()) { diff --git a/testdata/lstream/basic.lstr b/testdata/lstream/basic.lstr new file mode 100644 index 000000000..43f18d60d Binary files /dev/null and b/testdata/lstream/basic.lstr differ diff --git a/testdata/lstream/basic_au.oas b/testdata/lstream/basic_au.oas new file mode 100644 index 000000000..6daa83022 Binary files /dev/null and b/testdata/lstream/basic_au.oas differ diff --git a/testdata/lstream/boxes.lstr b/testdata/lstream/boxes.lstr new file mode 100644 index 000000000..0a6431f01 Binary files /dev/null and b/testdata/lstream/boxes.lstr differ diff --git a/testdata/lstream/boxes_au.oas b/testdata/lstream/boxes_au.oas new file mode 100644 index 000000000..0c54e6c2e Binary files /dev/null and b/testdata/lstream/boxes_au.oas differ diff --git a/testdata/lstream/cells.lstr b/testdata/lstream/cells.lstr new file mode 100644 index 000000000..c0a75fa24 Binary files /dev/null and b/testdata/lstream/cells.lstr differ diff --git a/testdata/lstream/cells_au.oas b/testdata/lstream/cells_au.oas new file mode 100644 index 000000000..c37822b6d Binary files /dev/null and b/testdata/lstream/cells_au.oas differ diff --git a/testdata/lstream/cells_with_instances.lstr b/testdata/lstream/cells_with_instances.lstr new file mode 100644 index 000000000..64d5d623a Binary files /dev/null and b/testdata/lstream/cells_with_instances.lstr differ diff --git a/testdata/lstream/cells_with_instances_au.oas b/testdata/lstream/cells_with_instances_au.oas new file mode 100644 index 000000000..7e9da646c Binary files /dev/null and b/testdata/lstream/cells_with_instances_au.oas differ diff --git a/testdata/lstream/edge_pairs.lstr b/testdata/lstream/edge_pairs.lstr new file mode 100644 index 000000000..5a78b3cf6 Binary files /dev/null and b/testdata/lstream/edge_pairs.lstr differ diff --git a/testdata/lstream/edge_pairs_au.oas b/testdata/lstream/edge_pairs_au.oas new file mode 100644 index 000000000..052eed6f0 Binary files /dev/null and b/testdata/lstream/edge_pairs_au.oas differ diff --git a/testdata/lstream/edges.lstr b/testdata/lstream/edges.lstr new file mode 100644 index 000000000..c097e8c0d Binary files /dev/null and b/testdata/lstream/edges.lstr differ diff --git a/testdata/lstream/edges_au.oas b/testdata/lstream/edges_au.oas new file mode 100644 index 000000000..86d843765 Binary files /dev/null and b/testdata/lstream/edges_au.oas differ diff --git a/testdata/lstream/ghost_cells.lstr b/testdata/lstream/ghost_cells.lstr new file mode 100644 index 000000000..cbe778d0a Binary files /dev/null and b/testdata/lstream/ghost_cells.lstr differ diff --git a/testdata/lstream/ghost_cells_au.oas b/testdata/lstream/ghost_cells_au.oas new file mode 100644 index 000000000..5aaf0fcbe Binary files /dev/null and b/testdata/lstream/ghost_cells_au.oas differ diff --git a/testdata/lstream/meta_data.lstr b/testdata/lstream/meta_data.lstr new file mode 100644 index 000000000..6095fcaf1 Binary files /dev/null and b/testdata/lstream/meta_data.lstr differ diff --git a/testdata/lstream/meta_data_au.oas b/testdata/lstream/meta_data_au.oas new file mode 100644 index 000000000..a95608e31 Binary files /dev/null and b/testdata/lstream/meta_data_au.oas differ diff --git a/testdata/lstream/paths.lstr b/testdata/lstream/paths.lstr new file mode 100644 index 000000000..99e9acf47 Binary files /dev/null and b/testdata/lstream/paths.lstr differ diff --git a/testdata/lstream/paths_au.oas b/testdata/lstream/paths_au.oas new file mode 100644 index 000000000..fbf62fc9c Binary files /dev/null and b/testdata/lstream/paths_au.oas differ diff --git a/testdata/lstream/pcells.lstr b/testdata/lstream/pcells.lstr new file mode 100644 index 000000000..55075c9a3 Binary files /dev/null and b/testdata/lstream/pcells.lstr differ diff --git a/testdata/lstream/pcells_au.oas b/testdata/lstream/pcells_au.oas new file mode 100644 index 000000000..88943799d Binary files /dev/null and b/testdata/lstream/pcells_au.oas differ diff --git a/testdata/lstream/points.lstr b/testdata/lstream/points.lstr new file mode 100644 index 000000000..ffc042f41 Binary files /dev/null and b/testdata/lstream/points.lstr differ diff --git a/testdata/lstream/points_au.oas b/testdata/lstream/points_au.oas new file mode 100644 index 000000000..97b971d27 Binary files /dev/null and b/testdata/lstream/points_au.oas differ diff --git a/testdata/lstream/polygons.lstr b/testdata/lstream/polygons.lstr new file mode 100644 index 000000000..c94e1a3f1 Binary files /dev/null and b/testdata/lstream/polygons.lstr differ diff --git a/testdata/lstream/polygons_au.oas b/testdata/lstream/polygons_au.oas new file mode 100644 index 000000000..14b5519b2 Binary files /dev/null and b/testdata/lstream/polygons_au.oas differ diff --git a/testdata/lstream/properties.lstr b/testdata/lstream/properties.lstr new file mode 100644 index 000000000..3cecdb481 Binary files /dev/null and b/testdata/lstream/properties.lstr differ diff --git a/testdata/lstream/properties_au.oas b/testdata/lstream/properties_au.oas new file mode 100644 index 000000000..4e070b4ed Binary files /dev/null and b/testdata/lstream/properties_au.oas differ diff --git a/testdata/lstream/simple_polygons.lstr b/testdata/lstream/simple_polygons.lstr new file mode 100644 index 000000000..ffe2dc344 Binary files /dev/null and b/testdata/lstream/simple_polygons.lstr differ diff --git a/testdata/lstream/simple_polygons_au.oas b/testdata/lstream/simple_polygons_au.oas new file mode 100644 index 000000000..bbfed5c86 Binary files /dev/null and b/testdata/lstream/simple_polygons_au.oas differ diff --git a/testdata/lstream/texts.lstr b/testdata/lstream/texts.lstr new file mode 100644 index 000000000..4354713b3 Binary files /dev/null and b/testdata/lstream/texts.lstr differ diff --git a/testdata/lstream/texts_au.oas b/testdata/lstream/texts_au.oas new file mode 100644 index 000000000..04ba73993 Binary files /dev/null and b/testdata/lstream/texts_au.oas differ diff --git a/testdata/lstream/variants.lstr b/testdata/lstream/variants.lstr new file mode 100644 index 000000000..af267bf17 Binary files /dev/null and b/testdata/lstream/variants.lstr differ diff --git a/testdata/lstream/variants_au.oas b/testdata/lstream/variants_au.oas new file mode 100644 index 000000000..d7af3ebaf Binary files /dev/null and b/testdata/lstream/variants_au.oas differ