From 5bec54e535dca53c9347caddb0b395c4651a0919 Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Thu, 2 Jun 2022 18:06:03 +0000 Subject: Support VerificationStatement in the naming plugin (#2555) (#2557) Previously, verification statements (assert, assume, cover, and printf) were only named via reflection. (cherry picked from commit 7fa2691f670813eef4ec59fc27c4e4f625d598de) Co-authored-by: Jack Koenig --- .../scala/chisel3/internal/plugin/ChiselComponent.scala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'plugin') diff --git a/plugin/src/main/scala/chisel3/internal/plugin/ChiselComponent.scala b/plugin/src/main/scala/chisel3/internal/plugin/ChiselComponent.scala index eced652b..f98049e2 100644 --- a/plugin/src/main/scala/chisel3/internal/plugin/ChiselComponent.scala +++ b/plugin/src/main/scala/chisel3/internal/plugin/ChiselComponent.scala @@ -78,10 +78,13 @@ class ChiselComponent(val global: Global, arguments: ChiselPluginArguments) } } - private val shouldMatchData: Type => Boolean = shouldMatchGen(tq"chisel3.Data") - private val shouldMatchDataOrMem: Type => Boolean = shouldMatchGen(tq"chisel3.Data", tq"chisel3.MemBase[_]") - private val shouldMatchModule: Type => Boolean = shouldMatchGen(tq"chisel3.experimental.BaseModule") - private val shouldMatchInstance: Type => Boolean = shouldMatchGen(tq"chisel3.experimental.hierarchy.Instance[_]") + private val shouldMatchData: Type => Boolean = shouldMatchGen(tq"chisel3.Data") + // Checking for all chisel3.internal.NamedComponents, but since it is internal, we instead have + // to match the public subtypes + private val shouldMatchNamedComp: Type => Boolean = + shouldMatchGen(tq"chisel3.Data", tq"chisel3.MemBase[_]", tq"chisel3.VerificationStatement") + private val shouldMatchModule: Type => Boolean = shouldMatchGen(tq"chisel3.experimental.BaseModule") + private val shouldMatchInstance: Type => Boolean = shouldMatchGen(tq"chisel3.experimental.hierarchy.Instance[_]") // Given a type tree, infer the type and return it private def inferType(t: Tree): Type = localTyper.typed(t, nsc.Mode.TYPEmode).tpe @@ -176,7 +179,7 @@ class ChiselComponent(val global: Global, arguments: ChiselPluginArguments) treeCopy.ValDef(dd, mods, name, tpt, localTyper.typed(named)) } // If a Data or a Memory, get the name and a prefix - else if (shouldMatchDataOrMem(tpe)) { + else if (shouldMatchNamedComp(tpe)) { val str = stringFromTermName(name) val newRHS = transform(rhs) val prefixed = q"chisel3.experimental.prefix.apply[$tpt](name=$str)(f=$newRHS)" -- cgit v1.2.3