Problem in synthesizing function

S

sps

Guest
Hello ppl,

I was trying to synthesize this function with XST
It gives the following error...Can anybody suggest some changes
*********************
'Return' statement must be the last statement in a function.
***********************

The Function is :

************************************************************************
function GetCategory (Coef : in std_logic_vector) return integer is
variable Coeff : std_logic_vector(Coef'High downto 0);
begin
if Coef(Coef'High) = '1' then
Coeff := (not Coef) + 1;
else
Coeff := Coef;
end if;
for index in Coeff'range loop
if Coeff(index) = '1' then
return(index + 1);
end if;

end loop;
return 0;
end GetCategory;
**************************************************************************

Thanx
 
sps wrote:

*********************
'Return' statement must be the last statement in a function.
***********************
....
************************************************************************
function GetCategory (Coef : in std_logic_vector) return integer is
variable Coeff : std_logic_vector(Coef'High downto 0);
begin
if Coef(Coef'High) = '1' then
Coeff := (not Coef) + 1;
else
Coeff := Coef;
end if;
for index in Coeff'range loop
if Coeff(index) = '1' then
return(index + 1);
^^^^^^
end if;

end loop;
return 0;
end GetCategory;
**************************************************************************
^There is a return-statement and it is not the last statement of the
function.
-> Use an intermediate variable for the result and return the
intermediate variable at the end.

Ralf
 

Welcome to EDABoard.com

Sponsor

Back
Top