Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Fix cat of zero-width SInt #2116

Merged
merged 1 commit into from
Mar 14, 2021
Merged

Fix cat of zero-width SInt #2116

merged 1 commit into from
Mar 14, 2021

Conversation

jackkoenig
Copy link
Contributor

@jackkoenig jackkoenig commented Mar 13, 2021

Previously, concatenating two SInts where one is of zero-width would
return the non-zero-width SInt. This is incorrect because the output of
Cat should be of type UInt. Now the ZeroWidth transform will introduce a
cast when removing a Cat when the argument type is non-UInt.

Fixes #2096

h/t @drom for finding the issue and h/t @seldridge for identifying the cause.

For the input in #2096 we don't actually emit the expected behavior because we also constant propagate the register, so the result is:

module top_mod(
  input         clock,
  input         reset,
  input  [10:0] inp_e,
  output        tmp15
);
  assign tmp15 = 1'h0;
endmodule

Contributor Checklist

  • [NA] Did you add Scaladoc to every public function/method?
  • [NA] Did you update the FIRRTL spec to include every new feature/behavior?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you state the API impact?
  • Did you specify the code generation impact?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • bug fix

API Impact

No impact

Backend Code Generation Impact

No impact

Desired Merge Strategy

  • Squash

Release Notes

Fix bug in zero-width handling when the type of an SInt concatenated with a zero-width SInt could be incorrectly interpreted as an SInt (instead of a UInt) resulting in incorrect constant propagation.

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (1.2.x, 1.3.0, 1.4.0) ?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you mark as Please Merge?

@jackkoenig jackkoenig added this to the 1.2.x milestone Mar 13, 2021
Previously, concatenating two SInts where one is of zero-width would
return the non-zero-width SInt. This is incorrect because the output of
Cat should be of type UInt. Now the ZeroWidth transform will introduce a
cast when removing a Cat when the argument type is non-UInt.
@jackkoenig jackkoenig added the Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI. label Mar 14, 2021
@mergify mergify bot merged commit fd55c51 into master Mar 14, 2021
mergify bot pushed a commit that referenced this pull request Mar 14, 2021
Previously, concatenating two SInts where one is of zero-width would
return the non-zero-width SInt. This is incorrect because the output of
Cat should be of type UInt. Now the ZeroWidth transform will introduce a
cast when removing a Cat when the argument type is non-UInt.

(cherry picked from commit fd55c51)

# Conflicts:
#	src/main/scala/firrtl/passes/ZeroWidth.scala
mergify bot pushed a commit that referenced this pull request Mar 14, 2021
Previously, concatenating two SInts where one is of zero-width would
return the non-zero-width SInt. This is incorrect because the output of
Cat should be of type UInt. Now the ZeroWidth transform will introduce a
cast when removing a Cat when the argument type is non-UInt.

(cherry picked from commit fd55c51)

# Conflicts:
#	src/main/scala/firrtl/passes/ZeroWidth.scala
mergify bot pushed a commit that referenced this pull request Mar 14, 2021
Previously, concatenating two SInts where one is of zero-width would
return the non-zero-width SInt. This is incorrect because the output of
Cat should be of type UInt. Now the ZeroWidth transform will introduce a
cast when removing a Cat when the argument type is non-UInt.

(cherry picked from commit fd55c51)
@mergify mergify bot added the Backported This PR has been backported to marked stable branch label Mar 14, 2021
mergify bot added a commit that referenced this pull request Mar 14, 2021
Previously, concatenating two SInts where one is of zero-width would
return the non-zero-width SInt. This is incorrect because the output of
Cat should be of type UInt. Now the ZeroWidth transform will introduce a
cast when removing a Cat when the argument type is non-UInt.

(cherry picked from commit fd55c51)

Co-authored-by: Jack Koenig <koenig@sifive.com>
mergify bot added a commit that referenced this pull request Mar 14, 2021
* Fix cat of zero-width SInt (#2116)

Previously, concatenating two SInts where one is of zero-width would
return the non-zero-width SInt. This is incorrect because the output of
Cat should be of type UInt. Now the ZeroWidth transform will introduce a
cast when removing a Cat when the argument type is non-UInt.

(cherry picked from commit fd55c51)

# Conflicts:
#	src/main/scala/firrtl/passes/ZeroWidth.scala

* Fix merge conflicts

Co-authored-by: Jack Koenig <koenig@sifive.com>
mergify bot added a commit that referenced this pull request Mar 14, 2021
* Fix cat of zero-width SInt (#2116)

Previously, concatenating two SInts where one is of zero-width would
return the non-zero-width SInt. This is incorrect because the output of
Cat should be of type UInt. Now the ZeroWidth transform will introduce a
cast when removing a Cat when the argument type is non-UInt.

(cherry picked from commit fd55c51)

# Conflicts:
#	src/main/scala/firrtl/passes/ZeroWidth.scala

* Fix merge conflicts

Co-authored-by: Jack Koenig <koenig@sifive.com>
@jackkoenig jackkoenig deleted the fix-zero-width-sint-cat branch March 26, 2021 23:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Backported This PR has been backported to marked stable branch 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.

(cat / gt) mismatch
2 participants