summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/aop/injecting/InjectingAspect.scala
diff options
context:
space:
mode:
authorAdam Izraelevitz2020-03-02 10:51:51 -0800
committerGitHub2020-03-02 18:51:51 +0000
commit1a4e0dd65ba3e64268beca8f592bd58d98c434a4 (patch)
treea1ba3415731e88065c00dc6e874d65e113a337ef /src/main/scala/chisel3/aop/injecting/InjectingAspect.scala
parent016939265e15936dc3ba9310d1a79ec1f60176f6 (diff)
Cleanup aspects (#1359)
* Clean up aspects * Refactored InjectingAspect with InjectorAspect * Made AspectLibrary work with objects * Cleaned up code * Apply suggestions from code review * Added tests, removed deprecated newInstance call * Backed out removal of newInstance as exceptions were different * Removed trailing commas
Diffstat (limited to 'src/main/scala/chisel3/aop/injecting/InjectingAspect.scala')
-rw-r--r--src/main/scala/chisel3/aop/injecting/InjectingAspect.scala26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/main/scala/chisel3/aop/injecting/InjectingAspect.scala b/src/main/scala/chisel3/aop/injecting/InjectingAspect.scala
index 00a17d86..ec0b5d28 100644
--- a/src/main/scala/chisel3/aop/injecting/InjectingAspect.scala
+++ b/src/main/scala/chisel3/aop/injecting/InjectingAspect.scala
@@ -12,21 +12,35 @@ import firrtl.stage.RunFirrtlTransformAnnotation
import firrtl.{ir, _}
import scala.collection.mutable
-import scala.reflect.runtime.universe.TypeTag
/** Aspect to inject Chisel code into a module of type M
*
* @param selectRoots Given top-level module, pick the instances of a module to apply the aspect (root module)
* @param injection Function to generate Chisel hardware that will be injected to the end of module m
* Signals in m can be referenced and assigned to as if inside m (yes, it is a bit magical)
- * @param tTag Needed to prevent type-erasure of the top-level module type
* @tparam T Type of top-level module
* @tparam M Type of root module (join point)
*/
-case class InjectingAspect[T <: RawModule,
- M <: RawModule](selectRoots: T => Iterable[M],
- injection: M => Unit
- )(implicit tTag: TypeTag[T]) extends Aspect[T] {
+case class InjectingAspect[T <: RawModule, M <: RawModule](
+ selectRoots: T => Iterable[M],
+ injection: M => Unit
+) extends InjectorAspect[T, M](
+ selectRoots,
+ injection
+)
+
+/** Extend to inject Chisel code into a module of type M
+ *
+ * @param selectRoots Given top-level module, pick the instances of a module to apply the aspect (root module)
+ * @param injection Function to generate Chisel hardware that will be injected to the end of module m
+ * Signals in m can be referenced and assigned to as if inside m (yes, it is a bit magical)
+ * @tparam T Type of top-level module
+ * @tparam M Type of root module (join point)
+ */
+abstract class InjectorAspect[T <: RawModule, M <: RawModule](
+ selectRoots: T => Iterable[M],
+ injection: M => Unit
+) extends Aspect[T] {
final def toAnnotation(top: T): AnnotationSeq = {
toAnnotation(selectRoots(top), top.name)
}