From c7d095eed6dca1ff7308201912abd4eff2416055 Mon Sep 17 00:00:00 2001 From: Martin Schoeberl Date: Tue, 19 Feb 2019 12:29:36 -0800 Subject: ScalaDoc for OneHot (#1016) --- src/main/scala/chisel3/util/OneHot.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/main/scala/chisel3/util/OneHot.scala b/src/main/scala/chisel3/util/OneHot.scala index 3ffbdfe2..4493a21b 100644 --- a/src/main/scala/chisel3/util/OneHot.scala +++ b/src/main/scala/chisel3/util/OneHot.scala @@ -11,6 +11,10 @@ import chisel3._ * * Inverse operation of [[UIntToOH]]. * + * @example {{{ + * OHToUInt("b0100".U) // results in 2.U + * }}} + * * @note assumes exactly one high bit, results undefined otherwise */ object OHToUInt { @@ -31,6 +35,10 @@ object OHToUInt { } /** Returns the bit position of the least-significant high bit of the input bitvector. + * + * @example {{{ + * PriorityEncoder("b0110".U) // results in 1.U + * }}} * * Multiple bits may be high in the input. */ @@ -40,6 +48,11 @@ object PriorityEncoder { } /** Returns the one hot encoding of the input UInt. + * + * @example {{{ + * UIntToOH(2.U) // results in "b0100".U + * }}} + * */ object UIntToOH { def apply(in: UInt): UInt = 1.U << in @@ -55,6 +68,10 @@ object UIntToOH { /** Returns a bit vector in which only the least-significant 1 bit in the input vector, if any, * is set. + * + * @example {{{ + * PriorityEncoderOH((false.B, true.B, true.B, false.B)) // results in (false.B, false.B, true.B, false.B) + * }}} */ object PriorityEncoderOH { private def encode(in: Seq[Bool]): UInt = { -- cgit v1.2.3