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

Improve quality of code generation for UInt.-% #961

Merged
merged 1 commit into from
Dec 11, 2018
Merged

Improve quality of code generation for UInt.-% #961

merged 1 commit into from
Dec 11, 2018

Conversation

aswaterman
Copy link
Member

@aswaterman aswaterman commented Dec 11, 2018

Emit it as

tail(sub(x, y), 1)

rather than

tail(asUInt(sub(x, y)), 1)

This is semantically equivalent, but gets rid of a bunch of Firrtl text. It also gets rid of a bunch of Verilog, because Firrtl is capable of pattern-matching the new expression into SubWrap. The effect is that we now get

wire [4:0] in;
wire [4:0] res;
assign res = 5'h0 - in;

instead of

wire [4:0] in;
wire [5:0] _T_40;
wire [5:0] _T_41;
wire [4:0] res;
assign _T_40 = 5'h0 - in;
assign _T_41 = $unsigned(_T_40);
assign res = _T_41[4:0];

Type of change: other enhancement

Impact: no functional change

Development Phase: implementation

Release Notes
Improved code generation for modular UInt subtraction.

This is semantically equivalent, but gets rid of a bunch of Firrtl text.
It also gets rid of a bunch of Verilog, because Firrtl is capable of
pattern-matching the new expression into SubWrap.  The effect is that
we now get

    wire [4:0] in;
    wire [4:0] res;
    assign res = 5'h0 - in;

instead of

    wire [4:0] in;
    wire [5:0] _T_40;
    wire [5:0] _T_41;
    wire [4:0] res;
    assign _T_40 = 5'h0 - in;
    assign _T_41 = $unsigned(_T_40);
    assign res = _T_41[4:0];
@aswaterman aswaterman requested a review from a team as a code owner December 11, 2018 22:18
@aswaterman aswaterman changed the title Emit UInt.-% as tail(sub(x,y),1), rather than tail(asUInt(sub(x,y)),1) Improve quality of code generation for UInt.-% Dec 11, 2018
Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

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

lgtm

@seldridge seldridge merged commit 9ce6d7d into master Dec 11, 2018
@aswaterman aswaterman deleted the subwrap branch December 11, 2018 22:49
jackkoenig pushed a commit that referenced this pull request Feb 28, 2023
* Seal Direction trait

* Add WRef factories for ports and instances
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.

2 participants