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

Method createBindInstance_

src/DesignCompile/DesignElaboration.cpp:627–683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

625}
626
627ModuleInstance* DesignElaboration::createBindInstance_(
628 BindStmt* bind, ModuleInstance* parent, ModuleInstanceFactory* factory,
629 Config* config) {
630 ModuleInstance* instance = nullptr;
631 const FileContent* fC = bind->getFileContent();
632 Library* lib = fC->getLibrary();
633 NodeId bindNodeId = bind->getBindId();
634 const std::string bindModName =
635 StrCat(lib->getName(), "@", fC->SymName(bindNodeId));
636 NodeId instNameId = bind->getInstanceId();
637 const std::string_view instName = fC->SymName(instNameId);
638 NodeId targetModId = bind->getTargetModId();
639 NodeId targetInstId = bind->getTargetInstId();
640 const std::string targetName =
641 StrCat(lib->getName(), "@", fC->SymName(targetModId));
642 DesignComponent* def = parent->getDefinition();
643 Design* design = m_compileDesign->getCompiler()->getDesign();
644 bool instanceMatch = true;
645 if (targetInstId) {
646 const std::string_view targetInstName = fC->SymName(targetInstId);
647 instanceMatch = (targetInstName == parent->getInstanceName());
648 }
649 DesignComponent* targetDef = nullptr;
650 if (def && (def->getName() == targetName) && instanceMatch) {
651 targetDef = design->getModuleDefinition(bindModName);
652 if (targetDef) {
653 instance = factory->newModuleInstance(targetDef, fC, bind->getStmtId(),
654 parent->getParent(), instName,
655 bindModName);
656 } else {
657 SymbolTable* st =
658 m_compileDesign->getCompiler()->getErrorContainer()->getSymbolTable();
659 Location loc(fC->getFileId(bind->getStmtId()),
660 fC->Line(bind->getStmtId()), fC->Column(bind->getStmtId()),
661 st->registerSymbol(bindModName));
662 Error err(ErrorDefinition::ELAB_NO_MODULE_DEFINITION, loc);
663 m_compileDesign->getCompiler()->getErrorContainer()->addError(err, false,
664 false);
665 }
666 }
667 if (instance) {
668 std::vector<ModuleInstance*> parentSubInstances;
669 instance->setInstanceBinding(parent);
670 if (instance->getParent() == nullptr) {
671 instance->setParent(parent);
672 }
673 NodeId parameterOverloading = fC->Sibling(bindNodeId);
674 if (fC->Type(parameterOverloading) ==
675 VObjectType::paHierarchical_instance) {
676 parameterOverloading = InvalidNodeId;
677 }
678 elaborateInstance_(targetDef->getFileContents()[0],
679 targetDef->getNodeIds()[0], parameterOverloading,
680 factory, instance, config, parentSubInstances);
681 }
682 return instance;
683}
684

Callers

nothing calls this directly

Calls 15

StrCatFunction · 0.85
getBindIdMethod · 0.80
getTargetModIdMethod · 0.80
getTargetInstIdMethod · 0.80
getDesignMethod · 0.80
getInstanceNameMethod · 0.80
newModuleInstanceMethod · 0.80
getStmtIdMethod · 0.80
setInstanceBindingMethod · 0.80
getFileContentMethod · 0.45
getLibraryMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected