summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman2016-03-30 21:58:54 -0700
committerAndrew Waterman2016-04-01 16:34:35 -0700
commit001aab20b38861067f413bd6b828d7d4c40050ad (patch)
tree4726dbc97d2077fb3ea479bb545e979a4bda830f
parent8d71195234c18fb9148f7b198dbea60acd7f3e42 (diff)
Return Seq, not Vec, from PriorityEncoderOH
It doesn't really make sense to create a one-hot result then follow it with a decoder. It's more performant to use a PriorityEncoder followed by a comparator. Discourage the former by returning Seq, not Vec. In Chisel2, it seems the return type was originally Seq, but was at some point inadvertently changed to Vec.
-rw-r--r--src/main/scala/Chisel/util/OneHot.scala6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/scala/Chisel/util/OneHot.scala b/src/main/scala/Chisel/util/OneHot.scala
index 38b96511..73f27403 100644
--- a/src/main/scala/Chisel/util/OneHot.scala
+++ b/src/main/scala/Chisel/util/OneHot.scala
@@ -51,12 +51,12 @@ object UIntToOH
object PriorityEncoderOH
{
private def encode(in: Seq[Bool]): UInt = {
- val outs = Vec.tabulate(in.size)(i => UInt(BigInt(1) << i, in.size))
+ val outs = Seq.tabulate(in.size)(i => UInt(BigInt(1) << i, in.size))
PriorityMux(in :+ Bool(true), outs :+ UInt(0, in.size))
}
- def apply(in: Seq[Bool]): Vec[Bool] = {
+ def apply(in: Seq[Bool]): Seq[Bool] = {
val enc = encode(in)
- Vec.tabulate(in.size)(enc(_))
+ Seq.tabulate(in.size)(enc(_))
}
def apply(in: Bits): UInt = encode((0 until in.getWidth).map(i => in(i)))
}