Added "techmap -map %{design-name}"

This commit is contained in:
Clifford Wolf 2014-07-29 16:06:27 +02:00
parent 397b00252d
commit 03c96f9ce7
4 changed files with 29 additions and 10 deletions

View File

@ -219,6 +219,11 @@ void RTLIL::Selection::optimize(RTLIL::Design *design)
} }
} }
RTLIL::Design::Design()
{
refcount_modules_ = 0;
}
RTLIL::Design::~Design() RTLIL::Design::~Design()
{ {
for (auto it = modules_.begin(); it != modules_.end(); it++) for (auto it = modules_.begin(); it != modules_.end(); it++)

View File

@ -352,11 +352,16 @@ struct RTLIL::Design
std::map<RTLIL::IdString, RTLIL::Selection> selection_vars; std::map<RTLIL::IdString, RTLIL::Selection> selection_vars;
std::string selected_active_module; std::string selected_active_module;
Design();
~Design(); ~Design();
RTLIL::ObjRange<RTLIL::Module*> modules(); RTLIL::ObjRange<RTLIL::Module*> modules();
RTLIL::Module *module(RTLIL::IdString name); RTLIL::Module *module(RTLIL::IdString name);
bool has(RTLIL::IdString id) const {
return modules_.count(id) != 0;
}
void add(RTLIL::Module *module); void add(RTLIL::Module *module);
RTLIL::Module *addModule(RTLIL::IdString name); RTLIL::Module *addModule(RTLIL::IdString name);
void remove(RTLIL::Module *module); void remove(RTLIL::Module *module);

View File

@ -603,9 +603,9 @@ struct ExtractPass : public Pass {
delete map; delete map;
log_cmd_error("Can't saved design `%s'.\n", filename.c_str()+1); log_cmd_error("Can't saved design `%s'.\n", filename.c_str()+1);
} }
for (auto &it : saved_designs.at(filename.substr(1))->modules_) for (auto mod : saved_designs.at(filename.substr(1))->modules())
if (!map->modules_.count(it.first)) if (!map->has(mod->name))
map->modules_[it.first] = it.second->clone(); map->add(mod->clone());
} }
else else
{ {

View File

@ -656,13 +656,22 @@ struct TechmapPass : public Pass {
Frontend::frontend_call(map, f, "<stdcells.v>", verilog_frontend); Frontend::frontend_call(map, f, "<stdcells.v>", verilog_frontend);
fclose(f); fclose(f);
} else } else
for (auto &fn : map_files) { for (auto &fn : map_files)
FILE *f = fopen(fn.c_str(), "rt"); if (fn.substr(0, 1) == "%") {
if (f == NULL) if (!saved_designs.count(fn.substr(1))) {
log_cmd_error("Can't open map file `%s'\n", fn.c_str()); delete map;
Frontend::frontend_call(map, f, fn, (fn.size() > 3 && fn.substr(fn.size()-3) == ".il") ? "ilang" : verilog_frontend); log_cmd_error("Can't saved design `%s'.\n", fn.c_str()+1);
fclose(f); }
} for (auto mod : saved_designs.at(fn.substr(1))->modules())
if (!map->has(mod->name))
map->add(mod->clone());
} else {
FILE *f = fopen(fn.c_str(), "rt");
if (f == NULL)
log_cmd_error("Can't open map file `%s'\n", fn.c_str());
Frontend::frontend_call(map, f, fn, (fn.size() > 3 && fn.substr(fn.size()-3) == ".il") ? "ilang" : verilog_frontend);
fclose(f);
}
std::map<RTLIL::IdString, RTLIL::Module*> modules_new; std::map<RTLIL::IdString, RTLIL::Module*> modules_new;
for (auto &it : map->modules_) { for (auto &it : map->modules_) {