Use Seq, not Iterable, when traversal order matters
This commit is contained in:
parent
431dd2219b
commit
a2fdcdcaef
@ -40,7 +40,7 @@ object DecodeLogic
|
|||||||
}
|
}
|
||||||
}).reverse.reduceRight(Cat(_,_))
|
}).reverse.reduceRight(Cat(_,_))
|
||||||
}
|
}
|
||||||
def apply(addr: UInt, default: Iterable[BitPat], mappingIn: Iterable[(BitPat, Iterable[BitPat])]): Iterable[UInt] = {
|
def apply(addr: UInt, default: Seq[BitPat], mappingIn: Iterable[(BitPat, Seq[BitPat])]): Seq[UInt] = {
|
||||||
val mapping = collection.mutable.ArrayBuffer.fill(default.size)(collection.mutable.ArrayBuffer[(BitPat, BitPat)]())
|
val mapping = collection.mutable.ArrayBuffer.fill(default.size)(collection.mutable.ArrayBuffer[(BitPat, BitPat)]())
|
||||||
for ((key, values) <- mappingIn)
|
for ((key, values) <- mappingIn)
|
||||||
for ((value, i) <- values zipWithIndex)
|
for ((value, i) <- values zipWithIndex)
|
||||||
@ -48,8 +48,8 @@ object DecodeLogic
|
|||||||
for ((thisDefault, thisMapping) <- default zip mapping)
|
for ((thisDefault, thisMapping) <- default zip mapping)
|
||||||
yield apply(addr, thisDefault, thisMapping)
|
yield apply(addr, thisDefault, thisMapping)
|
||||||
}
|
}
|
||||||
def apply(addr: UInt, default: Iterable[BitPat], mappingIn: List[(UInt, Iterable[BitPat])]): Iterable[UInt] =
|
def apply(addr: UInt, default: Seq[BitPat], mappingIn: List[(UInt, Seq[BitPat])]): Seq[UInt] =
|
||||||
apply(addr, default, mappingIn.map(m => (BitPat(m._1), m._2)).asInstanceOf[Iterable[(BitPat, Iterable[BitPat])]])
|
apply(addr, default, mappingIn.map(m => (BitPat(m._1), m._2)).asInstanceOf[Iterable[(BitPat, Seq[BitPat])]])
|
||||||
def apply(addr: UInt, trues: Iterable[UInt], falses: Iterable[UInt]): Bool =
|
def apply(addr: UInt, trues: Iterable[UInt], falses: Iterable[UInt]): Bool =
|
||||||
apply(addr, BitPat.DC(1), trues.map(BitPat(_) -> BitPat("b1")) ++ falses.map(BitPat(_) -> BitPat("b0"))).toBool
|
apply(addr, BitPat.DC(1), trues.map(BitPat(_) -> BitPat("b1")) ++ falses.map(BitPat(_) -> BitPat("b0"))).toBool
|
||||||
private val caches = collection.mutable.Map[UInt,collection.mutable.Map[Term,Bool]]()
|
private val caches = collection.mutable.Map[UInt,collection.mutable.Map[Term,Bool]]()
|
||||||
|
@ -9,8 +9,8 @@ import scala.math._
|
|||||||
object Util {
|
object Util {
|
||||||
implicit def intToUInt(x: Int): UInt = UInt(x)
|
implicit def intToUInt(x: Int): UInt = UInt(x)
|
||||||
implicit def booleanToBool(x: Boolean): Bits = Bool(x)
|
implicit def booleanToBool(x: Boolean): Bits = Bool(x)
|
||||||
implicit def intSeqToUIntSeq(x: Iterable[Int]): Iterable[UInt] = x.map(UInt(_))
|
implicit def intSeqToUIntSeq(x: Seq[Int]): Seq[UInt] = x.map(UInt(_))
|
||||||
implicit def seqToVec[T <: Data](x: Iterable[T]): Vec[T] = Vec(x)
|
implicit def seqToVec[T <: Data](x: Seq[T]): Vec[T] = Vec(x)
|
||||||
implicit def wcToUInt(c: WideCounter): UInt = c.value
|
implicit def wcToUInt(c: WideCounter): UInt = c.value
|
||||||
implicit def sextToConv(x: UInt) = new AnyRef {
|
implicit def sextToConv(x: UInt) = new AnyRef {
|
||||||
def sextTo(n: Int): UInt = Cat(Fill(n - x.getWidth, x(x.getWidth-1)), x)
|
def sextTo(n: Int): UInt = Cat(Fill(n - x.getWidth, x(x.getWidth-1)), x)
|
||||||
|
Loading…
Reference in New Issue
Block a user