algofoogle
New Contributor
2 years agoBUG: Verilog 1.0*(2.0**N) const expression evaluates to 0 if N is a localparam
Is it fine to report Quartus Prime Lite bugs here?
I'm using Quartus Prime Version 22.1std.0 Build 915 10/25/2022 SC Lite Edition with no patches. I will try a newer version later.
Given this Verilog code:
localparam N = 12.0; initial begin $display("%f %d", 1.0*(2.0*N), 1.0*(2.0*N)); // Two products. $display("%f %d", 1.0*(2.0**12.0), 1.0*(2.0**12.0)); // Product & power. $display("%f %d", 1.0*(2.0**N), 1.0*(2.0**N)); //BUG! Product & power. $display("%f %d", (2.0**N), (2.0**N)); // Power only. end
...at compile-time the log includes these unexpected results:
Info (10648): Verilog HDL Display System Task info at raybox.v(104): 24.000000 24 Info (10648): Verilog HDL Display System Task info at raybox.v(105): 4096.000000 4096 Info (10648): Verilog HDL Display System Task info at raybox.v(106): 0.000000 0 Info (10648): Verilog HDL Display System Task info at raybox.v(107): 4096.000000 4096
Notice that specifically 1.0*(2.0**N) gives an incorrect result (0) while the others work as expected. This problem also happens if assigning this expression to another localparam, or trying to use it in logic.
I tried other definitions of the localparam, too, including:
localparam real N = 12.0; localparam integer N = 12; localparam [3:0] N = 12;