function [ CorrFilter, RxSignal, CorrFilterFixPt, RxSignalFixPt ] = hdlv_uvmtb_generator (RandomSeed)

%#codegen

persistent seedInitialized
if isempty(seedInitialized)
    seedInitialized = true;
    if RandomSeed >= 0
        rng(RandomSeed);
    else
        rng('shuffle');
    end
end

% Create pulse to detect
%rng('default');
PulseLen = 64;
theta = rand(PulseLen,1);
pulse = exp(1i*2*pi*theta);

% Insert pulse to Tx signal
%rng('shuffle');
TxLen = 5000;
PulseLoc = randi(TxLen-PulseLen*2);

TxSignal = complex(zeros(TxLen,1));
TxSignal(PulseLoc:PulseLoc+PulseLen-1) = pulse;

% Create Rx signal by adding noise
Noise = complex(randn(TxLen,1),randn(TxLen,1));
RxSignal = TxSignal + 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(311); plot(real(TxSignal)); title('Tx Signal (real)');
subplot(312); plot(real(RxSignal)); title('Rx Signal (real)');

end
