summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/ImplicitConversionsSpec.scala
blob: 4bccf636aa881fffe9ee2f933a0f3026543c522d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-License-Identifier: Apache-2.0

package chiselTests

import chisel3._

class ImplicitConversionsSpec extends ChiselFlatSpec {
  ".data on arbitrary Data objects" should "not work" in {
    assertTypeError("UInt(8.W).data")
    assertTypeError("8.S.data")
    assertTypeError("(new Bundle {}).data")
    assertTypeError("VecInit(1.U).data")
  }

  ".target on arbitrary Data objects" should "not work" in {
    assertTypeError("UInt(8.W).target")
    assertTypeError("8.S.target")
    assertTypeError("(new Bundle {}).target")
    assertTypeError("VecInit(1.U).target")
  }

  ".x on Strings and Numerical values" should "not work" in {
    assertTypeError("3.x")
    assertTypeError("3L.x")
    assertTypeError("BigInt(-4).x")
    assertTypeError("false.x")
    assertTypeError(""""a".x""")
  }

  ".bigint on Strings and Numerical values" should "not work" in {
    assertTypeError("3.bigint")
    assertTypeError("3L.bigint")
    assertTypeError("BigInt(-4).bigint")
    assertTypeError("false.bigint")
    assertTypeError(""""a".bigint""")
  }

  ".target on DecoupledIO" should "not work" in {
    import chisel3.util._
    assertTypeError("Decoupled(UInt(8.W)).target")
  }

  "X.B for X not in [0,1]" should "throw an exception, even outside hardware context" in {
    a[ChiselException] should be thrownBy {
      65.B
    }
  }
}