summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/experimental
diff options
context:
space:
mode:
authorJack Koenig2021-09-08 14:31:10 -0700
committerGitHub2021-09-08 14:31:10 -0700
commit2b51053fe7744d6860416c7de8bcb99d4aa9e532 (patch)
treefeb5c83ae84d0bde40b4c2734dd2cd4cfd08fffe /core/src/main/scala/chisel3/experimental
parentff1bcb09d9bd416fcba68496b7cef1d0e454dfd5 (diff)
Restore return type of BaseModule.toTarget to ModuleTarget (#2117)
Definition/Instance introduced the need for representing the targets of instances as InstanceTargets. This original implementation changed the return type of BaseModule.toTarget to express this need. This is a backwards incompatible change that is actually unnecessary because it is impossible for users to get references to the internal InstanceClone objects, instead only accessing such modules via Instance[_] wrappers and cloned Data. We restored the old API by adding a new internal method "getTarget" which will give the correct targets for InstanceClones while maintaining the API of BaseModule.toTarget.
Diffstat (limited to 'core/src/main/scala/chisel3/experimental')
-rw-r--r--core/src/main/scala/chisel3/experimental/hierarchy/Definition.scala7
-rw-r--r--core/src/main/scala/chisel3/experimental/hierarchy/Instance.scala12
2 files changed, 10 insertions, 9 deletions
diff --git a/core/src/main/scala/chisel3/experimental/hierarchy/Definition.scala b/core/src/main/scala/chisel3/experimental/hierarchy/Definition.scala
index 2e917dfa..0cc3d131 100644
--- a/core/src/main/scala/chisel3/experimental/hierarchy/Definition.scala
+++ b/core/src/main/scala/chisel3/experimental/hierarchy/Definition.scala
@@ -3,13 +3,14 @@
package chisel3.experimental.hierarchy
import scala.language.experimental.macros
-
import chisel3._
+
import scala.collection.mutable.HashMap
import chisel3.internal.{Builder, DynamicContext}
import chisel3.internal.sourceinfo.{DefinitionTransform, DefinitionWrapTransform, SourceInfo}
import chisel3.experimental.BaseModule
import chisel3.internal.BaseModule.IsClone
+import firrtl.annotations.{IsModule, ModuleTarget}
/** User-facing Definition type.
* Represents a definition of an object of type [[A]] which are marked as @instantiable
@@ -64,12 +65,12 @@ object Definition extends SourceInfoDoc {
/** If this is an instance of a Module, returns the toTarget of this instance
* @return target of this instance
*/
- def toTarget = d.proto.toTarget
+ def toTarget: ModuleTarget = d.proto.toTarget
/** If this is an instance of a Module, returns the toAbsoluteTarget of this instance
* @return absoluteTarget of this instance
*/
- def toAbsoluteTarget = d.proto.toAbsoluteTarget
+ def toAbsoluteTarget: IsModule = d.proto.toAbsoluteTarget
}
/** A construction method to build a Definition of a Module
*
diff --git a/core/src/main/scala/chisel3/experimental/hierarchy/Instance.scala b/core/src/main/scala/chisel3/experimental/hierarchy/Instance.scala
index aec42da3..9b17bfce 100644
--- a/core/src/main/scala/chisel3/experimental/hierarchy/Instance.scala
+++ b/core/src/main/scala/chisel3/experimental/hierarchy/Instance.scala
@@ -4,11 +4,11 @@ package chisel3.experimental.hierarchy
import scala.collection.mutable.{ArrayBuffer, HashMap}
import scala.language.experimental.macros
-
import chisel3._
-import chisel3.internal.BaseModule.{ModuleClone, IsClone, InstantiableClone}
+import chisel3.internal.BaseModule.{InstantiableClone, IsClone, ModuleClone}
import chisel3.internal.sourceinfo.{InstanceTransform, SourceInfo}
import chisel3.experimental.BaseModule
+import firrtl.annotations.IsModule
/** User-facing Instance type.
* Represents a unique instance of type [[A]] which are marked as @instantiable
@@ -75,15 +75,15 @@ object Instance extends SourceInfoDoc {
/** If this is an instance of a Module, returns the toTarget of this instance
* @return target of this instance
*/
- def toTarget = i.cloned match {
- case Left(x: BaseModule) => x.toTarget
- case Right(x: IsClone[_] with BaseModule) => x.toTarget
+ def toTarget: IsModule = i.cloned match {
+ case Left(x: BaseModule) => x.getTarget
+ case Right(x: IsClone[_] with BaseModule) => x.getTarget
}
/** If this is an instance of a Module, returns the toAbsoluteTarget of this instance
* @return absoluteTarget of this instance
*/
- def toAbsoluteTarget = i.cloned match {
+ def toAbsoluteTarget: IsModule = i.cloned match {
case Left(x) => x.toAbsoluteTarget
case Right(x: IsClone[_] with BaseModule) => x.toAbsoluteTarget
}