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

Modify ReadyValidIO noenq to set the data payload to DontCare. #902

Merged
merged 2 commits into from
Oct 3, 2018
Merged

Modify ReadyValidIO noenq to set the data payload to DontCare. #902

merged 2 commits into from
Oct 3, 2018

Conversation

stevenmburns
Copy link

Related issue: None

Type of change: other enhancement

Impact: no functional change (probably)

Development Phase: implementation

Release Notes
Modified ReadyValidIO (also used in DecoupledIO) to set the data payload (.bits) to don't care when a no enqueue action (noenq) is called. This will clean up the frequently used idiom:

c.noenq
when( cond) {
  c.enq( data)
}

This currently needs to be written as:

c.noenq
c.bits := DontCare
when( cond) {
  c.enq( data)
}

It is possible that noenq was used like this in some existing code:

c.bits := 47.U
c.noenq
when( cond) {
  c.valid := true.B
}

If this was the case, then the PR will change the behavior of the circuit.
The comment for noenq is:

    /** Indicate no enqueue occurs. Valid is set to false, and bits are
      * connected to an uninitialized wire
      */

so it wasn't supposed to be used this way.

@stevenmburns stevenmburns requested a review from a team as a code owner October 3, 2018 18:30
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 - @ucbjrl @jackkoenig any thoughts?

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.

This was the intent of 72e6c88 in Dec 2016. Looks like it was erroneously removed in c313e13 in Oct 2017, and no one noticed it, probably for the reason you mentioned.

@ucbjrl
Copy link
Contributor

ucbjrl commented Oct 3, 2018

This is the classic trade-off of "intent" vs. "ease of use".

Without the explicit DontCare connection, FIRRTL will issue a warning if bits isn't connected. There could be complicated logic with nested whens where one of the conditions leaves bits unassigned and this will be correctly flagged as an error by FIRRTL.

With the DontCare connection, this error (a missing connection to bits) will no longer be diagnosed by FIRRTL.

@albert-magyar
Copy link
Contributor

albert-magyar commented Oct 3, 2018

I think that connecting a DontCare for a noenq actually does more explicitly align with programmer intent.

Also, the problem with not flagging missing connections is universal for all "default assignment" patterns; a default enq at the top would cause the same problem

@albert-magyar albert-magyar merged commit b87e6cf into chipsalliance:master Oct 3, 2018
@ucbjrl ucbjrl added this to the 3.1.4 milestone Dec 4, 2018
ucbjrl pushed a commit that referenced this pull request Dec 13, 2018
* Modify noenq to set the input wires to DontCare.

(cherry picked from commit b87e6cf)
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