Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make BaseModule.name lazy #912

Merged
merged 2 commits into from
Oct 28, 2018
Merged

Make BaseModule.name lazy #912

merged 2 commits into from
Oct 28, 2018

Conversation

seldridge
Copy link
Member

@seldridge seldridge commented Oct 25, 2018

Fixes #911

This makes BaseModule.name lazy (previously eager) so that a Module's desiredName can be a function of some property associated with a sub-instance.

Related issue:

Type of change: other enhancement

Impact: no functional change

Development Phase: implementation

Release Notes

  • Make BaseModule.name lazy to enable better name parameterization, e.g., a module name can now be a function of a submodule name

This changes BaseModule.name to be lazy (instead of eager) to enable a
desiredName to be a function of a sub-instance. This includes a test case
showing the new behavior.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
@seldridge seldridge requested a review from a team as a code owner October 25, 2018 17:41
Copy link
Contributor

@edwardcwang edwardcwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me, if everything still passes

Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely an improvement over the status quo so I approve.

Food for thought: It's still possible to get a NullPointerException like in #911 if you ask for name in the Module before it's available (ie. evaluating the lazy val early). Perhaps when evaluating name we should check if desiredName is null and throw a more precise error message?

Error: desiredName of MyModuleClass@1f3d6e4 is null. Perhaps you evaluated "name" before all values accessed by desiredName were available?

@seldridge
Copy link
Member Author

Hmm... I ran this locally and it passed. Poking around...

Good point, @jackkoenig. Let me get a test and include that.

@jackkoenig
Copy link
Contributor

We really need to get the chisel3 Travis/CircleCI testing running

This wraps the evaluation of BaseModule.name in try/catch to look for a
NullPointerException that may result from trying to evaluate desiredName
before it's ready. This catches a test case of using a desiredName that
depends on a later defined eager subinstance.

h/t @jackkoenig

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
@seldridge
Copy link
Member Author

@jackkoenig: Pushed a commit that updates this with your message. This catches the case shown in the test. I've requested you re-review this and make sure that this catches what you were thinking.

The output of a new, excepting testing case is now:

[info]   chisel3.internal.ChiselException: Error: desiredName of chiselTests.NullModuleWrapper is null. Did you evaluate 'name' before all values needed by desiredName were available?

Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@seldridge
Copy link
Member Author

seldridge commented Oct 25, 2018

Ugh... Chisel master is broken with FIRRTL master for StrongEnumSpec and LoadMemoryFromFileSpec... Looking into it.

Edit: Filed chipsalliance/firrtl#922

@seldridge
Copy link
Member Author

retest this please

@seldridge seldridge merged commit 44124f2 into chipsalliance:master Oct 28, 2018
@seldridge seldridge deleted the c911 branch October 28, 2018 15:31
@ucbjrl ucbjrl added this to the 3.1.4 milestone Dec 4, 2018
@azidar azidar mentioned this pull request Mar 20, 2023
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants