diff options
| author | Martin Schoeberl | 2019-02-19 12:29:36 -0800 |
|---|---|---|
| committer | Schuyler Eldridge | 2019-02-19 15:29:36 -0500 |
| commit | c7d095eed6dca1ff7308201912abd4eff2416055 (patch) | |
| tree | ed9e597400a6bc0f1a90fcb3ba69c396f974e244 /src | |
| parent | 419ea7c7de626bb83e1f141683e90c325e3085d4 (diff) | |
ScalaDoc for OneHot (#1016)
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/chisel3/util/OneHot.scala | 17 |
1 files changed, 17 insertions, 0 deletions
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 { @@ -32,6 +36,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. */ object PriorityEncoder { @@ -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 = { |
