summaryrefslogtreecommitdiff
path: root/src/main/scala/Chisel/util/Mux.scala
diff options
context:
space:
mode:
authorducky2016-05-20 18:09:57 -0700
committerducky2016-06-08 16:22:27 -0700
commitf36524e388b060b1bb535ae21cb1bcbbea220be9 (patch)
treea32772f816f18b14002948964917be0cb8280c48 /src/main/scala/Chisel/util/Mux.scala
parent53813f61b7dfe246d214ab966739d01c65c8ecb0 (diff)
Rename packages to lowercase chisel, add compatibility layer
Diffstat (limited to 'src/main/scala/Chisel/util/Mux.scala')
-rw-r--r--src/main/scala/Chisel/util/Mux.scala61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/main/scala/Chisel/util/Mux.scala b/src/main/scala/Chisel/util/Mux.scala
deleted file mode 100644
index 9d92321a..00000000
--- a/src/main/scala/Chisel/util/Mux.scala
+++ /dev/null
@@ -1,61 +0,0 @@
-// See LICENSE for license details.
-
-/** Mux circuit generators.
- */
-
-package Chisel
-
-/** Builds a Mux tree out of the input signal vector using a one hot encoded
- select signal. Returns the output of the Mux tree.
- */
-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)
- 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
-}
-
-/** Builds a Mux tree under the assumption that multiple select signals
- can be enabled. Priority is given to the first select signal.
-
- 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](sel: Bits, in: Seq[T]): T = apply((0 until in.size).map(sel(_)), in)
-}
-
-/** MuxLookup creates a cascade of n Muxs to search for a key value */
-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 <: Bits] (key: S, default: T, mapping: Seq[(S, T)]): T = {
- var res = default
- for ((k, v) <- mapping.reverse)
- res = Mux(k === key, v, res)
- res
- }
-
-}
-
-/** MuxCase returns the first value that is enabled in a map of values */
-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 <: Bits] (default: T, mapping: Seq[(Bool, T)]): T = {
- var res = default
- for ((t, v) <- mapping.reverse){
- res = Mux(t, v, res)
- }
- res
- }
-}