summaryrefslogtreecommitdiff
path: root/no-plugin-tests/src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala
blob: 286734955418b612827c6dea2ce8331e2b70fe5c (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
49
50
51
52
53
54
55
// SPDX-License-Identifier: Apache-2.0

package chiselTests
import Chisel.ChiselException
import chisel3.stage.ChiselStage
import org.scalatest._
import org.scalatest.matchers.should.Matchers

class MissingCloneBindingExceptionSpec extends ChiselFlatSpec with Matchers with Utils {
  behavior of "missing cloneType in Chisel3"
  ( the [ChiselException] thrownBy extractCause[ChiselException] {
    import chisel3._

    class Test extends Module {
      class TestIO(w: Int) extends Bundle {
        val a = Input(Vec(4, UInt(w.W)))
      }

      val io = IO(new TestIO(32))
    }

    class TestTop extends Module {
      val io = IO(new Bundle {})

      val subs = VecInit(Seq.fill(2) {
        Module(new Test).io
      })
    }

    ChiselStage.elaborate(new TestTop)
  }).getMessage should include("make all parameters immutable")

  behavior of "missing cloneType in Chisel2"
  ( the [ChiselException] thrownBy extractCause[ChiselException] {
    import Chisel._

    class Test extends Module {
      class TestIO(w: Int) extends Bundle {
        val a = Vec(4, UInt(width = w)).asInput
      }

      val io = IO(new TestIO(32))
    }

    class TestTop extends Module {
      val io = IO(new Bundle {})

      val subs = Vec.fill(2) {
        Module(new Test).io
      }
    }

    ChiselStage.elaborate(new TestTop)
  }).getMessage should include("make all parameters immutable")
}