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 Counter emit valid FIRRTL #1408

Merged
merged 1 commit into from
Apr 10, 2020
Merged

Make Counter emit valid FIRRTL #1408

merged 1 commit into from
Apr 10, 2020

Conversation

jackkoenig
Copy link
Contributor

@jackkoenig jackkoenig commented Apr 10, 2020

Remove var from object Counter.apply, using a Wire instead. Also improve
some ScalaDoc and the class Counter require message.

EDIT: At @seldridge's suggestion, here is a more minimal fix that doesn't mess with the API of class Counter.inc()

The one thing I want to highlight:

-// This if-guard maintains older behavior for wrap when n == 1
-val wrap = if (n > 1) c.inc(cond) else cond

As the comment says, if we did just c.inc(cond), it changes the behavior for n == 1 to return true.B rather than cond.

Related issue:

Type of change: bug fix

Impact: API addition (no impact on existing code)

Development Phase: implementation

Release Notes

  • Fix bug where chisel3.util.Counter emitted illegal FIRRTL

@jackkoenig jackkoenig requested a review from a team as a code owner April 10, 2020 18:43
// in a when statement, but still needed to refer to the final value returned by
// c.inc() so we could return cond && wrap. Unless you really, really know what
// you are doing, IGNORE THIS CODE!!!!!
var wrap: Bool = null
Copy link
Member

Choose a reason for hiding this comment

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

mea culpa, mea culpa, mea maxima culpa

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove var from object Counter.apply, using a Wire instead. Also improve
some ScalaDoc and the class Counter require message.
@jackkoenig
Copy link
Contributor Author

This fix is also backportable now

@seldridge seldridge added the Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI. label Apr 10, 2020
@mergify mergify bot merged commit a39d0e1 into master Apr 10, 2020
mergify bot pushed a commit that referenced this pull request Apr 10, 2020
Remove var from object Counter.apply, using a Wire instead. Also improve
some ScalaDoc and the class Counter require message.

(cherry picked from commit a39d0e1)
@mergify mergify bot added the Backported This PR has been backported label Apr 10, 2020
mergify bot added a commit that referenced this pull request Apr 10, 2020
Remove var from object Counter.apply, using a Wire instead. Also improve
some ScalaDoc and the class Counter require message.

(cherry picked from commit a39d0e1)

Co-authored-by: Jack Koenig <koenig@sifive.com>
@jackkoenig jackkoenig deleted the fix-counter branch April 10, 2020 21:46
albert-magyar added a commit to chipsalliance/firrtl that referenced this pull request Apr 14, 2020
albert-magyar added a commit to chipsalliance/firrtl that referenced this pull request Apr 14, 2020
albert-magyar added a commit to chipsalliance/firrtl that referenced this pull request Jul 22, 2020
albert-magyar added a commit to chipsalliance/firrtl that referenced this pull request Jul 27, 2020
albert-magyar added a commit to chipsalliance/firrtl that referenced this pull request Jul 27, 2020
jackkoenig pushed a commit that referenced this pull request Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported This PR has been backported Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants