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

3 次查看(过去 30 天)
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?)

采纳的回答

Bharath Venkataraman
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 个评论
Fayaz
Fayaz 2023-7-25
编辑:Fayaz 2023-7-30
% 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 2023-7-25
#############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

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by