design: -import to not count black/white-boxes as candidates for top
authorEddie Hung <eddie@fpgeh.com>
Thu, 16 Apr 2020 19:46:07 +0000 (12:46 -0700)
committerEddie Hung <eddie@fpgeh.com>
Thu, 16 Apr 2020 19:46:07 +0000 (12:46 -0700)
passes/cmds/design.cc

index cfe97067d03b511164cdb51b7a241c6d9fdbe6eb..421defe0c70a46b7ca8a496f9a8f9ed30c382f7d 100644 (file)
@@ -228,14 +228,20 @@ struct DesignPass : public Pass {
                        }
 
                        if (import_mode) {
+                               std::vector<RTLIL::Module*> candidates;
                                for (auto module : copy_src_modules)
                                {
                                        if (module->get_bool_attribute(ID::top)) {
-                                               copy_src_modules.clear();
-                                               copy_src_modules.push_back(module);
+                                               candidates.clear();
+                                               candidates.push_back(module);
                                                break;
                                        }
+                                       if (!module->get_blackbox_attribute())
+                                               candidates.push_back(module);
                                }
+
+                               if (GetSize(candidates) == 1)
+                                       copy_src_modules = std::move(candidates);
                        }
                }