Skip to content

Commit

Permalink
fix: evaluate target lazily in Path
Browse files Browse the repository at this point in the history
At the moment `toTarget` does not work properly with the D/I system,
seeing that we cannot get the instanceName of a module when evaluating
it, and even if we call `toTarget` in `atModuleBodyEnd` we will get the
wrong circuit name since the definition of the module's parent is still
in construction.

In order to construct `Path` properly, we need to defer the evaluation
of `target` to the IR generation time in the `isMember` constructor,
just as the other constructors already do.

Signed-off-by: unlsycn <[email protected]>
  • Loading branch information
unlsycn committed Dec 2, 2024
1 parent e12a1ef commit 2b17841
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/chisel3/properties/Path.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ object Path {

/** Construct a Path from a target
*/
def apply(target: IsMember): Path = apply(target, false)
def apply(target: IsMember, isMemberPath: Boolean): Path = {
def apply(target: => IsMember): Path = apply(target, false)
def apply(target: => IsMember, isMemberPath: Boolean): Path = {
val _isMemberPath = isMemberPath // avoid name shadowing below
new TargetPath {
def toTarget(): IsMember = target
Expand Down

0 comments on commit 2b17841

Please sign in to comment.