summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3
diff options
context:
space:
mode:
authorMegan Wachs2022-01-07 15:28:56 -0800
committerGitHub2022-01-07 23:28:56 +0000
commita1af6b7099f1207c67db3561507615fd18c487ef (patch)
tree86083634d8b7a67ff0a249768692164737f35de3 /src/main/scala/chisel3
parent72d5be9634c677e47ec8fce204be55c8936166fb (diff)
Add a Select.ios that works with Definition/Instance, fix isA behavior (#2315)
* New Feature: Add a Select.ios that works with Definition/Instance * BugFix: isA now truly ignores type parameters
Diffstat (limited to 'src/main/scala/chisel3')
-rw-r--r--src/main/scala/chisel3/aop/Select.scala19
-rw-r--r--src/main/scala/chisel3/aop/injecting/InjectingAspect.scala1
2 files changed, 18 insertions, 2 deletions
diff --git a/src/main/scala/chisel3/aop/Select.scala b/src/main/scala/chisel3/aop/Select.scala
index 8f5a2577..6bd13445 100644
--- a/src/main/scala/chisel3/aop/Select.scala
+++ b/src/main/scala/chisel3/aop/Select.scala
@@ -65,6 +65,8 @@ object Select {
/** Selects all Instances of instances/modules directly instantiated within given module, of provided type
*
* @note IMPORTANT: this function requires summoning a TypeTag[T], which will fail if T is an inner class.
+ * @note IMPORTANT: this function ignores type parameters. E.g. instancesOf[List[Int]] would return List[String].
+ *
* @param parent hierarchy which instantiates the returned Definitions
*/
def instancesOf[T <: BaseModule : TypeTag](parent: Hierarchy[BaseModule]): Seq[Instance[T]] = {
@@ -90,6 +92,8 @@ object Select {
/** Selects all Instances directly and indirectly instantiated within given root hierarchy, of provided type
*
* @note IMPORTANT: this function requires summoning a TypeTag[T], which will fail if T is an inner class.
+ * @note IMPORTANT: this function ignores type parameters. E.g. allInstancesOf[List[Int]] would return List[String].
+ *
* @param root top of the hierarchy to search for instances/modules of given type
*/
def allInstancesOf[T <: BaseModule : TypeTag](root: Hierarchy[BaseModule]): Seq[Instance[T]] = {
@@ -128,6 +132,8 @@ object Select {
/** Selects all Definitions of instances/modules directly instantiated within given module, of provided type
*
* @note IMPORTANT: this function requires summoning a TypeTag[T], which will fail if T is an inner class.
+ * @note IMPORTANT: this function ignores type parameters. E.g. definitionsOf[List[Int]] would return List[String].
+ *
* @param parent hierarchy which instantiates the returned Definitions
*/
def definitionsOf[T <: BaseModule : TypeTag](parent: Hierarchy[BaseModule]): Seq[Definition[T]] = {
@@ -158,6 +164,8 @@ object Select {
*
* @note IMPORTANT: this function requires summoning a TypeTag[T], which will fail if T is an inner class, i.e.
* a class defined within another class.
+ * @note IMPORTANT: this function ignores type parameters. E.g. allDefinitionsOf[List[Int]] would return List[String].
+ *
* @param root top of the hierarchy to search for definitions of given type
*/
def allDefinitionsOf[T <: BaseModule : TypeTag](root: Hierarchy[BaseModule]): Seq[Definition[T]] = {
@@ -253,7 +261,7 @@ object Select {
}
}
- /** Selects all ios directly contained within given module
+ /** Selects all ios on a given module
* @param module
*/
def ios(module: BaseModule): Seq[Data] = {
@@ -261,6 +269,15 @@ object Select {
module._component.get.asInstanceOf[DefModule].ports.map(_.id)
}
+ /** Selects all ios directly on a given Instance or Definition of a module
+ * @param parent the Definition or Instance to get the IOs of
+ */
+ def ios[T <: BaseModule](parent: Hierarchy[T]): Seq[Data] = {
+ check(parent)
+ implicit val mg = new chisel3.internal.MacroGenerated{}
+ parent._lookup { x => ios(parent.proto) }
+ }
+
/** Selects all SyncReadMems directly contained within given module
* @param module
*/
diff --git a/src/main/scala/chisel3/aop/injecting/InjectingAspect.scala b/src/main/scala/chisel3/aop/injecting/InjectingAspect.scala
index dc7e6487..ed59d4fb 100644
--- a/src/main/scala/chisel3/aop/injecting/InjectingAspect.scala
+++ b/src/main/scala/chisel3/aop/injecting/InjectingAspect.scala
@@ -4,7 +4,6 @@ package chisel3.aop.injecting
import chisel3.{Module, ModuleAspect, RawModule, withClockAndReset}
import chisel3.aop._
-import chisel3.experimental.hierarchy.IsInstantiable
import chisel3.internal.{Builder, DynamicContext}
import chisel3.internal.firrtl.DefModule
import chisel3.stage.DesignAnnotation