Skip to content

Commit c59842a

Browse files
jackkoenigmergify[bot]
authored andcommitted
Fix Select.attachedTo (#4458)
Previously it would always fail to find anything. (cherry picked from commit 1aa41cd) # Conflicts: # src/main/scala/chisel3/aop/Select.scala
1 parent f852d07 commit c59842a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/main/scala/chisel3/aop/Select.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ object Select {
373373
*/
374374
def attachedTo(module: BaseModule)(signal: Data): Set[Data] = {
375375
check(module)
376+
<<<<<<< HEAD
376377
module._component.get
377378
.asInstanceOf[DefModule]
378379
.commands
@@ -381,6 +382,16 @@ object Select {
381382
}
382383
.flatMap { seq => seq.map(_.id.asInstanceOf[Data]) }
383384
.toSet
385+
=======
386+
collect(
387+
module._component.get
388+
.asInstanceOf[DefModule]
389+
.block
390+
.getCommands()
391+
) {
392+
case Attach(_, seq) if seq.contains(Node(signal)) => seq
393+
}.flatMap { seq => seq.map(_.id.asInstanceOf[Data]) }.toSet
394+
>>>>>>> 1aa41cdb7 (Fix Select.attachedTo (#4458))
384395
}
385396

386397
/** Selects all connections to a signal or its parent signal(s) (if the signal is an element of an aggregate signal)

src/test/scala/chiselTests/aop/SelectSpec.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,20 @@ class SelectSpec extends ChiselFlatSpec {
130130
)
131131
}
132132

133+
"Test" should "pass if selecting attach" in {
134+
import chisel3.experimental.{attach, Analog}
135+
class AttachTest extends RawModule {
136+
val a, b, c = IO(Analog(8.W))
137+
attach(a, b, c)
138+
}
139+
val dut = ChiselGeneratorAnnotation(() => new AttachTest)
140+
.elaborate(1)
141+
.asInstanceOf[DesignAnnotation[AttachTest]]
142+
.design
143+
Select.attachedTo(dut)(dut.a) should be(Set(dut.a, dut.b, dut.c))
144+
145+
}
146+
133147
"Test" should "pass if selecting ops by kind" in {
134148
execute(
135149
() => new SelectTester(Seq(0, 1, 2)),

0 commit comments

Comments
 (0)