Commit b1500981 by lvzhengyang

link db_mgr to minieda

parent 3bdafcdd
......@@ -7,6 +7,7 @@ add_library(db_mgr)
target_sources(db_mgr
PRIVATE
src/db_mgr.cpp
src/MakeDbMgr.cpp
)
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 @@
namespace odb {
class dbDatabase;
class lefin;
}
// Logger symbol: MGR
......@@ -16,6 +17,8 @@ class Logger;
}
namespace eda {
namespace db_mgr {
/* DB Manager: for hierarchical design. A hierarchical design
* contains multiple sub-block within the 'top' module. Because
* dbBlock class in OpenDB only supports two-levels of hierarchy,
......@@ -41,8 +44,8 @@ namespace eda {
class DbMgr {
public:
DbMgr();
void deleteDbMgr(); // dbDatadase::destroy()
bool readLibDB();
~DbMgr(); // dbDatadase::destroy()
bool readLibDB(const char* path);
/*
bool readBlockDBs();
bool addBlockDB();
......@@ -51,6 +54,7 @@ public:
bool haveBlockDB(std::string block);
void setLogger(utl::Logger* logger);
void init(utl::Logger* logger);
private:
/* all Blocks share the same lib (.lef files)
......@@ -67,7 +71,11 @@ private:
std::unordered_map<std::string, odb::dbDatabase*> block_dbs_;
utl::Logger* logger_;
// parsers
odb::lefin* lef_parser_;
};
} // namespace db_mgr
} // namespace eda
#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.h"
#include "lefin.h"
#include "utl/Logger.h"
namespace eda {
namespace db_mgr {
DbMgr::DbMgr()
: lib_db_(nullptr),
......@@ -11,7 +15,16 @@ DbMgr::DbMgr()
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) {
lib_db_->destroy(lib_db_);
......@@ -36,10 +49,17 @@ void DbMgr::setLogger(utl::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;
}
} // namespace db_mgr
} // namespace eda
......@@ -4,7 +4,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/src/cmake")
include("swig_lib")
# paths for submodule
set(odb_HOME ${PROJECT_SOURCE_DIR}/src/odb)
set(ODB_HOME ${PROJECT_SOURCE_DIR}/src/odb)
# main program source
set(MINIEDA_SOURCE
......
......@@ -4,7 +4,8 @@
#include "utl/MakeLogger.h"
#include "utl/Logger.h"
#include "utl/tcl_utl.h"
#include "odb/db.h"
#include "db_mgr/db_mgr.h"
#include "db_mgr/MakeDbMgr.h"
namespace eda {
extern const char* minieda_swig_tcl_inits[];
......@@ -24,19 +25,16 @@ namespace eda {
using utl::evalTclInit;
using utl::initTclUtil;
using odb::dbDatabase;
MiniEda::MiniEda()
: tcl_interp_(nullptr),
logger_(nullptr),
db_(nullptr)
{
}
db_mgr_(nullptr)
{}
MiniEda::~MiniEda()
{
odb::dbDatabase::destroy(db_);
delete db_mgr_;
delete logger_;
}
......@@ -68,16 +66,18 @@ void MiniEda::init(Tcl_Interp* interp)
}
logger_ = makeLogger(log_filename, metrics_filename);
db_ = dbDatabase::create();
db_mgr_ = makeDbMgr();
// Init components.
Minieda_swig_Init(interp);
// Import TCL scripts
initTclUtil(interp);
evalTclInit(interp, eda::minieda_swig_tcl_inits);
evalTclInit(interp, minieda_swig_tcl_inits);
// defined in MakeModuleXX.h
initLogger(logger_, interp);
// TOBE implemented
// initDbMgr(this);
}
} // namespace eda
......@@ -3,6 +3,7 @@
#include "eda/MiniEda.hh"
#include "utl/Logger.h"
#include "odb/db.h"
#include "db_mgr/db_mgr.h"
////////////////////////////////////////////////////////////////
//
......@@ -23,17 +24,18 @@ utl::Logger* getLogger()
return MiniEda::miniEda()->getLogger();
}
odb::dbDatabase* getDb()
/*
db_mgr::DbMgr* getDbMgr()
{
return MiniEda::miniEda()->getDb();
return MiniEda::miniEda()->getDbMgr();
}
*/
} // namespace eda
using eda::MiniEda;
using eda::getMiniEda;
using eda::getLogger;
using eda::getDb;
%}
......@@ -62,11 +64,6 @@ void logger_echo(const char* usr_input)
getLogger()->info(utl::EDA, 1, usr_input);
}
odb::dbDatabase* get_db()
{
return getDb();
}
}
%} // inline
......
......@@ -8,12 +8,12 @@ namespace utl {
class Logger;
}
namespace odb {
class dbDatabase;
}
namespace eda {
namespace db_mgr {
class DbMgr;
}
class MiniEda
{
public:
......@@ -22,9 +22,7 @@ public:
Tcl_Interp* tclInterp() { return tcl_interp_; }
utl::Logger* getLogger() { return logger_; }
// currently, we use db directly
// TODO: makes a db manager
odb::dbDatabase* getDb() { return db_; }
db_mgr::DbMgr* getDbMgr() { return db_mgr_; }
protected:
~MiniEda();
......@@ -35,9 +33,7 @@ private:
Tcl_Interp* tcl_interp_;
utl::Logger* logger_;
// currently, we use db directly
// TODO: makes a db manager
odb::dbDatabase* db_;
db_mgr::DbMgr* db_mgr_;
};
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