diff options
| author | Jim Lawson | 2016-08-30 09:18:35 -0700 |
|---|---|---|
| committer | Jim Lawson | 2016-08-30 09:18:35 -0700 |
| commit | 5df671531c4a83dc17ecfdce6aecc8789d50fa7f (patch) | |
| tree | 3478861f7e60f9199522eb14bf59c6194e9a253c /src | |
| parent | 98e35eb6b46b144e3daec78e21e807769e6db505 (diff) | |
Add abstract classes with explicit connection checking options.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/scala/chiselTests/CompileOptionsTest.scala | 81 |
1 files changed, 70 insertions, 11 deletions
diff --git a/src/test/scala/chiselTests/CompileOptionsTest.scala b/src/test/scala/chiselTests/CompileOptionsTest.scala index 5bd3f959..5b27bf90 100644 --- a/src/test/scala/chiselTests/CompileOptionsTest.scala +++ b/src/test/scala/chiselTests/CompileOptionsTest.scala @@ -9,6 +9,9 @@ import chisel3.testers.BasicTester class CompileOptionsSpec extends ChiselFlatSpec { + abstract class StrictModule extends Module()(chisel3.Strict.CompileOptions) + abstract class NotStrictModule extends Module()(chisel3.NotStrict.CompileOptions) + class SmallBundle extends Bundle { val f1 = UInt(width = 4) val f2 = UInt(width = 5) @@ -19,7 +22,7 @@ class CompileOptionsSpec extends ChiselFlatSpec { override def cloneType: this.type = (new BigBundle).asInstanceOf[this.type] } - "A Module with missing bundle fields when compiled with Strict.CompileOption " should "throw an exception" in { + "A Module with missing bundle fields when compiled with implicit Strict.CompileOption " should "throw an exception" in { a [ChiselException] should be thrownBy { import chisel3.Strict.CompileOptions @@ -34,7 +37,7 @@ class CompileOptionsSpec extends ChiselFlatSpec { } } - "A Module with missing bundle fields when compiled with NotStrict.CompileOption " should "not throw an exception" in { + "A Module with missing bundle fields when compiled with implicit NotStrict.CompileOption " should "not throw an exception" in { import chisel3.NotStrict.CompileOptions class ConnectFieldMismatchModule extends Module { @@ -47,7 +50,7 @@ class CompileOptionsSpec extends ChiselFlatSpec { elaborate { new ConnectFieldMismatchModule() } } - "A Module in which a Reg is created with a bound type when compiled with Strict.CompileOption " should "throw an exception" in { + "A Module in which a Reg is created with a bound type when compiled with implicit Strict.CompileOption " should "throw an exception" in { a [BindingException] should be thrownBy { import chisel3.Strict.CompileOptions @@ -62,7 +65,7 @@ class CompileOptionsSpec extends ChiselFlatSpec { } } - "A Module in which a Reg is created with a bound type when compiled with NotStrict.CompileOption " should "not throw an exception" in { + "A Module in which a Reg is created with a bound type when compiled with implicit NotStrict.CompileOption " should "not throw an exception" in { import chisel3.NotStrict.CompileOptions class CreateRegFromBoundTypeModule extends Module { @@ -75,8 +78,7 @@ class CompileOptionsSpec extends ChiselFlatSpec { elaborate { new CreateRegFromBoundTypeModule() } } - - "A Module with wrapped IO when compiled with Strict.CompileOption " should "not throw an exception" in { + "A Module with wrapped IO when compiled with implicit Strict.CompileOption " should "not throw an exception" in { import chisel3.Strict.CompileOptions class RequireIOWrapModule extends Module { @@ -89,7 +91,7 @@ class CompileOptionsSpec extends ChiselFlatSpec { elaborate { new RequireIOWrapModule() } } - "A Module with unwrapped IO when compiled with NotStrict.CompileOption " should "not throw an exception" in { + "A Module with unwrapped IO when compiled with implicit NotStrict.CompileOption " should "not throw an exception" in { import chisel3.NotStrict.CompileOptions class RequireIOWrapModule extends Module { @@ -102,7 +104,24 @@ class CompileOptionsSpec extends ChiselFlatSpec { elaborate { new RequireIOWrapModule() } } - "A Module connecting output as source to input as sink when compiled with Strict.CompileOption " should "throw an exception" in { + "A Module with unwrapped IO when compiled with implicit Strict.CompileOption " should "throw an exception" in { + a [BindingException] should be thrownBy { + import chisel3.Strict.CompileOptions + + class RequireIOWrapModule extends Module { + val io = new Bundle { + val in = UInt(width = 32).asInput + val out = Bool().asOutput + } + io.out := io.in(1) + } + elaborate { + new RequireIOWrapModule() + } + } + } + + "A Module connecting output as source to input as sink when compiled with implicit Strict.CompileOption " should "throw an exception" in { a [ChiselException] should be thrownBy { import chisel3.Strict.CompileOptions @@ -120,7 +139,7 @@ class CompileOptionsSpec extends ChiselFlatSpec { } } - "A Module connecting output as source to input as sink when compiled with NotStrict.CompileOption " should "not throw an exception" in { + "A Module connecting output as source to input as sink when compiled with implicit NotStrict.CompileOption " should "not throw an exception" in { import chisel3.NotStrict.CompileOptions class SimpleModule extends Module { @@ -136,7 +155,7 @@ class CompileOptionsSpec extends ChiselFlatSpec { elaborate { new SwappedConnectionModule() } } - "A Module with directionless connections when compiled with Strict.CompileOption " should "throw an exception" in { + "A Module with directionless connections when compiled with implicit Strict.CompileOption " should "throw an exception" in { a [ChiselException] should be thrownBy { import chisel3.Strict.CompileOptions @@ -158,7 +177,7 @@ class CompileOptionsSpec extends ChiselFlatSpec { } } - "A Module with directionless connections when compiled with NotStrict.CompileOption " should "not throw an exception" in { + "A Module with directionless connections when compiled with implicit NotStrict.CompileOption " should "not throw an exception" in { import chisel3.NotStrict.CompileOptions class SimpleModule extends Module { @@ -177,4 +196,44 @@ class CompileOptionsSpec extends ChiselFlatSpec { } elaborate { new DirectionLessConnectionModule() } } + + "A Module with wrapped IO when compiled with explicit Strict.CompileOption " should "not throw an exception" in { + + class RequireIOWrapModule extends StrictModule { + val io = IO(new Bundle { + val in = UInt(width = 32).asInput + val out = Bool().asOutput + }) + io.out := io.in(1) + } + elaborate { new RequireIOWrapModule() } + } + + "A Module with unwrapped IO when compiled with explicit NotStrict.CompileOption " should "not throw an exception" in { + + class RequireIOWrapModule extends NotStrictModule { + val io = new Bundle { + val in = UInt(width = 32).asInput + val out = Bool().asOutput + } + io.out := io.in(1) + } + elaborate { new RequireIOWrapModule() } + } + + "A Module with unwrapped IO when compiled with explicit Strict.CompileOption " should "throw an exception" in { + a [BindingException] should be thrownBy { + + class RequireIOWrapModule extends StrictModule { + val io = new Bundle { + val in = UInt(width = 32).asInput + val out = Bool().asOutput + } + io.out := io.in(1) + } + elaborate { + new RequireIOWrapModule() + } + } + } } |
