Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  IPC::Locker
  Parallel::Forker
  Voneline
General Info
  Papers

Issue #1581

Ranges starting with zero result in unsigned/constant warning

Added by Mitch Hayenga about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Lint
% Done:

0%


Description

Trying to use the inside operator with a range, had multiple functions fail on warnings and realized it was all that had ranges starting with zero. Below is a minimal test case. This was done with the Fedora 31 default verilator (distro released this week).

1 package test_pkg;
  2 
  3 function automatic logic testRangeWorks(input [7:0] byte_in);
  4   return byte_in inside { 8'h00, [8'h01 : 8'h04] };
  5 endfunction
  6 
  7 function automatic logic testRangeFails(input [7:0] byte_in);
  8   return byte_in inside { [8'h00 : 8'h04] };
  9 endfunction
 10 
 11 endpackage
*$ verilator --version*
Verilator 4.016 2019-06-16 rev UNKNOWN_REV

*$ verilator --lint-only -sv test_pkg.sv* 
%Warning-UNSIGNED: test_pkg.sv:8: Comparison is constant due to unsigned arithmetic
                   ... Use "/* verilator lint_off UNSIGNED */" and lint_on around source to disable this message.
%Error: Exiting due to 1 warning(s)
%Error: Command Failed /usr/bin/verilator_bin --lint-only -sv test_pkg.sv

History

#1 Updated by Mitch Hayenga about 1 month ago

Note: It also seems to have a range issue issue if the range extends to the end of the range (8'hff). Works if I split it and make it { [8'h40 : 8'hfe], 8'hff }

  7 function automatic logic testRangeAlsoFails(input [7:0] byte_in);
  8   return byte_in inside { [8'h40 : 8'hff] };
  9 endfunction

%Warning-CMPCONST: test_pkg.sv:8: Comparison is constant due to limited range
                   ... Use "/* verilator lint_off CMPCONST */" and lint_on around source to disable this message.

#2 Updated by Wilson Snyder about 1 month ago

  • Category set to Lint
  • Status changed from New to Resolved
  • Assignee set to Wilson Snyder

Thanks for the good report. Verilator internally converts the inside to <= or >=, which normally give those warnings, but obviously pointless to the user.

Fixed in git towards next release 4.022.

#3 Updated by Wilson Snyder about 1 month ago

  • Status changed from Resolved to Closed

In 4.022.

Also available in: Atom