Commit b1500981 by lvzhengyang

link db_mgr to minieda

parent 3bdafcdd
...@@ -7,6 +7,7 @@ add_library(db_mgr) ...@@ -7,6 +7,7 @@ add_library(db_mgr)
target_sources(db_mgr target_sources(db_mgr
PRIVATE PRIVATE
src/db_mgr.cpp src/db_mgr.cpp
src/MakeDbMgr.cpp
) )
target_include_directories(db_mgr target_include_directories(db_mgr
......
#pragma once
namespace eda {
namespace db_mgr {
class DbMgr;
}
/*
* this is one of the components of minieda, and
* minieda should first call make*Comp*(), then
* call init*Comp*(this)
*/
// simply return a ptr
db_mgr::DbMgr* makeDbMgr();
// initDbMgr();
} // namespace eda
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace odb { namespace odb {
class dbDatabase; class dbDatabase;
class lefin;
} }
// Logger symbol: MGR // Logger symbol: MGR
...@@ -16,6 +17,8 @@ class Logger; ...@@ -16,6 +17,8 @@ class Logger;
} }
namespace eda { namespace eda {
namespace db_mgr {
/* DB Manager: for hierarchical design. A hierarchical design /* DB Manager: for hierarchical design. A hierarchical design
* contains multiple sub-block within the 'top' module. Because * contains multiple sub-block within the 'top' module. Because
* dbBlock class in OpenDB only supports two-levels of hierarchy, * dbBlock class in OpenDB only supports two-levels of hierarchy,
...@@ -41,8 +44,8 @@ namespace eda { ...@@ -41,8 +44,8 @@ namespace eda {
class DbMgr { class DbMgr {
public: public:
DbMgr(); DbMgr();
void deleteDbMgr(); // dbDatadase::destroy() ~DbMgr(); // dbDatadase::destroy()
bool readLibDB(); bool readLibDB(const char* path);
/* /*
bool readBlockDBs(); bool readBlockDBs();
bool addBlockDB(); bool addBlockDB();
...@@ -51,6 +54,7 @@ public: ...@@ -51,6 +54,7 @@ public:
bool haveBlockDB(std::string block); bool haveBlockDB(std::string block);
void setLogger(utl::Logger* logger); void setLogger(utl::Logger* logger);
void init(utl::Logger* logger);
private: private:
/* all Blocks share the same lib (.lef files) /* all Blocks share the same lib (.lef files)
...@@ -67,7 +71,11 @@ private: ...@@ -67,7 +71,11 @@ private:
std::unordered_map<std::string, odb::dbDatabase*> block_dbs_; std::unordered_map<std::string, odb::dbDatabase*> block_dbs_;
utl::Logger* logger_; utl::Logger* logger_;
// parsers
odb::lefin* lef_parser_;
}; };
} // namespace db_mgr
} // namespace eda } // namespace eda
#endif // _DB_MGR_H_ #endif // _DB_MGR_H_
#include "db_mgr/MakeDbMgr.h"
#include "db_mgr/db_mgr.h"
namespace eda {
db_mgr::DbMgr* makeDbMgr()
{
return new db_mgr::DbMgr();
}
} // namespace eda
\ No newline at end of file
#include <libgen.h> // for basename()
#include "db_mgr/db_mgr.h" #include "db_mgr/db_mgr.h"
#include "db.h" #include "db.h"
#include "lefin.h"
#include "utl/Logger.h" #include "utl/Logger.h"
namespace eda { namespace eda {
namespace db_mgr {
DbMgr::DbMgr() DbMgr::DbMgr()
: lib_db_(nullptr), : lib_db_(nullptr),
...@@ -11,7 +15,16 @@ DbMgr::DbMgr() ...@@ -11,7 +15,16 @@ DbMgr::DbMgr()
block_dbs_.clear(); block_dbs_.clear();
} }
void DbMgr::deleteDbMgr() void DbMgr::init(utl::Logger* logger)
{
setLogger(logger);
lib_db_ = new odb::dbDatabase();
bool ignore_non_routing_layers = false;
lef_parser_ = new odb::lefin(lib_db_, logger_,
ignore_non_routing_layers);
}
DbMgr::~DbMgr()
{ {
if (lib_db_ != nullptr) { if (lib_db_ != nullptr) {
lib_db_->destroy(lib_db_); lib_db_->destroy(lib_db_);
...@@ -36,10 +49,17 @@ void DbMgr::setLogger(utl::Logger* logger) ...@@ -36,10 +49,17 @@ void DbMgr::setLogger(utl::Logger* logger)
logger_ = logger; logger_ = logger;
} }
bool DbMgr::readLibDB() bool DbMgr::readLibDB(const char* path)
{ {
const char* libname = basename(const_cast<char*>(path));
if (!lib_db_->getTech()) {
return lef_parser_->createTechAndLib(libname, path) != nullptr;
} else {
return lef_parser_->createLib(libname, path) != nullptr;
}
return true; return true;
} }
} // namespace db_mgr
} // namespace eda } // namespace eda
...@@ -4,7 +4,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/src/cmake") ...@@ -4,7 +4,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/src/cmake")
include("swig_lib") include("swig_lib")
# paths for submodule # paths for submodule
set(odb_HOME ${PROJECT_SOURCE_DIR}/src/odb) set(ODB_HOME ${PROJECT_SOURCE_DIR}/src/odb)
# main program source # main program source
set(MINIEDA_SOURCE set(MINIEDA_SOURCE
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#include "utl/MakeLogger.h" #include "utl/MakeLogger.h"
#include "utl/Logger.h" #include "utl/Logger.h"
#include "utl/tcl_utl.h" #include "utl/tcl_utl.h"
#include "odb/db.h" #include "db_mgr/db_mgr.h"
#include "db_mgr/MakeDbMgr.h"
namespace eda { namespace eda {
extern const char* minieda_swig_tcl_inits[]; extern const char* minieda_swig_tcl_inits[];
...@@ -24,19 +25,16 @@ namespace eda { ...@@ -24,19 +25,16 @@ namespace eda {
using utl::evalTclInit; using utl::evalTclInit;
using utl::initTclUtil; using utl::initTclUtil;
using odb::dbDatabase;
MiniEda::MiniEda() MiniEda::MiniEda()
: tcl_interp_(nullptr), : tcl_interp_(nullptr),
logger_(nullptr), logger_(nullptr),
db_(nullptr) db_mgr_(nullptr)
{ {}
}
MiniEda::~MiniEda() MiniEda::~MiniEda()
{ {
odb::dbDatabase::destroy(db_); delete db_mgr_;
delete logger_; delete logger_;
} }
...@@ -68,16 +66,18 @@ void MiniEda::init(Tcl_Interp* interp) ...@@ -68,16 +66,18 @@ void MiniEda::init(Tcl_Interp* interp)
} }
logger_ = makeLogger(log_filename, metrics_filename); logger_ = makeLogger(log_filename, metrics_filename);
db_ = dbDatabase::create(); db_mgr_ = makeDbMgr();
// Init components. // Init components.
Minieda_swig_Init(interp); Minieda_swig_Init(interp);
// Import TCL scripts // Import TCL scripts
initTclUtil(interp); initTclUtil(interp);
evalTclInit(interp, eda::minieda_swig_tcl_inits); evalTclInit(interp, minieda_swig_tcl_inits);
// defined in MakeModuleXX.h // defined in MakeModuleXX.h
initLogger(logger_, interp); initLogger(logger_, interp);
// TOBE implemented
// initDbMgr(this);
} }
} // namespace eda } // namespace eda
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "eda/MiniEda.hh" #include "eda/MiniEda.hh"
#include "utl/Logger.h" #include "utl/Logger.h"
#include "odb/db.h" #include "odb/db.h"
#include "db_mgr/db_mgr.h"
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// //
...@@ -23,17 +24,18 @@ utl::Logger* getLogger() ...@@ -23,17 +24,18 @@ utl::Logger* getLogger()
return MiniEda::miniEda()->getLogger(); return MiniEda::miniEda()->getLogger();
} }
odb::dbDatabase* getDb() /*
db_mgr::DbMgr* getDbMgr()
{ {
return MiniEda::miniEda()->getDb(); return MiniEda::miniEda()->getDbMgr();
} }
*/
} // namespace eda } // namespace eda
using eda::MiniEda; using eda::MiniEda;
using eda::getMiniEda; using eda::getMiniEda;
using eda::getLogger; using eda::getLogger;
using eda::getDb;
%} %}
...@@ -62,11 +64,6 @@ void logger_echo(const char* usr_input) ...@@ -62,11 +64,6 @@ void logger_echo(const char* usr_input)
getLogger()->info(utl::EDA, 1, usr_input); getLogger()->info(utl::EDA, 1, usr_input);
} }
odb::dbDatabase* get_db()
{
return getDb();
}
} }
%} // inline %} // inline
......
...@@ -8,12 +8,12 @@ namespace utl { ...@@ -8,12 +8,12 @@ namespace utl {
class Logger; class Logger;
} }
namespace odb {
class dbDatabase;
}
namespace eda { namespace eda {
namespace db_mgr {
class DbMgr;
}
class MiniEda class MiniEda
{ {
public: public:
...@@ -22,9 +22,7 @@ public: ...@@ -22,9 +22,7 @@ public:
Tcl_Interp* tclInterp() { return tcl_interp_; } Tcl_Interp* tclInterp() { return tcl_interp_; }
utl::Logger* getLogger() { return logger_; } utl::Logger* getLogger() { return logger_; }
// currently, we use db directly db_mgr::DbMgr* getDbMgr() { return db_mgr_; }
// TODO: makes a db manager
odb::dbDatabase* getDb() { return db_; }
protected: protected:
~MiniEda(); ~MiniEda();
...@@ -35,9 +33,7 @@ private: ...@@ -35,9 +33,7 @@ private:
Tcl_Interp* tcl_interp_; Tcl_Interp* tcl_interp_;
utl::Logger* logger_; utl::Logger* logger_;
// currently, we use db directly db_mgr::DbMgr* db_mgr_;
// TODO: makes a db manager
odb::dbDatabase* db_;
}; };
int tclAppInit(Tcl_Interp* interp); int tclAppInit(Tcl_Interp* interp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment