summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/Data.scala
diff options
context:
space:
mode:
authorAdam Izraelevitz2020-07-29 20:48:31 -0700
committerGitHub2020-07-29 20:48:31 -0700
commit164490c8fbf132ca65644d05d6ff8d0d7a3beb20 (patch)
tree862750b85dca5b8496c40c24b3a4e5e67c268bd4 /core/src/main/scala/chisel3/Data.scala
parent8aeb39b9b3755ccd0e3aa600b813ed4220ac72d8 (diff)
Improved Chisel Naming via Compiler Plugins + Prefixing (#1448)
Added prefixing and a compiler plugin to improve naming. Only works for Scala 2.12 and above. Co-authored-by: Jack Koenig <koenig@sifive.com>
Diffstat (limited to 'core/src/main/scala/chisel3/Data.scala')
-rw-r--r--core/src/main/scala/chisel3/Data.scala20
1 files changed, 18 insertions, 2 deletions
diff --git a/core/src/main/scala/chisel3/Data.scala b/core/src/main/scala/chisel3/Data.scala
index 46c98bae..983307a6 100644
--- a/core/src/main/scala/chisel3/Data.scala
+++ b/core/src/main/scala/chisel3/Data.scala
@@ -283,6 +283,14 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
}
}
+ override def autoSeed(name: String): this.type = {
+ topBindingOpt match {
+ // Ports are special in that the autoSeed will keep the first name, not the last name
+ case Some(PortBinding(m)) if hasAutoSeed && Builder.currentModule.contains(m) => this
+ case _ => super.autoSeed(name)
+ }
+ }
+
// User-specified direction, local at this node only.
// Note that the actual direction of this node can differ from child and parent specifiedDirection.
private var _specifiedDirection: SpecifiedDirection = SpecifiedDirection.Unspecified
@@ -490,7 +498,11 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
* @param that the $coll to connect to
* @group Connect
*/
- final def := (that: Data)(implicit sourceInfo: SourceInfo, connectionCompileOptions: CompileOptions): Unit = this.connect(that)(sourceInfo, connectionCompileOptions)
+ final def := (that: => Data)(implicit sourceInfo: SourceInfo, connectionCompileOptions: CompileOptions): Unit = {
+ prefix(this) {
+ this.connect(that)(sourceInfo, connectionCompileOptions)
+ }
+ }
/** Connect this $coll to that $coll bi-directionally and element-wise.
*
@@ -499,7 +511,11 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
* @param that the $coll to connect to
* @group Connect
*/
- final def <> (that: Data)(implicit sourceInfo: SourceInfo, connectionCompileOptions: CompileOptions): Unit = this.bulkConnect(that)(sourceInfo, connectionCompileOptions)
+ final def <> (that: => Data)(implicit sourceInfo: SourceInfo, connectionCompileOptions: CompileOptions): Unit = {
+ prefix(this) {
+ this.bulkConnect(that)(sourceInfo, connectionCompileOptions)
+ }
+ }
@chiselRuntimeDeprecated
@deprecated("litArg is deprecated, use litOption or litTo*Option", "3.2")