-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdvbs2.asv
executable file
·64 lines (51 loc) · 2.48 KB
/
dvbs2.asv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function [TEB, nbIncorrectFrames] = dvbs2(modOrd, nbFrame, LDPCRate, roff, EsNo)
%% Parameters
bitPerSymbol = log2(modOrd); % Nombre de bits par symbole
RowInterleave = 21600;
ColumnInterleave = 3;
spanInSymbols = 10;
samplesPerSymbol = 8;
%% BCH encoder
[kBCH, nBCH] = BCHCoeffs(LDPCRate);
BCHEncoder = comm.BCHEncoder(nBCH, kBCH);
%% LDPC encoder
parityCheckMatrix = dvbs2ldpc(LDPCRate);
LDPCEncoder = comm.LDPCEncoder('ParityCheckMatrix', parityCheckMatrix);
%% Modulation
gamma = gamma_dvbs2(LDPCRate, modOrd);
%% shape filter emetter
txfilter = comm.RaisedCosineTransmitFilter('RolloffFactor', roff);
delay = txfilter.FilterSpanInSymbols; % Delay of the filter
%% shape filter receiver
rxfilter = comm.RaisedCosineReceiveFilter('RolloffFactor', roff);
%% LDPC decoder
LDPCDecoder = comm.LDPCDecoder('ParityCheckMatrix', parityCheckMatrix, 'IterationTerminationCondition', 'Parity check satisfied');
%% BCH decoder
BCHDecoder = comm.BCHDecoder(nBCH, kBCH);
%% Error rate
%errorRate = comm.ErrorRate;
nbErrorsFrame = zeros(1, nbFrame;)
%% Simulation
parfor frame = 1:nbFrame
data = randi([0 1], kBCH,1); % Data generation
BCHEncodedData = step(BCHEncoder, data); % BCH encoding
LDPCEncodedData = step(LDPCEncoder, BCHEncodedData); % LDCP encoding
interleavedData = matintrlv(LDPCEncodedData, ColumnInterleave, RowInterleave); % Interleaving
modData = modulation(interleavedData, modOrd, gamma);
modDataZP = [modData; zeros(delay, 1)]; % Zero padding
filteredData = step(txfilter, modDataZP); % Pulse shaping filter
[channelOutput, noiseVar] = AWGNChannel(filteredData, EsNo, txfilter, var(modData));
filteredReceivedData = step(rxfilter, channelOutput); % Adaptated filter
demodulatedData = soft_demod(filteredReceivedData(delay+1:end), modOrd, gamma, noiseVar); % Demapping
deinterleavedData = matintrlv(demodulatedData, RowInterleave, ColumnInterleave); % Deinterleaving
LDPCDecodedData = step(LDPCDecoder, deinterleavedData); % LDPC decoding
BCHDecodedData = step(BCHDecoder, LDPCDecodedData); % BCH decoding
nbErrorsFrame(frame) = sum(data ~= BCHDecodedData);
end
nbIncorrectFrame =
TEB = sum(nbErrorsFrame)/(kBCH*nbFrame);
%% View
%scatterplot(modData)
%scatterplot(filteredReceivedData(delay+1:end))
%fprintf('Error rate = %1.2f\nNumber of errors = %d\n', errorStats(1), errorStats(2))
end