First test for generic DRC feature

This commit is contained in:
Matthias Koefferlein 2021-01-06 09:52:24 +01:00
parent 736fe874eb
commit 0d9ee8a70d
8 changed files with 127 additions and 11 deletions

View File

@ -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

View File

@ -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%

View File

@ -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);
}

View File

@ -8,6 +8,7 @@ include($$PWD/../../lib_ut.pri)
SOURCES = \
drcBasicTests.cc \
drcGenericTests.cc \
drcSimpleTests.cc \
drcSuiteTests.cc \

30
testdata/drc/drcGenericTests_1.drc vendored Normal file
View File

@ -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)

BIN
testdata/drc/drcGenericTests_1.gds vendored Normal file

Binary file not shown.

BIN
testdata/drc/drcGenericTests_au1.gds vendored Normal file

Binary file not shown.

BIN
testdata/drc/drcGenericTests_au1d.gds vendored Normal file

Binary file not shown.