Commit 705cc2ad by lvzhengyang

add readDef

parent 2380229d
...@@ -3,6 +3,17 @@ ...@@ -3,6 +3,17 @@
* I install tcltk in my path. Run shell command first `source setup.sh` * I install tcltk in my path. Run shell command first `source setup.sh`
* To run minieda, enter ./install, and `./bin/minieda` * To run minieda, enter ./install, and `./bin/minieda`
## ROAD MAP
* **Finnal Goal :** design pin positions for abutting design style
* design db style
* (**This**) each block per db
* a db contains multiple block, with each block in a dbChip
* a db supports containing multiple chips
* create a new data structure for pin assignment task
## TODO ## TODO
* add DB Manager * add DB Manager
......
...@@ -55,9 +55,11 @@ public: ...@@ -55,9 +55,11 @@ public:
bool haveBlockDB(const std::string block); bool haveBlockDB(const std::string block);
bool createBlockDB(const char* block_name); bool createBlockDB(const char* block_name);
bool deleteBlockDB(const char* block_name); bool deleteBlockDB(const char* block_name);
/* bool readBlockDef(const char* block_name,
bool readBlockDef(); const char* def_file,
*/ bool cont_on_err,
bool is_floorplan,
bool is_incr); // incr: incremental
void setLogger(utl::Logger* logger); void setLogger(utl::Logger* logger);
void init(utl::Logger* logger); void init(utl::Logger* logger);
......
...@@ -93,5 +93,82 @@ bool DbMgr::deleteBlockDB(const char* block_name) ...@@ -93,5 +93,82 @@ bool DbMgr::deleteBlockDB(const char* block_name)
return true; return true;
} }
bool DbMgr::readBlockDef(const char* block_name,
const char* def_file,
bool cont_on_err,
bool is_floorplan,
bool is_incr)
{
// Before read def, ensure the corresponding block has been created.
// Read netlist before read def?
/* ** About the Def Reader **
odb::defin simply wraps odb::definReader.
odb::definReader::createBlock() calls LefDefParser::defrRead()
LefDefParser::defrRead()
- the main reader function.
- defined in odb/src/def/def/defrReader.cpp.
- calls Bison Parser entry: defyyparse(), to do the detailed parse job.
- parser rules is defined in odb/src/defin/def.y, and Bison read this to create parser.
def parsing process is monitored by LefDefParser::defContext, whose prototype is LefDefParser::defrContext.
class LefDefParser::defrContext
- defined in odb/src/def/def/defrData.hpp.
LefDefParser::defContext
- instantiate in odb/src/def/def/defrData.hpp.
- initialized in odb/src/def/def/defrReader.cpp
- content of def file is parsed and stored by corresponding callback function of syntaxes.
definReader::designCallback
- if reader_->parent_ (odb::dbBlock* ) exists, create a new child dbBlock of reader_->parent_
- else: create block under reader_->_db->getChip();
- if DEFAULT mode, create a new block
- else: read to an existing block
- different modes corresponds to different callbacks.
odb::dbBlock::create
- 1. create top block for a chip.
- 2. create a hierarchical/child block for a block.
*/
if (!haveBlockDB(block_name)) {
logger_->error(utl::MGR, 5, "Failed to read DEF {} for block {}",
def_file, block_name);
return false;
}
if (is_floorplan && is_incr) {
logger_->error(utl::MGR, 6, "Cannot set floorplan and incremental mode at the same time");
return false;
}
odb::defin::MODE mode = odb::defin::DEFAULT;
if (is_floorplan) {
mode = odb::defin::FLOORPLAN;
} else if (is_incr) {
mode = odb::defin::INCREMENTAL;
}
odb::dbDatabase* block_db = block_dbs_.find(block_name)->second;
// to ensure `delete` can work, use `new` here
def_parser_ = std::move(std::unique_ptr<odb::defin>(
new odb::defin(block_db, logger_, mode)));
if (cont_on_err) {
def_parser_->continueOnErrors();
}
std::vector<odb::dbLib*> search_libs;
for (auto lib : block_db->getLibs()) {
search_libs.push_back(lib);
}
// temprary test
if (block_db->getChip() == nullptr) {
odb::dbChip* chip = def_parser_->createChip(search_libs, def_file);
} else {
odb::dbBlock* block = def_parser_->createBlock(
block_db->getChip()->getBlock(),
search_libs, def_file);
}
delete def_parser_.release(); // def_parser_ becomes an empty ptr now.
return true;
}
} // namespace db_mgr } // namespace db_mgr
} // namespace eda } // namespace eda
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