summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala14
-rw-r--r--src/main/scala/chisel3/util/Mux.scala4
2 files changed, 13 insertions, 5 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala b/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala
index eee8d598..f2d9558d 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala
@@ -28,13 +28,21 @@ abstract class BlackBox extends Module {
// Do not do reflective naming of internal signals, just name io
override private[core] def setRefs(): this.type = {
- for ((name, port) <- ports) {
- port.setRef(ModuleIO(this, _namespace.name(name)))
- }
// setRef is not called on the actual io.
// There is a risk of user improperly attempting to connect directly with io
// Long term solution will be to define BlackBox IO differently as part of
// it not descending from the (current) Module
+ for ((name, port) <- ports) {
+ port.setRef(ModuleIO(this, _namespace.name(name)))
+ }
+ // We need to call forceName and onModuleClose on all of the sub-elements
+ // of the io bundle, but NOT on the io bundle itself.
+ // Doing so would cause the wrong names to be assigned, since their parent
+ // is now the module itself instead of the io bundle.
+ for (id <- _ids; if id ne io) {
+ id.forceName(default="T", _namespace)
+ id._onModuleClose
+ }
this
}
diff --git a/src/main/scala/chisel3/util/Mux.scala b/src/main/scala/chisel3/util/Mux.scala
index 07a34f9b..9956a7e3 100644
--- a/src/main/scala/chisel3/util/Mux.scala
+++ b/src/main/scala/chisel3/util/Mux.scala
@@ -40,7 +40,7 @@ object MuxLookup {
* @param mapping a sequence to search of keys and values
* @return the value found or the default if not
*/
- def apply[S <: UInt, T <: Bits] (key: S, default: T, mapping: Seq[(S, T)]): T = {
+ def apply[S <: UInt, T <: Data] (key: S, default: T, mapping: Seq[(S, T)]): T = {
var res = default
for ((k, v) <- mapping.reverse)
res = Mux(k === key, v, res)
@@ -54,7 +54,7 @@ object MuxCase {
/** @param default the default value if none are enabled
* @param mapping a set of data values with associated enables
* @return the first value in mapping that is enabled */
- def apply[T <: Bits] (default: T, mapping: Seq[(Bool, T)]): T = {
+ def apply[T <: Data] (default: T, mapping: Seq[(Bool, T)]): T = {
var res = default
for ((t, v) <- mapping.reverse){
res = Mux(t, v, res)