-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebeeBitGenerator.m
43 lines (31 loc) · 1.39 KB
/
webeeBitGenerator.m
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
function [psdu, scramInit] = webeeBitGenerator(sym, cfgNonHT)
[~, nsym, ~] = size(sym);
mcsTable = wlan.internal.getRateTable(cfgNonHT);
persistent codMtrx;
persistent controlBitIdx;
if isempty(codMtrx) || isempty(controlBitIdx)
[codMtrx, controlBitIdx] = getCodMatrix(mcsTable, sym);
end
% Constellation demapping
qamDemodOut = wlanConstellationDemap(sym, 0, mcsTable.NBPSCS, 'hard');
qamDemodOut = reshape(qamDemodOut, [], 1);
% Deinterleave
deintlvrOut = wlanBCCDeinterleave(qamDemodOut, 'Non-HT', mcsTable.NCBPS);
deintlvrOut = reshape(deintlvrOut, [], nsym);
% Deduce uncode bits based on "coded bits".
decBits = uncodeDeduct(codMtrx, deintlvrOut, controlBitIdx);
decBits = reshape(decBits, [], 1);
% Derive initial state of the scrambler
scramInitBits = [0, 1, 0, 0, 1, 0, 0]'; % Fixed according to WEBee.
% Remove pad and tail bits, and descramble
if all(scramInitBits == 0)
% Scrambler initialization invalid (0), therefore do not descramble
descramDataOut = decBits(1:(16 + 8 * cfgNonHT.PSDULength));
else
descramDataOut = wlanScramble(decBits(1:(16 + 8 * cfgNonHT.PSDULength)), scramInitBits);
end
% Remove the 16 service bits
psdu = descramDataOut(17:end);
% Convert scrambler initialization bits to number
scramInit = bit2int(scramInitBits, length(scramInitBits));
end