Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Select.instances now works with blackboxes (bp #1303) #1304

Merged
merged 1 commit into from
Jan 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}

}