diff --git a/src/main/scala/tilelink/RegisterRouter.scala b/src/main/scala/tilelink/RegisterRouter.scala index 2d99a693..dc5b6319 100644 --- a/src/main/scala/tilelink/RegisterRouter.scala +++ b/src/main/scala/tilelink/RegisterRouter.scala @@ -111,7 +111,12 @@ case class TLRegisterNode( ("baseAddress" -> base) ~ ("regfields" -> regDescs) )) - ElaborationArtefacts.add(s"${base}.regmap.json", pretty(render(json))) + + var suffix = 0 + while( ElaborationArtefacts.contains(s"${base}.${suffix}.regmap.json")){ + suffix = suffix + 1 + } + ElaborationArtefacts.add(s"${base}.${suffix}regmap.json", pretty(render(json))) } } diff --git a/src/main/scala/util/GeneratorUtils.scala b/src/main/scala/util/GeneratorUtils.scala index c7830ddf..8d9d9339 100644 --- a/src/main/scala/util/GeneratorUtils.scala +++ b/src/main/scala/util/GeneratorUtils.scala @@ -139,7 +139,12 @@ trait GeneratorApp extends App with HasGeneratorUtilities { object ElaborationArtefacts { var files: Seq[(String, () => String)] = Nil - def add(extension: String, contents: => String) { + + def add(extension: String, contents: => String) = { files = (extension, () => contents) +: files } + + def contains(extension: String): Boolean = { + files.foldLeft(false)((t, s) => {s._1 == extension | t}) + } }