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

Fix Select.attachedTo (backport #4458) #4461

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions src/main/scala/chisel3/aop/Select.scala
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ object Select {
*/
def attachedTo(module: BaseModule)(signal: Data): Set[Data] = {
check(module)
<<<<<<< HEAD
module._component.get
.asInstanceOf[DefModule]
.commands
Expand All @@ -378,6 +379,16 @@ object Select {
}
.flatMap { seq => seq.map(_.id.asInstanceOf[Data]) }
.toSet
=======
collect(
module._component.get
.asInstanceOf[DefModule]
.block
.getCommands()
) {
case Attach(_, seq) if seq.contains(Node(signal)) => seq
}.flatMap { seq => seq.map(_.id.asInstanceOf[Data]) }.toSet
>>>>>>> 1aa41cdb7 (Fix Select.attachedTo (#4458))
}

/** Selects all connections to a signal or its parent signal(s) (if the signal is an element of an aggregate signal)
Expand Down
14 changes: 14 additions & 0 deletions src/test/scala/chiselTests/aop/SelectSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ class SelectSpec extends ChiselFlatSpec {
)
}

"Test" should "pass if selecting attach" in {
import chisel3.experimental.{attach, Analog}
class AttachTest extends RawModule {
val a, b, c = IO(Analog(8.W))
attach(a, b, c)
}
val dut = ChiselGeneratorAnnotation(() => new AttachTest)
.elaborate(1)
.asInstanceOf[DesignAnnotation[AttachTest]]
.design
Select.attachedTo(dut)(dut.a) should be(Set(dut.a, dut.b, dut.c))

}

"Test" should "pass if selecting ops by kind" in {
execute(
() => new SelectTester(Seq(0, 1, 2)),
Expand Down
Loading