123 lines
2.6 KiB
Matlab
123 lines
2.6 KiB
Matlab
%% Rate setup
|
|
fs = 4096e6;
|
|
Ts = 1/fs;
|
|
|
|
%% Host Sample Time in Simulation
|
|
TsHost = 5e-5;
|
|
|
|
SamplesPerCycle = 16;
|
|
|
|
FPGAClkRate = fs/SamplesPerCycle;
|
|
TsFPGA = 1/FPGAClkRate;
|
|
|
|
%% Channelizer parameters
|
|
|
|
% Number of channels, maximally decimated channelizer M/D=1
|
|
nChan = 128;
|
|
|
|
% Taps per band
|
|
nTapsPerBand = 12;
|
|
|
|
% Create channelizer object
|
|
channelizer = dsp.Channelizer('NumFrequencyBands',nChan,...
|
|
'DecimationFactor',nChan,...
|
|
'NumTapsPerBand',nTapsPerBand);
|
|
% Channelizer coefficients
|
|
channelizerCoeffs = channelizer.coeffs.Numerator;
|
|
|
|
% Channel bandwidth
|
|
chanBW = fs/nChan;
|
|
|
|
% Starting frequency for each channel
|
|
chanFStart = chanBW/2:chanBW:(fs/2-chanBW/2);
|
|
|
|
% Number of frames out of channelzier
|
|
nFrames = nChan/SamplesPerCycle;
|
|
|
|
% Frame size after serializing x2
|
|
frameSize = SamplesPerCycle/2;
|
|
|
|
%% Detection parameters
|
|
|
|
% Moving average window length
|
|
movingAverageWindowLength = 64;
|
|
|
|
% Moving average comparison offset
|
|
movingAverageCompareOffset = 32;
|
|
|
|
% Threshold for ratio of current moving average to offset
|
|
thresholdScale = 500;
|
|
thresholdScaleDT = fixdt(1,18,-6);
|
|
thresholdScaleFi = fi(thresholdScale, thresholdScaleDT);
|
|
|
|
%% Tx signal generator parameters
|
|
|
|
% NCO accumulator word length
|
|
NCOAccumWL = 16;
|
|
|
|
% NCO phase increment scale factor
|
|
NCOIncScale = Ts*2^NCOAccumWL;
|
|
|
|
% NCO phase increments datatype
|
|
NCOIncDT = numerictype(1,NCOAccumWL,0);
|
|
|
|
% NCO counter increment datatype
|
|
NCOCountIncDT = numerictype(1,NCOAccumWL*2,NCOAccumWL);
|
|
|
|
%% Test signal parameters
|
|
|
|
% Pulse width
|
|
pulseWidth = 8e-6;
|
|
|
|
% Pulse start/end frequencies
|
|
pulseStartFreq = 1305e6;
|
|
pulseEndFreqOffset = 15e6;
|
|
|
|
% Number of pulses
|
|
numPulses = 2;
|
|
|
|
% Pulse repetition interval
|
|
PRI = 50e-6;
|
|
|
|
% Output gain
|
|
pulseGenGain = 1;
|
|
|
|
%% Capture parameters
|
|
|
|
% Time to capture after a detection
|
|
captureDuration = 10e-6;
|
|
captureLength = round(captureDuration*chanBW);
|
|
|
|
% Length of capture frame
|
|
% Contains I/Q data plus channel number and two words of timestamp
|
|
captureFrameLength = captureLength+3;
|
|
|
|
% Max number of capture frames in a DMA packet
|
|
captureFramesPerPacket = 50;
|
|
|
|
% Timeout to transfer a DMA packet if number of frames less than max
|
|
capturePacketTimeout = 1e-3;
|
|
|
|
%% DMA parameters
|
|
|
|
% DMA packet length
|
|
DMAPacketLength = captureFrameLength*captureFramesPerPacket;
|
|
DMAPacketSize = captureFrameLength*captureFramesPerPacket;
|
|
|
|
% Number of DMA buffers
|
|
DMANumBuffers = 8;
|
|
|
|
% DMA FIFO depth
|
|
DMAFIFODepth = 4096;
|
|
|
|
%% Software parameters
|
|
|
|
% Signal generator update rate
|
|
TsSW = 0.25;
|
|
|
|
%% Simulation parameters
|
|
|
|
% Sim run time
|
|
% stoptime = PRI*numPulses + 1e-3;
|
|
stoptime = PRI*captureFramesPerPacket + 1e-5;
|