diff options
| author | Jiuyang Liu | 2021-08-27 04:37:34 +0800 |
|---|---|---|
| committer | GitHub | 2021-08-26 20:37:34 +0000 |
| commit | e74b978d5188d9cd28e3520912d858d228136e75 (patch) | |
| tree | 1b391cb548b37b604c9aeb9dad39817deb805837 /src/test/scala/chiselTests | |
| parent | 3840fec3d918f23df07a18311136ac6a1bc365e1 (diff) | |
add new APIs to BitPat (#2076)
* add Y and N to BitPat.
* add ## for BitPat.
* add rawString API.
* use rawString in decoder
* add select and slice to BitPat.
Diffstat (limited to 'src/test/scala/chiselTests')
| -rw-r--r-- | src/test/scala/chiselTests/util/BitPatSpec.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/util/BitPatSpec.scala b/src/test/scala/chiselTests/util/BitPatSpec.scala index ca8dd85c..0c83493f 100644 --- a/src/test/scala/chiselTests/util/BitPatSpec.scala +++ b/src/test/scala/chiselTests/util/BitPatSpec.scala @@ -15,7 +15,30 @@ class BitPatSpec extends AnyFlatSpec with Matchers { BitPat("b" + testPattern).toString should be (s"BitPat($testPattern)") } + it should "convert a BitPat to raw form" in { + val testPattern = "0" * 32 + "1" * 32 + "?" * 32 + "?01" * 32 + BitPat("b" + testPattern).rawString should be(testPattern) + } + it should "not fail if BitPat width is 0" in { intercept[IllegalArgumentException]{BitPat("b")} } + + it should "contact BitPat via ##" in { + (BitPat.Y(4) ## BitPat.dontCare(3) ## BitPat.N(2)).toString should be (s"BitPat(1111???00)") + } + + it should "index and return new BitPat" in { + val b = BitPat("b1001???") + b(0) should be(BitPat.dontCare(1)) + b(6) should be(BitPat.Y()) + b(5) should be(BitPat.N()) + } + + it should "slice and return new BitPat" in { + val b = BitPat("b1001???") + b(2, 0) should be(BitPat("b???")) + b(4, 3) should be(BitPat("b01")) + b(6, 6) should be(BitPat("b1")) + } } |
