summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala
blob: bd1bade8653b4941a8d2e252839ced4407bc82c1 (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
56
57
// See LICENSE for license details.

package chiselTests
import Chisel.ChiselException
import org.scalatest._

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

    class TestIO(w: Int) extends Bundle {
      val a = Vec(4, UInt(w.W)).asInput

      //override def cloneType = (new TestIO(w)).asInstanceOf[this.type]
    }

    class Test extends Module {
      val io = IO(new TestIO(32))
    }

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

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

    elaborate(new TestTop)
  }).getMessage should include("needs cloneType method")

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

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

      //override def cloneType = (new TestIO(w)).asInstanceOf[this.type]
    }

    class Test extends Module {
      val io = IO(new TestIO(32))
    }

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

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

    elaborate(new TestTop)
  }).getMessage should include("needs cloneType method")
}