YosysHQ / yosys

Yosys Open SYnthesis Suite
https://yosyshq.net/yosys/
ISC License
3.3k stars 860 forks source link

Feature request: SystemVerilog static casts #2923

Open daglem opened 2 years ago

daglem commented 2 years ago

Verilog 2005 specifies that implicit conversion from real to integer should be done by rounding. yosys does this correctly, however it also generates warnings which cannot be removed (without resorting to $rtoi, which does truncation). E.g.

int i;
i = (2.5 * 3.5);

yields

Warning: converting real value 8.750000e+00 to binary 9.

If SystemVerilog static casts were supported, one could be explicit about the cast, and in this case a warning would not be called for:

int i;
i = int'(2.5 * 3.5);

The same code would then also pass through the Verilator linter.

See also issue #487

daglem commented 2 years ago

Pull request #2179 added support for static cast of size and signedness, but not type.