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

Use firrtl elses in elsewhen/otherwise case emission #510

Merged
merged 4 commits into from
Aug 18, 2017

Conversation

albert-magyar
Copy link
Contributor

@albert-magyar albert-magyar commented Feb 15, 2017

This changes Chisel3's firrtl emission to use nested firrtl when and else statements for chisel when, elsewhen, and otherwise blocks.

There is something of a naming confusion with 132b80e, which adds a counter to keep track of the depth of the chisel when "level." This branch keeps track of the firrtl when nesting with a similarly named depth, which does not hold the same value.

The two features could potentially be combined, especially given that Builder.whenDepth is only ever checked for nonzero values.

Tested with chipsalliance/rocket-chip@abe344a, chipsalliance/firrtl@8f3c7d3

@azidar azidar self-assigned this Feb 22, 2017
* false.
*/
final class WhenContext(sourceInfo: SourceInfo, cond: Bool, prevCond: => Bool, block: => Unit) {
final class WhenContext(sourceInfo: SourceInfo, cond: Option[() => Bool], block: => Unit, depth: Int = 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment explaining new WhenContext behavior

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe label depth as firrtlDepth

case mod: DefModule => for (cmd <- mod.commands) {
body ++= newline + emit(cmd, mod)
case mod: DefModule => {
val procMod = mod.copy(commands = processWhens(mod.commands))
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment explaining the post-processing of the whens

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.

Did you follow through with the check that DC QoR is not negatively affected by this change?

@albert-magyar albert-magyar force-pushed the use-elses branch 5 times, most recently from 6fcb327 to 214815d Compare March 1, 2017 21:10
Preprocess chisel3 IR before emission to determing whether
whens have alternatives.
@albert-magyar
Copy link
Contributor Author

chipsalliance/firrtl#601 now transforms the code generated under this PR to have the same expanded mux tree structure as the prior when emission style.

@jackkoenig
Copy link
Contributor

I have run DC with recent rocket-chip + FPU and as far as I can tell, this PR does not cause a QoR regression. Reason why results are different from past experiments is unclear, but I think we should move forward with this. Not only does it enable the invalidate API, it also improves coverage.

@albert-magyar
Copy link
Contributor Author

albert-magyar commented Aug 3, 2017 via email

@jackkoenig
Copy link
Contributor

As is, I just merged this branch into the branch of chisel3 being used by rocket-chip, no changes to firrtl.

@jackkoenig
Copy link
Contributor

There have been lots of changes to rocket-chip in the last few weeks, especially to critical paths. I suspect these changes may have removed the problematic path(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants