Files
Zcu111ResmReceiver/codegen_frft/fracF_cg.m
canisio edef1dbed3 validation: add checkCounterSamples and verify capture up to 1024 frames on ZCU111
Created checkCounterSamples.m to validate sample continuity, counter wraps,
and frame index progression. Verified counter bypass, sine bypass, and
channelizer modes up to nFrames=1024 across 10 DPWs on ZCU111.
2026-04-27 18:32:31 -03:00

80 lines
1.9 KiB
Matlab

function F = fracF_cg(f, a)
%#codegen
%% fracF_cg Fractional Fourier Transform (FrFT) - codegen-ready version
%
% Author: Canisio Barth
%
% F = fracF_cg(f, a) computes the Fractional Fourier Transform (FrFT)
% of the input signal 'f' for a single transform order 'a'.
%
% This version is adapted for MATLAB Coder and hardware-oriented workflows.
%
% Key characteristics:
% - Fixed input size: [1024 x 1] complex(single)
% - Output size: [512 x 1] complex(single)
% - Assumes input 'f' is already interpolated externally
% - No input validation (assumes valid scalar 'a' in core region)
% - Deterministic execution (no branching, no dynamic allocation)
%
% INPUTS:
% f - [1024 x 1] complex(single)
% a - scalar single
%
% OUTPUTS:
% F - [512 x 1] complex(single)
%
% Notes:
% - Internal FFT size = 2048
% - Designed for code generation and future FPGA mapping
% Fixed sizes
N = 1024;
%N2 = 512;
Nfft = 2048;
% Ensure types
pi_s = single(pi);
% Transform parameter
phi = a * (pi_s / 2);
% Precompute trig terms
tan_half_phi = tan(phi / 2);
sin_phi = sin(phi);
cos_phi = cos(phi);
csc_phi = 1 / sin_phi;
cot_phi = cos_phi / sin_phi;
twoDelta = 2 * sqrt(single(N) / 2);
%% === Chirp A ===
n = single((-N/2:N/2-1).') / twoDelta;
Achirp = exp(-1j * pi_s * (n .* n) * tan_half_phi);
%% Chirp multiplication #1
g = Achirp .* f;
%% === Chirp B ===
m = single((-N:N-1).') / twoDelta;
Bchirp = exp(1j * pi_s * csc_phi .* (m .* m));
%% === Zero-padded buffer ===
g_pad = complex(zeros(Nfft,1,'single'));
g_pad(1:N) = g;
%% === FFT convolution ===
G = ifft( fft(g_pad) .* fft(Bchirp) );
%% Extract valid part and decimate
G_valid = G(N+1:2:end); % [512 x 1]
%% Complex phase constant
Aphi = sqrt(1 - 1j * cot_phi);
%% === Chirp multiplication #2 ===
F = (Aphi / twoDelta) .* G_valid .* Achirp(1:2:end);
end