Forum Discussion

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

Compare results between VHDL an MATLAB.

Hi, I need some help:

I implemented the Cordic algorithm in vhdl (to calculate sin and cos) and it works very well, now I have to compare Cordic vhdl results with sin and cos from matlab, what can i do ? I want to obtain the results from cordic vhdl in a text file and after read this text file in matlab and make the comparation in matlab, Please give me an idea or any suggest. I'm using Quartus II.

Thanks.

1 Reply

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

    Use modelsim to simulate the hardware, feed it with inputs that vary from 0 to 360 in 0,1 degree steps, output the values of sin and cos to 2 .txt files (use vhdl.text_io package)

    In Matlab do this:

    in=[0:0,1:360];

    mcos=cos(in);

    msin=sin(in);

    Then read the two vhdl produced text files in Matlab

    something like:

    vsin=read_txt_file('your_hdl_sinfile.txt');

    vcos=read_txt_file('your_hdl_cosfile.txt');

    and compare then with the two arrays mcos and msin

    plot(msin-vsin);

    plot(mcos-vcos);