summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/TransitName.scala
diff options
context:
space:
mode:
authorJim Lawson2016-07-06 10:01:23 -0700
committerJim Lawson2016-07-18 15:17:56 -0700
commitc5f9ea3133ef363ff8944e17d94fea79767b6bed (patch)
treecc80a6df1eb58f0feaf9f138eb7fe261ccda4ea2 /src/main/scala/chisel3/util/TransitName.scala
parent53813f61b7dfe246d214ab966739d01c65c8ecb0 (diff)
Rename "Chisel" to "chisel3" (only git mv).
Diffstat (limited to 'src/main/scala/chisel3/util/TransitName.scala')
-rw-r--r--src/main/scala/chisel3/util/TransitName.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/util/TransitName.scala b/src/main/scala/chisel3/util/TransitName.scala
new file mode 100644
index 00000000..ec5a11cc
--- /dev/null
+++ b/src/main/scala/chisel3/util/TransitName.scala
@@ -0,0 +1,21 @@
+package Chisel
+
+import internal.HasId
+
+object TransitName {
+ // The purpose of this is to allow a library to 'move' a name call to a more
+ // appropriate place.
+ // For example, a library factory function may create a module and return
+ // the io. The only user-exposed field is that given IO, which can't use
+ // any name supplied by the user. This can add a hook so that the supplied
+ // name then names the Module.
+ // See Queue companion object for working example
+ def apply[T<:HasId](from: T, to: HasId): T = {
+ from.addPostnameHook((given_name: String) => {to.suggestName(given_name)})
+ from
+ }
+ def withSuffix[T<:HasId](suffix: String)(from: T, to: HasId): T = {
+ from.addPostnameHook((given_name: String) => {to.suggestName(given_name+suffix)})
+ from
+ }
+}