diff options
| author | Andrew Waterman | 2016-08-15 22:48:14 -0700 |
|---|---|---|
| committer | GitHub | 2016-08-15 22:48:14 -0700 |
| commit | ddb7278760029be9d960ba8bf2b06ac8a8aac767 (patch) | |
| tree | 1c9e7306c2de99abc233d4dc8fe8640ce82e5cad /src/main/scala/chisel3/util/BitPat.scala | |
| parent | 2a074c828ddd8e6c20fa21d618664d50120f3d7a (diff) | |
Make "def width" a private API; expose isWidthKnown instead (#257)
* Make "def width" a private API; expose isWidthKnown instead
Resolves #256.
Since width was used to determine whether getWidth would succeed, I added
def isWidthKnown: Boolean
but another option would be to expose something like
def widthOption: Option[Int]
...thoughts?
* Document getWidth/isWidthKnown
* Add widthOption for more idiomatic Scala manipulation of widths
Diffstat (limited to 'src/main/scala/chisel3/util/BitPat.scala')
| -rw-r--r-- | src/main/scala/chisel3/util/BitPat.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main/scala/chisel3/util/BitPat.scala b/src/main/scala/chisel3/util/BitPat.scala index d476f957..26106080 100644 --- a/src/main/scala/chisel3/util/BitPat.scala +++ b/src/main/scala/chisel3/util/BitPat.scala @@ -68,7 +68,7 @@ object BitPat { */ def apply(x: UInt): BitPat = { require(x.isLit) - val len = if (x.width.known) x.getWidth else 0 + val len = if (x.isWidthKnown) x.getWidth else 0 apply("b" + x.litValue.toString(2).reverse.padTo(len, "0").reverse.mkString) } } |
