When I try to synthesize the following Verilog code using Xilinx XST, I get the error, "Unsupported real constant". If I try wrapping that expression in an $rtoi function, XST gives a different error: "Unsupported System Function Call".
Using the Xilinx synthesis tools, is it possible to cast a real constant to an integer constant? If so, how?
module example(clk, n_rst, tick, done);
parameter CLOCK_HZ = 50_000_000;
parameter BAUD_RATE = 3_000_000;
input clk, n_rst;
output reg tick, done;
reg [31:0] counter;
always @(posedge clk, negedge n_rst) begin
if (!n_rst) begin
counter <= 32'h00000000;
tick <= 0;
done <= 0;
end
else if (counter == (0.5*CLOCK_HZ/BAUD_RATE) || // ERROR:Xst:850 - Unsupported real constant
counter == (1.5*CLOCK_HZ/BAUD_RATE) || // ERROR:Xst:850 - Unsupported real constant
counter == (2.5*CLOCK_HZ/BAUD_RATE) || // ERROR:Xst:850 - Unsupported real constant
counter == (3.5*CLOCK_HZ/BAUD_RATE) || // ERROR:Xst:850 - Unsupported real constant
counter == (4.5*CLOCK_HZ/BAUD_RATE) || // ERROR:Xst:850 - Unsupported real constant
counter == (5.5*CLOCK_HZ/BAUD_RATE) || // ERROR:Xst:850 - Unsupported real constant
counter == (6.5*CLOCK_HZ/BAUD_RATE) || // ERROR:Xst:850 - Unsupported real constant
counter == (7.5*CLOCK_HZ/BAUD_RATE) || // ERROR:Xst:850 - Unsupported real constant
counter == (8.5*CLOCK_HZ/BAUD_RATE) || // ERROR:Xst:850 - Unsupported real constant
counter == (9.5*CLOCK_HZ/BAUD_RATE)) // ERROR:Xst:850 - Unsupported real constant
begin
counter <= counter + 1;
tick <= 1;
done <= 0;
end
else if (counter == 10*CLOCK_HZ/BAUD_RATE) begin
counter <= 32'h00000000;
tick <= 0;
done <= 1;
end
else begin
counter <= counter + 1;
tick <= 0;
done <= 0;
end
end
endmodule