Clear Filters
Clear Filters

How to pass complex double value of array in the workspace to "HDL FFT block-DSP HDL toolbox block" to generate HDL code

3 views (last 30 days)
script:
FFT_OUTPUT = fft(ARRAY);% TAKE FFT FOR THE SAMPLES
worspace:
what are the blocks shoulb be added before the FFT block prior to pass the complex double (fixed point value?)

Accepted Answer

Bharath Venkataraman
Bharath Venkataraman on 14 Jul 2023
I assume the data you are showing is for a 512 point FFT and you have 20 frames of data.
I would first serialize this data using reshape the data:
ARRAY2 = ARRAY(:);
Check to make sure that ARRAY2(1:10) has the right order of data you expect to send in to the FFT.
The attached model uses the Signal From Workspace block to get the data into the Simulink model and uses the data type conversion block to convert it to fixed point before feeding it to the FFT block. I have the set teh input valid to be true all the time - this is something you can modify if needed.
The sample time for the Signal From Workspace is set to 1sec, so I run the model 512*20 seconds to get the 20 frames of data in. Because of the FFT latency, you will get about 18-19 frames of data out. To get all the 20 frames out, you can add another 600 seconds to the Stop Time.
Hope this helps,
Bharath
  16 Comments
Fayaz
Fayaz on 25 Jul 2023
Edited: Fayaz on 30 Jul 2023
% array = sin(0:2*pi/128:2*pi-2*pi/128); % 1x128 array
% array1 = repmat(array,1,4); % 1x512
array1 = fi(ARRAY,1,18,16); % fixed point
array2 = array1(:);
% Behavioral FFT
fft_out1 = fft(double(array1));
fft_out2 = fft_out1(:);
% Run HDL FFT model
open_system("FFTHDL_model.slx")
sim("FFTHDL_model.slx")
% Get output of HDLFFT model
hdlfft_data = squeeze(logsout.getElement('fft_data_out').Values.Data);
hdlfft_valid = squeeze(logsout.getElement('fft_vld_out').Values.Data);
hdlfft_valid_data = hdlfft_data(hdlfft_valid);
% Difference between HDL and behavioral output
last_idx = 10240;
fft_diff = fft_out2(1:last_idx)-hdlfft_valid_data(1:last_idx);
fprintf("Max real diff is %f\n", max(real(fft_diff)));
fprintf("Max imag diff is %f\n", max(imag(fft_diff)));
fft_diff = fft_out2(1:last_idx)-hdlfft_valid_data(1:last_idx);
in the above line you are calculating the difference etween 'fft_out2' which is doubel precision floating point value and 'hdlfft_valid_data' is fixed point value. Is that correct, two diffenret data types are there, isnt it?
please consider this ........................................
Fayaz
Fayaz on 25 Jul 2023
#############SIR ANOTHER HUGE HELP SIR.................
Sir,you are the only one responding my questions and helping me. You have given me guidance for the "NCO" opration process to make it work, but still i have confusion and not able to get the correct block system for that case of frequency shifting. I studied and tried up with applying "LUT-look up table". I dont know it is using a LUT is correct or not for the process, according the MATLAB script of frequency shifting,
fs_shift1 = 4;
fs_u = 30.72;
Reverse_NCO_out_20 = combined_carrier_shifted_20.*exp(-1i*2*pi*fs_shift1/fs_u*(1:length(combined_carrier_shifted_20)));
the length of "combined_carrier_shifted_20" is multiplied with phase, so in that case do we have to add a LUT? i dont know.
Sir im in the around the corner of submission of my undergraduate project and as im an undergraduate, have lack of knowledge about the MATLAB and not interacted much with it, not aware of advance things in MATALB because started use it for the final year project only. Its difficult to get good practice and knowledge within a short period with those high technical base documents available in matlab and cources are too expensive. So, sir kindly request you to consider and i would be much more grateful to you

Sign in to comment.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!