| 4710 | } |
| 4711 | |
| 4712 | vpiHandle UhdmWriter::write(PathId uhdmFileId) { |
| 4713 | FileSystem* const fileSystem = FileSystem::getInstance(); |
| 4714 | ModPortMap modPortMap; |
| 4715 | InstanceMap instanceMap; |
| 4716 | ModuleMap moduleMap; |
| 4717 | Serializer& s = m_compileDesign->getSerializer(); |
| 4718 | ExprBuilder exprBuilder; |
| 4719 | exprBuilder.seterrorReporting( |
| 4720 | m_compileDesign->getCompiler()->getErrorContainer(), |
| 4721 | m_compileDesign->getCompiler()->getSymbolTable()); |
| 4722 | |
| 4723 | Location loc(uhdmFileId); |
| 4724 | Error err(ErrorDefinition::UHDM_CREATING_MODEL, loc); |
| 4725 | m_compileDesign->getCompiler()->getErrorContainer()->addError(err); |
| 4726 | m_compileDesign->getCompiler()->getErrorContainer()->printMessages( |
| 4727 | m_compileDesign->getCompiler()->getCommandLineParser()->muteStdout()); |
| 4728 | |
| 4729 | m_helper.setElabMode(false); |
| 4730 | |
| 4731 | // Compute list of design components that are part of the instance tree |
| 4732 | std::set<DesignComponent*> designComponents; |
| 4733 | { |
| 4734 | std::queue<ModuleInstance*> queue; |
| 4735 | for (const auto& pack : m_design->getPackageDefinitions()) { |
| 4736 | if (!pack.second->getFileContents().empty()) { |
| 4737 | if (pack.second->getFileContents()[0] != nullptr) |
| 4738 | designComponents.insert(pack.second); |
| 4739 | } |
| 4740 | } |
| 4741 | for (auto instance : m_design->getTopLevelModuleInstances()) { |
| 4742 | queue.push(instance); |
| 4743 | } |
| 4744 | |
| 4745 | while (!queue.empty()) { |
| 4746 | ModuleInstance* current = queue.front(); |
| 4747 | DesignComponent* def = current->getDefinition(); |
| 4748 | queue.pop(); |
| 4749 | if (current == nullptr) continue; |
| 4750 | for (ModuleInstance* sub : current->getAllSubInstances()) { |
| 4751 | queue.push(sub); |
| 4752 | } |
| 4753 | const FileContent* fC = current->getFileContent(); |
| 4754 | if (fC) { |
| 4755 | designComponents.insert(def); |
| 4756 | } |
| 4757 | } |
| 4758 | } |
| 4759 | |
| 4760 | vpiHandle designHandle = nullptr; |
| 4761 | std::vector<vpiHandle> designs; |
| 4762 | design* d = nullptr; |
| 4763 | if (m_design) { |
| 4764 | d = s.MakeDesign(); |
| 4765 | m_uhdmDesign = d; |
| 4766 | designHandle = reinterpret_cast<vpiHandle>(new uhdm_handle(uhdmdesign, d)); |
| 4767 | std::string designName = "unnamed"; |
| 4768 | auto topLevelModules = m_design->getTopLevelModuleInstances(); |
| 4769 | if (!topLevelModules.empty()) { |
no test coverage detected