Skip to content

Commit

Permalink
Fix HeterogeneousBag for chisel3 #2945
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenithalHourlyRate committed Feb 11, 2023
1 parent 70631a5 commit 89efe64
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/scala/util/HeterogeneousBag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ package freechips.rocketchip.util

import Chisel._
import chisel3.Record
import chisel3.reflect.DataMirror.internal.chiselTypeClone
import chisel3.experimental.requireIsChiselType
import scala.collection.immutable.ListMap

final case class HeterogeneousBag[T <: Data](elts: Seq[T]) extends Record with collection.IndexedSeq[T] {
def apply(x: Int) = elts(x)
def length = elts.length

override def className: String = super.className
val elements = ListMap(elts.zipWithIndex.map { case (n,i) => (i.toString, n) }:_*)
val elements = ListMap(elts.zipWithIndex.map { case (n,i) => (i.toString, {
requireIsChiselType(n)
chiselTypeClone(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

0 comments on commit 89efe64

Please sign in to comment.