Fatal Error Modelsim Ok Xilinx

Discussion in 'VHDL' started by mreister, Sep 12, 2008.

  1. mreister

    mreister

    Joined:
    Aug 19, 2008
    Messages:
    10
    I am running into a frustrating problem. I have a function that returns x"0000" as the default value and assigns its value to a signal. The files syntax is correct accourding to xilinx, but when i similate the file in modelsim i get a fatal error on the line where the assignment takes place. I have verified through modelsim that it is returning x"0000" so i suspect it has something types being used? Here is my code:


    function get_current_data(channel_selection_data_par : in channel_selection_array;
    channel_output_data_par : in channel_output_array;
    adc_selected_par : in std_logic_vector(6 downto 0))
    return std_logic_vector is
    begin
    -- first determine the current channel that needs to be selected
    for i in 0 to 3 loop
    if ( channel_selection_data_par(conv_integer(i),conv_integer(adc_selected_par)) = '1') then
    -- the channel needed has been found. Now get the data
    return channel_output_data_par(i,conv_integer(adc_selected_par));
    end if;
    end loop;
    return x"0000";
    end function get_current_data;

    The assignment is:

    signal output_reg_buffer : std_logic_vector (31 downto 0);
    output_reg_buffer <= get_current_data(channel_selection_data,channel_output_data,adc_selected);

    If anyone could help i would appreciete it.
     
    mreister, Sep 12, 2008
    #1
    1. Advertising

  2. mreister

    Steff

    Joined:
    Sep 8, 2008
    Messages:
    11
    Hy,

    can you give me the type declarations of the both arrays:

    channel_selection_array and
    channel_output_array

    thanx, Steff
     
    Steff, Sep 12, 2008
    #2
    1. Advertising

  3. mreister

    mreister

    Joined:
    Aug 19, 2008
    Messages:
    10
    type channel_output_array is array (0 to 3,integer range 0 to 6) of std_logic_vector ( 31 downto 0);
    type channel_selection_array is array ( 0 to 3,integer range 0 to 6) of bit;

    Here they are.
     
    mreister, Sep 12, 2008
    #3
  4. mreister

    Steff

    Joined:
    Sep 8, 2008
    Messages:
    11
    hy mreiser,

    one more question:
    Have you ever compiled this code or occures the fatal error at this time?
    (Because your code has compile errors.)

    Here a version of your function without compile errors:

    HTML:
    library ieee;
      use ieee.numeric_std.unsigned;
      use ieee.numeric_std.to_integer;
    
    function get_current_data(channel_selection_data_par : in channel_selection_array;
                              channel_output_data_par    : in channel_output_array;
                              adc_selected_par           : in std_logic_vector(6 downto 0))
    return std_logic_vector is
      variable v_channel_output_data_par : std_logic_vector(31 downto 0);
    begin
      
    -- pragma translate_off
      -- set default
      v_channel_output_data_par := (others => 'X');
      
        if not(is_x(adc_selected_par)) then
    -- pragma translate_on
          -- first determine the current channel that needs to be selected
          for i in 0 to 3 loop
            if (channel_selection_data_par(i, to_integer(unsigned(adc_selected_par))) = '1') then
              -- the channel needed has been found. Now get the data
              v_channel_output_data_par := channel_output_data_par(i, to_integer(unsigned(adc_selected_par)));
            else
              v_channel_output_data_par := (others => '0');
            end if;
          end loop;
    -- pragma translate_off
        end if;
    -- pragma translate_on
      
      -- set return value
      return v_channel_output_data_par;
      
    end function get_current_data;
    
    
    Note: In my opinion its better style having only one return statement.

    Hope I could help you! ;o)

    Steff
     
    Last edited: Sep 15, 2008
    Steff, Sep 15, 2008
    #4
  5. mreister

    mreister

    Joined:
    Aug 19, 2008
    Messages:
    10
    Thanks that worked great.
     
    mreister, Sep 16, 2008
    #5
  6. mreister

    Steff

    Joined:
    Sep 8, 2008
    Messages:
    11
    Your welcome!
     
    Steff, Sep 17, 2008
    #6
    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. David Bishop

    Re: ModelSim 5.7 and xilinx libraries

    David Bishop, Jun 28, 2003, in forum: VHDL
    Replies:
    1
    Views:
    2,189
    Tim Hubberstey
    Jun 28, 2003
  2. Tim Terry
    Replies:
    1
    Views:
    2,076
    Michael Nicklas
    Jul 21, 2003
  3. fpgaengineer
    Replies:
    7
    Views:
    3,763
    Mike Treseler
    Mar 12, 2007
  4. aim9x
    Replies:
    0
    Views:
    1,951
    aim9x
    Apr 10, 2009
  5. vino_TUM
    Replies:
    1
    Views:
    1,387
    vino_TUM
    Nov 25, 2011
Loading...

Share This Page