From 501dfc25d0bf96f2097ff100ed3b3bcc11c1cbb5 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 10 Sep 2017 01:21:10 +0200 Subject: [PATCH] Direct table access for RBA::CellMapping and RBA::LayerMapping. --- src/db/db/gsiDeclDbCellMapping.cc | 10 +++++++++- src/db/db/gsiDeclDbLayerMapping.cc | 9 ++++++++- testdata/ruby/dbCellMapping.rb | 21 +++++++++++++++++++++ testdata/ruby/dbLayerMapping.rb | 18 ++++++++++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/db/db/gsiDeclDbCellMapping.cc b/src/db/db/gsiDeclDbCellMapping.cc index 935ef25cf..70d21ddc3 100644 --- a/src/db/db/gsiDeclDbCellMapping.cc +++ b/src/db/db/gsiDeclDbCellMapping.cc @@ -159,7 +159,15 @@ Class decl_CellMapping ("CellMapping", "\n" "This method has been introduced in version 0.23." ) + - gsi::method ("map", &db::CellMapping::map, + gsi::method ("table", &db::CellMapping::table, + "@brief Returns the mapping table.\n" + "\n" + "The mapping table is a dictionary where the keys are source layout cell indexes and the values are the target layout cell indexes.\n" + "Note that the target cell index can be \\DropCell to indicate that a cell is supposed to be dropped.\n" + "\n" + "This method has been introduced in version 0.25." + ) + + gsi::method ("map", &db::CellMapping::map, "@brief Explicitly specifies a mapping.\n" "\n" "@args cell_index_b, cell_index_a\n" diff --git a/src/db/db/gsiDeclDbLayerMapping.cc b/src/db/db/gsiDeclDbLayerMapping.cc index 980839439..154511e28 100644 --- a/src/db/db/gsiDeclDbLayerMapping.cc +++ b/src/db/db/gsiDeclDbLayerMapping.cc @@ -70,7 +70,14 @@ Class decl_LayerMapping ("LayerMapping", "Beside using the mapping generator algorithms provided through \\create and \\create_full, " "it is possible to explicitly specify layer mappings using this method.\n" ) + - gsi::method ("has_mapping?", &db::LayerMapping::has_mapping, + gsi::method ("table", &db::LayerMapping::table, + "@brief Returns the mapping table.\n" + "\n" + "The mapping table is a dictionary where the keys are source layout layer indexes and the values are the target layout layer indexes.\n" + "\n" + "This method has been introduced in version 0.25." + ) + + gsi::method ("has_mapping?", &db::LayerMapping::has_mapping, "@brief Determine if a layer in layout_b has a mapping to a layout_a layer.\n" "\n" "@args layer_index_b\n" diff --git a/testdata/ruby/dbCellMapping.rb b/testdata/ruby/dbCellMapping.rb index 16e38d824..078d49a19 100644 --- a/testdata/ruby/dbCellMapping.rb +++ b/testdata/ruby/dbCellMapping.rb @@ -41,6 +41,25 @@ def mapping_to_s(ly1, ly2, cm) r end +def mapping_to_s_from_table(ly1, ly2, cm) + table = cm.table + r = "" + ly1.each_cell_top_down do |c| + s = ly1.cell(c).name + if table[c] + t = table[c] + if t == RBA::CellMapping::DropCell + s += "=>(0)" + else + s += "=>" + ly2.cell(t).name + end + end + r == "" || (r += ";") + r += s + end + r +end + class DBCellMapping_TestClass < TestBase def test_1 @@ -102,6 +121,7 @@ class DBCellMapping_TestClass < TestBase mp = RBA::CellMapping::new mp.from_names(ly1, top1, ly2, top2) assert_equal(mapping_to_s(ly2, ly1, mp), "c0;c2=>c2;c1=>c1;c3=>c3") + assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "c0;c2=>c2;c1=>c1;c3=>c3") mp = RBA::CellMapping::new mp.from_geometry(ly1, top1, ly2, top2) @@ -181,6 +201,7 @@ class DBCellMapping_TestClass < TestBase mp.from_geometry(ly1, top1, ly2, top2) mp.map(ci2, RBA::CellMapping::DropCell) assert_equal(mapping_to_s(ly2, ly1, mp), "c0;c2=>(0);c1=>c1;c3") + assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "c0;c2=>(0);c1=>c1;c3") end diff --git a/testdata/ruby/dbLayerMapping.rb b/testdata/ruby/dbLayerMapping.rb index 62d70fc96..fdf2727da 100644 --- a/testdata/ruby/dbLayerMapping.rb +++ b/testdata/ruby/dbLayerMapping.rb @@ -36,6 +36,20 @@ def mapping_to_s(ly1, ly2, lm) r end +def mapping_to_s_from_table(ly1, ly2, lm) + r = "" + table = lm.table + ly1.layer_indices.each do |li| + s = ly1.get_info(li).to_s + if table[li] + s += "=>" + ly2.get_info(table[li]).to_s + end + r == "" || (r += ";") + r += s + end + r +end + class DBLayerMapping_TestClass < TestBase def test_1 @@ -60,6 +74,8 @@ class DBLayerMapping_TestClass < TestBase a3 = ly1.insert_layer(RBA::LayerInfo::new("A")) ly2 = RBA::Layout::new + assert_equal(mapping_to_s(ly2, ly1, mp), "") + assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "") b1 = ly2.insert_layer(RBA::LayerInfo::new("A")) b2 = ly2.insert_layer(RBA::LayerInfo::new(3, 0)) @@ -68,10 +84,12 @@ class DBLayerMapping_TestClass < TestBase mp = RBA::LayerMapping::new mp.create(ly1, ly2) assert_equal(mapping_to_s(ly2, ly1, mp), "A=>A;3/0;2/0=>2/0") + assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "A=>A;3/0;2/0=>2/0") mp = RBA::LayerMapping::new nl = mp.create_full(ly1, ly2) assert_equal(mapping_to_s(ly2, ly1, mp), "A=>A;3/0=>3/0;2/0=>2/0") + assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "A=>A;3/0=>3/0;2/0=>2/0") assert_equal(nl.inspect, "[3]") end