aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJack Koenig2018-12-06 15:23:08 -0800
committerGitHub2018-12-06 15:23:08 -0800
commit50ba95fe05cc348496425733554be5fc7d797de1 (patch)
tree447b6cb3d10c0d7f2d02eacd4a5628e784ec1302 /src
parent9787e6a877375008645481f39388728436c85829 (diff)
Fix bug in dedup where lots of annotations could prevent dedup (#958)
Iterating on a HashSet could cause identical modules (including annotations) to not dedup
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/firrtl/transforms/Dedup.scala2
-rw-r--r--src/test/scala/firrtlTests/transforms/DedupTests.scala28
2 files changed, 29 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/transforms/Dedup.scala b/src/main/scala/firrtl/transforms/Dedup.scala
index a33eeca6..56ea7cf8 100644
--- a/src/main/scala/firrtl/transforms/Dedup.scala
+++ b/src/main/scala/firrtl/transforms/Dedup.scala
@@ -335,7 +335,7 @@ object DedupModules {
// Build tag
val builder = new mutable.ArrayBuffer[Any]()
agnosticModule.ports.foreach { builder ++= _.serialize }
- builder ++= agnosticAnnos
+ builder += agnosticAnnos
agnosticModule match {
case Module(i, n, ps, b) => builder ++= fastSerializedHash(b).toString()//.serialize
diff --git a/src/test/scala/firrtlTests/transforms/DedupTests.scala b/src/test/scala/firrtlTests/transforms/DedupTests.scala
index 5ee2b927..d4fe54a1 100644
--- a/src/test/scala/firrtlTests/transforms/DedupTests.scala
+++ b/src/test/scala/firrtlTests/transforms/DedupTests.scala
@@ -376,6 +376,34 @@ class DedupModuleTests extends HighTransformSpec {
""".stripMargin
execute(input, check, Seq(dontTouch("A.b"), dontTouch("A_.b")))
}
+ "The module A and A_" should "be deduped with same annotation targets when there are a lot" in {
+ val input =
+ """circuit Top :
+ | module Top :
+ | inst a1 of A
+ | inst a2 of A_
+ | module A :
+ | output x: UInt<1>[100]
+ | wire b: UInt<1>[100]
+ | x <= b
+ | module A_ :
+ | output x: UInt<1>[100]
+ | wire b: UInt<1>[100]
+ | x <= b
+ """.stripMargin
+ val check =
+ """circuit Top :
+ | module Top :
+ | inst a1 of A
+ | inst a2 of A
+ | module A :
+ | output x: UInt<1>[100]
+ | wire b: UInt<1>[100]
+ | x <= b
+ """.stripMargin
+ val annos = (0 until 100).flatMap(i => Seq(dontTouch(s"A.b[$i]"), dontTouch(s"A_.b[$i]")))
+ execute(input, check, annos)
+ }
"The module A and A_" should "not be deduped with same annotations with same multi-targets, but which have different root modules" in {
val input =
"""circuit Top :