From 0d9ee8a70dd06359dace2239b09a1fd83b0d1122 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 6 Jan 2021 09:52:24 +0100 Subject: [PATCH] First test for generic DRC feature --- .../drc/built-in-macros/_drc_complex_ops.rb | 6 +- .../built-in-macros/_drc_cop_integration.rb | 21 +++-- src/drc/unit_tests/drcGenericTests.cc | 80 ++++++++++++++++++ src/drc/unit_tests/unit_tests.pro | 1 + testdata/drc/drcGenericTests_1.drc | 30 +++++++ testdata/drc/drcGenericTests_1.gds | Bin 0 -> 1020 bytes testdata/drc/drcGenericTests_au1.gds | Bin 0 -> 8382 bytes testdata/drc/drcGenericTests_au1d.gds | Bin 0 -> 4724 bytes 8 files changed, 127 insertions(+), 11 deletions(-) create mode 100644 src/drc/unit_tests/drcGenericTests.cc create mode 100644 testdata/drc/drcGenericTests_1.drc create mode 100644 testdata/drc/drcGenericTests_1.gds create mode 100644 testdata/drc/drcGenericTests_au1.gds create mode 100644 testdata/drc/drcGenericTests_au1d.gds diff --git a/src/drc/drc/built-in-macros/_drc_complex_ops.rb b/src/drc/drc/built-in-macros/_drc_complex_ops.rb index 8569143f0..adf7b579f 100644 --- a/src/drc/drc/built-in-macros/_drc_complex_ops.rb +++ b/src/drc/drc/built-in-macros/_drc_complex_ops.rb @@ -1119,7 +1119,7 @@ class DRCOpNodeWithCompare < DRCOpNode end def _self_or_original - return self.original || self + return (self.original || self).dup end def ==(other) @@ -1505,7 +1505,6 @@ class DRCOpNodeCheck < DRCOpNodeWithCompare if self.gt || self.ge dmax = self.ge ? @engine._make_value(self.ge) : @engine._make_value(self.gt) + 1 max_check = RBA::CompoundRegionOperationNode::send(factory, dmax, *self.args + [ true ]) - res_max = RBA::CompoundRegionOperationNode::new_edge_pair_to_first_edges(max_check) if res if self.check == :width || self.check == :notch # Same polygon check - we need to take both edges of the result @@ -1513,9 +1512,10 @@ class DRCOpNodeCheck < DRCOpNodeWithCompare else and_with = RBA::CompoundRegionOperationNode::new_edge_pair_to_first_edges(res) end + res_max = RBA::CompoundRegionOperationNode::new_edge_pair_to_first_edges(max_check) res = RBA::CompoundRegionOperationNode::new_geometrical_boolean(RBA::CompoundRegionOperationNode::GeometricalOp::And, and_with, res_max) else - res = res_max + res = max_check end end diff --git a/src/drc/drc/built-in-macros/_drc_cop_integration.rb b/src/drc/drc/built-in-macros/_drc_cop_integration.rb index 2a76fa4df..f9f233857 100644 --- a/src/drc/drc/built-in-macros/_drc_cop_integration.rb +++ b/src/drc/drc/built-in-macros/_drc_cop_integration.rb @@ -76,8 +76,8 @@ module DRC def drc(op) @engine._context("drc") do requires_region - expr.is_a?(DRCOpNode) || raise("A DRC expression is required for the argument (got #{expr.inspect})") - return DRCLayer::new(@engine, self.data.complex_op(op.create_node({}))) + op.is_a?(DRCOpNode) || raise("A DRC expression is required for the argument (got #{op.inspect})") + DRCLayer::new(@engine, self.data.complex_op(op.create_node({}))) end end @@ -632,9 +632,13 @@ CODE # out = in.drc(0.1.um <= enclosing(other) < 0.2.um) # @/code # - # The result of the enclosing check are edge pairs forming the violation - # markers. With a lower limit, these markers are formed by two, identical but opposite edges attached to - # the primary shape. Without a lower limit, the first edge of the marker is attached to the + # The result of the enclosing check are edges or edge pairs forming the markers. + # These markers indicate the presence of the specified condition. + # + # With a lower and upper limit, the results are edges marking the positions on the + # primary shape where the condition is met. + # With a lower limit alone, these markers are formed by two, identical but opposite edges attached to + # the primary shape. Without an upper limit only, the first edge of the marker is attached to the # primary shape while the second edge is attached to the shape of the "other" layer. # %DRC% @@ -682,9 +686,10 @@ CODE # out = in.drc(0.1.um <= width < 0.2.um) # @/code # - # The result of the width check are edge pairs forming the violation - # markers. With a lower limit, these markers are formed by two, identical but opposite edges attached to - # the primary shape. Without a lower limit, both edges are attached to different sides of the primary + # With a lower and upper limit, the results are edges marking the positions on the + # primary shape where the condition is met. + # With a lower limit alone, these markers are formed by two, identical but opposite edges attached to + # the primary shape. Without an upper limit only, both edges are attached to different sides of the primary # shape. # %DRC% diff --git a/src/drc/unit_tests/drcGenericTests.cc b/src/drc/unit_tests/drcGenericTests.cc new file mode 100644 index 000000000..41b416b4e --- /dev/null +++ b/src/drc/unit_tests/drcGenericTests.cc @@ -0,0 +1,80 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2021 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 "tlUnitTest.h" +#include "dbReader.h" +#include "dbTestSupport.h" +#include "dbNetlist.h" +#include "dbNetlistSpiceReader.h" +#include "lymMacro.h" +#include "tlFileUtils.h" + +static void runTest (tl::TestBase *_this, const std::string &number, bool deep) +{ + std::string rs = tl::testsrc (); + rs += "/testdata/drc/drcGenericTests_" + number + ".drc"; + + std::string input = tl::testsrc (); + input += "/testdata/drc/drcGenericTests_" + number + ".gds"; + + std::string au = tl::testsrc (); + au += "/testdata/drc/drcGenericTests_au" + number + std::string (deep ? "d" : "") + ".gds"; + + std::string output = _this->tmp_file ("tmp.gds"); + + { + // Set some variables + lym::Macro config; + config.set_text (tl::sprintf ( + "$drc_test_source = '%s'\n" + "$drc_test_target = '%s'\n" + "$drc_test_deep = %s\n" + , input, output, deep ? "true" : "false") + ); + config.set_interpreter (lym::Macro::Ruby); + EXPECT_EQ (config.run (), 0); + } + + lym::Macro drc; + drc.load_from (rs); + EXPECT_EQ (drc.run (), 0); + + db::Layout layout; + + { + tl::InputStream stream (output); + db::Reader reader (stream); + reader.read (layout); + } + + db::compare_layouts (_this, layout, au, db::NoNormalization); +} + +TEST(1) +{ + runTest (_this, "1", false); +} + +TEST(1d) +{ + runTest (_this, "1", true); +} diff --git a/src/drc/unit_tests/unit_tests.pro b/src/drc/unit_tests/unit_tests.pro index 1acc6688f..30b2d3db0 100644 --- a/src/drc/unit_tests/unit_tests.pro +++ b/src/drc/unit_tests/unit_tests.pro @@ -8,6 +8,7 @@ include($$PWD/../../lib_ut.pri) SOURCES = \ drcBasicTests.cc \ + drcGenericTests.cc \ drcSimpleTests.cc \ drcSuiteTests.cc \ diff --git a/testdata/drc/drcGenericTests_1.drc b/testdata/drc/drcGenericTests_1.drc new file mode 100644 index 000000000..3bbb96f4b --- /dev/null +++ b/testdata/drc/drcGenericTests_1.drc @@ -0,0 +1,30 @@ + +source $drc_test_source +target $drc_test_target + +if $drc_test_deep + deep +end + +l1 = input(1, 0) +l2 = input(2, 0) +l3 = input(3, 0) + +l1.output(1, 0) +l2.output(2, 0) +l3.output(3, 0) + +wcheck = width(projection) + +l1.drc(wcheck < 1.0).polygons.output(100, 0) +l1.drc(wcheck <= 0.5).polygons.output(101, 0) +l1.drc(1.0 > wcheck).polygons.output(102, 0) +l1.drc(0.5 >= wcheck).polygons.output(103, 0) +l1.drc(wcheck > 1.0).output(104, 0) +l1.drc(wcheck >= 1.5).output(105, 0) +l1.drc(1.0 < wcheck).output(106, 0) +l1.drc(1.5 <= wcheck).output(107, 0) +l1.drc(wcheck == 1.5).output(108, 0) +l1.drc(1.0 <= wcheck <= 1.5).output(109, 0) +l1.drc(1.0 < wcheck < 2.0).output(110, 0) + diff --git a/testdata/drc/drcGenericTests_1.gds b/testdata/drc/drcGenericTests_1.gds new file mode 100644 index 0000000000000000000000000000000000000000..18c6261a138332ab52f1f70c58ab1464a815dc84 GIT binary patch literal 1020 zcmaiyy-or_6on7_Gc33Wq6S4uOB3yki7|o{5J@Cv3u9$rX+ddWVPT=qU_+;cr3DXQ ztbG7WO^7ju7-Niu*ZJ{=AuPDXe#4nL_s-q}1RQ4%rG%4wMgjsU%%Nzn5jdhzuK+Wy zzfrze-M+u-tyMeA?aTcLC4Y=hh-P^=f)@ZHPdiFyaBf1j*NYX3j!1wuqSO_N(ySEh0tbQ}vjv7g_^;D-$(OHABPC cb)wf}A|~r{)^>k)FjM7;&xCbJ&cyTZ3v#662><{9 literal 0 HcmV?d00001 diff --git a/testdata/drc/drcGenericTests_au1.gds b/testdata/drc/drcGenericTests_au1.gds new file mode 100644 index 0000000000000000000000000000000000000000..8b1e4402057e29d4666604cb2387bf036a710d28 GIT binary patch literal 8382 zcmbuE&ud*p6vt2QOI{L^_>^ZTLN|g-G3`nO5fnj-fS~tfhqT2=Z{z@qF*O-+O1?%SyRi)dzBV zu3G#{=Av!(I7jU;J`t@Yh`Uz!Re~HxZ+=Cx&|DdBS z^s!UypIwjhU~nIFd8YYRlj~OKRDZasOHi6?-V_0u19#x2lAU@-H)%?`k{=+^V_9=kKIA&8e#TXO{$j^l-|18IEh^&^{`Jv}{Kqr$pUlXA+VSdpzv=t; zv*~b0^$&dy8)aP8-@hooa$o1?dwm|Yd2XE7ck2f7n+|tWZz8`b<0*dcw(+&zZ#b$x z*RIFvSHE0A?nX8D;2V2Jt&HD@@#@omt7mLBdfxaEmGR9yetcG+^N)H*qwRAO{NQWU zuX$D5yiI<_Rg?W2Zg>4h|Iq(h8Q+fawr}H&MzwC4v-)dgd?U?s|Ho(bIcwle8IRY` z{+eQL_P(|Gfnt7+>p!j!w>#dSzc!v&|AQZFexRfC>VrRZiu&z(eEo-S84ty}56^W9 z-mb@Z?bCNyr)k@_rhkm5-XFjIM>j2hs~Po=Hnm>ubFCBgxA8>(_b(X>#rpTJbc$!% z_1OAte{mo8A3XX{E92q&^Vy947v)>uOZ%V4+q+Ajqwi4}pXgt}+k7{3PT!**J^uk; z;C~)p`d^gK z^goX;^1p!h=YNI1M?KpA0=~fiJif^PqC9<%8u7n?FYv#BFYrH)FY>=Bo<2w4qcT3> ze*y3JKhyuF_}1t0{4d}O{4d}O{LkZy{LkZy{4d}O{4d}O{4d}O{O{6?{ukvl{mnQ&-A}3 z{)GM)@CE)C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