From fddb5943b1d36925a5435d327c3312572e98ca58 Mon Sep 17 00:00:00 2001 From: Adam Izraelevitz Date: Mon, 12 Aug 2019 15:49:42 -0700 Subject: Aspect-Oriented Programming for Chisel (#1077) Added Aspects to Chisel, enabling a mechanism for dependency injection to hardware modules.--- chiselFrontend/src/main/scala/chisel3/internal/Binding.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'chiselFrontend/src/main/scala/chisel3/internal/Binding.scala') diff --git a/chiselFrontend/src/main/scala/chisel3/internal/Binding.scala b/chiselFrontend/src/main/scala/chisel3/internal/Binding.scala index 34de36a3..23e35f5c 100644 --- a/chiselFrontend/src/main/scala/chisel3/internal/Binding.scala +++ b/chiselFrontend/src/main/scala/chisel3/internal/Binding.scala @@ -74,7 +74,15 @@ sealed trait UnconstrainedBinding extends TopBinding { // Location will track where this Module is, and the bound object can be referenced in FIRRTL sealed trait ConstrainedBinding extends TopBinding { def enclosure: BaseModule - def location: Option[BaseModule] = Some(enclosure) + def location: Option[BaseModule] = { + // If an aspect is present, return the aspect module. Otherwise, return the enclosure module + // This allows aspect modules to pretend to be enclosed modules for connectivity checking, + // inside vs outside instance checking, etc. + Builder.aspectModule(enclosure) match { + case None => Some(enclosure) + case Some(aspect) => Some(aspect) + } + } } // A binding representing a data that cannot be (re)assigned to. -- cgit v1.2.3