From 086c6806708d14ad5144ca064d4c644d0f62592d Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Mon, 7 Nov 2022 18:29:31 +0000 Subject: Add DataMirror.getParent for getting parents of Modules (#2825) (#2833) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit fce8394bb0ddc9ae0d9c6668e034e483bd6b71c5) Co-authored-by: Jack Koenig --- core/src/main/scala/chisel3/Data.scala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/src/main') diff --git a/core/src/main/scala/chisel3/Data.scala b/core/src/main/scala/chisel3/Data.scala index 52cc041c..3af5ade1 100644 --- a/core/src/main/scala/chisel3/Data.scala +++ b/core/src/main/scala/chisel3/Data.scala @@ -265,6 +265,14 @@ package experimental { } } + /** Returns the parent module within which a module instance is instantiated + * + * @note Top-level modules in any given elaboration do not have a parent + * @param target a module instance + * @return the parent of the `target`, if one exists + */ + def getParent(target: BaseModule): Option[BaseModule] = target._parent + // Internal reflection-style APIs, subject to change and removal whenever. object internal { def isSynthesizable(target: Data): Boolean = target.isSynthesizable -- cgit v1.2.3