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

Support literals cast to aggregates as async reset reg init values #1225

Merged
merged 3 commits into from
Nov 5, 2019

Conversation

jackkoenig
Copy link
Contributor

Accomplished by changing the code gen for casting literals to
aggregates. Rather than connecting the literal to a wire that is then
bit selected from, just bit select from the literal which saves the
creation of an intermediate wire and matches FIRRTL's semantics for
legal async reset initial values.

Turned out to be a very clean implementation, most work (as usual) in the testing.

Related issue: chipsalliance/firrtl#1201

Type of change: bug fix

Impact: API addition? (only in that it fixes a bug)

Development Phase: implementation

Release Notes
Fix bug where literals cast to aggregates could not be used as async reset register initial values.

Accomplished by changing the code gen for casting literals to
aggregates. Rather than connecting the literal to a wire that is then
bit selected from, just bit select from the literal which saves the
creation of an intermediate wire and matches FIRRTL's semantics for
legal async reset initial values.
Copy link
Member

@aswaterman aswaterman left a comment

Choose a reason for hiding this comment

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

I appreciate this approach for its simplicity.

Copy link
Contributor

@ducky64 ducky64 left a comment

Choose a reason for hiding this comment

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

This seems fine as a quickfix for this problem.

But I think there is a larger underlying discussion about how much the frontend should special-case literals, and where functionality is duplicated with FIRRTL, weighing the trade-offs of non-DRY code. The duplication is trivial in this case, so bugs are less likely, but this might not be the last time we need a feature like this...

@johnsbrew
Copy link
Contributor

@jackkoenig regarding your comment on chipsalliance/firrtl#1201 I guess you do not expect to fix the issues raised in #1208 test-cases now but rather wait for an in-depth work about proper constant propagation ?
As far as I understand the current PR does not address the idea of

      val x = WireInit(123.U + 456.U)
      withReset(reset.asAsyncReset)(RegInit(x))

seen as a valid reset value ?

@jackkoenig
Copy link
Contributor Author

@johnsbrew, you are correct that this is not intended to address test cases like 123.U + 456.U as a reset value. I'll continue discussion of the more general issue on chipsalliance/firrtl#1201.

@jackkoenig jackkoenig added this to the 3.2.1 milestone Nov 5, 2019
@jackkoenig
Copy link
Contributor Author

Failing CircleCI will be fixed by #1227

@jackkoenig jackkoenig merged commit 92d88ff into master Nov 5, 2019
@jackkoenig jackkoenig deleted the async-reset-lit-cast-to-aggregate branch November 5, 2019 21:41
@azidar
Copy link
Contributor

azidar commented Nov 23, 2019

@Mergifyio backport 3.2.x

mergify bot pushed a commit that referenced this pull request Nov 23, 2019
…1225)

Accomplished by changing the code gen for casting literals to
aggregates. Rather than connecting the literal to a wire that is then
bit selected from, just bit select from the literal which saves the
creation of an intermediate wire and matches FIRRTL's semantics for
legal async reset initial values.

(cherry picked from commit 92d88ff)
@mergify
Copy link
Contributor

mergify bot commented Nov 23, 2019

Command backport 3.2.x: success

Backports have been created
The following pull requests have been created:

Hey, we reacted but our real name is @Mergifyio

mergify bot added a commit that referenced this pull request Nov 23, 2019
…1225) (#1247)

Accomplished by changing the code gen for casting literals to
aggregates. Rather than connecting the literal to a wire that is then
bit selected from, just bit select from the literal which saves the
creation of an intermediate wire and matches FIRRTL's semantics for
legal async reset initial values.

(cherry picked from commit 92d88ff)
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.

5 participants