diff options
| author | Schuyler Eldridge | 2020-02-13 11:42:46 -0500 |
|---|---|---|
| committer | GitHub | 2020-02-13 11:42:46 -0500 |
| commit | 8ef2ab50411642f9eaa2c1aac7147658fbab8368 (patch) | |
| tree | 8493e32ba0936a7f576745de94f361b0ce91f5b5 /src/main | |
| parent | dd6bbd4f6b21025913005658c562d2ad530aa3b1 (diff) | |
| parent | adf1a2f43d7e36dc3a34daa2b397ad5db60356a7 (diff) | |
Merge pull request #1391 from freechipsproject/instance-graph-helpers
Add InstaceGraph (Un)?Reachable Helpers
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/analyses/InstanceGraph.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/analyses/InstanceGraph.scala b/src/main/scala/firrtl/analyses/InstanceGraph.scala index b8b40065..7b60b110 100644 --- a/src/main/scala/firrtl/analyses/InstanceGraph.scala +++ b/src/main/scala/firrtl/analyses/InstanceGraph.scala @@ -140,6 +140,16 @@ class InstanceGraph(c: Circuit) { def getChildrenInstanceMap: collection.Map[OfModule, collection.Map[Instance, OfModule]] = childInstances.map(kv => kv._1.OfModule -> asOrderedMap(kv._2, (i: WDefInstance) => i.toTokens)) + /** The set of all modules in the circuit */ + lazy val modules: collection.Set[OfModule] = graph.getVertices.map(_.OfModule) + + /** The set of all modules in the circuit reachable from the top module */ + lazy val reachableModules: collection.Set[OfModule] = + mutable.LinkedHashSet(trueTopInstance.OfModule) ++ graph.reachableFrom(trueTopInstance).map(_.OfModule) + + /** The set of all modules *not* reachable in the circuit */ + lazy val unreachableModules: collection.Set[OfModule] = modules diff reachableModules + } object InstanceGraph { |
