Skip to content

Commit

Permalink
Bugfix: Select.instances now works with blackboxes (#1303)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0a98a82)
  • Loading branch information
azidar authored and mergify-bot committed Jan 17, 2020
1 parent 1366be0 commit 51983ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main/scala/chisel3/aop/Select.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ object Select {
*/
def instances(module: BaseModule): Seq[BaseModule] = {
check(module)
module._component.get.asInstanceOf[DefModule].commands.collect {
case i: DefInstance => i.id
module._component.get match {
case d: DefModule => d.commands.collect {
case i: DefInstance => i.id
}
case other => Nil
}
}

Expand Down
16 changes: 15 additions & 1 deletion src/test/scala/chiselTests/aop/SelectSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import chiselTests.ChiselFlatSpec
import chisel3._
import chisel3.aop.Select.{PredicatedConnect, When, WhenNot}
import chisel3.aop.{Aspect, Select}
import firrtl.{AnnotationSeq}
import chisel3.experimental.ExtModule
import chisel3.stage.{ChiselGeneratorAnnotation, DesignAnnotation}
import firrtl.AnnotationSeq

import scala.reflect.runtime.universe.TypeTag

Expand Down Expand Up @@ -139,5 +141,17 @@ class SelectSpec extends ChiselFlatSpec {
)
}

"Blackboxes" should "be supported in Select.instances" in {
class BB extends ExtModule { }
class Top extends RawModule {
val bb = Module(new BB)
}
val top = ChiselGeneratorAnnotation(() => {
new Top()
}).elaborate(1).asInstanceOf[DesignAnnotation[Top]].design
val bbs = Select.collectDeep(top) { case b: BB => b }
assert(bbs.size == 1)
}

}

0 comments on commit 51983ed

Please sign in to comment.