summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/BitPat.scala
diff options
context:
space:
mode:
authorRichard Lin2016-12-06 17:16:40 -0800
committerGitHub2016-12-06 17:16:40 -0800
commit9aba55e7452981058d069b3096544d45e730dba9 (patch)
treeec5314ad92aac0847d2b0b27484707b23f088900 /src/main/scala/chisel3/util/BitPat.scala
parenta1e8ae80888b6b4d7bac057c6486b3442334cdc6 (diff)
utils scaladoc examples for BitPat through CircuitMath (#398)
Add examples for utils, move examples from individual apply methods to class overview scaladoc
Diffstat (limited to 'src/main/scala/chisel3/util/BitPat.scala')
-rw-r--r--src/main/scala/chisel3/util/BitPat.scala19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/scala/chisel3/util/BitPat.scala b/src/main/scala/chisel3/util/BitPat.scala
index 9c9909cd..add40f79 100644
--- a/src/main/scala/chisel3/util/BitPat.scala
+++ b/src/main/scala/chisel3/util/BitPat.scala
@@ -35,7 +35,7 @@ object BitPat {
}
/** Creates a [[BitPat]] literal from a string.
- *
+ *
* @param n the literal value as a string, in binary, prefixed with 'b'
* @note legal characters are '0', '1', and '?', as well as '_' and white
* space (which are ignored)
@@ -45,7 +45,12 @@ object BitPat {
new BitPat(bits, mask, width)
}
- /** Creates a [[BitPat]] of all don't cares of the specified bitwidth. */
+ /** Creates a [[BitPat]] of all don't cares of the specified bitwidth.
+ *
+ * @example {{{
+ * val myDontCare = BitPat.dontCare(4) // equivalent to BitPat("b????")
+ * }}}
+ */
def dontCare(width: Int): BitPat = BitPat("b" + ("?" * width))
@deprecated("Use BitPat.dontCare", "chisel3")
@@ -73,10 +78,14 @@ object BitPat {
}
}
-// TODO: Break out of Core? (this doesn't involve FIRRTL generation)
/** Bit patterns are literals with masks, used to represent values with don't
- * cares. Equality comparisons will ignore don't care bits (for example,
- * BitPat(0b10?1) === 0b1001.asUInt and 0b1011.asUInt.
+ * care bits. Equality comparisons will ignore don't care bits.
+ *
+ * @example {{{
+ * "b10101".U === BitPat("b101??") // evaluates to true.B
+ * "b10111".U === BitPat("b101??") // evaluates to true.B
+ * "b10001".U === BitPat("b101??") // evaluates to false.B
+ * }}}
*/
sealed class BitPat(val value: BigInt, val mask: BigInt, width: Int) {
def getWidth: Int = width