diff options
| author | Justin Deters | 2020-08-11 18:28:12 -0500 |
|---|---|---|
| committer | GitHub | 2020-08-11 23:28:12 +0000 |
| commit | e0c805171ddb9707b0f9fe93e5d85ef9cdcab044 (patch) | |
| tree | 8b331390b99204b72c7abfab67351845b685f06c /core/src/main/scala/chisel3/internal/Builder.scala | |
| parent | 3668532fabc4ba4eaf70cf0ad1a55522aa33cdb3 (diff) | |
Bug fix for manipulating submodules in aspects (#1538)
* Fixed the aspect as parent bug in Data and MonoConnect
* refactored and cleaned up finding an aspect parent
* Added aspect fix to the BiConnect class
* added unit test for manipulating submodules via aspects
* Refactored to move determination of proper parent to Builder and made logic simpler in MonoConnect, Data, and BiConnect
* Removed unused function and provided Scaladoc for retrieveParent
Diffstat (limited to 'core/src/main/scala/chisel3/internal/Builder.scala')
| -rw-r--r-- | core/src/main/scala/chisel3/internal/Builder.scala | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/src/main/scala/chisel3/internal/Builder.scala b/core/src/main/scala/chisel3/internal/Builder.scala index 3c6d7290..d05a69f7 100644 --- a/core/src/main/scala/chisel3/internal/Builder.scala +++ b/core/src/main/scala/chisel3/internal/Builder.scala @@ -427,6 +427,28 @@ private[chisel3] object Builder { case Some(dynamicContext) => dynamicContext.aspectModule.get(module) case _ => None } + /** Retrieves the parent of a module based on the elaboration context + * + * @param module the module to get the parent of + * @param context the context the parent should be evaluated in + * @return the parent of the module provided + */ + def retrieveParent(module: BaseModule, context: BaseModule): Option[BaseModule] = { + module._parent match { + case Some(parentModule) => { //if a parent exists investigate, otherwise return None + context match { + case aspect: ModuleAspect => { //if aspect context, do the translation + Builder.aspectModule(parentModule) match { + case Some(parentAspect) => Some(parentAspect) //we've found a translation + case _ => Some(parentModule) //no translation found + } + } //otherwise just return our parent + case _ => Some(parentModule) + } + } + case _ => None + } + } def addAspect(module: BaseModule, aspect: BaseModule): Unit = { dynamicContext.aspectModule += ((module, aspect)) } |
