% COMMDVBC_INIT Preloads workspace variables for example models commdvbc
% and commdvbc_fixpt.

% Copyright 2008-2019 The MathWorks, Inc.

prmDVBC.bitsPerByte = 8;
prmDVBC.bitsPerMTpl = 6;
prmDVBC.MPEG2DatRateBitPerS = 9.6e6;
prmDVBC.rawMPEG2DataPcktLen = 184;
prmDVBC.MPEG2TrnsprtPcktLen = 188;
prmDVBC.MPEG2TrnsprtFramePer = prmDVBC.bitsPerByte * prmDVBC.MPEG2TrnsprtPcktLen / prmDVBC.MPEG2DatRateBitPerS;
prmDVBC.MPEG2PcktsPerSprFrm = 8;
prmDVBC.MPEG2TrnsSuperFrame = prmDVBC.MPEG2PcktsPerSprFrm * prmDVBC.MPEG2TrnsprtPcktLen;
prmDVBC.PRBSSeqPeriodBytes = prmDVBC.MPEG2TrnsSuperFrame - 1;
prmDVBC.PRBSSeqPeriodBits = prmDVBC.bitsPerByte * prmDVBC.PRBSSeqPeriodBytes;
prmDVBC.RSCodewordLength = 204;
prmDVBC.CableChanFrameLen = prmDVBC.RSCodewordLength * (prmDVBC.bitsPerByte / prmDVBC.bitsPerMTpl);
prmDVBC.CableChanFrmPeriod = prmDVBC.MPEG2TrnsprtFramePer;
prmDVBC.RCosineSampsPerSym = 8;
prmDVBC.CableSymbolPeriod = prmDVBC.CableChanFrmPeriod / (prmDVBC.RCosineSampsPerSym * prmDVBC.CableChanFrameLen);
prmDVBC.RCosineFilterSpan = 16;
prmDVBC.TxRxSymbolSampDelay = prmDVBC.CableChanFrameLen + (2*prmDVBC.RCosineFilterSpan/2); % Two filters each with a group delay of 1/2 filter span
prmDVBC.DeintrlvrAlignDelay = prmDVBC.RSCodewordLength  - (2*prmDVBC.RCosineFilterSpan/2) * (prmDVBC.bitsPerMTpl / prmDVBC.bitsPerByte);
prmDVBC.QAMSymbolMapping = [...
  44 45 41 40 52 54 62 60 46 47 43 42 53 55 63 61 ...
  38 39 35 34 49 51 59 57 36 37 33 32 48 50 58 56 ...
  8 10 2 0 16 17 21 20  9 11 3 1 18 19 23 22 ...
  13 15 7 5 26 27 31 30 12 14 6 4 24 25 29 28 ];
prmDVBC.ConvIntlNumBranches = 12;
prmDVBC.ConvIntlCellDepth = 17;

%%
% Compute pulse shaping filter coefficients for use in Transmitter and
% Receiver
num = rcosdesign(0.15,prmDVBC.RCosineFilterSpan,prmDVBC.RCosineSampsPerSym);

% Compute signal power for EbNo
%
M = 2^prmDVBC.bitsPerMTpl;
constPoints = qammod((0:M-1)', M, prmDVBC.QAMSymbolMapping);
constPower  = mean(abs(constPoints).^2);

sigPower = constPower / prmDVBC.RCosineSampsPerSym;

% [EOF]
