UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 23370

8.1i - XST error occurs when using constant function in XST: "ERROR:HDLCompilers:303"

Description

Keywords: ISE, HDL, Verilog

When I use a contant function in Verilog with XST, the following error occurs:

"ERROR:HDLCompilers:303"

The following Verilog example triggers this problem:

=================================
function integer APPROX_LOG2(input integer N);
integer i;
begin
i = 0;
while (2**i < N) i = i+1;
APPROX_LOG2 = i;
end
endfunction

// This expression is a CONSTANT FUNCTION call...
localparam COUNTER_WIDTH = APPROX_LOG2(PRESCALE_RATIO-1);

reg [COUNTER_WIDTH-1 : 0] counter;

=================================================

Solution

This issue is fixed in ISE 9.1i or you can work around the issue using the following VHDL code:

========================================
ARCHITECTURE rtl OF supported_ok IS

function APPROX_LOG2(constant N : in integer)
return integer is
variable i : integer;
begin
i := 0;
while (2**i < N) loop
i := i+1;
end loop;
return i;
end function;

-- This expression is a CONSTANT FUNCTION call...
constant COUNTER_WIDTH : integer := APPROX_LOG2(PRESCALE_RATIO-1);

signal counter : unsigned(COUNTER_WIDTH-1 downto 0);

====================================================

AR# 23370
Date Created 09/04/2007
Last Updated 01/08/2009
Status Archive
Type General Article