1
0

functional style on MuxBundle

This commit is contained in:
Henry Cook 2014-07-10 16:59:48 -07:00
parent f249da1803
commit f7b1e23ead

View File

@ -5,11 +5,7 @@ import Chisel._
object MuxBundle { object MuxBundle {
def apply[T <: Data] (default: T, mapping: Seq[(Bool, T)]): T = { def apply[T <: Data] (default: T, mapping: Seq[(Bool, T)]): T = {
var res = default; mapping.reverse.foldLeft(default)((b, a) => Mux(a._1, a._2, b))
for ((t, v) <- mapping.reverse){
res = Mux(t, v, res);
}
res
} }
} }