function [ CorrFilter, RxSignal, CorrFilterFixPt, RxSignalFixPt] = prm_uvmtb_generator (PulseLocation, SNR)

%#codegen

% Fixed seed initialization for this component's RNG.  RNG management for
% the generated DPI code will be the subject of a later example.
persistent rngInitialized 
if isempty(rngInitialized)
    rngInitialized = true;
    rng(0); 
end

TxLen = 5000;
TxSignal = complex(zeros(TxLen,1));

% Create pulse to detect. (PulseLoc == 0 --> no pulse in received signal.)
PulseLen = 64;
theta = rand(PulseLen,1);
pulse = exp(1i*2*pi*theta);
if PulseLocation > 0
    TxSignal(PulseLocation:PulseLocation+PulseLen-1) = pulse;
end

% Model noise in the transmission channel.
Noise = complex(randn(TxLen,1),randn(TxLen,1));
RxSignal = TxSignal*(double(SNR)) + Noise;

% Scale Rx signal to +/- one
scale1 = max([abs(real(RxSignal)); abs(imag(RxSignal))]);
RxSignal = RxSignal/scale1;

% Create matched filter coefficients
CorrFilter = conj(flip(pulse))/PulseLen;

% Add extra fixed-point outputs for implementation and UVM testbench
CorrFilterFixPt = fi(CorrFilter,true,16,14);
RxSignalFixPt = fi(RxSignal,true,16,14);

% Plot
figure(1)
subplot(411); plot(real(TxSignal)); title('Tx Signal (real)');
subplot(412); plot(real(RxSignal)); title('Rx Signal (real)');

end
