From 99100f367d9239b4607a7fee05855a5f34be4467 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 17 Jun 2015 09:38:56 +0200 Subject: Added "rename -top new_name" --- kernel/rtlil.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'kernel/rtlil.cc') 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); -- cgit v1.2.3