Added design->rename(module, new_name)
authorClifford Wolf <clifford@clifford.at>
Mon, 29 Jun 2015 23:37:59 +0000 (01:37 +0200)
committerClifford Wolf <clifford@clifford.at>
Mon, 29 Jun 2015 23:37:59 +0000 (01:37 +0200)
kernel/rtlil.cc
kernel/rtlil.h
passes/cmds/rename.cc

index 7cd2dd4bbd8a0fa0a60d8362ddd2ce7eaadef599..cc7b1a7b85403add53b1b47d6356e05e10412f61 100644 (file)
@@ -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();
index b6248c4c0d5b930578d83151d962b34953d47933..854ec13039c42e5f0b6d0fa40509a48126bfff7d 100644 (file)
@@ -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);
 
index d1671317597fe1a5defa9330624b84cada126cc5..81e532590d31b98420b277ee64a4319a5da7484d 100644 (file)
@@ -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
                {