diff options
| author | Boyang Han | 2021-03-19 01:28:56 +0800 |
|---|---|---|
| committer | GitHub | 2021-03-18 17:28:56 +0000 |
| commit | 2a56c6540e914611ac12647e157aec4c5c595758 (patch) | |
| tree | 100ae252b7d028eb09e7f45fa65766f4f4c7230f /src/main/scala/chisel3 | |
| parent | ac094a5e8f7fb8237b54d4d6b9e0b7b759b44ef7 (diff) | |
Add toString method to BitPat (#1819)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/scala/chisel3')
| -rw-r--r-- | src/main/scala/chisel3/util/BitPat.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/util/BitPat.scala b/src/main/scala/chisel3/util/BitPat.scala index 12a421a0..5a40d312 100644 --- a/src/main/scala/chisel3/util/BitPat.scala +++ b/src/main/scala/chisel3/util/BitPat.scala @@ -119,4 +119,11 @@ sealed class BitPat(val value: BigInt, val mask: BigInt, width: Int) extends Sou !(this === that) } + override def toString = { + "BitPat(" + + (0 until width).map(i => + if (((mask >> i) & 1) == 1) if (((value >> i) & 1) == 1) "1" else "0" else "?" + ).reverse.reduce(_ + _) + + ")" + } } |
