| 201 | } |
| 202 | |
| 203 | void Design::reportInstanceTreeStats(uint32_t& nbTopLevelModules, |
| 204 | uint32_t& maxDepth, |
| 205 | uint32_t& numberOfInstances, |
| 206 | uint32_t& numberOfLeafInstances, |
| 207 | uint32_t& nbUndefinedModules, |
| 208 | uint32_t& nbUndefinedInstances) const { |
| 209 | nbTopLevelModules = 0; |
| 210 | maxDepth = 0; |
| 211 | numberOfInstances = 0; |
| 212 | numberOfLeafInstances = 0; |
| 213 | nbUndefinedModules = 0; |
| 214 | nbUndefinedInstances = 0; |
| 215 | std::set<std::string_view> undefModules; |
| 216 | ModuleInstance* tmp; |
| 217 | std::queue<ModuleInstance*> queue; |
| 218 | for (auto instance : m_topLevelModuleInstances) { |
| 219 | queue.push(instance); |
| 220 | nbTopLevelModules++; |
| 221 | } |
| 222 | while (!queue.empty()) { |
| 223 | tmp = queue.front(); |
| 224 | queue.pop(); |
| 225 | bool isInstance = false; |
| 226 | if (!tmp->getDefinition()) |
| 227 | isInstance = true; |
| 228 | else { |
| 229 | isInstance = tmp->getDefinition()->isInstance(); |
| 230 | } |
| 231 | |
| 232 | if (isInstance) { |
| 233 | numberOfInstances++; |
| 234 | uint32_t depth = tmp->getDepth(); |
| 235 | if (depth > maxDepth) { |
| 236 | maxDepth = depth; |
| 237 | } |
| 238 | } |
| 239 | if (tmp->getNbChildren()) { |
| 240 | for (uint32_t i = 0; i < tmp->getNbChildren(); i++) { |
| 241 | queue.push(tmp->getChildren(i)); |
| 242 | } |
| 243 | } else { |
| 244 | if (isInstance) numberOfLeafInstances++; |
| 245 | } |
| 246 | std::string def; |
| 247 | if (tmp->getDefinition()) { |
| 248 | } else { |
| 249 | nbUndefinedInstances++; |
| 250 | undefModules.emplace(tmp->getModuleName()); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | nbUndefinedModules = undefModules.size(); |
| 255 | } |
| 256 | |
| 257 | ModuleInstance* Design::findInstance(std::string_view path, |
| 258 | ModuleInstance* scope) const { |
no test coverage detected