diff options
| author | Schuyler Eldridge | 2020-02-11 17:55:21 -0500 |
|---|---|---|
| committer | Schuyler Eldridge | 2020-02-11 22:53:14 -0500 |
| commit | 55cb667f048e685d1a67588fa30b2c0e4f7ec21f (patch) | |
| tree | 9e9c0431f663422d7b760c7ab508eede526793c6 /src | |
| parent | 081848854ce692964491cfc4fa8e8ed47c13bcef (diff) | |
Report dead modules in staticInstanceCount
Change InstanceGraph.staticInstanceCount to include modules with no
instances. Previously, these modules would just not be included.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/analyses/InstanceGraph.scala | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/main/scala/firrtl/analyses/InstanceGraph.scala b/src/main/scala/firrtl/analyses/InstanceGraph.scala index 1a453a42..b8b40065 100644 --- a/src/main/scala/firrtl/analyses/InstanceGraph.scala +++ b/src/main/scala/firrtl/analyses/InstanceGraph.scala @@ -62,16 +62,22 @@ class InstanceGraph(c: Circuit) { */ lazy val fullHierarchy: mutable.LinkedHashMap[WDefInstance,Seq[Seq[WDefInstance]]] = graph.pathsInDAG(trueTopInstance) - /** A count of the *static* number of instances of each module. For any module - * other than the top (main) module, this is equivalent to the number of inst - * statements in the circuit instantiating each module, irrespective of the - * number of times (if any) the enclosing module appears in the hierarchy. - * Note that top module of the circuit has an associated count of 1, even - * though it is never directly instantiated. + /** A count of the *static* number of instances of each module. For any module other than the top (main) module, this is + * equivalent to the number of inst statements in the circuit instantiating each module, irrespective of the number + * of times (if any) the enclosing module appears in the hierarchy. Note that top module of the circuit has an + * associated count of one, even though it is never directly instantiated. Any modules *not* instantiated at all will + * have a count of zero. */ lazy val staticInstanceCount: Map[OfModule, Int] = { - val instModules = childInstances.flatMap(_._2.view.map(_.OfModule).toSeq) - instModules.foldLeft(Map(c.main.OfModule -> 1)) { case (counts, mod) => counts.updated(mod, counts.getOrElse(mod, 0) + 1) } + val foo = mutable.LinkedHashMap.empty[OfModule, Int] + childInstances.keys.foreach { + case main if main == c.main => foo += main.OfModule -> 1 + case other => foo += other.OfModule -> 0 + } + childInstances.values.flatten.map(_.OfModule).foreach { + case mod => foo += mod -> (foo(mod) + 1) + } + foo.toMap } /** Finds the absolute paths (each represented by a Seq of instances |
