From 182e8781473b72e3a086dbf806081639d52aac06 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 13:11:44 -0400 Subject: Add Enum deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index eece45e2..9a00ac0f 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -358,4 +358,28 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + + behavior of "Enum" + + it should "support apply[T <: Bits](nodeType: T, n: Int): List[T]" in { + class Foo extends Module { + val io = IO(new Bundle{}) + + info("works for a UInt") + Enum(UInt(), 4) shouldBe a [List[UInt]] + + info("throw an exception for non-UInt types") + intercept [IllegalArgumentException] { + Enum(SInt(), 4) + }.getMessage should include ("Only UInt supported for enums") + + info("throw an exception if the bit width is specified") + intercept [IllegalArgumentException] { + Enum(UInt(width = 8), 4) + }.getMessage should include ("Bit width may no longer be specified for enums") + } + + elaborate(new Foo) + } + } -- cgit v1.2.3