Skip to content
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
4 changes: 2 additions & 2 deletions core/src/main/scala/chisel3/reflect/DataMirror.scala
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ object DataMirror {
object internal {
def isSynthesizable(target: Data): Boolean = target.isSynthesizable
// For those odd cases where you need to care about object reference and uniqueness
def chiselTypeClone[T <: Data](target: Data): T = {
target.cloneTypeFull.asInstanceOf[T]
def chiselTypeClone[T <: Data](target: T): T = {
target.cloneTypeFull
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/test/scala/chiselTests/reflect/DataMirrorSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,15 @@ class DataMirrorSpec extends ChiselFlatSpec {
it should "not support name guesses for non-hardware" in {
an[ExpectedHardwareException] should be thrownBy DataMirror.queryNameGuess(UInt(8.W))
}

"chiselTypeClone" should "preserve Scala type information" in {
class MyModule extends Module {
val in = IO(Input(UInt(8.W)))
val out = IO(Output(DataMirror.internal.chiselTypeClone(in)))
// The connection checks the types
out :#= in
}
ChiselStage.emitCHIRRTL(new MyModule)
}

}