Handling aliases of non-instantiated nets
For example $true and $false in Yosys
This commit is contained in:
parent
7d5338c9be
commit
d7f9e5cb87
|
@ -153,7 +153,7 @@ Cell * Blif::load ( string cellPath ) //, Cell *cell )
|
||||||
or current_names[2] != "1" or current_names[3] != "1"
|
or current_names[2] != "1" or current_names[3] != "1"
|
||||||
){
|
){
|
||||||
ostringstream mess;
|
ostringstream mess;
|
||||||
mess << "Name statement is not an alias and will be ignored "
|
mess << ".names statement is not an alias and will be ignored "
|
||||||
<< "(map to standard cells for functions and tie cells for constants)\n";
|
<< "(map to standard cells for functions and tie cells for constants)\n";
|
||||||
for(string const & S: current_names){
|
for(string const & S: current_names){
|
||||||
mess << S << " ";
|
mess << S << " ";
|
||||||
|
@ -295,6 +295,9 @@ Cell * Blif::load ( string cellPath ) //, Cell *cell )
|
||||||
std::vector<Cell*> model_cells;
|
std::vector<Cell*> model_cells;
|
||||||
for(auto M : models){
|
for(auto M : models){
|
||||||
Cell * design = framework->createCell(M.name);
|
Cell * design = framework->createCell(M.name);
|
||||||
|
if(design == NULL){
|
||||||
|
throw Error("Model " + M.name + " is NULL\n");
|
||||||
|
}
|
||||||
model_cells.push_back(design);
|
model_cells.push_back(design);
|
||||||
addSupplyNets(design);
|
addSupplyNets(design);
|
||||||
|
|
||||||
|
@ -323,6 +326,7 @@ Cell * Blif::load ( string cellPath ) //, Cell *cell )
|
||||||
}
|
}
|
||||||
// Second pass: every cell and its nets have already been created
|
// Second pass: every cell and its nets have already been created
|
||||||
for(int i=0; i<models.size(); ++i){
|
for(int i=0; i<models.size(); ++i){
|
||||||
|
cmess2 << "Handling model " << models[i].name << endl;
|
||||||
auto const & M = models[i];
|
auto const & M = models[i];
|
||||||
Cell * design = model_cells[i];
|
Cell * design = model_cells[i];
|
||||||
for(int j=0; j<M.subcircuits.size(); ++j){
|
for(int j=0; j<M.subcircuits.size(); ++j){
|
||||||
|
@ -331,22 +335,38 @@ Cell * Blif::load ( string cellPath ) //, Cell *cell )
|
||||||
subckt_name << "subckt_" << j;
|
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 << Error("Cell " + S.cell + " to instanciate hasn't been found\n");
|
throw Error("Cell <" + S.cell + "> to instanciate hasn't been found\n");
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
//cmess2 << "Creating instance <" << subckt_name.str() << "> of <" << S.cell << "> in <" << models[i].name << ">" << endl;
|
||||||
Instance* instance = Instance::create( design, subckt_name.str(), cell);
|
Instance* instance = Instance::create( design, subckt_name.str(), cell);
|
||||||
|
|
||||||
for(auto & P : S.pins){
|
for(auto & P : S.pins){
|
||||||
Net* internalNet = cell->getNet( P.first );
|
Net* internalNet = cell->getNet( P.first );
|
||||||
Net* externalNet = design->getNet( P.second );
|
Net* externalNet = design->getNet( P.second );
|
||||||
assert(internalNet != NULL and externalNet != NULL);
|
assert(internalNet != NULL and externalNet != NULL and instance != NULL);
|
||||||
instance->getPlug( internalNet )->setNet( externalNet );
|
instance->getPlug( internalNet )->setNet( externalNet );
|
||||||
}
|
}
|
||||||
//connectSupplyNets(instance, design);
|
//connectSupplyNets(instance, design);
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
|
// Merge the aliased nets
|
||||||
for(auto alias : M.aliases){
|
for(auto alias : M.aliases){
|
||||||
design->getNet( alias.first )->merge(design->getNet( alias.second ));
|
//cmess2 << "Merging nets <" << alias.first << "> and <" << alias.second << ">" << endl;
|
||||||
|
Net * first_net = design->getNet( alias.first );
|
||||||
|
Net * second_net = design->getNet( alias.second );
|
||||||
|
if(first_net == NULL or second_net == NULL){
|
||||||
|
ostringstream mess;
|
||||||
|
mess << "Trying to create an alias for non-instantiated nets:";
|
||||||
|
if(first_net == NULL)
|
||||||
|
mess << " <" << alias.first << ">";
|
||||||
|
if(second_net == NULL)
|
||||||
|
mess << " <" << alias.second << ">";
|
||||||
|
mess << ", will be ignored\n";
|
||||||
|
cerr << Warning(mess.str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!first_net->isExternal())
|
||||||
|
swap(first_net, second_net); // If only one net is external, it needs to be the first
|
||||||
|
first_net->merge(second_net);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmess2 << "BLIF file loaded" << endl;
|
cmess2 << "BLIF file loaded" << endl;
|
||||||
|
|
Loading…
Reference in New Issue