Problem in synthesizing function

S

sps

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
 
R

Ralf Hildebrandt

sps said:
*********************
'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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top