diff options
| author | Jim Lawson | 2016-11-10 10:05:15 -0800 |
|---|---|---|
| committer | Jim Lawson | 2016-11-10 10:05:15 -0800 |
| commit | 2e62da09ed1ed0725a14185ae76a683da73b32f4 (patch) | |
| tree | 29cc5966074ba9eb71c4a8bced5d8ff1f2601cae /src | |
| parent | b2b80ce24881782b82b545e0e3cb2a0e4ef83557 (diff) | |
Throw exceptions for cloneType failures - fix #358
Add a Builder.exception() method for those cases where continuing is likely to mask the initial error.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala b/src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala new file mode 100644 index 00000000..fd48206e --- /dev/null +++ b/src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala @@ -0,0 +1,57 @@ +// See LICENSE for license details. + +package chiselTests +import Chisel.ChiselException +import org.scalatest._ + +class MissingCloneBindingExceptionSpec extends FlatSpec with Matchers { + behavior of "missing cloneType in Chisel3" + ( the[ChiselException] thrownBy { + import chisel3._ + + 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 + } + } + + val dummy = 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 + } + } + + val dummy = new TestTop + }).getMessage should include("needs cloneType method") +} |
