From 13a1bf713d59bb9481109fff911c5df390562cda Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 4 Apr 2026 20:05:37 +0200 Subject: [PATCH] Added DRC integration and tests --- src/drc/drc/built-in-macros/_drc_engine.rb | 41 ++++++++++++++++++++- src/drc/unit_tests/drcSimpleTests.cc | 5 +++ testdata/algo/dss_sparse_array.gds | Bin 0 -> 568 bytes testdata/algo/dss_sparse_array_au1.gds | Bin 0 -> 1800 bytes testdata/drc/drcSimpleTests_148.drc | 39 ++++++++++++++++++++ testdata/drc/drcSimpleTests_148.gds | Bin 0 -> 568 bytes testdata/drc/drcSimpleTests_au148d.gds | Bin 0 -> 1800 bytes 7 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 testdata/algo/dss_sparse_array.gds create mode 100644 testdata/algo/dss_sparse_array_au1.gds create mode 100644 testdata/drc/drcSimpleTests_148.drc create mode 100644 testdata/drc/drcSimpleTests_148.gds create mode 100644 testdata/drc/drcSimpleTests_au148d.gds diff --git a/src/drc/drc/built-in-macros/_drc_engine.rb b/src/drc/drc/built-in-macros/_drc_engine.rb index e2ff2b7ee..fb331bc86 100644 --- a/src/drc/drc/built-in-macros/_drc_engine.rb +++ b/src/drc/drc/built-in-macros/_drc_engine.rb @@ -197,10 +197,11 @@ module DRC @total_timer = nil @drc_progress = nil - # initialize the defaults for max_area_ratio, max_vertex_count + # initialize the defaults for max_area_ratio, max_vertex_count, sparse_array_limit dss = RBA::DeepShapeStore::new @max_area_ratio = dss.max_area_ratio @max_vertex_count = dss.max_vertex_count + @sparse_array_limit = dss.sparse_array_limit @deep_reject_odd_polygons = dss.reject_odd_polygons dss._destroy @@ -1309,6 +1310,43 @@ module DRC self.max_vertex_count(count) end + # %DRC% + # @name sparse_array_limit + # @brief Gets or sets the sparse array singularization limit + # @synopsis sparse_array_limit(limit) + # @synopsis sparse_array_limit + # + # In deep mode, array instances with a bad ratio of overall bounding box area + # vs. actually covered area, induce a performance penalty, because their bounding + # box is not longer a good approximation for their footprint. + # The "sparse array limit" defines the ratio of array instance bounding box area + # vs. sum of bounding box areas of the individual instances, above which the array + # is resolved into single instances. + # + # Use this method without an argument to get the current value. + # + # By default, this feature is off (the sparse array limit value is negative). + # If your design uses many arrays with a bad coverage, you can set the sparse + # array limit to a value of 10 for example. + + def sparse_array_limit(sal = nil) + if sal + if @dss + raise("sparse_array_limit must be set before the first 'input' statement in deep mode") + end + if sal.is_a?(1.0.class) || sal.is_a?(1.class) + @sparse_array_limit = sal + else + raise("Argument is not numerical in sparse_array_limit") + end + end + @sparse_array_limit + end + + def sparse_array_limit=(sal) + self.sparse_array_limit(sal) + end + # %DRC% # @name max_area_ratio # @brief Gets or sets the maximum bounding box to polygon area ratio for deep mode fragmentation @@ -3305,6 +3343,7 @@ CODE @dss.reject_odd_polygons = @deep_reject_odd_polygons @dss.max_vertex_count = @max_vertex_count @dss.max_area_ratio = @max_area_ratio + @dss.sparse_array_limit = @sparse_array_limit r = cls.new(iter, @dss, RBA::ICplxTrans::new(sf.to_f)) diff --git a/src/drc/unit_tests/drcSimpleTests.cc b/src/drc/unit_tests/drcSimpleTests.cc index 5efe37ba9..2d6db90f1 100644 --- a/src/drc/unit_tests/drcSimpleTests.cc +++ b/src/drc/unit_tests/drcSimpleTests.cc @@ -2108,3 +2108,8 @@ TEST(147_MeasureNetsWithL2N) compare_text_files (output, au_output); } +TEST(148_sparse_array_limit) +{ + run_test (_this, "148", true); +} + diff --git a/testdata/algo/dss_sparse_array.gds b/testdata/algo/dss_sparse_array.gds new file mode 100644 index 0000000000000000000000000000000000000000..a7c1821fd8ca6d8fa7445fa43c30e5eafc44eb81 GIT binary patch literal 568 zcmaKpu}T9$5Qe|o+uNMx)MzY3?-9g+jo1VXHlm@-{H3LysMk!XA&jkj5&6P`(hIy>pXW}I}7?ha1h zi`n7vxbyfh?2{+;I;E6R$rRLzAVRGQV7C=({j=o(@ic^wTSl%|dJ*b>Gp$QN^c}*- zE!XModzW|G literal 0 HcmV?d00001 diff --git a/testdata/algo/dss_sparse_array_au1.gds b/testdata/algo/dss_sparse_array_au1.gds new file mode 100644 index 0000000000000000000000000000000000000000..118962d23b474c5e34d5a7519609177bd2a50e12 GIT binary patch literal 1800 zcmaKsv1?ON6vn^2_i__Ww5<_ZY(NAD5m9ikC{nbDAPN?#5DE@X4t8*L>)=qg4i17# zwiG(l!J(srh-3eN4jqG22Ztcy^L)Aad^hO5c^rPpch7gvdFNgNhb-%%Tgw{XQP|VL z1+iJC&gZcRB-bWi~I% zUkeH#ABG{FL@`(Sv(W#$U6ww8+K(`#lQBQ@$LnKn{Sc@^`ak~mr2cL8|MQ}PUhff4 zd;zLZ9_jmOAUUs`d7?tI4duqPH`2tUmf#*A(FWvyV zM}R2Z7@luyGT#mM{KPH|_aI+x0DD$fq~5>e*GcxZW$!0){q=%hC#kchsC|w9t8e!+ zyidT~yXgq-Th!0K8wbAs`B%QaDBYO!^Q^cJ&yW3!(v49+-8bkku@1?) z^o!C{^?5F=L$WTZs%Ok&+xYz?G>(Ti!mw6=P*87Um zjZy!NkKRwxe}A@-{H3LysMk!XA&jkj5&6P`(hIy>pXW}I}7?ha1h zi`n7vxbyfh?2{+;I;E6R$rRLzAVRGQV7C=({j=o(@ic^wTSl%|dJ*b>Gp$QN^c}*- zE!XModzW|G literal 0 HcmV?d00001 diff --git a/testdata/drc/drcSimpleTests_au148d.gds b/testdata/drc/drcSimpleTests_au148d.gds new file mode 100644 index 0000000000000000000000000000000000000000..118962d23b474c5e34d5a7519609177bd2a50e12 GIT binary patch literal 1800 zcmaKsv1?ON6vn^2_i__Ww5<_ZY(NAD5m9ikC{nbDAPN?#5DE@X4t8*L>)=qg4i17# zwiG(l!J(srh-3eN4jqG22Ztcy^L)Aad^hO5c^rPpch7gvdFNgNhb-%%Tgw{XQP|VL z1+iJC&gZcRB-bWi~I% zUkeH#ABG{FL@`(Sv(W#$U6ww8+K(`#lQBQ@$LnKn{Sc@^`ak~mr2cL8|MQ}PUhff4 zd;zLZ9_jmOAUUs`d7?tI4duqPH`2tUmf#*A(FWvyV zM}R2Z7@luyGT#mM{KPH|_aI+x0DD$fq~5>e*GcxZW$!0){q=%hC#kchsC|w9t8e!+ zyidT~yXgq-Th!0K8wbAs`B%QaDBYO!^Q^cJ&yW3!(v49+-8bkku@1?) z^o!C{^?5F=L$WTZs%Ok&+xYz?G>(Ti!mw6=P*87Um zjZy!NkKRwxe}A