diff options
| author | Jack Koenig | 2020-10-22 18:40:54 -0700 |
|---|---|---|
| committer | GitHub | 2020-10-22 18:40:54 -0700 |
| commit | 0745dedefea901df029e65aa59846d8b561dfd31 (patch) | |
| tree | c887b28eaa896af282ad91809fac5c511aac3b8a /plugin/src/main/scala-2.12/chisel3/internal | |
| parent | 26deb7703389b78a9b2a61f7e191f3f0e2a6623b (diff) | |
Use Data refs for name prefixing with aggregate elements (#1616)
* Use Data refs for name prefixing with aggregate elements
Vecs set the refs of their elements upon construction of those elements.
In the past, Records haven't set their elements refs until module close,
but it can be done sooner. Doing it upon binding means that refs will at
least be available for Records used in hardware elements. Since only
bound Data can be connected to anyway, Aggregate elements being
connected to will always have a ref which we can then use for creating
naming prefixes.
* Add tighter correctness checks
* Handle more cases in connection prefixing
Add support for forcing setRef to override a previous setting. This
is only used by BlackBox ports which need to drop their io prefix.
Also add a Try() around Data.bindingToString which sometimes throws
exceptions when being used to .toString a Data in an error message.
* Strip trailing spaces in names in compiler plugin
Diffstat (limited to 'plugin/src/main/scala-2.12/chisel3/internal')
| -rw-r--r-- | plugin/src/main/scala-2.12/chisel3/internal/plugin/ChiselPlugin.scala | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/plugin/src/main/scala-2.12/chisel3/internal/plugin/ChiselPlugin.scala b/plugin/src/main/scala-2.12/chisel3/internal/plugin/ChiselPlugin.scala index 6e4f3ece..9f90ba16 100644 --- a/plugin/src/main/scala-2.12/chisel3/internal/plugin/ChiselPlugin.scala +++ b/plugin/src/main/scala-2.12/chisel3/internal/plugin/ChiselPlugin.scala @@ -124,27 +124,30 @@ class ChiselComponent(val global: Global) extends PluginComponent with TypingTra dd.symbol.logicallyEnclosingMember.thisType <:< inferType(tq"chisel3.Bundle") } + private def stringFromTermName(name: TermName): String = + name.toString.trim() // Remove trailing space (Scalac implementation detail) + // Method called by the compiler to modify source tree override def transform(tree: Tree): Tree = tree match { // Check if a subtree is a candidate case dd @ ValDef(mods, name, tpt, rhs) if okVal(dd) => // If a Data and in a Bundle, just get the name but not a prefix if (shouldMatchData(dd) && inBundle(dd)) { - val TermName(str: String) = name + val str = stringFromTermName(name) val newRHS = transform(rhs) // chisel3.internal.plugin.autoNameRecursively val named = q"chisel3.internal.plugin.autoNameRecursively($str, $newRHS)" treeCopy.ValDef(dd, mods, name, tpt, localTyper typed named) } // If a Data or a Memory, get the name and a prefix else if (shouldMatchDataOrMem(dd)) { - val TermName(str: String) = name + val str = stringFromTermName(name) val newRHS = transform(rhs) val prefixed = q"chisel3.experimental.prefix.apply[$tpt](name=$str)(f=$newRHS)" val named = q"chisel3.internal.plugin.autoNameRecursively($str, $prefixed)" treeCopy.ValDef(dd, mods, name, tpt, localTyper typed named) // If an instance, just get a name but no prefix } else if (shouldMatchModule(dd)) { - val TermName(str: String) = name + val str = stringFromTermName(name) val newRHS = transform(rhs) val named = q"chisel3.internal.plugin.autoNameRecursively($str, $newRHS)" treeCopy.ValDef(dd, mods, name, tpt, localTyper typed named) |
