From 8187318e7aef42d541ce307f93d9fc946ed4c38d Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Thu, 5 Nov 2020 15:54:14 -0800 Subject: For HasId.setRef, have first set win (with force override) (#1655) This is a refinement of the assertion added in #1616 then removed in #1654. Because Records now set the refs of children upon binding, later, unbound Records could incorrectly override the refs. The first set should win.--- src/test/scala/chiselTests/BundleSpec.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/test/scala/chiselTests/BundleSpec.scala b/src/test/scala/chiselTests/BundleSpec.scala index df02aa20..5d3f23ec 100644 --- a/src/test/scala/chiselTests/BundleSpec.scala +++ b/src/test/scala/chiselTests/BundleSpec.scala @@ -141,4 +141,17 @@ class BundleSpec extends ChiselFlatSpec with BundleSpecUtils with Utils { } } } + + "Bound Data" should "have priority in setting ref over unbound Data" in { + class MyModule extends RawModule { + val foo = IO(new Bundle { + val x = Output(UInt(8.W)) + }) + foo.x := 0.U // getRef on foo.x is None.get without fix + val bar = new Bundle { + val y = foo.x + } + } + ChiselStage.emitChirrtl(new MyModule) + } } -- cgit v1.2.3