For a project, i need to take sine samples in MATLAB and somehow i need to call it in Xilinx ISE testbench, so that i can use them for further operations. Please tell me how to do it?

  • 2
    \$\begingroup\$ Your question is not clear! Do you want to use bunch of values from MATLAB on your FPGA(guessing) board? then you can download csv values from MATLAB and store them on your non-volatile memory part of your board! \$\endgroup\$
    – charansai
    Feb 8, 2018 at 18:02
  • \$\begingroup\$ I need some 18 or 19 samples of a sine wave of one full cycle. and somehow i need these values in ISE testbench for simulation purpose, by calling or any other way but directly from Matlab to ISE testbench. \$\endgroup\$
    – dev
    Feb 8, 2018 at 18:09
  • 1
    \$\begingroup\$ See how to run input data file on Isim. \$\endgroup\$
    – Dave Tweed
    Feb 8, 2018 at 19:08

1 Answer 1


You want to create input stimulus in Matlab and use them in your Xilinx ISE simulator. First, you need to put your Matlab data into a file. The easiest way is just to write the data to file line by line. Example:

% Make a 16-bit sin wave
data = floor(2^15*sin(0:0.001:10));

%open the file for writing
file = fopen('my_data.txt','w');
for i=1:length(data)
    fprintf(file,'%d\n', data(i));

Now you need to use that data in VHDL. I have mostly got examples in Verilog, but in VHDL you can use something like this:

How to read a text file using vhdl

Use file_open to open the file:

file_open (file_pointer, "my_data.txt", READ_MODE);

And readline and read to read a line and get its contents:

readline (file_pointer, line_num); 
read (line_num, line_content);

You'd need to cast your number into whatever type you need it as and generate the valids/surrounding signals accordingly.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.