Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/buddies/src/bd/bd.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ INCLUDEPATH += $$RBA_INC
DEPENDPATH += $$RBA_INC

equals(HAVE_RUBY, "1") {
LIBS += -lklayout_rba
INCLUDEPATH += $$DRC_INC $$LVS_INC
DEPENDPATH += $$DRC_INC $$LVS_INC
LIBS += -lklayout_rba -lklayout_drc -lklayout_lvs
} else {
LIBS += -lklayout_rbastub
}
Expand Down
2 changes: 2 additions & 0 deletions src/buddies/src/bd/strmrun.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "libForceLink.h"
#include "rdbForceLink.h"
#include "pexForceLink.h"
#include "drcForceLink.h"
#include "lvsForceLink.h"
#include "lymMacro.h"
#include "lymMacroCollection.h"

Expand Down
2 changes: 1 addition & 1 deletion src/buddies/src/buddy_app.pri
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ INCLUDEPATH += $$RBA_INC
DEPENDPATH += $$RBA_INC

equals(HAVE_RUBY, "1") {
LIBS += -lklayout_rba
LIBS += -lklayout_rba -lklayout_drc -lklayout_lvs
} else {
LIBS += -lklayout_rbastub
}
Expand Down
44 changes: 32 additions & 12 deletions src/buddies/unit_tests/bdStrmrunTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,50 @@
TEST(1)
{
#if defined(HAVE_PYTHON)
std::string fp (tl::testsrc ());
fp += "/testdata/bd/strmrun.py";

std::string cmd;
std::string cmd_call;

#if defined(__APPLE__)
// NOTE: because of system integrity, MacOS does not inherit DYLD_LIBRARY_PATH to child
// processes like sh. We need to port this variable explicitly.
const char *ldpath_name = "DYLD_LIBRARY_PATH";
const char *ldpath = getenv (ldpath_name);
if (ldpath) {
cmd += std::string (ldpath_name) + "=\"" + ldpath + "\"; export " + ldpath_name + "; ";
cmd_call += std::string (ldpath_name) + "=\"" + ldpath + "\"; export " + ldpath_name + "; ";
}
#endif

cmd += tl::combine_path (tl::get_inst_path (), "strmrun ") + fp;
tl::info << cmd;
cmd_call += tl::combine_path (tl::get_inst_path (), "strmrun");

{
std::string fp (tl::testsrc ());
fp += "/testdata/bd/strmrun.py";

std::string cmd = cmd_call + " " + fp;
tl::info << cmd;

tl::InputPipe pipe (cmd);
tl::InputStream is (pipe);
std::string data = is.read_all ();
tl::info << data;

EXPECT_EQ (data, "Hello, world (0,-42;42,0)!\n");
}

{
std::string fp (tl::testsrc ());
fp += "/testdata/bd/strmrun.drc";

std::string cmd = cmd_call + " " + fp;
tl::info << cmd;

tl::InputPipe pipe (cmd);
tl::InputStream is (pipe);
std::string data = is.read_all ();
tl::info << data;
tl::InputPipe pipe (cmd);
tl::InputStream is (pipe);
std::string data = is.read_all ();
tl::info << data;

EXPECT_EQ (data, "This is DRC.\n");
}

EXPECT_EQ (data, "Hello, world (0,-42;42,0)!\n");
#endif
}

2 changes: 2 additions & 0 deletions src/db/db/db.pro
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SOURCES = \
dbEdgeProcessor.cc \
dbEdges.cc \
dbEdgesLocalOperations.cc \
dbFileBasedLibrary.cc \
dbFillTool.cc \
dbFuzzyCellMapping.cc \
dbGenericShapeIterator.cc \
Expand Down Expand Up @@ -274,6 +275,7 @@ HEADERS = \
dbEdges.h \
dbEdgesLocalOperations.h \
dbEdgesToContours.h \
dbFileBasedLibrary.h \
dbFillTool.h \
dbFuzzyCellMapping.h \
dbGenericShapeIterator.h \
Expand Down
13 changes: 12 additions & 1 deletion src/db/db/dbCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ class DB_PUBLIC Cell
void check_locked () const;

/**
* @brief Tell, if this cell is a proxy cell
* @brief Gets a value indicating if this cell is a proxy cell
*
* Proxy cells are such whose layout represents a snapshot of another entity.
* Such cells can be PCell variants or library references for example.
Expand All @@ -867,6 +867,17 @@ class DB_PUBLIC Cell
return false;
}

/**
* @brief Gets a value indicating that this cell is a replica that can be skipped
*
* This attribute is evaluated by file writers to skip cell replicas for
* library cells that do not want to replicated.
*/
virtual bool can_skip_replica () const
{
return false;
}

/**
* @brief Sets the cell name
*
Expand Down
22 changes: 22 additions & 0 deletions src/db/db/dbColdProxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,36 @@ ColdProxy::ColdProxy (db::cell_index_type ci, db::Layout &layout, const LayoutOr
}
i->second->push_back (this);
}

layout.register_cold_proxy (this);
}

ColdProxy::~ColdProxy ()
{
if (layout ()) {
layout ()->unregister_cold_proxy (this);
}

delete mp_context_info;
mp_context_info = 0;
}

void
ColdProxy::unregister ()
{
if (layout ()) {
layout ()->unregister_cold_proxy (this);
}
}

void
ColdProxy::reregister ()
{
if (layout ()) {
layout ()->register_cold_proxy (this);
}
}

Cell *
ColdProxy::clone (Layout &layout) const
{
Expand Down
10 changes: 10 additions & 0 deletions src/db/db/dbColdProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ class DB_PUBLIC ColdProxy
return true;
}

/**
* @brief Reimplemented from Cell: unregisters the proxy at the layout
*/
virtual void unregister ();

/**
* @brief Reimplemented from Cell: reregisters the proxy at the layout
*/
virtual void reregister ();

/**
* @brief Gets a list of cold proxies for a given library name
*/
Expand Down
5 changes: 5 additions & 0 deletions src/db/db/dbCommonReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,11 @@ class CommonFormatDeclaration
return false;
}

virtual bool supports_context () const
{
return false;
}

virtual tl::XMLElementBase *xml_reader_options_element () const
{
return new db::ReaderOptionsXMLElement<db::CommonReaderOptions> ("common",
Expand Down
146 changes: 146 additions & 0 deletions src/db/db/dbFileBasedLibrary.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@

/*

KLayout Layout Viewer
Copyright (C) 2006-2026 Matthias Koefferlein

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

*/


#include "dbFileBasedLibrary.h"
#include "dbReader.h"
#include "dbCellMapping.h"

#include "tlFileUtils.h"
#include "tlStream.h"

namespace db
{

// -------------------------------------------------------------------------------------------

FileBasedLibrary::FileBasedLibrary (const std::string &path, const std::string &name)
: db::Library (), m_name (name), m_path (path), m_is_loaded (false)
{
set_description (tl::filename (path));

// preliminary name, may be replaced later
if (! name.empty ()) {
set_name (name);
}
}

void
FileBasedLibrary::merge_with_other_layout (const std::string &path)
{
m_other_paths.push_back (path);
if (m_is_loaded) {
merge_impl (path);
}
}

bool
FileBasedLibrary::is_for_path (const std::string &path)
{
return m_other_paths.empty () && m_path == path;
}

bool
FileBasedLibrary::is_for_paths (const std::vector<std::string> &paths)
{
if (paths.size () != m_other_paths.size () + 1) {
return false;
}

// this check is purely based on path strings
std::set<std::string> p1 (paths.begin (), paths.end ());
std::set<std::string> p2;
p2.insert (m_path);
p2.insert (m_other_paths.begin (), m_other_paths.end ());
return p1 == p2;
}

std::string
FileBasedLibrary::load ()
{
if (! m_is_loaded) {
return reload ();
} else {
return get_name ();
}
}

std::string
FileBasedLibrary::reload ()
{
std::string name = m_name.empty () ? tl::basename (m_path) : m_name;

layout ().clear ();

tl::InputStream stream (m_path);
db::Reader reader (stream);
reader.read (layout ());

// Use the libname if there is one
if (m_name.empty ()) {
db::Layout::meta_info_name_id_type libname_name_id = layout ().meta_info_name_id ("libname");
for (db::Layout::meta_info_iterator m = layout ().begin_meta (); m != layout ().end_meta (); ++m) {
if (m->first == libname_name_id && ! m->second.value.is_nil ()) {
name = m->second.value.to_string ();
break;
}
}
}

for (auto p = m_other_paths.begin (); p != m_other_paths.end (); ++p) {
merge_impl (*p);
}

m_is_loaded = true;

return name;
}

void
FileBasedLibrary::merge_impl (const std::string &path)
{
db::Layout ly;

tl::InputStream stream (path);
db::Reader reader (stream);
reader.read (ly);

std::vector<db::cell_index_type> target_cells, source_cells;

// collect the cells to pull in (all top cells of the library layout)
// NOTE: cells are not overwritten - the first layout wins, in terms
// of cell names and also in terms of database unit.
for (auto c = ly.begin_top_down (); c != ly.end_top_cells (); ++c) {
std::string cn = ly.cell_name (*c);
if (! layout ().has_cell (cn.c_str ())) {
source_cells.push_back (*c);
target_cells.push_back (layout ().add_cell (cn.c_str ()));
}
}

db::CellMapping cm;
cm.create_multi_mapping_full (layout (), target_cells, ly, source_cells);
layout ().copy_tree_shapes (ly, cm);
}

}

Loading
Loading