Forum Discussion

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

Model sim testbench

Hello,

I have a test bench that simulate a 32bit data bus interfacing my fpga.

I would like my test bench to be able to inject data to fpga from a file.

so, testbench will read data from a file and transmit it to the fpga entity.

my code is in vhdl.

Does anybody know how to do that?

thanks

5 Replies

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

    You cannot transmit data to the FPGA from the simulator. You will need to build a link for that, like via RS232

    nless you're just trying to test your design in the simulator and do file IO for simulation purposes (not on real hardware)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I am just trying to test my design in the modelsim simulator.

    I have this code in my test bench, the code increment data and drive it to my design.

    while ( cnt_loop < 256 ) loop

    data_sig <= data_sig + '1' ;

    usb_data_out <=usb_data_out +'1';

    wait for 10 ns;

    cnt_loop := cnt_loop + 1;

    Instead of increment data I would like this test bench to pull data from a file.

    This way I can make any kind of file. its very comfortable.

    Do you know how to do that?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    you can use the std.textio library for file IO. it works very well with text files. There are plenty of tutorials on textio if you google it.

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

    - do you have an example for std.textio commands?

    read,write from a file ?

    - where sould I place this file?