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

Enum value not made sized when enum sized #1442

Closed
veripoolbot opened this issue May 16, 2019 · 5 comments
Closed

Enum value not made sized when enum sized #1442

veripoolbot opened this issue May 16, 2019 · 5 comments
Assignees

Comments

@veripoolbot
Copy link

@veripoolbot veripoolbot commented May 16, 2019


Author Name: Dan Petrisko (@dpetrisko)
Original Redmine Issue: 1442 from https://www.veripool.org

Original Assignee: Wilson Snyder (@wsnyder)


typedef enum logic[2:0] {P=0, W, E, N, S} Dirs;

module test;

  localparam LEN = 3;
  localparam COL = 4;
  localparam [59:0] SEQ = {LEN'(N), LEN'(E), LEN'(W), LEN'(P)
                    ,LEN'(S), LEN'(E), LEN'(W), LEN'(P)
                    ,LEN'(S), LEN'(N), LEN'(W), LEN'(P)
                    ,LEN'(S), LEN'(N), LEN'(E), LEN'(P)
                    ,LEN'(S), LEN'(N), LEN'(E), LEN'(W)};

endmodule

$ verilator --lint-only test.v 
%Warning-WIDTHCONCAT: test.v:8: Unsized numbers/parameters not allowed in concatenations.
%Warning-WIDTHCONCAT: Use "/* verilator lint_off WIDTHCONCAT */" and lint_on around source to disable this message.
%Warning-WIDTHCONCAT: test.v:9: Unsized numbers/parameters not allowed in concatenations.
%Warning-WIDTHCONCAT: test.v:10: Unsized numbers/parameters not allowed in concatenations.
%Warning-WIDTHCONCAT: test.v:11: Unsized numbers/parameters not allowed in concatenations.
%Warning-WIDTHCONCAT: test.v:12: Unsized numbers/parameters not allowed in concatenations.
%Warning-WIDTHCONCAT: test.v:8: Unsized numbers/parameters not allowed in replications.
%Error: Exiting due to 6 warning(s)
%Error: Command Failed /usr/bin/verilator_bin --lint-only test.v

The fix is to explictly size the enum value. But it seems like the typedef should take care of this
typedef enum logic[2:0] {P=3'd0, W, E, N, S} Dirs;

@veripoolbot

This comment has been minimized.

Copy link
Author

@veripoolbot veripoolbot commented May 16, 2019


Original Redmine Comment
Author Name: Dan Petrisko (@dpetrisko)
Original Date: 2019-05-16T00:48:57Z


$ verilator --lint-only test.v

%Warning-WIDTHCONCAT: test.v:8:

Unsized numbers/parameters not allowed in concatenations.

%Warning-WIDTHCONCAT: Use "/* verilator lint_off WIDTHCONCAT */" and lint_on around source to disable this message.

%Warning-WIDTHCONCAT: test.v:9: Unsized numbers/parameters not allowed in concatenations.

%Warning-WIDTHCONCAT: test.v:10: Unsized numbers/parameters not allowed in concatenations.

%Warning-WIDTHCONCAT: test.v:11: Unsized numbers/parameters not allowed in concatenations.

%Warning-WIDTHCONCAT: test.v:12: Unsized numbers/parameters not allowed in concatenations.

%Warning-WIDTHCONCAT: test.v:8: Unsized numbers/parameters not allowed in replications.

%Error: Exiting due to 6 warning(s) %Error: Command Failed /usr/bin/verilator_bin --lint-only test.v

The fix is to explictly size the enum value. But it seems like the typedef should take care of this

typedef enum logic[2:0] {P=3'd0, W, E, N, S} Dirs;

@veripoolbot

This comment has been minimized.

Copy link
Author

@veripoolbot veripoolbot commented May 16, 2019


Original Redmine Comment
Author Name: Dan Petrisko (@dpetrisko)
Original Date: 2019-05-16T00:50:11Z


Verilator 4.015 devel rev UNKNOWN_REV

@veripoolbot

This comment has been minimized.

Copy link
Author

@veripoolbot veripoolbot commented May 16, 2019


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-05-16T01:44:18Z


I suspect you added the LEN casts to try to work around this, but note they are unnecessary to show the problem, which can simply be seen with

typedef enum logic [2:0] {P=0};
localparam [5:0] SEQ = {P, P};

What is happening is the assignment of P to 0 is seen as unsized because the zero is unsized. Indeed if you use P=3'b0 it works. This is an unfortunate side effect of trying not to give WIDTH warnings when a user does "enum { P=0 }" then uses P in a context that is looking for only a few bit wide number (versus 32 bits wide).

Requires some experiments as how to fix this without adding those unfortunate WIDTH warnings.

@veripoolbot

This comment has been minimized.

Copy link
Author

@veripoolbot veripoolbot commented Jul 6, 2019


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-07-06T20:27:54Z


Fixed in git towards 4.018.

I tried a few alternatives to preserve the behavior I thought was best for WIDTH warnings but ended up not finding anything that seemed consistent and didn't break this case (which seemed worse).

@veripoolbot

This comment has been minimized.

Copy link
Author

@veripoolbot veripoolbot commented Aug 29, 2019


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-08-29T23:14:39Z


In 4.018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.