MCPcopy Create free account
hub / github.com/chipsalliance/Surelog / identifyTopModules_

Method identifyTopModules_

src/DesignCompile/DesignElaboration.cpp:270–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270bool DesignElaboration::identifyTopModules_() {
271 FileSystem* const fileSystem = FileSystem::getInstance();
272 m_topLevelModules.clear();
273 bool modulePresent = false;
274 bool toplevelModuleFound = false;
275 SymbolTable* st = m_compileDesign->getCompiler()->getSymbolTable();
276 auto& userTopList = m_compileDesign->getCompiler()
277 ->getCommandLineParser()
278 ->getTopLevelModules();
279 auto all_files =
280 m_compileDesign->getCompiler()->getDesign()->getAllFileContents();
281 typedef std::multimap<std::string,
282 std::pair<const DesignElement*, const FileContent*>>
283 ModuleMultiMap;
284 ModuleMultiMap all_modules;
285 for (auto file : all_files) {
286 if (m_compileDesign->getCompiler()->isLibraryFile(file.first)) continue;
287 for (const DesignElement* element : file.second->getDesignElements()) {
288 const std::string_view elemName = st->getSymbol(element->m_name);
289 if (element->m_type == DesignElement::Module) {
290 if (element->m_parent) {
291 // This is a nested element
292 continue;
293 }
294 const std::string_view libName = file.second->getLibrary()->getName();
295 std::string topname = StrCat(libName, "@", elemName);
296
297 if (!file.second->getParent()) {
298 // Files that have parent are splited files (When a module is too
299 // large it is splited)
300 all_modules.emplace(topname, std::make_pair(element, file.second));
301 }
302
303 modulePresent = true;
304 bool used = false;
305 for (auto file1 : all_files) {
306 if (file1.second->getReferencedObjects().find(elemName) !=
307 file1.second->getReferencedObjects().end()) {
308 if (m_compileDesign->getCompiler()->isLibraryFile(file1.first))
309 continue;
310 used = true;
311 break;
312 }
313 }
314
315 if (!used) {
316 bool isTop = true;
317
318 if (!m_toplevelConfigModules.empty()) {
319 isTop = false;
320 if (m_toplevelConfigModules.find(topname) !=
321 m_toplevelConfigModules.end()) {
322 isTop = true;
323 }
324 }
325
326 if (isTop) {
327 SymbolId topid = st->registerSymbol(topname);

Callers

nothing calls this directly

Calls 15

StrCatFunction · 0.85
clearMethod · 0.80
getDesignMethod · 0.80
isLibraryFileMethod · 0.80
insertMethod · 0.80
copyMethod · 0.80
getSymbolTableMethod · 0.45
getCompilerMethod · 0.45
getCommandLineParserMethod · 0.45
getSymbolMethod · 0.45
getNameMethod · 0.45
getLibraryMethod · 0.45

Tested by

no test coverage detected