Supports several models in a Blif file
This commit is contained in:
parent
bacea5214c
commit
4035a6cb46
|
@ -228,6 +228,7 @@ Cell * Blif::load ( string cellPath ) //, Cell *cell )
|
||||||
throw Error("Unexpected token after model name\n");
|
throw Error("Unexpected token after model name\n");
|
||||||
else{
|
else{
|
||||||
models.back().name = token;
|
models.back().name = token;
|
||||||
|
cmess2 << "Processing model <" << token << ">" << endl;
|
||||||
hasName = true;
|
hasName = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,13 +256,11 @@ Cell * Blif::load ( string cellPath ) //, Cell *cell )
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(models.size() > 1){
|
// Two passes: first create the cells and their nets, then create the internals
|
||||||
cerr << Warning("Several models in the file; only the last was open\n");
|
std::vector<Cell*> model_cells;
|
||||||
}
|
|
||||||
|
|
||||||
Cell * design = NULL;
|
|
||||||
for(auto M : models){
|
for(auto M : models){
|
||||||
design = framework->createCell(M.name);
|
Cell * design = framework->createCell(M.name);
|
||||||
|
model_cells.push_back(design);
|
||||||
addSupplyNets(design);
|
addSupplyNets(design);
|
||||||
|
|
||||||
unordered_set<string> net_names;
|
unordered_set<string> net_names;
|
||||||
|
@ -282,14 +281,18 @@ Cell * Blif::load ( string cellPath ) //, Cell *cell )
|
||||||
new_net->setDirection( it->second );
|
new_net->setDirection( it->second );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
int i=0;
|
// Second pass: every cell and its nets have already been created
|
||||||
for(auto & S : M.subcircuits){
|
for(int i=0; i<models.size(); ++i){
|
||||||
|
auto const & M = models[i];
|
||||||
|
Cell * design = model_cells[i];
|
||||||
|
for(int j=0; j<M.subcircuits.size(); ++j){
|
||||||
|
auto & S = M.subcircuits[j];
|
||||||
ostringstream subckt_name;
|
ostringstream subckt_name;
|
||||||
subckt_name << "subckt_" << i;
|
subckt_name << "subckt_" << j;
|
||||||
Cell * cell = framework->getCell(S.cell, Catalog::State::Views, 0);
|
Cell * cell = framework->getCell(S.cell, Catalog::State::Views, 0);
|
||||||
if(cell == NULL){
|
if(cell == NULL){
|
||||||
cerr << Warning("Cell " + S.cell + "to instanciate hasn't been found\n");
|
cerr << Error("Cell " + S.cell + " to instanciate hasn't been found\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Instance* instance = Instance::create( design, subckt_name.str(), cell);
|
Instance* instance = Instance::create( design, subckt_name.str(), cell);
|
||||||
|
@ -304,8 +307,14 @@ Cell * Blif::load ( string cellPath ) //, Cell *cell )
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cmess2 << "BLIF file loaded" << endl;
|
||||||
return design;
|
if(model_cells.empty()){
|
||||||
|
throw Error("No model found in the file\n");
|
||||||
|
}
|
||||||
|
else if(model_cells.size() > 1){
|
||||||
|
cerr << Warning("Several models found: returned the first one\n");
|
||||||
|
}
|
||||||
|
return model_cells[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue