summaryrefslogtreecommitdiff
path: root/src/main/scala/Chisel/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/Chisel/util')
-rw-r--r--src/main/scala/Chisel/util/Decoupled.scala2
-rw-r--r--src/main/scala/Chisel/util/TransitName.scala21
2 files changed, 22 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/util/Decoupled.scala b/src/main/scala/Chisel/util/Decoupled.scala
index 498af572..faee2a5f 100644
--- a/src/main/scala/Chisel/util/Decoupled.scala
+++ b/src/main/scala/Chisel/util/Decoupled.scala
@@ -175,6 +175,6 @@ object Queue
q.io.enq.valid := enq.valid // not using <> so that override is allowed
q.io.enq.bits := enq.bits
enq.ready := q.io.enq.ready
- q.io.deq
+ TransitName(q.io.deq, q)
}
}
diff --git a/src/main/scala/Chisel/util/TransitName.scala b/src/main/scala/Chisel/util/TransitName.scala
new file mode 100644
index 00000000..ec5a11cc
--- /dev/null
+++ b/src/main/scala/Chisel/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
+ }
+}