From 97871178cb511063965f971b768f91c289c4776f Mon Sep 17 00:00:00 2001 From: Richard Lin Date: Wed, 28 Feb 2018 17:31:43 -0800 Subject: Auto Clone Bundles in Companion Objects (#788) --- src/test/scala/chiselTests/AutoClonetypeSpec.scala | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/AutoClonetypeSpec.scala b/src/test/scala/chiselTests/AutoClonetypeSpec.scala index 0b02c3ab..59ce98b7 100644 --- a/src/test/scala/chiselTests/AutoClonetypeSpec.scala +++ b/src/test/scala/chiselTests/AutoClonetypeSpec.scala @@ -47,6 +47,15 @@ class ModuleWithInner extends Module { require(myWire.i == 14) } +object CompanionObjectWithBundle { + class ParameterizedInner(val i: Int) extends Bundle { + val data = UInt(i.W) + } + class Inner extends Bundle { + val data = UInt(8.W) + } +} + // A Bundle with an argument that is also a field. // Not necessarily good style (and not necessarily recommended), but allowed to preserve compatibility. class BundleWithArgumentField(val x: Data, val y: Data) extends Bundle @@ -123,4 +132,18 @@ class AutoClonetypeSpec extends ChiselFlatSpec { io.y := 1.U } } } + + "Bundles inside companion objects" should "not need clonetype" in { + elaborate { new Module { + val io = IO(Output(new CompanionObjectWithBundle.Inner)) + io.data := 1.U + } } + } + + "Parameterized bundles inside companion objects" should "not need clonetype" in { + elaborate { new Module { + val io = IO(Output(new CompanionObjectWithBundle.ParameterizedInner(8))) + io.data := 1.U + } } + } } -- cgit v1.2.3