functional style on MuxBundle
This commit is contained in:
parent
f249da1803
commit
f7b1e23ead
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user