diff options
author | Clifford Wolf <clifford@clifford.at> | 2015-06-17 09:38:56 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2015-06-17 09:38:56 +0200 |
commit | 99100f367d9239b4607a7fee05855a5f34be4467 (patch) | |
tree | d858fc477e922432708583ce687a8ac8b7a18479 /kernel | |
parent | 9f7a5b4ef92357761a3526fdc1c8171d8be9888c (diff) | |
download | yosys-99100f367d9239b4607a7fee05855a5f34be4467.tar.gz yosys-99100f367d9239b4607a7fee05855a5f34be4467.tar.bz2 yosys-99100f367d9239b4607a7fee05855a5f34be4467.zip |
Added "rename -top new_name"
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/rtlil.cc | 15 | ||||
-rw-r--r-- | kernel/rtlil.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 5deef8507..7cd2dd4bb 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -316,6 +316,21 @@ RTLIL::Module *RTLIL::Design::module(RTLIL::IdString name) return modules_.count(name) ? modules_.at(name) : NULL; } +RTLIL::Module *RTLIL::Design::top_module() +{ + RTLIL::Module *module = nullptr; + int module_count = 0; + + for (auto mod : selected_modules()) { + if (mod->get_bool_attribute("\\top")) + return mod; + module_count++; + module = mod; + } + + return module_count == 1 ? module : nullptr; +} + void RTLIL::Design::add(RTLIL::Module *module) { log_assert(modules_.count(module->name) == 0); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index e9deb1d5f..b6248c4c0 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -800,6 +800,7 @@ struct RTLIL::Design RTLIL::ObjRange<RTLIL::Module*> modules(); RTLIL::Module *module(RTLIL::IdString name); + RTLIL::Module *top_module(); bool has(RTLIL::IdString id) const { return modules_.count(id) != 0; |