Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

Importing data into ModelSim

Is it possible to import arbitrary data into ModelSim (Altera web version)?

I would like to evaluate the frequency response of a filter. I don't see how I could generate a signal having a particular frequency within a test bench. Each test frequency would require at least 200 samples.

It would be simple to do if I could read the test data from a file.

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can either read text file or generate data stream directly in testbench.

    Here is example of reading text file:

    
    -- read input stimulus 
    process(reset,clk)
    file file_in : text open read_mode is "filename.txt";
    variable line_in : line;
    variable input_tmp : integer := 0;
    begin
    if(reset = '1')then
      data_in <= (others => '0');
    elsif(rising_edge(clk))then
      if not endfile(file_in)then
         readline(file_in,line_in);
         read(line_in,input_tmp);
         data_in <= std_logic_vector(to_signed(input_tmp,16));
      end if;
    end if;
    end process;
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    if its a sine wave or other mathmatical function, why not write a function for it/

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If he's using VHDL, the ieee.math_real package has them.

    If he's using Verilog.. it's uglier, he has to use PLI or equivalent.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    DSP Builder is a nice tool for this. It automatically converts Matlab stimuli to separate input files and generates the Modelsim testbench.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    if its a sine wave or other mathmatical function, why not write a function for it/

    --- Quote End ---

    I'm using Verilog; is that possible. If so, how?