From 09f7aa03e1e729ad9e6eb97ab08419d0b95c8703 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 12:57:13 -0400 Subject: Add BitPat deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 24149cf3..eece45e2 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -338,4 +338,24 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks }) } // scalastyle:on line.size.limit + + behavior of "BitPat" + + it should "support old operators" in { + class Foo extends Module { + val io = IO(new Bundle{}) + + info("Deprecated method DC hasn't been removed") + val bp = BitPat.DC(4) + + info("BitPat != UInt is a Bool") + (bp != UInt(4)) shouldBe a [Bool] + + /* This test does not work, but I'm not sure it's supposed to? It does *not* work on chisel3. */ + // info("UInt != BitPat is a Bool") + // (UInt(4) != bp) shouldBe a [Bool] + } + + elaborate(new Foo) + } } -- cgit v1.2.3 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 From a16743208a0b3a5f075585dd0c3f7c96b4f5994a Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 13:41:53 -0400 Subject: Add Queue deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 9a00ac0f..9584e82a 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -382,4 +382,20 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + behavior of "Queue" + + it should "support deprecated constructors" in { + class Foo extends Module { + val io = IO(new Bundle{}) + + info("reset: Option[Bool] constructor works") + val option = Module(new Queue(UInt(), 4, false, false, Some(Bool(true)))) + + info("reset: Bool constructor works") + val explicit = Module(new Queue(UInt(), 4, false, false, Bool(true))) + } + + elaborate(new Foo) + } + } -- cgit v1.2.3 From 09254342f9bb95c23a094c156bd15e2f5af9ee9d Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 13:47:01 -0400 Subject: Add LFSR16 deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 9584e82a..d9f4ccdb 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -96,9 +96,6 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks dcd shouldBe a [DecoupledIO[UInt]] Queue(dcd) shouldBe a [DecoupledIO[UInt]] Enum(UInt(), 2) shouldBe a [List[UInt]] - val lfsr16 = LFSR16() - lfsr16 shouldBe a [UInt] - lfsr16.getWidth shouldBe (16) ListLookup(wire, List(wire), Array((BitPat("b1"), List(wire)))) shouldBe a [List[UInt]] Lookup(wire, wire, Seq((BitPat("b1"), wire))) shouldBe a [UInt] Mux1H(wire, Seq(wire)) shouldBe a [UInt] @@ -398,4 +395,23 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + behavior of "LFSR16" + + it should "still exist" in { + class Foo extends Module { + val io = IO(new Bundle{}) + + info("Still exists") + val lfsr = LFSR16() + + info("apply method returns a UInt") + lfsr shouldBe a [UInt] + + info("returned UInt has a width of 16") + lfsr.getWidth should be (16) + } + + elaborate(new Foo) + } + } -- cgit v1.2.3 From 43146ebc08716b06f63f1965e698d9f0d9a4f40c Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 13:58:04 -0400 Subject: Add Mem/SeqMem deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index d9f4ccdb..3cc8fb89 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -414,4 +414,40 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + behavior of "Mem" + + it should "support deprecated apply methods" in { + class Foo extends Module { + val io = IO(new Bundle{}) + + info("apply[T <: Data](t: T, size: BigInt): Mem[T] works") + val memBigInt = Mem(UInt(), 8: BigInt) + memBigInt shouldBe a [Mem[UInt]] + + info("apply[T <: Data](t: T, size: Int): Mem[T] works") + val memInt = Mem(SInt(), 16: Int) + memInt shouldBe a [Mem[SInt]] + } + + elaborate(new Foo) + } + + behavior of "SeqMem" + + it should "support deprecated apply methods" in { + class Foo extends Module { + val io = IO(new Bundle{}) + + info("apply[T <: Data](t: T, size: BigInt): SeqMem[T] works") + val seqMemBigInt = SeqMem(UInt(), 8: BigInt) + seqMemBigInt shouldBe a [SeqMem[UInt]] + + info("apply[T <: Data](t: T, size: Int): SeqMem[T] works") + val seqMemInt = SeqMem(UInt(), 16: Int) + seqMemInt shouldBe a [SeqMem[UInt]] + } + + elaborate(new Foo) + } + } -- cgit v1.2.3 From fc85e085ae525c39a24778c5e35bec87145d1652 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 14:00:36 -0400 Subject: Add debug deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 3cc8fb89..7194cb3c 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -450,4 +450,17 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + behavior of "debug" + + it should "still exist" in { + class Foo extends Module { + val io = IO(new Bundle{}) + + val data = UInt(width = 2) + debug(data) + } + + elaborate(new Foo) + } + } -- cgit v1.2.3 From cb7bd3e70f2864d233a32e9935af4b7a829ff0af Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 14:19:58 -0400 Subject: Add Data deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 7194cb3c..2fa936ed 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -463,4 +463,22 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + behavior of "Data methods" + + it should "support legacy methods" in { + class Foo extends Module { + val io = IO(new Bundle{}) + + info("litArg works") + UInt(width=3).litArg() should be (None) + UInt(0, width=3).litArg() should be (Some(chisel3.internal.firrtl.ULit(0, 3.W))) + + info("toBits works") + val wire = Wire(UInt(width=4)) + Vec.fill(4)(wire).toBits.getWidth should be (wire.getWidth * 4) + } + + elaborate(new Foo) + } + } -- cgit v1.2.3 From d6bbbf664fa15e85132e33b42e64d4e37483a514 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 14:27:21 -0400 Subject: Add Wire deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 2fa936ed..81c97ee9 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -481,4 +481,26 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + behavior of "Wire" + + it should "support legacy methods" in { + class Foo extends Module { + val io = IO(new Bundle{}) + + info("apply[T <: Data](dummy: Int = 0, init: T): T works") + val first = Wire(init=UInt("hdeadbeef")) + first shouldBe a [UInt] + + info("apply[T <: Data](t: T, init: T): T works") + val second = Wire(SInt(), SInt(-100)) + second shouldBe a [SInt] + + info("apply[T <: Data](t: T, init: DontCare.type): T works") + val third = Wire(UInt(), chisel3.DontCare) + third shouldBe a [UInt] + } + + elaborate(new Foo) + } + } -- cgit v1.2.3 From 86b8e14f5f5dcb09546e4a7ff2b088e4109b0df9 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 15:04:05 -0400 Subject: Add VecLike deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 81c97ee9..11f44449 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -2,6 +2,8 @@ package chiselTests +import chisel3.testers.BasicTester + import org.scalacheck.Gen import org.scalatest.prop.GeneratorDrivenPropertyChecks @@ -503,4 +505,25 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + behavior of "Vec" + + it should "support legacy methods" in { + class Foo extends BasicTester { + val seq = Seq(Wire(UInt(0, width=4)), Wire(UInt(1, width=4)), Wire(UInt(2, width=4))) + val vec = Vec(seq) + + info("read works") + chisel3.assert(vec.read(UInt(0)) === UInt(0)) + + info("write works") + vec.write(UInt(1), UInt(3)) + chisel3.assert(vec.read(UInt(1)) === UInt(3)) + + val (_, done) = Counter(Bool(true), 4) + when (done) { stop } + } + + assertTesterPasses(new Foo) + } + } -- cgit v1.2.3 From 4a919c83318c6964d9a864c50cb3ba719b1fdbfe Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 15:45:29 -0400 Subject: Add Bits deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 11f44449..88228475 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -526,4 +526,32 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks assertTesterPasses(new Foo) } + behavior of "Bits methods" + + it should "support legacy methods" in { + class Foo extends Module { + val io = new Bundle{} + + val u = UInt(8) + val s = SInt(-4) + + info("toBools works") + u.toBools shouldBe a [Seq[Bool]] + + info("asBits works") + s.asBits shouldBe a [Bits] + + info("toSInt works") + u.toSInt shouldBe a [SInt] + + info("toUInt works") + s.toUInt shouldBe a [UInt] + + info("toBool works") + UInt(1).toBool shouldBe a [Bool] + } + + elaborate(new Foo) + } + } -- cgit v1.2.3 From c875e6af9aaad80de1d305d9b5f80962dabe4b4c Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 15:46:11 -0400 Subject: Add UInt deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 88228475..97eb58d0 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -554,4 +554,17 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + behavior of "UInt" + + it should "support legacy methods" in { + class Foo extends Module { + val io = new Bundle{} + + info("!= works") + (UInt(1) != UInt(1)) shouldBe a [Bool] + } + + elaborate(new Foo) + } + } -- cgit v1.2.3 From 2056bd8750fc7d7b78334a75e6449a711a872972 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 31 Jul 2019 15:46:26 -0400 Subject: Add SInt deprecated compatibility tests Signed-off-by: Schuyler Eldridge --- src/test/scala/chiselTests/CompatibilitySpec.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 97eb58d0..c602efa3 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -567,4 +567,17 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks elaborate(new Foo) } + behavior of "SInt" + + it should "support legacy methods" in { + class Foo extends Module { + val io = new Bundle{} + + info("!= works") + (SInt(-1) != SInt(-1)) shouldBe a [Bool] + } + + elaborate(new Foo) + } + } -- cgit v1.2.3