From 26f8fc5c830a5af48fe090d5b6402023351b63e1 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 Sep 2019 21:27:12 +0200 Subject: [PATCH] Bug fixed strmxor with deep mode, added tests. --- src/buddies/src/bd/strmxor.cc | 21 +- src/buddies/unit_tests/bdStrmxorTests.cc | 318 ++++++++++++++++++++++- testdata/bd/strmxor_au1d.oas | Bin 0 -> 818 bytes testdata/bd/strmxor_au2d.oas | Bin 0 -> 843 bytes testdata/bd/strmxor_au3d.oas | Bin 0 -> 818 bytes testdata/bd/strmxor_au4d.oas | Bin 0 -> 1033 bytes testdata/bd/strmxor_au5d.oas | Bin 0 -> 1026 bytes testdata/bd/strmxor_au6d.oas | Bin 0 -> 498 bytes 8 files changed, 321 insertions(+), 18 deletions(-) create mode 100644 testdata/bd/strmxor_au1d.oas create mode 100644 testdata/bd/strmxor_au2d.oas create mode 100644 testdata/bd/strmxor_au3d.oas create mode 100644 testdata/bd/strmxor_au4d.oas create mode 100644 testdata/bd/strmxor_au5d.oas create mode 100644 testdata/bd/strmxor_au6d.oas diff --git a/src/buddies/src/bd/strmxor.cc b/src/buddies/src/bd/strmxor.cc index da2092718..bc592af0b 100644 --- a/src/buddies/src/bd/strmxor.cc +++ b/src/buddies/src/bd/strmxor.cc @@ -94,9 +94,11 @@ struct ResultDescriptor size_t count () const { if (layout && layer_output >= 0) { - // NOTE: this assumes the output is flat - tl_assert (layout->cells () == 1); - return layout->cell (top_cell).shapes (layer_output).size (); + size_t res = 0; + for (db::Layout::const_iterator c = layout->begin (); c != layout->end (); ++c) { + res += c->shapes (layer_output).size (); + } + return res; } else { return shape_count; } @@ -105,9 +107,12 @@ struct ResultDescriptor bool is_empty () const { if (layout && layer_output >= 0) { - // NOTE: this assumes the output is flat - tl_assert (layout->cells () == 1); - return layout->cell (top_cell).shapes (layer_output).empty (); + for (db::Layout::const_iterator c = layout->begin (); c != layout->end (); ++c) { + if (! c->shapes (layer_output).empty ()) { + return false; + } + } + return true; } else { return shape_count == 0; } @@ -185,7 +190,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[]) << tl::arg ("-tb|--top-b=name", &top_b, "Specifies the top cell for the second layout", "See --top-a for details." ) - << tl::arg ("-d|--deep", &deep, "Deep (hierarchical mode)", + << tl::arg ("-u|--deep", &deep, "Deep (hierarchical mode)", "Enables hierarchical XOR (experimental). In this mode, tiling is not supported " "and the tiling arguments are ignored." ) @@ -593,7 +598,7 @@ bool run_deep_xor (const XORData &xor_data) ri_a = db::RecursiveShapeIterator (*xor_data.layout_a, xor_data.layout_a->cell (xor_data.cell_a), ll->second.first); } - if (ll->second.second < 0) { + if (ll->second.second >= 0) { ri_b = db::RecursiveShapeIterator (*xor_data.layout_b, xor_data.layout_b->cell (xor_data.cell_b), ll->second.second); } diff --git a/src/buddies/unit_tests/bdStrmxorTests.cc b/src/buddies/unit_tests/bdStrmxorTests.cc index 27871f521..2ccf0a4d1 100644 --- a/src/buddies/unit_tests/bdStrmxorTests.cc +++ b/src/buddies/unit_tests/bdStrmxorTests.cc @@ -30,7 +30,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[]); -TEST(0) +TEST(0_Basic_Flat) { tl::CaptureChannel cap; @@ -51,7 +51,28 @@ TEST(0) ); } -TEST(1A) +TEST(0_Basic_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in1.gds"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "-u", input_a.c_str (), input_b.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 0); + + EXPECT_EQ (cap.captured_text (), + "No differences found\n" + ); +} + +TEST(1A_Flat) { tl::CaptureChannel cap; @@ -93,7 +114,49 @@ TEST(1A) ); } -TEST(1B) +TEST(1A_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in2.gds"; + + std::string au = tl::testsrc (); + au += "/testdata/bd/strmxor_au1d.oas"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "--deep", input_a.c_str (), input_b.c_str (), output.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + + db::Layout layout; + + { + tl::InputStream stream (output); + db::Reader reader (stream); + reader.read (layout); + } + + db::compare_layouts (this, layout, au, db::NoNormalization); + EXPECT_EQ (cap.captured_text (), + "Layer 10/0 is not present in first layout, but in second\n" + "Result summary (layers without differences are not shown):\n" + "\n" + " Layer Output Differences (shape count)\n" + " -------------------------------------------------------\n" + " 3/0 3/0 3\n" + " 6/0 6/0 314\n" + " 8/1 8/1 1\n" + " 10/0 - (no such layer in first layout)\n" + "\n" + ); +} + +TEST(1B_Flat) { tl::CaptureChannel cap; @@ -123,7 +186,37 @@ TEST(1B) ); } -TEST(1C) +TEST(1B_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in2.gds"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "-u", input_a.c_str (), input_b.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + + EXPECT_EQ (cap.captured_text (), + "Layer 10/0 is not present in first layout, but in second\n" + "Result summary (layers without differences are not shown):\n" + "\n" + " Layer Output Differences (shape count)\n" + " -------------------------------------------------------\n" + " 3/0 - 30\n" + " 6/0 - 314\n" + " 8/1 - 1\n" + " 10/0 - (no such layer in first layout)\n" + "\n" + ); +} + +TEST(1C_Flat) { tl::CaptureChannel cap; @@ -144,7 +237,28 @@ TEST(1C) ); } -TEST(1D) +TEST(1C_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in2.gds"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "-u", "--no-summary", input_a.c_str (), input_b.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + + EXPECT_EQ (cap.captured_text (), + "Layer 10/0 is not present in first layout, but in second\n" + ); +} + +TEST(1D_Flat) { tl::CaptureChannel cap; @@ -162,7 +276,25 @@ TEST(1D) EXPECT_EQ (cap.captured_text (), ""); } -TEST(2) +TEST(1D_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in2.gds"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "-u", "-s", input_a.c_str (), input_b.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + EXPECT_EQ (cap.captured_text (), ""); +} + +TEST(2_Flat) { tl::CaptureChannel cap; @@ -195,7 +327,40 @@ TEST(2) ); } -TEST(3) +TEST(2_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in2.gds"; + + std::string au = tl::testsrc (); + au += "/testdata/bd/strmxor_au2d.oas"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "-u", "--no-summary", "-l", input_a.c_str (), input_b.c_str (), output.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + + db::Layout layout; + + { + tl::InputStream stream (output); + db::Reader reader (stream); + reader.read (layout); + } + + db::compare_layouts (this, layout, au, db::NoNormalization); + EXPECT_EQ (cap.captured_text (), + "" + ); +} + +TEST(3_Flat) { tl::CaptureChannel cap; @@ -228,7 +393,41 @@ TEST(3) ); } -TEST(4) +TEST(3_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in2.gds"; + + std::string au = tl::testsrc (); + au += "/testdata/bd/strmxor_au3d.oas"; + + std::string output = this->tmp_file ("tmp.oas"); + + // NOTE: -p is ignored in deep mode + const char *argv[] = { "x", "-u", "--no-summary", "-p=1.0", "-n=4", input_a.c_str (), input_b.c_str (), output.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + + db::Layout layout; + + { + tl::InputStream stream (output); + db::Reader reader (stream); + reader.read (layout); + } + + db::compare_layouts (this, layout, au, db::NoNormalization); + EXPECT_EQ (cap.captured_text (), + "Layer 10/0 is not present in first layout, but in second\n" + ); +} + +TEST(4_Flat) { tl::CaptureChannel cap; @@ -261,7 +460,40 @@ TEST(4) ); } -TEST(5) +TEST(4_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in2.gds"; + + std::string au = tl::testsrc (); + au += "/testdata/bd/strmxor_au4d.oas"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "-u", "--no-summary", "-p=1.0", "-n=4", "-t=0.0,0.005,0.01,0.02,0.09,0.1", input_a.c_str (), input_b.c_str (), output.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + + db::Layout layout; + + { + tl::InputStream stream (output); + db::Reader reader (stream); + reader.read (layout); + } + + db::compare_layouts (this, layout, au, db::NoNormalization); + EXPECT_EQ (cap.captured_text (), + "Layer 10/0 is not present in first layout, but in second\n" + ); +} + +TEST(5_Flat) { tl::CaptureChannel cap; @@ -294,7 +526,40 @@ TEST(5) ); } -TEST(6) +TEST(5_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in2.gds"; + + std::string au = tl::testsrc (); + au += "/testdata/bd/strmxor_au5d.oas"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "-u", "--no-summary", "-b=1000", "-t=0.0,0.005,0.01,0.02,0.09,0.1", input_a.c_str (), input_b.c_str (), output.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + + db::Layout layout; + + { + tl::InputStream stream (output); + db::Reader reader (stream); + reader.read (layout); + } + + db::compare_layouts (this, layout, au, db::NoNormalization); + EXPECT_EQ (cap.captured_text (), + "Layer 10/0 is not present in first layout, but in second\n" + ); +} + +TEST(6_Flat) { tl::CaptureChannel cap; @@ -326,3 +591,36 @@ TEST(6) "Layer 10/0 is not present in first layout, but in second\n" ); } + +TEST(6_Deep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testsrc (); + input_a += "/testdata/bd/strmxor_in1.gds"; + + std::string input_b = tl::testsrc (); + input_b += "/testdata/bd/strmxor_in2.gds"; + + std::string au = tl::testsrc (); + au += "/testdata/bd/strmxor_au6d.oas"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "-u", "--no-summary", "-ta=INV2", "-tb=2VNI", input_a.c_str (), input_b.c_str (), output.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + + db::Layout layout; + + { + tl::InputStream stream (output); + db::Reader reader (stream); + reader.read (layout); + } + + db::compare_layouts (this, layout, au, db::NoNormalization); + EXPECT_EQ (cap.captured_text (), + "Layer 10/0 is not present in first layout, but in second\n" + ); +} diff --git a/testdata/bd/strmxor_au1d.oas b/testdata/bd/strmxor_au1d.o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S$#2-!dlP}|(57BavLy-gGaY(0 N;UaYfr0|~$p-*?^@LlU)1qNTR zopSMxbE~kqsY%<#l0?g;yk$#srgiVSB>qHE6eoPtkX1D1dg4)CMtn^|n0S=EmV8Y` zM*-7!v)bczQ_(@zBcQt%B&fi(m;dNXeV-_@mS_Y zGsXhHZ)3tQPzk?RFlm8uI_!AZU)&ANwvxcxlNANIpGkc=kW!gXrl$j7oybh}PzTj& zHsmq~eZ*D+T5)2*+vw zpB;S;D=^wG)Po&>1L5k1g5mNW_${fCeZx53vp8;wSJD=*q}wJO_n%6{{ht>?e*vd? BOg{hs literal 0 HcmV?d00001 diff --git a/testdata/bd/strmxor_au5d.oas b/testdata/bd/strmxor_au5d.oas new file mode 100644 index 0000000000000000000000000000000000000000..fed55a71321fc55a3d4f6f0d9ce31a4d367185a8 GIT binary patch literal 1026 zcmd^7L2DC16rP#wY&P9ZH`&b4BrM&Fq6aP3Q$R}zHq?bSk!;lVl#3Vt#a2Azkb;LC z#8ZME;w=>qf)qp|B+|o*9^xSoA;O9xv8Uuv@Xc;hTJRtE_VV6-?|t7lZ|0(t-?Fb3 zbB^uA=CQQ0d=2>#bT&+$aVlH6?TTY>6!Pm8yHL(=yr2rLouB2QBzjYm>Y?Q4H@w@31Q+<_CoSC z6&;Z{&x*Q>dzn_6ul|gjqUaogKkFR7UF7(=6(fl*RuzxMXTjHGU}Y0}OePd7$YW#9 z%>#WP2gNg!o1JKXg}@BIiJ^y8qhB;6@@kTG7HVJ&@`lB}M&B4g{#awjWG|ctGC+T& zSc_eraj+5naULI0)?KZqNd!dLAVbjmMKLzMzz%d@o6Xf^*3zdm&|r1iiJoXYlDXN^ zS>X4TF8l(O@OuT5HYlgVi3k0Kz0hns3A{a7QIPwQG?oJ?mHA|Px&YRR&QuQ#P_0=Z z$D#27P9G>8k#Nau3JM~H9S$;+r63*AUZxIr@;ic4Pc@fTle@H&V*4qV?nC-V^=LzO zskgLChsJjbqu&gdPN5X1I+2dQ&a!6KqwVC-@Sve#1)WW6XiT9LcO+aXux~*)Rs;C# x>a$pZ)qbKLd;vHRu5Kt8E^o(gOHJz~<9Hn5xDQX{9Xyei#qpC%#QmQGp}(drNB#f+ literal 0 HcmV?d00001 diff --git a/testdata/bd/strmxor_au6d.oas b/testdata/bd/strmxor_au6d.oas new file mode 100644 index 0000000000000000000000000000000000000000..2b90eba605162f66effed2900f71099ac85e40b1 GIT binary patch literal 498 zcmY!lcJ=kt^>+;R4CduxWH!_@V0gjKfDB|rrGn#q9V6m{J>C6WUE)3cLR{TlgW|(I zT|zuKSY&u*Akv|J*c8Z!as|hS_y@#0yZZR>Fh}?YF|&pQIr;@NgV?+bqV{YIj7%T6 zFR*rU{$%B5SimO0%P9DQVIdng!v|3z!OR7045HQ`H5XV