From 3131c0daad41dea78bede4517669e376c41a325a Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Mon, 10 Jan 2022 10:39:52 -0800 Subject: Apply scalafmt Command: sbt scalafmtAll --- src/main/scala/chisel3/util/Mux.scala | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/main/scala/chisel3/util/Mux.scala') diff --git a/src/main/scala/chisel3/util/Mux.scala b/src/main/scala/chisel3/util/Mux.scala index 946de461..e84b86a4 100644 --- a/src/main/scala/chisel3/util/Mux.scala +++ b/src/main/scala/chisel3/util/Mux.scala @@ -23,8 +23,8 @@ import chisel3._ */ object Mux1H { def apply[T <: Data](sel: Seq[Bool], in: Seq[T]): T = - apply(sel zip in) - def apply[T <: Data](in: Iterable[(Bool, T)]): T = SeqUtils.oneHotMux(in) + apply(sel.zip(in)) + def apply[T <: Data](in: Iterable[(Bool, T)]): T = SeqUtils.oneHotMux(in) def apply[T <: Data](sel: UInt, in: Seq[T]): T = apply((0 until in.size).map(sel(_)), in) def apply(sel: UInt, in: UInt): Bool = (sel & in).orR @@ -44,8 +44,8 @@ object Mux1H { * Returns the output of the Mux tree. */ object PriorityMux { - def apply[T <: Data](in: Seq[(Bool, T)]): T = SeqUtils.priorityMux(in) - def apply[T <: Data](sel: Seq[Bool], in: Seq[T]): T = apply(sel zip in) + def apply[T <: Data](in: Seq[(Bool, T)]): T = SeqUtils.priorityMux(in) + def apply[T <: Data](sel: Seq[Bool], in: Seq[T]): T = apply(sel.zip(in)) def apply[T <: Data](sel: Bits, in: Seq[T]): T = apply((0 until in.size).map(sel(_)), in) } @@ -57,12 +57,13 @@ object PriorityMux { * }}} */ object MuxLookup { + /** @param key a key to search for * @param default a default value if nothing is found * @param mapping a sequence to search of keys and values * @return the value found or the default if not */ - def apply[S <: UInt, T <: Data] (key: S, default: T, mapping: Seq[(S, T)]): T = { + def apply[S <: UInt, T <: Data](key: S, default: T, mapping: Seq[(S, T)]): T = { /* If the mapping is defined for all possible values of the key, then don't use the default value */ val (defaultx, mappingx) = key.widthOption match { case Some(width) => @@ -77,7 +78,7 @@ object MuxLookup { case None => (default, mapping) } - mappingx.foldLeft(defaultx){ case (d, (k, v)) => Mux(k === key, v, d) } + mappingx.foldLeft(defaultx) { case (d, (k, v)) => Mux(k === key, v, d) } } } @@ -89,12 +90,14 @@ object MuxLookup { * }}} */ object MuxCase { + /** @param default the default value if none are enabled * @param mapping a set of data values with associated enables - * @return the first value in mapping that is enabled */ - def apply[T <: Data] (default: T, mapping: Seq[(Bool, T)]): T = { + * @return the first value in mapping that is enabled + */ + def apply[T <: Data](default: T, mapping: Seq[(Bool, T)]): T = { var res = default - for ((t, v) <- mapping.reverse){ + for ((t, v) <- mapping.reverse) { res = Mux(t, v, res) } res -- cgit v1.2.3