|
| 1 | +# encoding: UTF-8 |
| 2 | + |
| 3 | +# KLayout Layout Viewer |
| 4 | +# Copyright (C) 2006-2026 Matthias Koefferlein |
| 5 | +# |
| 6 | +# This program is free software; you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU General Public License as published by |
| 8 | +# the Free Software Foundation; either version 2 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# This program is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License |
| 17 | +# along with this program; if not, write to the Free Software |
| 18 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | + |
| 20 | +if !$:.member?(File::dirname($0)) |
| 21 | + $:.push(File::dirname($0)) |
| 22 | +end |
| 23 | + |
| 24 | +load("test_prologue.rb") |
| 25 | + |
| 26 | +class LAYNetlistBrowser_TestClass < TestBase |
| 27 | + |
| 28 | + # Basic view creation and MainWindow events |
| 29 | + def test_1 |
| 30 | + |
| 31 | + if !RBA.constants.member?(:Application) |
| 32 | + return |
| 33 | + end |
| 34 | + |
| 35 | + app = RBA::Application.instance |
| 36 | + mw = app.main_window |
| 37 | + mw.close_all |
| 38 | + |
| 39 | + cv = mw.load_layout(ENV["TESTSRC"] + "/testdata/lvs/ringo_mixed_hierarchy.gds", 0) |
| 40 | + lv = cv.view |
| 41 | + |
| 42 | + nb = lv.netlist_browser |
| 43 | + |
| 44 | + db = lv.lvsdb(lv.create_lvsdb("DB1")) |
| 45 | + db.read(ENV["TESTSRC"] + "/testdata/lvs/ringo_mixed_hierarchy.lvsdb") |
| 46 | + |
| 47 | + lv.show_lvsdb(0, 0) |
| 48 | + |
| 49 | + # Test path selections |
| 50 | + |
| 51 | + nl = nb.db.netlist |
| 52 | + |
| 53 | + # net |
| 54 | + n = nl.circuit_by_name("INVX1").net_by_name("OUT") |
| 55 | + pth = RBA::NetlistObjectsPath.from_first(n) |
| 56 | + nb.current_path = pth |
| 57 | + assert_equal(nb.current_path.first.net.to_s, "INVX1:OUT") |
| 58 | + assert_equal(nb.current_path.second.net.to_s, "INVX1:OUT") |
| 59 | + |
| 60 | + # device |
| 61 | + n = nl.circuit_by_name("INVX1").device_by_id(1) |
| 62 | + pth = RBA::NetlistObjectsPath.from_first(n) |
| 63 | + nb.current_path = pth |
| 64 | + assert_equal(nb.current_path.first.device.expanded_name, "$1") |
| 65 | + assert_equal(nb.current_path.second.device.expanded_name, "$1") |
| 66 | + |
| 67 | + # subcircuit |
| 68 | + n = nl.circuit_by_name("RINGO").subcircuit_by_id(2) |
| 69 | + pth = RBA::NetlistObjectsPath.from_first(n) |
| 70 | + nb.current_path = pth |
| 71 | + assert_equal(nb.current_path.first.path[-1].expanded_name, "$2") |
| 72 | + assert_equal(nb.current_path.second.path[-1].expanded_name, "$11") |
| 73 | + |
| 74 | + # circuit |
| 75 | + n = nl.circuit_by_name("INVX1") |
| 76 | + pth = RBA::NetlistObjectsPath.from_first(n) |
| 77 | + nb.current_path = pth |
| 78 | + assert_equal(nb.current_path.first.root.name, "INVX1") |
| 79 | + assert_equal(nb.current_path.second.root.name, "INVX1") |
| 80 | + |
| 81 | + nl = nb.db.reference |
| 82 | + |
| 83 | + # net: |
| 84 | + n = nl.circuit_by_name("INVX1").net_by_name("OUT") |
| 85 | + pth = RBA::NetlistObjectsPath.from_second(n) |
| 86 | + nb.current_path = pth |
| 87 | + assert_equal(nb.current_path.first.net.to_s, "INVX1:OUT") |
| 88 | + assert_equal(nb.current_path.second.net.to_s, "INVX1:OUT") |
| 89 | + |
| 90 | + # device |
| 91 | + n = nl.circuit_by_name("INVX1").device_by_name("$2") |
| 92 | + pth = RBA::NetlistObjectsPath.from_second(n) |
| 93 | + nb.current_path = pth |
| 94 | + assert_equal(nb.current_path.first.device.expanded_name, "$2") |
| 95 | + assert_equal(nb.current_path.second.device.expanded_name, "$2") |
| 96 | + |
| 97 | + # subcircuit |
| 98 | + n = nl.circuit_by_name("RINGO").subcircuit_by_name("$3") |
| 99 | + pth = RBA::NetlistObjectsPath.from_second(n) |
| 100 | + nb.current_path = pth |
| 101 | + assert_equal(nb.current_path.first.path[-1].expanded_name, "$4") |
| 102 | + assert_equal(nb.current_path.second.path[-1].expanded_name, "$3") |
| 103 | + |
| 104 | + # circuit |
| 105 | + n = nl.circuit_by_name("INVX1") |
| 106 | + pth = RBA::NetlistObjectsPath.from_second(n) |
| 107 | + nb.current_path = pth |
| 108 | + assert_equal(nb.current_path.first.root.name, "INVX1") |
| 109 | + assert_equal(nb.current_path.second.root.name, "INVX1") |
| 110 | + |
| 111 | + mw.close_all |
| 112 | + |
| 113 | + end |
| 114 | + |
| 115 | +end |
| 116 | + |
| 117 | +load("test_epilogue.rb") |
| 118 | + |
0 commit comments