Skip to content

Commit

Permalink
Update HeterogeneousBag to chisel3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryz123 committed May 10, 2023
1 parent ebeef50 commit fff6914
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/scala/util/HeterogeneousBag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

package freechips.rocketchip.util

import Chisel._
import chisel3.Record
import chisel3._
import chisel3.experimental.DataMirror
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)
val elements = ListMap(elts.zipWithIndex.map { case (n,i) => (i.toString, DataMirror.internal.chiselTypeClone(n)) }:_*)

def apply(x: Int): T = elements.values.toSeq(x)
def length = elts.length

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

Please sign in to comment.