summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util
diff options
context:
space:
mode:
authorchick2020-01-21 16:49:35 -0800
committerchick2020-01-21 16:49:35 -0800
commit6356d3297052cecf209eeb3256fb72150a914e38 (patch)
treeaafb3d2a6daa2b82f9ae2bbfb85a36de0f675884 /src/main/scala/chisel3/util
parent0bcce65d5e3001b1b7098aa2c1ccd60fcc2a6628 (diff)
parent7341082e3c5b08dc9d1a01937b5aad55e9833603 (diff)
Merge branch 'master' into big-decimal-methods-for-num-types
# Conflicts: # src/test/scala/chiselTests/IntervalSpec.scala
Diffstat (limited to 'src/main/scala/chisel3/util')
-rw-r--r--src/main/scala/chisel3/util/BitPat.scala9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/scala/chisel3/util/BitPat.scala b/src/main/scala/chisel3/util/BitPat.scala
index 83475d1b..7c0abdb2 100644
--- a/src/main/scala/chisel3/util/BitPat.scala
+++ b/src/main/scala/chisel3/util/BitPat.scala
@@ -14,7 +14,7 @@ object BitPat {
* @return bits the literal value, with don't cares being 0
* @return mask the mask bits, with don't cares being 0 and cares being 1
* @return width the number of bits in the literal, including values and
- * don't cares.
+ * don't cares, but not including the white space and underscores
*/
private def parse(x: String): (BigInt, BigInt, Int) = {
// Notes:
@@ -25,14 +25,17 @@ object BitPat {
require(x.head == 'b', "BitPats must be in binary and be prefixed with 'b'")
var bits = BigInt(0)
var mask = BigInt(0)
+ var count = 0
for (d <- x.tail) {
- if (d != '_') {
+ if (! (d == '_' || d.isWhitespace)) {
require("01?".contains(d), "Literal: " + x + " contains illegal character: " + d)
mask = (mask << 1) + (if (d == '?') 0 else 1)
bits = (bits << 1) + (if (d == '1') 1 else 0)
+ count += 1
}
}
- (bits, mask, x.length - 1)
+
+ (bits, mask, count)
}
/** Creates a [[BitPat]] literal from a string.