Skip to content

Commit

Permalink
Specify type parameter when calling chiselTypeClone
Browse files Browse the repository at this point in the history
  • Loading branch information
konda-x1 committed Aug 21, 2023
1 parent 281e5c8 commit 580197e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/diplomacy/BundleBridge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ case class BundleBridgeSink[T <: Data](genOpt: Option[() => T] = None)
}

def makeIO()(implicit valName: ValName): T = {
val io: T = IO(if (inferOutput) Output(chiselTypeOf(bundle)) else chiselTypeClone(bundle))
val io: T = IO(if (inferOutput) Output(chiselTypeOf(bundle)) else chiselTypeClone[T](bundle))
io.suggestName(valName.name)
io <> bundle
io
Expand All @@ -72,7 +72,7 @@ case class BundleBridgeSource[T <: Data](genOpt: Option[() => T] = None)(implici
}

def makeIO()(implicit valName: ValName): T = {
val io: T = IO(if (inferInput) Input(chiselTypeOf(bundle)) else Flipped(chiselTypeClone(bundle)))
val io: T = IO(if (inferInput) Input(chiselTypeOf(bundle)) else Flipped(chiselTypeClone[T](bundle)))
io.suggestName(valName.name)
bundle <> io
io
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/util/BundleMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class BundleMap(val fields: Seq[BundleFieldBase]) extends Record with CustomBulk
// All fields must have distinct key.names
require(fields.map(_.key.name).distinct.size == fields.size)

val elements: ListMap[String, Data] = ListMap(fields.map { bf => bf.key.name -> chisel3.experimental.DataMirror.internal.chiselTypeClone(bf.data) } :_*)
val elements: ListMap[String, Data] = ListMap(fields.map { bf => bf.key.name -> chisel3.experimental.DataMirror.internal.chiselTypeClone[Data](bf.data) } :_*)

// A BundleMap is best viewed as a map from BundleKey to Data
def keydata: Seq[(BundleKeyBase, Data)] = (fields zip elements) map { case (field, (_, data)) => (field.key, data) }
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/util/HeterogeneousBag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import chisel3.experimental.DataMirror
import scala.collection.immutable.VectorMap

final case class HeterogeneousBag[T <: Data](elts: Seq[T]) extends Record with collection.IndexedSeq[T] {
val elements = VectorMap(elts.zipWithIndex.map { case (n,i) => (i.toString, DataMirror.internal.chiselTypeClone(n)) }:_*)
val elements = VectorMap(elts.zipWithIndex.map { case (n,i) => (i.toString, DataMirror.internal.chiselTypeClone[T](n)) }:_*)

def apply(x: Int): T = {
val key = elements.keys(x) // VectorMap.keys returns a Vector
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/util/RecordMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class RecordMap[T <: Data] (eltMap: ListMap[String, T])
eltMap.foreach { case (name, elt) => requireIsChiselType(elt, name) }

// This is needed for Record
val elements = ListMap[String, T]() ++ eltMap.mapValues(chiselTypeClone(_).asInstanceOf[T]) // mapValues return value is lazy
val elements = ListMap[String, T]() ++ eltMap.mapValues(chiselTypeClone[T](_)) // mapValues return value is lazy

def apply(x: Int) = elements.values.toSeq(x)
def apply(x: String) = elements.get(x)
Expand Down

0 comments on commit 580197e

Please sign in to comment.