From c1b08926418ff93e5131a78ce1ea476ec94e43ad Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 23 Sep 2018 16:08:00 +0200 Subject: [PATCH] WIP: More testcases, better test coverage, some bug fixes --- .../tools/netx/db_plugin/dbHierProcessor.cc | 30 ++++----- .../tools/netx/db_plugin/dbHierProcessor.h | 28 +++++++- src/plugins/tools/netx/testdata/hlp8.oas | Bin 0 -> 815 bytes src/plugins/tools/netx/testdata/hlp9.oas | Bin 0 -> 724 bytes .../netx/unit_tests/dbHierProcessorTests.cc | 61 +++++++++++++++++- 5 files changed, 99 insertions(+), 20 deletions(-) create mode 100644 src/plugins/tools/netx/testdata/hlp8.oas create mode 100644 src/plugins/tools/netx/testdata/hlp9.oas diff --git a/src/plugins/tools/netx/db_plugin/dbHierProcessor.cc b/src/plugins/tools/netx/db_plugin/dbHierProcessor.cc index 76ae117c2..897d12094 100644 --- a/src/plugins/tools/netx/db_plugin/dbHierProcessor.cc +++ b/src/plugins/tools/netx/db_plugin/dbHierProcessor.cc @@ -322,7 +322,10 @@ public: void add (const db::CellInstArray *inst1, int, const db::CellInstArray *inst2, int) { - (*mp_result) [inst1].first.insert (inst2); + // @@@ TODO: always insert, if both instances come from different layouts + if (*inst1 != *inst2) { + (*mp_result) [inst1].first.insert (inst2); + } } private: @@ -361,21 +364,8 @@ LocalProcessor::LocalProcessor (db::Layout *layout, db::Cell *top, LocalOperatio void LocalProcessor::run () { - try { - - mp_layout->update (); - mp_layout->start_changes (); - - std::pair, std::set > intruders; - compute_contexts (0, 0, mp_top, db::ICplxTrans (), intruders); - compute_results (); - - mp_layout->end_changes (); - - } catch (...) { - mp_layout->end_changes (); - throw; - } + compute_contexts (); + compute_results (); } void LocalProcessor::push_results (db::Cell *cell, const std::set &result) @@ -385,6 +375,14 @@ void LocalProcessor::push_results (db::Cell *cell, const std::set, std::set > intruders; + compute_contexts (0, 0, mp_top, db::ICplxTrans (), intruders); +} + void LocalProcessor::compute_contexts (db::LocalProcessorCellContext *parent_context, db::Cell *parent, db::Cell *cell, const db::ICplxTrans &cell_inst, const std::pair, std::set > &intruders) { db::LocalProcessorCellContexts &contexts = m_contexts_per_cell [cell]; diff --git a/src/plugins/tools/netx/db_plugin/dbHierProcessor.h b/src/plugins/tools/netx/db_plugin/dbHierProcessor.h index e8b6707ee..743139832 100644 --- a/src/plugins/tools/netx/db_plugin/dbHierProcessor.h +++ b/src/plugins/tools/netx/db_plugin/dbHierProcessor.h @@ -89,6 +89,11 @@ public: return m_propagated; } + size_t size () const + { + return m_drops.size (); + } + private: std::set m_propagated; std::vector m_drops; @@ -98,6 +103,8 @@ class DB_PLUGIN_PUBLIC LocalProcessorCellContexts { public: typedef std::pair, std::set > key_type; + typedef std::map map_type; + typedef map_type::const_iterator iterator; LocalProcessorCellContexts (); @@ -105,6 +112,16 @@ public: db::LocalProcessorCellContext *create (const key_type &intruders); void compute_results (db::Cell *cell, LocalProcessor *proc); + iterator begin () const + { + return m_contexts.begin (); + } + + iterator end () const + { + return m_contexts.end (); + } + private: std::map m_contexts; }; @@ -112,12 +129,20 @@ private: class DB_PLUGIN_PUBLIC LocalProcessor { public: + typedef std::map contexts_per_cell_type; + LocalProcessor (db::Layout *layout, db::Cell *top, LocalOperation *op, unsigned int scope_layer, unsigned int intruder_layer, unsigned int output_layer); void run (); + void compute_contexts (); + void compute_results (); + + const contexts_per_cell_type &contexts_per_cell () const + { + return m_contexts_per_cell; + } private: friend class LocalProcessorCellContexts; - typedef std::map contexts_per_cell_type; db::Layout *mp_layout; db::Cell *mp_top; @@ -126,7 +151,6 @@ private: LocalOperation *mp_op; void compute_contexts (db::LocalProcessorCellContext *parent_context, db::Cell *parent, db::Cell *cell, const db::ICplxTrans &cell_inst, const std::pair, std::set > &intruders); - void compute_results (); void push_results (db::Cell *cell, const std::set &result); void compute_local_cell (db::Cell *cell, const std::pair, std::set > &intruders, std::set &result) const; }; diff --git a/src/plugins/tools/netx/testdata/hlp8.oas b/src/plugins/tools/netx/testdata/hlp8.oas new file mode 100644 index 0000000000000000000000000000000000000000..27ca4eb75fd2088524110bed946c4b7a336d0ba0 GIT binary patch literal 815 zcmd^*ze^)Q6vyA2jhi#Ot0v4CBAeobU_caOb#f}iWYLwFh#P;9W*e<+1T9i1EO+e{ za@8RSK@d`EmvSu*uCSQGV#{Ea!eZ^T5oh*PEc_3A)thWl$4H=3 zn4E%M9Nw47MjUsgxaB(bV$~|UcC~ITT5Im6U9K;EiJ6A^f4pA(C}6ULkBer5V}v`W|-$MeiFLpWqvWBdm-zjy}yJuJL!=1 zo=7K6n|A|uW8EtRy4p?gq5*Ul!OOI1OQp?_{Yi%HC?;P7w*=_n&2XFYMoZP;`s)yz z*+FtK+8vK#Y!(U6_u{=%l=E(Ch)v0x_5^RR!nSOKEI&u~4T*R%DS@)*d0+Q)E!9wx z4{&UD(i-^lspJC@{@C{&z?iS!vt!fGdDB6bGZN+Bior4 flE=g{J$TWpMeFF{n`9yF)iTh!)C|P?%mwfa9jqtd literal 0 HcmV?d00001 diff --git a/src/plugins/tools/netx/testdata/hlp9.oas b/src/plugins/tools/netx/testdata/hlp9.oas new file mode 100644 index 0000000000000000000000000000000000000000..3baf603e09e750fea443d8d612e6402edb772029 GIT binary patch literal 724 zcmd^*ze~eF6vy9PN-Cz&q}*965r06iAc}QT5TV#m1GN=XQCzar$<;wnF(5cObnKuI zL7{^~QHPFk5ELA4a8Ph4;t<3kZh|0Q+Qq^Dz&CyGz3=<-KBrs8f;m>qSf(X+A|X9K z0e%#Imqz<6dm*!GTV}3cWNouhGIGX}y<%od^BoaQ*4pFc!e0iBc3O6+xM^ zN)YGf&3ra3v>uTqvyhW9*+cMpj_*5M(T_^-e1hUsFC$!4Z=WJSb}{R&Tp$1ms;5{X zW&aXiDQ%w&WCMYdtPxivTLG=AK@B$&WUG+~=;I3pvh&bWBW%qTCAc3_==3_m_2K4d z%SLAqW+^}FAER*Ij4N~^?9|5C8dni7_CYI}rw5d#`8_Q4*w4-ookExgjEC`|_F@4A zS8T6(F;AC~`Uw@Sk&wWfjjI8^%Rd##HUfXpNwPPget@XX?{Frossu;9N-N!&bO-z| zf#W{(uvC2?b6&nqHl5@l1t6ONZ6utV5GjQ7zd0w@?_KXB&1?QUq|}VF3}EL!7r+mO Cod>`G literal 0 HcmV?d00001 diff --git a/src/plugins/tools/netx/unit_tests/dbHierProcessorTests.cc b/src/plugins/tools/netx/unit_tests/dbHierProcessorTests.cc index 5d82fc840..2f195db78 100644 --- a/src/plugins/tools/netx/unit_tests/dbHierProcessorTests.cc +++ b/src/plugins/tools/netx/unit_tests/dbHierProcessorTests.cc @@ -56,7 +56,26 @@ void normalize_layer (db::Layout &layout, unsigned int layer) } } -void run_test_bool (tl::TestBase *_this, const char *file, TestMode mode, int out_layer_num) + +std::string contexts_to_s (db::Layout *layout, const db::LocalProcessor::contexts_per_cell_type &contexts) +{ + std::string res; + + for (db::Layout::top_down_const_iterator i = layout->begin_top_down (); i != layout->end_top_down(); ++i) { + db::LocalProcessor::contexts_per_cell_type::const_iterator cc = contexts.find (&layout->cell (*i)); + if (cc != contexts.end ()) { + int index = 1; + for (db::LocalProcessorCellContexts::iterator j = cc->second.begin (); j != cc->second.end (); ++j) { + res += tl::sprintf ("%s[%d] %d insts, %d shapes (%d times)\n", layout->cell_name (*i), index, int (j->first.first.size ()), int (j->first.second.size ()), int (j->second.size ())); + index += 1; + } + } + } + + return res; +} + +void run_test_bool (tl::TestBase *_this, const char *file, TestMode mode, int out_layer_num, std::string *context_doc = 0) { db::Layout layout_org; @@ -96,7 +115,14 @@ void run_test_bool (tl::TestBase *_this, const char *file, TestMode mode, int ou db::BoolAndOrNotLocalOperation op (mode == TMAnd); db::LocalProcessor proc (&layout_org, &layout_org.cell (*layout_org.begin_top_down ()), &op, l1, l2, lout); - proc.run (); + + if (! context_doc) { + proc.run (); + } else { + proc.compute_contexts (); + *context_doc = contexts_to_s (&layout_org, proc.contexts_per_cell ()); + proc.compute_results (); + } db::compare_layouts (_this, layout_org, testdata (file), lmap, false /*skip other layers*/, db::AsPolygons); } @@ -184,3 +210,34 @@ TEST(BasicNot7) // Context replication - direct and indirect, NOT run_test_bool (_this, "hlp7.oas", TMNot, 101); } + +TEST(BasicAnd8) +{ + // Mixed sibling-parent contexts, AND + run_test_bool (_this, "hlp8.oas", TMAnd, 100); +} + +TEST(BasicNot8) +{ + // Mixed sibling-parent contexts, NOT + run_test_bool (_this, "hlp8.oas", TMNot, 101); +} + +TEST(BasicAnd9) +{ + // Top-level ring structure, AND + std::string doc; + run_test_bool (_this, "hlp9.oas", TMAnd, 100, &doc); + EXPECT_EQ (doc, + "TOP[1] 0 insts, 0 shapes (1 times)\n" + "RING[1] 0 insts, 12 shapes (1 times)\n" + "CHILD1[1] 1 insts, 6 shapes (1 times)\n" + "CHILD1[2] 1 insts, 6 shapes (1 times)\n" + ); +} + +TEST(BasicNot9) +{ + // Top-level ring structure, NOT + run_test_bool (_this, "hlp9.oas", TMNot, 101); +}