Archived
31 lines
852 B
Matlab
31 lines
852 B
Matlab
clc; clear; close all;
|
|
|
|
% parameters
|
|
fs1 = 48e6; % sample rate 1
|
|
fs2 = 122.88e6; % sample rate 2
|
|
ratio_up = fs2/gcd(fs1,fs2); % upsample ratio
|
|
ratio_dn = fs1/gcd(fs1,fs2); % downsample ratio
|
|
interp = 8; % interpolation factor
|
|
sumbol_num = 16;
|
|
|
|
% standard pn sequence
|
|
pn_seq = comm.PNSequence('Polynomial','x^7+x^6+1', ...
|
|
'InitialConditions',[zeros(1,6),1],'SamplesPerFrame',2^7-1);
|
|
PRBS7 = pn_seq();
|
|
PRBS7_polar = 1-2*[PRBS7;0];
|
|
|
|
% square shaping
|
|
data_fs1 = kron(repmat(PRBS7_polar,sumbol_num,1),ones(interp,1));
|
|
|
|
% upsample
|
|
data_fs1_up = upsample(data_fs1,ratio_up);
|
|
|
|
% anti-aliasing filter
|
|
fir = fir1(1024,6e6/48e6/max(ratio_up,ratio_dn)*2*pi,'low');
|
|
|
|
% filtering & downsample
|
|
data_fs2 = downsample(conv(data_fs1_up,fir,'same'),ratio_dn);
|
|
|
|
% quantize & export fir coefficients
|
|
coe_gen(round(fir/max(abs(fir))*(2^15-1)),'lpf_125k.coe','filter');
|