From c7fe1cb1891963ec0b1225aafc688652f1dbc9f7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 16 Jun 2019 16:48:30 +0200 Subject: [PATCH] Fixed #275 (don't write PCell context with OASIS) The ability to disable PCell context on OASIS output with the "write_context_info" option was added. --- .../oasis/db_plugin/dbOASISWriter.cc | 60 +++--- .../oasis/unit_tests/dbOASISWriter.cc | 187 ++++++++++++------ testdata/oasis/dbOASISWriter119_au.gds | Bin 0 -> 3838 bytes testdata/oasis/pcell_test.gds | Bin 0 -> 4898 bytes 4 files changed, 166 insertions(+), 81 deletions(-) create mode 100644 testdata/oasis/dbOASISWriter119_au.gds create mode 100644 testdata/oasis/pcell_test.gds diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc index 76197bc28..15628938a 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc @@ -1343,20 +1343,24 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save } - // emit property name required for the PCell context information - std::vector context_prop_strings; - for (std::vector::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) { + if (options.write_context_info ()) { - const db::Cell &cref (layout.cell (*cell)); - if (cref.is_proxy () && ! cref.is_top () && layout.get_context_info (*cell, context_prop_strings)) { + // emit property name required for the PCell context information + std::vector context_prop_strings; + for (std::vector::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) { + + const db::Cell &cref (layout.cell (*cell)); + if (cref.is_proxy () && ! cref.is_top () && layout.get_context_info (*cell, context_prop_strings)) { + + if (m_propnames.insert (std::make_pair (std::string (klayout_context_name), m_propname_id)).second) { + begin_table (propnames_table_pos); + write_record_id (7); + write_nstring (klayout_context_name); + ++m_propname_id; + } + break; - if (m_propnames.insert (std::make_pair (std::string (klayout_context_name), m_propname_id)).second) { - begin_table (propnames_table_pos); - write_record_id (7); - write_nstring (klayout_context_name); - ++m_propname_id; } - break; } @@ -1422,25 +1426,29 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save } - // emit property string id's required for the PCell context information - std::vector context_prop_strings; - for (std::vector::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) { + if (options.write_context_info ()) { - m_progress.set (mp_stream->pos ()); + // emit property string id's required for the PCell context information + std::vector context_prop_strings; + for (std::vector::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) { - const db::Cell &cref (layout.cell (*cell)); - if (cref.is_proxy () && ! cref.is_top ()) { + m_progress.set (mp_stream->pos ()); - context_prop_strings.clear (); - if (layout.get_context_info (*cell, context_prop_strings)) { + const db::Cell &cref (layout.cell (*cell)); + if (cref.is_proxy () && ! cref.is_top ()) { - for (std::vector ::const_iterator c = context_prop_strings.begin (); c != context_prop_strings.end (); ++c) { - if (m_propstrings.insert (std::make_pair (*c, m_propstring_id)).second) { - begin_table (propstrings_table_pos); - write_record_id (9); - write_bstring (c->c_str ()); - ++m_propstring_id; + context_prop_strings.clear (); + if (layout.get_context_info (*cell, context_prop_strings)) { + + for (std::vector ::const_iterator c = context_prop_strings.begin (); c != context_prop_strings.end (); ++c) { + if (m_propstrings.insert (std::make_pair (*c, m_propstring_id)).second) { + begin_table (propstrings_table_pos); + write_record_id (9); + write_bstring (c->c_str ()); + ++m_propstring_id; + } } + } } @@ -1604,7 +1612,7 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save } // context information as property named KLAYOUT_CONTEXT - if (cref.is_proxy ()) { + if (cref.is_proxy () && options.write_context_info ()) { context_prop_strings.clear (); diff --git a/src/plugins/streamers/oasis/unit_tests/dbOASISWriter.cc b/src/plugins/streamers/oasis/unit_tests/dbOASISWriter.cc index 68bec61d0..13aef7df0 100644 --- a/src/plugins/streamers/oasis/unit_tests/dbOASISWriter.cc +++ b/src/plugins/streamers/oasis/unit_tests/dbOASISWriter.cc @@ -26,6 +26,8 @@ #include "dbLayoutDiff.h" #include "dbWriter.h" #include "dbTextWriter.h" +#include "dbLibraryProxy.h" +#include "dbTestSupport.h" #include "tlUnitTest.h" @@ -1258,61 +1260,6 @@ TEST(115) EXPECT_EQ (std::string (os.string ()), std::string (expected)) } -TEST(118) -{ - // 1x1 arrays (#902) - - db::Manager m; - db::Layout g (&m); - - db::LayerProperties lp1; - lp1.layer = 1; - lp1.datatype = 0; - - g.insert_layer (0, lp1); - - db::Cell &c1 (g.cell (g.add_cell ())); - c1.shapes (0).insert (db::Box (100, 0, 100, 200)); - - db::Cell &c2 (g.cell (g.add_cell ())); - c2.insert (db::array (db::CellInst (c1.cell_index ()), db::Trans (), db::Vector (0, 1), db::Vector (1, 0), 1, 1)); - c2.insert (db::array (db::CellInst (c1.cell_index ()), db::Trans (db::Vector (17, -42)), db::Vector (0, 1), db::Vector (1, 0), 1, 1)); - - std::string tmp_file = tl::TestBase::tmp_file ("tmp.oas"); - - { - tl::OutputStream out (tmp_file); - db::SaveLayoutOptions options; - options.set_format ("OASIS"); - db::Writer writer (options); - writer.write (g, out); - } - - tl::InputStream in (tmp_file); - db::Reader reader (in); - db::Layout gg; - reader.set_warnings_as_errors (true); - reader.read (gg); - - const char *expected = - "begin_lib 0.001\n" - "begin_cell {$1}\n" - "box 1 0 {100 0} {100 200}\n" - "end_cell\n" - "begin_cell {$2}\n" - "sref {$1} 0 0 1 {0 0}\n" - "sref {$1} 0 0 1 {17 -42}\n" - "end_cell\n" - "end_lib\n" - ; - - tl::OutputStringStream os; - tl::OutputStream stream (os); - db::TextWriter textwriter (stream); - textwriter.write (gg); - EXPECT_EQ (std::string (os.string ()), std::string (expected)) -} - TEST(116) { db::Manager m; @@ -1728,3 +1675,133 @@ TEST(117) EXPECT_EQ (std::string (os.string ()), std::string (expected)) } +TEST(118) +{ + // 1x1 arrays (#902) + + db::Manager m; + db::Layout g (&m); + + db::LayerProperties lp1; + lp1.layer = 1; + lp1.datatype = 0; + + g.insert_layer (0, lp1); + + db::Cell &c1 (g.cell (g.add_cell ())); + c1.shapes (0).insert (db::Box (100, 0, 100, 200)); + + db::Cell &c2 (g.cell (g.add_cell ())); + c2.insert (db::array (db::CellInst (c1.cell_index ()), db::Trans (), db::Vector (0, 1), db::Vector (1, 0), 1, 1)); + c2.insert (db::array (db::CellInst (c1.cell_index ()), db::Trans (db::Vector (17, -42)), db::Vector (0, 1), db::Vector (1, 0), 1, 1)); + + std::string tmp_file = tl::TestBase::tmp_file ("tmp.oas"); + + { + tl::OutputStream out (tmp_file); + db::SaveLayoutOptions options; + options.set_format ("OASIS"); + db::Writer writer (options); + writer.write (g, out); + } + + tl::InputStream in (tmp_file); + db::Reader reader (in); + db::Layout gg; + reader.set_warnings_as_errors (true); + reader.read (gg); + + const char *expected = + "begin_lib 0.001\n" + "begin_cell {$1}\n" + "box 1 0 {100 0} {100 200}\n" + "end_cell\n" + "begin_cell {$2}\n" + "sref {$1} 0 0 1 {0 0}\n" + "sref {$1} 0 0 1 {17 -42}\n" + "end_cell\n" + "end_lib\n" + ; + + tl::OutputStringStream os; + tl::OutputStream stream (os); + db::TextWriter textwriter (stream); + textwriter.write (gg); + EXPECT_EQ (std::string (os.string ()), std::string (expected)) +} + +TEST(119_WithAndWithoutContext) +{ + // PCells with context and without + + db::Manager m; + db::Layout g (&m); + + // Note: this sample requires the BASIC lib + + { + std::string fn (tl::testsrc ()); + fn += "/testdata/oasis/pcell_test.gds"; + tl::InputStream stream (fn); + db::Reader reader (stream); + reader.read (g); + } + + std::string tmp_file = tl::TestBase::tmp_file (tl::sprintf ("tmp_dbOASISWriter119a.oas")); + + { + tl::OutputStream out (tmp_file); + db::SaveLayoutOptions options; + options.set_format ("OASIS"); + db::Writer writer (options); + writer.write (g, out); + } + + { + tl::InputStream in (tmp_file); + db::Reader reader (in); + db::Layout gg; + reader.set_warnings_as_errors (true); + reader.read (gg); + + std::pair tc = gg.cell_by_name ("TEXT"); + tl_assert (tc.first); + + const db::Cell &text_cell = gg.cell (tc.second); + EXPECT_EQ (text_cell.is_proxy (), true); + EXPECT_EQ (text_cell.get_display_name (), "Basic.TEXT('KLAYOUT RULES')"); + + CHECKPOINT (); + db::compare_layouts (_this, gg, tl::testsrc () + "/testdata/oasis/dbOASISWriter119_au.gds", db::NoNormalization); + } + + tmp_file = tl::TestBase::tmp_file (tl::sprintf ("tmp_dbOASISWriter119b.oas")); + + { + tl::OutputStream out (tmp_file); + db::SaveLayoutOptions options; + options.set_write_context_info (false); + options.set_format ("OASIS"); + db::Writer writer (options); + writer.write (g, out); + } + + { + tl::InputStream in (tmp_file); + db::Reader reader (in); + db::Layout gg; + reader.set_warnings_as_errors (true); + reader.read (gg); + + std::pair tc = gg.cell_by_name ("TEXT"); + tl_assert (tc.first); + + const db::Cell &text_cell = gg.cell (tc.second); + EXPECT_EQ (text_cell.is_proxy (), false); + EXPECT_EQ (text_cell.get_display_name (), "TEXT"); + + CHECKPOINT (); + db::compare_layouts (_this, gg, tl::testsrc () + "/testdata/oasis/dbOASISWriter119_au.gds", db::NoNormalization); + } + +} diff --git a/testdata/oasis/dbOASISWriter119_au.gds b/testdata/oasis/dbOASISWriter119_au.gds new file mode 100644 index 0000000000000000000000000000000000000000..120a3f609c2bf763dc608de6b4ac849be58bd0e1 GIT binary patch literal 3838 zcma)9LJygvg7r7x9-;5?(VL8(IGbX(q5gpbknUD6DMI}Bg#LrLWKMyR(}W? z3^A>gj3Ff<6b4GBLK5_X^@sR}Noj-7CT-}89F?#wgp{p|dn-~01& z&NZHiMwgmgBs%U_aqbZKVaXU*H*8(eI1 z1$VIXyv6-X7n^v(7_TsDBE~C<8e@jjG2i#Q+{c*sX=5T!hm3uQ`%T8geiS(#+oy3d zdKRCP_!LSWX(Q>6`i_XyC%s#(~#o^VRK?HS;K|litJ(^2a=o z(JzcCpB<9@EMKL5k{ow>B=ae&Qy!W1V#SE$B>iUAD^3tEUtjDzRBn}C7VC<3B^jo(!B;`{EH9lp~*;(fE zzmopzuS>5!n6IW4^4C11{*Y16nC2Af*$U#G`=ohDc8!Z1)sIHZH}^?nmGf(vFTU+( z%WCP}k9lKXNY>Rl5|aIFJ*a+?9B;oEl6GyU(1OGt%ohrv8wTtH$)44~Tot z59M6vy=N4^Z@$>SL~=4Z)tG+t%98h`xChz4zWIt1#IyB|!!o|Zxt!FwT-TES1e~xI z5pc3vVzyE_WHJn*6J+5d7>C@_=@ptWJ6-lQG9AHA9s++6V>3a>>972PnCSu`C#grd zwUd25|8`|Gup>*2A?dI2Td^r4e`NFn$(?JQt)NOUpSKhN9B>fh=5|a7}toU0*EUyT60jWRXd+8@H z$q&hk^XeFRS@Y;fc_CK1Bjcz3lAn_OA=w8$IoQ|q-|9EXxak){(!Tf|=%F5xS4n+H z%I{sG{7Bk!osbhx$uDWw0pz^w`XCSEYeZx|l+$j~?vPwZla@;_hg_&%iGET}Qoj;& z=y+=!D)hsv>LGl=j-+1AcOe)Axs@CfBVa=e}W7Yk=#P zaV_z0(=MwfB7e#`Zgpsl9SY@oPOqg9Pm1b{>=kfKjn-&_qBk~r`+0M&(jb0K56whj?3DEeQ)6l z_N0vizcw!Xx%k{K^v8X{ILw=IEul|2{c+FJkE0upXL&ZUzJTa`e;w{E-MMAQ?&e8Q z>Uob3Jh8CvnMDH&o_u&kM|4+P8mS6V$EAJYUsrUWMYe2lQ zURni0{>MsVD)44-5q-^8`~HQ^;0fO!Mc*rTf_yY>^!?wT#r_)h{qx7MuhxM$Gpe_M zCD>nkeg8MeYmb6>5>LJ%PTwGT!yf519+6$sC|Ow-#?g$T882{d5gH17f+1f022Er?6kK?~_;?jYmMp8}@*2;Jm=E z26FNZ$!m{-(5u-iyXr0SQ?*WhCk-o3ZlmH>?o=Mx6Ur-FtvoAMEAPx@)sewmvaSrz zXVl4gX5E~3&A*7kYgEEc_QMMnblCV>x;f6?NUJA|5yY00EfwVgLXD literal 0 HcmV?d00001 diff --git a/testdata/oasis/pcell_test.gds b/testdata/oasis/pcell_test.gds new file mode 100644 index 0000000000000000000000000000000000000000..031c8f8e2ddcd8fcb68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