summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/WireSpec.scala
blob: 058a7f0874b1e0ed52c966924e9a89ca4d0a0b37 (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
// SPDX-License-Identifier: Apache-2.0

package chiselTests

import chisel3._
import chisel3.stage.ChiselStage

class WireSpec extends ChiselFlatSpec {
  "WireDefault.apply" should "work" in {
    assertCompiles("WireDefault(UInt(4.W), 2.U)")
  }
  it should "allow DontCare" in {
    assertCompiles("WireDefault(UInt(4.W), DontCare)")
  }
  it should "not allow DontCare to affect type inference" in {
    assertCompiles("val x: UInt = WireDefault(UInt(4.W), DontCare)")
  }
  it should "not allow init argument to affect type inference" in {
    assertDoesNotCompile("val x: UInt = WireDefault(UInt(4.W), 2.S)")
  }
  it should "have source locator information on wires" in {
    class Dummy extends chisel3.Module {
      val in = IO(Input(Bool()))
      val out = IO(Output(Bool()))

      val wire = WireInit(Bool(), true.B)
      val wire2 = Wire(Bool())
      wire2 := in
      out := in & wire & wire2
    }

    val chirrtl = ChiselStage.emitChirrtl(new Dummy)
    chirrtl should include("wire wire : UInt<1> @[WireSpec.scala")
    chirrtl should include("wire wire2 : UInt<1> @[WireSpec.scala")
  }
}