Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
albertchen-sifive committed Aug 4, 2023
1 parent 12f3380 commit c7ea51e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion core/src/main/scala/chisel3/internal/Builder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,6 @@ private[chisel3] object Builder extends LazyLogging {
product.productIterator.zip(product.productElementNames).foreach {
case (elt, fullName) =>
val name = fullName.stripPrefix("_")
// tuple field names are 1-based (_1, _2, _3, ...)
nameRecursively(s"${prefix}_${name}", elt, namer)
}
case _ => // Do nothing
Expand Down
19 changes: 19 additions & 0 deletions src/test/scala/chiselTests/naming/NamePluginSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,23 @@ class NamePluginSpec extends ChiselFlatSpec with Utils {
Select.wires(top).map(_.instanceName) should be(List("x_1", "x_2"))
}
}

"tuple assignment" should "name IOs and registers" in {
class Test extends Module {
def myFunc(): (UInt, String) = {
val out = IO(Output(UInt(3.W)))
val in = IO(Input(UInt(3.W)))
out := Mux(in(0), RegNext(in + 2.U), in << 3)
(out, "Hi!")
}

val foo = myFunc()
}

aspectTest(() => new Test) { top: Test =>
Select.ios(top).map(_.instanceName) should be(List("clock", "reset", "foo_1", "foo_in"))
Select.registers(top).map(_.instanceName) should be(List("foo_out_REG"))
Select.wires(top).map(_.instanceName) should be(List())
}
}
}

0 comments on commit c7ea51e

Please sign in to comment.