Skip to content
Snippets Groups Projects
Commit 264c45a1 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Use reorder.m to select the tb.subband_i.

parent c6730f1e
No related branches found
No related tags found
No related merge requests found
...@@ -47,20 +47,22 @@ clear all; ...@@ -47,20 +47,22 @@ clear all;
close all; close all;
fig=0; fig=0;
tb.model = 'floating point';
tb.model = 'fixed point';
tb.nof_complex = 2; tb.nof_complex = 2;
tb.nof_subbands = 512; tb.nof_subbands = 512;
tb.bsn_init = 0; tb.bsn_init = 0;
tb.subband_nr = 113; % subband range 0:511, can be fraction tb.subband_nr = 113; % subband range 0:511, can be fraction
%tb.subband_nr = 113.3; %tb.subband_nr = 113.5;
tb.subband_i = round(tb.subband_nr);
tb.subband_fft_size = tb.nof_complex*tb.nof_subbands; % subband filterbank real FFT tb.subband_fft_size = tb.nof_complex*tb.nof_subbands; % subband filterbank real FFT
tb.nof_blocks = 61; tb.nof_blocks = 61;
tb.model = 'floating point';
%tb.model = 'fixed point';
% DP quantization, width 0 is use double, width > 0 is use nof bits for data % DP quantization, width 0 is use double, width > 0 is use nof bits for data
ctrl_wg.agwn_sigma = 0; % AGWN sigma
if strcmp(tb.model, 'floating point') if strcmp(tb.model, 'floating point')
ctrl_wg.data_w = 0; ctrl_wg.data_w = 0;
ctrl_wg.agwn_sigma = 0; % AGWN sigma
%ctrl_wg.agwn_sigma = 0.01; %ctrl_wg.agwn_sigma = 0.01;
ctrl_pfir_subband.coeff_w = 0; ctrl_pfir_subband.coeff_w = 0;
ctrl_pfir_subband.scale_w = 0; ctrl_pfir_subband.scale_w = 0;
...@@ -71,8 +73,9 @@ if strcmp(tb.model, 'floating point') ...@@ -71,8 +73,9 @@ if strcmp(tb.model, 'floating point')
else else
ctrl_wg.data_w = 8; ctrl_wg.data_w = 8;
lsb = 1/2^ctrl_wg.data_w; lsb = 1/2^ctrl_wg.data_w;
%ctrl_wg.agwn_sigma = 2.6*lsb; % AGWN sigma ctrl_wg.agwn_sigma = 0; % AGWN sigma
ctrl_pfir_subband.coeff_w = 9; % bits/coefficient = 1 sign + (w-1) mantissa %ctrl_wg.agwn_sigma = 2.6*lsb;
ctrl_pfir_subband.coeff_w = 16; % bits/coefficient = 1 sign + (w-1) mantissa
ctrl_pfir_subband.scale_w = 1; % scale data by 2^scale before quantization to account for PFIR overshoot ctrl_pfir_subband.scale_w = 1; % scale data by 2^scale before quantization to account for PFIR overshoot
ctrl_pfir_subband.data_w = 16; ctrl_pfir_subband.data_w = 16;
ctrl_pfft_subband.data_w = 16; ctrl_pfft_subband.data_w = 16;
...@@ -111,11 +114,22 @@ ctrl_pfir_subband.r_stop = 0.0001; ...@@ -111,11 +114,22 @@ ctrl_pfir_subband.r_stop = 0.0001;
ctrl_pfir_subband.hp_factor = 1.050; % Adjust channel half power bandwidth ctrl_pfir_subband.hp_factor = 1.050; % Adjust channel half power bandwidth
ctrl_pfir_subband.hp_factor = 1; ctrl_pfir_subband.hp_factor = 1;
ctrl_pfir_subband.BWchan = ctrl_pfir_subband.hp_factor / tb.subband_fft_size; % Channel bandwidth ctrl_pfir_subband.BWchan = ctrl_pfir_subband.hp_factor / tb.subband_fft_size; % Channel bandwidth
ctrl_pfir_subband.config.design = 'fir1'; % 'fir1', 'fircls1', 'lofar_file' ctrl_pfir_subband.config.design = 'lofar file';
ctrl_pfir_subband.config.design = 'fircls1'; ctrl_pfir_subband.config.design = 'fir1';
ctrl_pfir_subband.config.design = 'fircls1'; % 'fir1', 'fircls1', 'lofar file'
ctrl_pfir_subband.config.design_flag = 'trace'; % 'trace' ctrl_pfir_subband.config.design_flag = 'trace'; % 'trace'
ctrl_pfir_subband.config.interpolate = 'interpft'; % 'resample', 'fourier', 'interpft' ctrl_pfir_subband.config.interpolate = 'interpft'; % 'resample', 'fourier', 'interpft'
if strcmp(ctrl_pfir_subband.config.design, 'lofar file')
% Load the quantized FIR coefficients of LOFAR station
ctrl_pfir_subband.downsample_factor = 1024;
ctrl_pfir_subband.nof_taps = 16;
ctrl_pfir_subband.nof_coefficients = ctrl_pfir_subband.downsample_factor*ctrl_pfir_subband.nof_taps;
ctrl_pfir_subband.coeff_w = 16;
coeff = load('data/Coeffs16384Kaiser-quant.dat');
coeff = reshape(coeff, ctrl_pfir_subband.downsample_factor, ctrl_pfir_subband.nof_taps);
else
% Calculate FIR coefficients
coeff = pfir_coeff(ctrl_pfir_subband.downsample_factor,.... coeff = pfir_coeff(ctrl_pfir_subband.downsample_factor,....
ctrl_pfir_subband.nof_taps, ... ctrl_pfir_subband.nof_taps, ...
ctrl_pfir_subband.BWchan, ... ctrl_pfir_subband.BWchan, ...
...@@ -123,6 +137,7 @@ coeff = pfir_coeff(ctrl_pfir_subband.downsample_factor,.... ...@@ -123,6 +137,7 @@ coeff = pfir_coeff(ctrl_pfir_subband.downsample_factor,....
ctrl_pfir_subband.r_stop, ... ctrl_pfir_subband.r_stop, ...
ctrl_pfir_subband.coeff_w, ... ctrl_pfir_subband.coeff_w, ...
ctrl_pfir_subband.config); ctrl_pfir_subband.config);
end
%ctrl_pfir_subband.coeff = fliplr(coeff); %ctrl_pfir_subband.coeff = fliplr(coeff);
%ctrl_pfir_subband.coeff = flipud(coeff); %ctrl_pfir_subband.coeff = flipud(coeff);
...@@ -135,11 +150,17 @@ ctrl_pfft_subband.fft_size = tb.subband_fft_size; ...@@ -135,11 +150,17 @@ ctrl_pfft_subband.fft_size = tb.subband_fft_size;
ctrl_pfft_subband.complex = false; ctrl_pfft_subband.complex = false;
ctrl_pfft_subband.gain = ctrl_pfft_subband.fft_size; ctrl_pfft_subband.gain = ctrl_pfft_subband.fft_size;
% Reorder subband select parameters
ctrl_reorder_subband.select = tb.subband_i + [1 2];
ctrl_reorder_subband.select = tb.subband_i + 1;
ctrl_reorder_subband.block_size = length(ctrl_reorder_subband.select);
% Run the data path processing (one block per row) % Run the data path processing (one block per row)
t_start = cputime; t_start = cputime;
data_dt = zeros(tb.nof_blocks, tb.subband_fft_size); data_dt = zeros(tb.nof_blocks, tb.subband_fft_size);
data_pfir_subband = zeros(tb.nof_blocks, tb.subband_fft_size); data_pfir_subband = zeros(tb.nof_blocks, tb.subband_fft_size);
data_pfft_subband = zeros(tb.nof_blocks, tb.nof_subbands); data_pfft_subband = zeros(tb.nof_blocks, tb.nof_subbands);
data_reorder_subband = zeros(tb.nof_blocks, ctrl_reorder_subband.block_size);
for bi = 1:tb.nof_blocks for bi = 1:tb.nof_blocks
% Control % Control
if ctrl_bsn_source.bsn == 30 if ctrl_bsn_source.bsn == 30
...@@ -152,11 +173,13 @@ for bi = 1:tb.nof_blocks ...@@ -152,11 +173,13 @@ for bi = 1:tb.nof_blocks
[ctrl_bsn_source] = bsn_source(ctrl_bsn_source); [ctrl_bsn_source] = bsn_source(ctrl_bsn_source);
[ctrl_pfir_subband, block_pfir_subband] = pfir( ctrl_pfir_subband, block_dt); [ctrl_pfir_subband, block_pfir_subband] = pfir( ctrl_pfir_subband, block_dt);
[ block_pfft_subband] = pfft( ctrl_pfft_subband, block_pfir_subband); [ block_pfft_subband] = pfft( ctrl_pfft_subband, block_pfir_subband);
[ctrl_reorder_subband, block_reorder_subband] = reorder( ctrl_reorder_subband, block_pfft_subband);
% Capture data at each DP interface % Capture data at each DP interface
data_dt(bi, :) = block_dt; data_dt(bi, :) = block_dt;
data_pfir_subband(bi, :) = block_pfir_subband; data_pfir_subband(bi, :) = block_pfir_subband;
data_pfft_subband(bi, :) = block_pfft_subband; data_pfft_subband(bi, :) = block_pfft_subband;
data_reorder_subband(bi, :) = block_reorder_subband;
end end
t_stop = cputime; t_stop = cputime;
disp(sprintf('Total processing time: %f seconds', t_stop-t_start)); disp(sprintf('Total processing time: %f seconds', t_stop-t_start));
...@@ -178,7 +201,7 @@ xlabel('Time [T bsn]'); ...@@ -178,7 +201,7 @@ xlabel('Time [T bsn]');
ylabel('Voltage'); ylabel('Voltage');
grid on; grid on;
% Plot PFIR transfer function % Plot subband PFIR transfer function
h = ctrl_pfir_subband.coeff; h = ctrl_pfir_subband.coeff;
h = h(:); h = h(:);
NL = ctrl_pfir_subband.nof_coefficients; NL = ctrl_pfir_subband.nof_coefficients;
...@@ -192,18 +215,18 @@ figure(fig); ...@@ -192,18 +215,18 @@ figure(fig);
plot(fx, db(hf_abs)); % db() = 20*log10 for voltage plot(fx, db(hf_abs)); % db() = 20*log10 for voltage
%xlim([-3 3]); %xlim([-3 3]);
grid on; grid on;
title(['FIR filter transfer function for ', ctrl_pfir_subband.config.design]); title(['Subband FIR filter transfer function for ', ctrl_pfir_subband.config.design]);
xlabel('Frequency [channels]'); xlabel('Frequency [channels]');
ylabel('Magnitude [dB]'); ylabel('Magnitude [dB]');
% Plot PFIR output % Plot subband PFIR output
fig=fig+1; fig=fig+1;
figure('position', [300+fig*20 200-fig*20 1000 800]); figure('position', [300+fig*20 200-fig*20 1000 800]);
figure(fig); figure(fig);
data = data_pfir_subband'; data = data_pfir_subband';
plot(ts, data(:)) plot(ts, data(:))
title(sprintf('Subband polyphase FIR filter output - FFT input data (WG subband %6.3f)', tb.subband_nr)); title(sprintf('Subband polyphase FIR filter output - FFT input data (WG subband %6.3f)', tb.subband_nr));
ylim([-1.3 1.3]); ylim([-2 2]); % DT step when tb.subband_nr is .5 causes double range
xlabel('Time [T bsn]'); xlabel('Time [T bsn]');
ylabel('Voltage'); ylabel('Voltage');
grid on; grid on;
...@@ -221,7 +244,7 @@ subplot(2,1,1); ...@@ -221,7 +244,7 @@ subplot(2,1,1);
data = ampl'; data = ampl';
plot(tsub, data(:)) plot(tsub, data(:))
title('Subband data - amplitude'); title('Subband data - amplitude');
xlabel('Time [T bsn]'); xlabel(sprintf('Subband 0:%d at time [T bsn]', tb.nof_subbands-1));
ylabel('Voltage'); ylabel('Voltage');
grid on; grid on;
subplot(2,1,2); subplot(2,1,2);
...@@ -229,20 +252,19 @@ data = phase'; ...@@ -229,20 +252,19 @@ data = phase';
plot(tsub, data(:)) plot(tsub, data(:))
ylim([-180 180]) ylim([-180 180])
title('Subband data - phase'); title('Subband data - phase');
xlabel('Time [T bsn]'); xlabel(sprintf('Subband 0:%d at time [T bsn]', tb.nof_subbands-1));
ylabel('Phase [degrees]'); ylabel('Phase [degrees]');
grid on; grid on;
% Plot phase step due to DT step for the subband that is set in the WG % Plot phase step due to DT step for the subband that is set in the WG
nr = round(tb.subband_nr); phase = angle(data_pfft_subband(:, tb.subband_i + 1))*180/pi;
phase = angle(data_pfft_subband(:, nr+1))*180/pi;
fig=fig+1; fig=fig+1;
figure('position', [300+fig*20 200-fig*20 1000 800]); figure('position', [300+fig*20 200-fig*20 1000 800]);
figure(fig); figure(fig);
plot(tblock, phase, '-o') plot(tblock, phase, '-o')
ylim([-180 180]) ylim([-180 180])
title(sprintf('Subband phase for subband %d in range 0:%d', nr, tb.nof_subbands-1)); title(sprintf('Subband phase for subband %d in range 0:%d', tb.subband_i, tb.nof_subbands-1));
xlabel('Time [T bsn]'); xlabel('Time [T bsn]');
ylabel('Phase [degrees]'); ylabel('Phase [degrees]');
grid on; grid on;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment