Problem in synthesizing function

Discussion in 'VHDL' started by sps, Aug 6, 2005.

  1. sps

    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, Aug 6, 2005
    #1
    1. Advertising

  2. 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
     
    Ralf Hildebrandt, Aug 6, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelvin @ Singapore

    Synthesizing a design with RAM.

    Kelvin @ Singapore, Sep 9, 2003, in forum: VHDL
    Replies:
    0
    Views:
    538
    Kelvin @ Singapore
    Sep 9, 2003
  2. Takuon Soho
    Replies:
    5
    Views:
    765
    Charles Bailey
    Mar 9, 2005
  3. Divyang M
    Replies:
    4
    Views:
    734
    Divyang M
    Aug 8, 2005
  4. universeee
    Replies:
    0
    Views:
    493
    universeee
    Nov 9, 2008
  5. amr elhosiny

    problem with synthesizing for loop

    amr elhosiny, Mar 5, 2009, in forum: VHDL
    Replies:
    2
    Views:
    471
    joris
    Mar 6, 2009
Loading...

Share This Page