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 {
def apply[T <: Data] (default: T, mapping: Seq[(Bool, T)]): T = {
var res = default;
for ((t, v) <- mapping.reverse){
res = Mux(t, v, res);
}
res
mapping.reverse.foldLeft(default)((b, a) => Mux(a._1, a._2, b))
}
}