diff --git a/src/db/db/dbLayout.cc b/src/db/db/dbLayout.cc index 8210fbba5..c3fa44e5a 100644 --- a/src/db/db/dbLayout.cc +++ b/src/db/db/dbLayout.cc @@ -346,6 +346,7 @@ ProxyContextInfo::serialize (std::vector &strings) Layout::Layout (db::Manager *manager) : db::Object (manager), + mp_library (0), m_cells_size (0), m_invalid (0), m_top_cells (0), @@ -362,6 +363,7 @@ Layout::Layout (db::Manager *manager) Layout::Layout (bool editable, db::Manager *manager) : db::Object (manager), + mp_library (0), m_cells_size (0), m_invalid (0), m_top_cells (0), @@ -382,6 +384,7 @@ Layout::Layout (const db::Layout &layout) gsi::ObjectBase (), tl::Object (), tl::UniqueId (), + mp_library (0), m_cells_size (0), m_invalid (0), m_top_cells (0), @@ -2270,6 +2273,7 @@ Layout::register_pcell (const std::string &name, pcell_declaration_type *declara declaration->m_id = id; declaration->m_name = name; + declaration->mp_layout = this; // marks this object being held by the layout declaration->keep (); diff --git a/src/db/db/dbLayout.h b/src/db/db/dbLayout.h index 478620390..788315a7c 100644 --- a/src/db/db/dbLayout.h +++ b/src/db/db/dbLayout.h @@ -582,6 +582,22 @@ public: return m_tech_name; } + /** + * @brief Gets the library the layout lives in or NULL if the layout is not part of a library + */ + Library *library () const + { + return mp_library; + } + + /** + * @brief Sets the library pointer + */ + void set_library (db::Library *library) + { + mp_library = library; + } + /** * @brief Gets the technology object the layout is associated with or null if no valid technology is associated */ @@ -1843,6 +1859,7 @@ protected: private: enum LayerState { Normal, Free, Special }; + db::Library *mp_library; cell_list m_cells; size_t m_cells_size; cell_ptr_vector m_cell_ptrs; diff --git a/src/db/db/dbLibrary.cc b/src/db/db/dbLibrary.cc index 5441b05b8..dc701e65c 100644 --- a/src/db/db/dbLibrary.cc +++ b/src/db/db/dbLibrary.cc @@ -32,13 +32,13 @@ namespace db Library::Library() : m_id (0), m_layout (true) { - // .. nothing yet .. + m_layout.set_library (this); } Library::Library(const Library &d) : gsi::ObjectBase (), tl::Object (), m_name (d.m_name), m_description (d.m_description), m_id (0), m_layout (d.m_layout) { - // .. nothing yet .. + m_layout.set_library (this); } Library::~Library () diff --git a/src/db/db/dbPCellDeclaration.cc b/src/db/db/dbPCellDeclaration.cc index 4e0d7a65d..42515ed0d 100644 --- a/src/db/db/dbPCellDeclaration.cc +++ b/src/db/db/dbPCellDeclaration.cc @@ -28,7 +28,7 @@ namespace db { PCellDeclaration::PCellDeclaration () - : m_ref_count (0), m_id (0), m_has_parameter_declarations (false) + : m_ref_count (0), m_id (0), mp_layout (0), m_has_parameter_declarations (false) { // .. nothing yet .. } diff --git a/src/db/db/dbPCellDeclaration.h b/src/db/db/dbPCellDeclaration.h index 4a8bce1bc..acd4d12c9 100644 --- a/src/db/db/dbPCellDeclaration.h +++ b/src/db/db/dbPCellDeclaration.h @@ -429,6 +429,14 @@ public: return db::Trans (); } + /** + * @brief Gets the Layout object the PCell is registered inside or NULL if it is not registered + */ + db::Layout *layout () const + { + return mp_layout; + } + /** * @brief Add a reference to this object * @@ -518,6 +526,7 @@ private: int m_ref_count; pcell_id_type m_id; std::string m_name; + db::Layout *mp_layout; mutable bool m_has_parameter_declarations; mutable std::vector m_parameter_declarations; diff --git a/src/db/db/gsiDeclDbLayout.cc b/src/db/db/gsiDeclDbLayout.cc index edf3363cd..e7df6268a 100644 --- a/src/db/db/gsiDeclDbLayout.cc +++ b/src/db/db/gsiDeclDbLayout.cc @@ -980,6 +980,10 @@ Class decl_Layout ("db", "Layout", "\n" "This method was introduced in version 0.22.\n" ) + + gsi::method ("library", &db::Layout::library, + "@brief Gets the library this layout lives in or nil if the layout is not part of a library\n" + "This attribute has been introduced in version 0.27.5." + ) + gsi::method ("add_meta_info", &db::Layout::add_meta_info, gsi::arg ("info"), "@brief Adds meta information to the layout\n" "See \\LayoutMetaInfo for details about layouts and meta information." diff --git a/src/db/db/gsiDeclDbLibrary.cc b/src/db/db/gsiDeclDbLibrary.cc index abab93825..0d6570bef 100644 --- a/src/db/db/gsiDeclDbLibrary.cc +++ b/src/db/db/gsiDeclDbLibrary.cc @@ -277,6 +277,10 @@ Class decl_PCellDeclaration_Native ("db", "PCellDeclaratio gsi::method ("parameters_from_shape", &db::PCellDeclaration::parameters_from_shape) + gsi::method ("transformation_from_shape", &db::PCellDeclaration::transformation_from_shape) + gsi::method ("display_text", &db::PCellDeclaration::get_display_name) + + gsi::method ("layout", &db::PCellDeclaration::layout, + "@brief Gets the Layout object the PCell is registered in or nil if it is not registered yet.\n" + "This attribute has been added in version 0.27.5." + ) + gsi::method ("id", &db::PCellDeclaration::id, "@brief Gets the integer ID of the PCell declaration\n" "This ID is used to identify the PCell in the context of a Layout object for example" diff --git a/testdata/ruby/dbLibrary.rb b/testdata/ruby/dbLibrary.rb index cd57a9498..6d62041bd 100644 --- a/testdata/ruby/dbLibrary.rb +++ b/testdata/ruby/dbLibrary.rb @@ -38,6 +38,10 @@ class DBLibrary_TestClass < TestBase lib_id = lib.id assert_equal(lib_id != 0, true) + # the layout inside the library knows the library + assert_equal(lib.layout.library.id == lib.id, true) + assert_equal(lib.layout.library.name, "RBA-unit-test") + assert_equal(RBA::Library::library_names.member?("RBA-unit-test"), true) assert_equal(RBA::Library::library_by_name("RBA-unit-test").id, lib_id) diff --git a/testdata/ruby/dbPCells.rb b/testdata/ruby/dbPCells.rb index f2c9208ae..66989d93f 100644 --- a/testdata/ruby/dbPCells.rb +++ b/testdata/ruby/dbPCells.rb @@ -588,6 +588,21 @@ class DBPCell_TestClass < TestBase end + def test_9 + + layout = RBA::Layout::new + + pcell = BoxPCell::new + assert_equal(pcell.layout == nil, true) + + # sets the layout reference of the PCell declaration: + layout.register_pcell("Box", pcell) + + assert_equal(pcell.layout == nil, false) + assert_equal(pcell.layout.object_id == layout.object_id, true) + + end + end load("test_epilogue.rb")