File tree Expand file tree Collapse file tree
core/src/main/scala/chisel3/reflect
src/test/scala/chiselTests/reflect Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -174,8 +174,8 @@ object DataMirror {
174174 object internal {
175175 def isSynthesizable (target : Data ): Boolean = target.isSynthesizable
176176 // For those odd cases where you need to care about object reference and uniqueness
177- def chiselTypeClone [T <: Data ](target : Data ): T = {
178- target.cloneTypeFull. asInstanceOf [ T ]
177+ def chiselTypeClone [T <: Data ](target : T ): T = {
178+ target.cloneTypeFull
179179 }
180180 }
181181
Original file line number Diff line number Diff line change @@ -111,4 +111,15 @@ class DataMirrorSpec extends ChiselFlatSpec {
111111 it should " not support name guesses for non-hardware" in {
112112 an[ExpectedHardwareException ] should be thrownBy DataMirror .queryNameGuess(UInt (8 .W ))
113113 }
114+
115+ " chiselTypeClone" should " preserve Scala type information" in {
116+ class MyModule extends Module {
117+ val in = IO (Input (UInt (8 .W )))
118+ val out = IO (Output (DataMirror .internal.chiselTypeClone(in)))
119+ // The connection checks the types
120+ out :#= in
121+ }
122+ ChiselStage .emitCHIRRTL(new MyModule )
123+ }
124+
114125}
You can’t perform that action at this time.
0 commit comments