strmxor: fixes and basic functionality tests.

This commit is contained in:
Matthias Koefferlein
2017-08-21 00:00:27 +02:00
parent 394947df72
commit 1baddd3632
11 changed files with 254 additions and 4 deletions
+24 -3
View File
@@ -26,10 +26,13 @@
#include "dbReader.h"
#include "dbWriter.h"
#include "dbSaveLayoutOptions.h"
#include "gsiExpression.h"
#include "tlCommandLineParser.h"
BD_PUBLIC int strmxor (int argc, char *argv[])
{
gsi::initialize_expressions ();
bd::GenericReaderOptions generic_reader_options_a;
generic_reader_options_a.set_prefix ("a");
generic_reader_options_a.set_long_prefix ("a-");
@@ -56,7 +59,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
cmd << tl::arg ("input_a", &infile_a, "The first input file (any format, may be gzip compressed)")
<< tl::arg ("input_b", &infile_b, "The second input file (any format, may be gzip compressed)")
<< tl::arg ("?output", &output, "The output file to which the XOR differences are written",
"This argument is optional. If not given, the exit status along indicates whether the layouts "
"This argument is optional. If not given, the exit status alone will indicate whether the layouts "
"are identical or not."
)
<< tl::arg ("-ta|--top-a=name", &top_a, "Specifies the cell to take as top cell from the first layout",
@@ -67,7 +70,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
<< tl::arg ("-tb|--top-b=name", &top_b, "Specifies the cell to take as top cell from the second layout",
"See --top-a for details."
)
<< tl::arg ("-s|--silent", &silent, "Enables silent mode",
<< tl::arg ("-s|--silent", &silent, "Silent mode",
"In silent mode, no summary is printed, but the exit code indicates whether "
"the layouts are the same (0) or differences exist (> 0)."
)
@@ -185,9 +188,22 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
proc.set_dbu (std::min (layout_a.dbu (), layout_b.dbu ()));
proc.set_threads (std::max (1, threads));
if (tile_size > db::epsilon) {
if (tl::verbosity () >= 20) {
tl::log << "Tile size: " << tile_size;
}
proc.tile_size (tile_size, tile_size);
}
proc.tile_border (tolerances.back () * 2.0, tolerances.back () * 2.0);
if (tl::verbosity () >= 20) {
tl::log << "Tile border: " << tolerances.back () * 2.0;
}
if (tl::verbosity () >= 20) {
tl::log << "Database unit: " << proc.dbu ();
tl::log << "Threads: " << threads;
tl::log << "Layer bump for tolerance: " << tolerance_bump;
}
db::Layout output_layout;
output_layout.dbu (proc.dbu ());
@@ -246,12 +262,17 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
proc.output (out, output_layout, output_top, output_layer);
if (*t > db::epsilon) {
expr += "x=x.sized(-int(" + tl::to_string (*t) + "/_dbu)/2).sized(int(" + tl::to_string (*t) + "/_dbu)/2); ";
expr += "x=x.sized(-round(" + tl::to_string (*t) + "/_dbu)/2).sized(round(" + tl::to_string (*t) + "/_dbu)/2); ";
}
expr += "_output(" + out + ",x); ";
++tol_index;
}
if (tl::verbosity () >= 20) {
tl::log << "Running expression: '" << expr << "' for layer " << ll->first;
}
proc.queue (expr);
}
+228
View File
@@ -0,0 +1,228 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2017 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "utHead.h"
#include "bdCommon.h"
#include "dbReader.h"
#include "tlLog.h"
#include <sstream>
BD_PUBLIC int strmxor (int argc, char *argv[]);
TEST(1)
{
ut::CaptureChannel cap;
std::string input_a = ut::testsrc ();
input_a += "/testdata/bd/strmxor_in1.gds";
std::string input_b = ut::testsrc ();
input_b += "/testdata/bd/strmxor_in2.gds";
std::string au = ut::testsrc ();
au += "/testdata/bd/strmxor_au1.oas";
std::string output = this->tmp_file ("tmp.oas");
char *argv[] = { "x", const_cast<char *> (input_a.c_str ()), const_cast<char *> (input_b.c_str ()), const_cast<char *> (output.c_str ()) };
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), argv), 1);
db::Layout layout;
{
tl::InputStream stream (output);
db::Reader reader (stream);
reader.read (layout);
}
this->compare_layouts (layout, au, ut::NoNormalization);
EXPECT_EQ (cap.captured_text (),
"Layer 10/0 is not present in first layout, but in second\n"
);
}
TEST(2)
{
ut::CaptureChannel cap;
std::string input_a = ut::testsrc ();
input_a += "/testdata/bd/strmxor_in1.gds";
std::string input_b = ut::testsrc ();
input_b += "/testdata/bd/strmxor_in2.gds";
std::string au = ut::testsrc ();
au += "/testdata/bd/strmxor_au2.oas";
std::string output = this->tmp_file ("tmp.oas");
char *argv[] = { "x", "-l", const_cast<char *> (input_a.c_str ()), const_cast<char *> (input_b.c_str ()), const_cast<char *> (output.c_str ()) };
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), argv), 1);
db::Layout layout;
{
tl::InputStream stream (output);
db::Reader reader (stream);
reader.read (layout);
}
this->compare_layouts (layout, au, ut::NoNormalization);
EXPECT_EQ (cap.captured_text (),
""
);
}
TEST(3)
{
ut::CaptureChannel cap;
std::string input_a = ut::testsrc ();
input_a += "/testdata/bd/strmxor_in1.gds";
std::string input_b = ut::testsrc ();
input_b += "/testdata/bd/strmxor_in2.gds";
std::string au = ut::testsrc ();
au += "/testdata/bd/strmxor_au3.oas";
std::string output = this->tmp_file ("tmp.oas");
char *argv[] = { "x", "-p=1.0", "-n=4", const_cast<char *> (input_a.c_str ()), const_cast<char *> (input_b.c_str ()), const_cast<char *> (output.c_str ()) };
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), argv), 1);
db::Layout layout;
{
tl::InputStream stream (output);
db::Reader reader (stream);
reader.read (layout);
}
this->compare_layouts (layout, au, ut::NoNormalization);
EXPECT_EQ (cap.captured_text (),
"Layer 10/0 is not present in first layout, but in second\n"
);
}
TEST(4)
{
ut::CaptureChannel cap;
std::string input_a = ut::testsrc ();
input_a += "/testdata/bd/strmxor_in1.gds";
std::string input_b = ut::testsrc ();
input_b += "/testdata/bd/strmxor_in2.gds";
std::string au = ut::testsrc ();
au += "/testdata/bd/strmxor_au4.oas";
std::string output = this->tmp_file ("tmp.oas");
char *argv[] = { "x", "-p=1.0", "-n=4", "-t=0.0,0.005,0.01,0.02,0.09,0.1", const_cast<char *> (input_a.c_str ()), const_cast<char *> (input_b.c_str ()), const_cast<char *> (output.c_str ()) };
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), argv), 1);
db::Layout layout;
{
tl::InputStream stream (output);
db::Reader reader (stream);
reader.read (layout);
}
this->compare_layouts (layout, au, ut::NoNormalization);
EXPECT_EQ (cap.captured_text (),
"Layer 10/0 is not present in first layout, but in second\n"
);
}
TEST(5)
{
ut::CaptureChannel cap;
std::string input_a = ut::testsrc ();
input_a += "/testdata/bd/strmxor_in1.gds";
std::string input_b = ut::testsrc ();
input_b += "/testdata/bd/strmxor_in2.gds";
std::string au = ut::testsrc ();
au += "/testdata/bd/strmxor_au5.oas";
std::string output = this->tmp_file ("tmp.oas");
char *argv[] = { "x", "-b=1000", "-t=0.0,0.005,0.01,0.02,0.09,0.1", const_cast<char *> (input_a.c_str ()), const_cast<char *> (input_b.c_str ()), const_cast<char *> (output.c_str ()) };
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), argv), 1);
db::Layout layout;
{
tl::InputStream stream (output);
db::Reader reader (stream);
reader.read (layout);
}
this->compare_layouts (layout, au, ut::NoNormalization);
EXPECT_EQ (cap.captured_text (),
"Layer 10/0 is not present in first layout, but in second\n"
);
}
TEST(6)
{
ut::CaptureChannel cap;
std::string input_a = ut::testsrc ();
input_a += "/testdata/bd/strmxor_in1.gds";
std::string input_b = ut::testsrc ();
input_b += "/testdata/bd/strmxor_in2.gds";
std::string au = ut::testsrc ();
au += "/testdata/bd/strmxor_au6.oas";
std::string output = this->tmp_file ("tmp.oas");
char *argv[] = { "x", "-ta=INV2", "-tb=2VNI", const_cast<char *> (input_a.c_str ()), const_cast<char *> (input_b.c_str ()), const_cast<char *> (output.c_str ()) };
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), argv), 1);
db::Layout layout;
{
tl::InputStream stream (output);
db::Reader reader (stream);
reader.read (layout);
}
this->compare_layouts (layout, au, ut::NoNormalization);
EXPECT_EQ (cap.captured_text (),
"Layer 10/0 is not present in first layout, but in second\n"
);
}
+2 -1
View File
@@ -9,7 +9,8 @@ SOURCES = \
bdConverterTests.cc \
bdStrm2txtTests.cc \
bdStrmclipTests.cc \
bdStrmcmpTests.cc
bdStrmcmpTests.cc \
bdStrmxorTests.cc \
INCLUDEPATH += ../src/bd
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.