Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify type parameter when calling chiselTypeClone #3476

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
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
10 changes: 5 additions & 5 deletions src/main/scala/diplomacy/BundleBridge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class BundleBridgeImp[T <: Data]() extends SimpleNodeImp[BundleBridgeParams[T],
(sourceOpt, sinkOpt) match {
case (None, None) =>
throw new Exception("BundleBridge needs source or sink to provide bundle generator function")
case (Some(a), None) => chiselTypeClone(a)
case (None, Some(b)) => chiselTypeClone(b)
case (Some(a), None) => chiselTypeClone[T](a)
case (None, Some(b)) => chiselTypeClone[T](b)
case (Some(a), Some(b)) => {
require(DataMirror.checkTypeEquivalence(a, b),
s"BundleBridge requires doubly-specified source and sink generators to have equivalent Chisel Data types, but got \n$a\n vs\n$b")
chiselTypeClone(a)
chiselTypeClone[T](a)
}
}
}
Expand All @@ -48,7 +48,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 @@ -71,7 +71,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 @@ -98,7 +98,7 @@ class BundleMap(val fields: Seq[BundleFieldBase]) extends Record {
// All fields must have distinct key.names
require(fields.map(_.key.name).distinct.size == fields.size)

val elements: SeqMap[String, Data] = SeqMap(fields.map { bf => bf.key.name -> chisel3.reflect.DataMirror.internal.chiselTypeClone(bf.data) } :_*)
val elements: SeqMap[String, Data] = SeqMap(fields.map { bf => bf.key.name -> chisel3.reflect.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 @@ -12,7 +12,7 @@ final case class HeterogeneousBag[T <: Data](elts: Seq[T]) extends Record with c
def length = elts.length

override def className: String = super.className
val elements = ListMap(elts.zipWithIndex.map { case (n,i) => (i.toString, chiselTypeClone(n)) }:_*)
val elements = ListMap(elts.zipWithIndex.map { case (n,i) => (i.toString, chiselTypeClone[T](n)) }:_*)
// IndexedSeq has its own hashCode/equals that we must not use
override def hashCode: Int = super[Record].hashCode
override def equals(that: Any): Boolean = super[Record].equals(that)
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