summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests
diff options
context:
space:
mode:
authorEdward Wang2018-07-08 02:36:18 -0700
committeredwardcwang2018-08-22 11:55:38 -0700
commit02d6fbbacaf5da2080dd406b98cddbdab2ab5cb1 (patch)
tree096fad5b80f2f7f8cd2e79526cd37111e326942b /src/test/scala/chiselTests
parent3679e80c72e67c7c1b09a8f3f5315bc4d3e8d9ab (diff)
Warn user that using Seq for hardware construction in Bundle is not supported
Diffstat (limited to 'src/test/scala/chiselTests')
-rw-r--r--src/test/scala/chiselTests/BundleSpec.scala48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/BundleSpec.scala b/src/test/scala/chiselTests/BundleSpec.scala
index bb1393bc..b248f7b5 100644
--- a/src/test/scala/chiselTests/BundleSpec.scala
+++ b/src/test/scala/chiselTests/BundleSpec.scala
@@ -25,6 +25,11 @@ trait BundleSpecUtils {
override def cloneType = (new BundleBar).asInstanceOf[this.type]
}
+ class BadSeqBundle extends Bundle {
+ val bar = Seq(UInt(16.W), UInt(8.W), UInt(4.W))
+ override def cloneType = (new BadSeqBundle).asInstanceOf[this.type]
+ }
+
class MyModule(output: Bundle, input: Bundle) extends Module {
val io = IO(new Bundle {
val in = Input(input)
@@ -68,4 +73,47 @@ class BundleSpec extends ChiselFlatSpec with BundleSpecUtils {
elaborate { new MyModule(new BundleFoo, new BundleFooBar) }
}).getMessage should include ("Left Record missing field")
}
+
+ "Bundles" should "not be able to use Seq for constructing hardware" in {
+ (the[ChiselException] thrownBy {
+ elaborate {
+ new Module {
+ val io = IO(new Bundle {
+ val b = new BadSeqBundle
+ })
+ }
+ }
+ }).getMessage should include("Public Seq members cannot be used to define Bundle elements")
+ }
+
+ "Bundles" should "be allowed to have Seq if need be" in {
+ assertTesterPasses {
+ new BasicTester {
+ val m = Module(new Module {
+ val io = IO(new Bundle {
+ val b = new BadSeqBundle {
+ override def ignoreSeq = true
+ }
+ })
+ })
+ stop()
+ }
+ }
+ }
+
+ "Bundles" should "be allowed to have non-Chisel Seqs" in {
+ assertTesterPasses {
+ new BasicTester {
+ val m = Module(new Module {
+ val io = IO(new Bundle {
+ val f = Output(UInt(8.W))
+ val unrelated = (0 to 10).toSeq
+ val unrelated2 = Seq("Hello", "World", "Chisel")
+ })
+ io.f := 0.U
+ })
+ stop()
+ }
+ }
+ }
}