From: Clifford Wolf Date: Mon, 29 Jun 2015 23:37:59 +0000 (+0200) Subject: Added design->rename(module, new_name) X-Git-Tag: yosys-0.6~240 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=caa274ada6f2f35119cff943d0e9ed05dfaaeec7;p=yosys.git Added design->rename(module, new_name) --- diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 7cd2dd4bb..cc7b1a7b8 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -444,6 +444,13 @@ void RTLIL::Design::remove(RTLIL::Module *module) delete module; } +void RTLIL::Design::rename(RTLIL::Module *module, RTLIL::IdString new_name) +{ + modules_.erase(module->name); + module->name = new_name; + add(module); +} + void RTLIL::Design::sort() { scratchpad.sort(); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index b6248c4c0..854ec1303 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -809,6 +809,7 @@ struct RTLIL::Design void add(RTLIL::Module *module); RTLIL::Module *addModule(RTLIL::IdString name); void remove(RTLIL::Module *module); + void rename(RTLIL::Module *module, RTLIL::IdString new_name); void scratchpad_unset(std::string varname); diff --git a/passes/cmds/rename.cc b/passes/cmds/rename.cc index d16713175..81e532590 100644 --- a/passes/cmds/rename.cc +++ b/passes/cmds/rename.cc @@ -193,9 +193,7 @@ struct RenamePass : public Pass { log_cmd_error("No top module found!\n"); log("Renaming module %s to %s.\n", log_id(module), log_id(new_name)); - design->modules_.erase(module->name); - module->name = new_name; - design->modules_[module->name] = module; + design->rename(module, new_name); } else {