gusucode.com > wlan工具箱matlab源码程序 > wlan/wlan/+wlan/+internal/vhtGetSTSPerUser.m
function y = vhtGetSTSPerUser(paddedData,scramInitBits,mcsTable,chanBW,numOFDMSym,userIdx,numSTS,varargin) %vhtGetSTSPerUser Encode, parse and map bits to create space-time streams % % Note: This is an internal undocumented function and its API and/or % functionality may change in subsequent releases. % % Y = vhtGetSTSPerUser(DATA,SCAM,MCSTABLE,CHANBW,NUMSYM,USERIDX,NUMSTS) % performs scrambling, encoding, stream parsing, segment parsing, % interleaving, constellation mapping and segment deparsing to form % complex 'BCC' encoded symbols representing the space-time stream for a % user. % % Y = vhtGetSTSPerUser(...,CHANNELCODING,NUMSYMMAXINIT,MSTBC) performs % scrambling, encoding, stream parsing, segment parsing, interleaving, % constellation mapping and segment deparsing to form complex 'BCC' or % 'LDPC' encoded symbols representing the space-time stream for a user. % % DATA is the padded PSDU with service bits. % % SCRAM is the scrambler initialization bits. % % MCSTABLE is a structure array containing the rate information for all % users. % % CHANBW is a string specifying the channel bandwidth. % % NUMSYM is the number of OFDM symbols. % % USERIDX is the user index of interest and is used to index into % MCSTABLE. % % NUMSTS is the number of space-time streams for the user. % % CHANNELCODING specifies the coding type as one of 'BCC' or 'LDPC'. The % default is set to 'BCC' encoding. % % NUMSYMMAXINIT is the number of OFDM symbols resulted due to LDPC % encoding as specified in IEEE Std 802.11ac(TM)-2013, Section % 22.3.10.5.5, Eq 22-65. The NUMSYMMAXINIT is the initial maximum number % of symbols without adding any extra symbols due to LDPC. The % NUMSYMMAXINIT input is only required for LDPC. % % MSTBC specifies the space-time block coding in the data field % transmission. The MSTBC of one mean no STBC. The STBC value of two % considers STBC in the calculation of LDPC encoding parameters. The % MSTBC input is only required for LDPC encoding. % Copyright 2016 The MathWorks, Inc. %#codegen narginchk(7,10); if nargin == 7 channelCoding = 'BCC'; else channelCoding = varargin{1}; numSymMaxInit = varargin{2}; mSTBC = varargin{3}; end chanBWMHz = str2double(chanBW(4:end)); numES = mcsTable.NES(userIdx); numSS = mcsTable.Nss(userIdx); rate = mcsTable.Rate(userIdx); numBPSCS = mcsTable.NBPSCS(userIdx); numCBPS = mcsTable.NCBPS(userIdx); numDBPS = mcsTable.NDBPS(userIdx); numSeg = 1 + any(strcmp(chanBW, {'CBW16', 'CBW160'})); numCBPSSI = numCBPS/numSS/numSeg; scrambData = wlan.internal.wlanScramble(paddedData, scramInitBits); if strcmp(channelCoding, 'BCC') % BCC Encoding % Reshape scrambled data as per IEEE Std 802.11ac-2013, Eq. 22-60 % for multiple encoders numTailBits = 6; encodedStreams = reshape(scrambData, numES, []).'; encodedData = zeros(round((size(encodedStreams,1)+numTailBits)/rate), numES, 'int8'); for i = 1:numES % BCC encoding, Section 22.3.10.5.3, IEEE Std 802.11ac-2013 encodedData(:, i) = wlan.internal.wlanBCCEncode([encodedStreams(:, i); ... zeros(numTailBits,1)], rate); end else % LDPC Encoding as specified in IEEE Std 802.11-2012, 802.11ac-2013, % Section 20.3.11.17.5 and Section 22.3.10.5.4 repectively. numPLD = numSymMaxInit*numDBPS; % Number of payload bits, Eq 22-61 cfg = wlan.internal.getLDPCparameters(numDBPS, rate, mSTBC, numPLD, numOFDMSym); encodedData = wlan.internal.wlanLDPCEncode(scrambData, cfg); end % Repetition coding % Repeat encoded data for S1G MCS 10 if (rate==1/2)&&(numDBPS==6) % rate and Ndbps for S1G MCS10 repeatedData = wlan.internal.repetitionForMCS10(encodedData); else repeatedData = encodedData; end % Parse encoded data into streams % Section 22.3.10.6, IEEE Std 802.11ac-2013 streamParsedData = wlan.internal.wlanStreamParser(repeatedData, numSS, numBPSCS); % Segment parsing for 16, 160, 80+80 MHz % Section 22.3.10.7, IEEE Std 802.11ac-2013 parsedData = wlan.internal.wlanSegmentParser(streamParsedData, chanBW, ... numBPSCS, numCBPS, numES, 'Tx'); % Interleaving, constellation mapping and segment deparsing mappedData = complex(zeros(numCBPSSI/numBPSCS, numSS, numSeg)); % [Nsd, Nsym, Nss] ssPerUser = complex(zeros(numCBPSSI/numBPSCS*numSeg, numOFDMSym, numSS)); if strcmp(channelCoding, 'BCC') interleavedData = zeros(numCBPSSI, numSS, numSeg); for i = 1:numOFDMSym for segIdx = 1:numSeg % Frequency segmentation, if needed % Interleaving, Section 22.3.10.8, IEEE Std 802.11ac-2013, % Section 24.3.9.8, IEEE Std P802.11ah/D5.0 interleavedData(:, :, segIdx) = wlan.internal.wlanBCCInterleave( ... parsedData((i-1)*numCBPSSI + (1:numCBPSSI).', :, segIdx), ... 'VHT', numCBPSSI, numBPSCS, chanBWMHz, numSS); % Constellation mapping, Section 22.3.10.9, IEEE Std 802.11ac-2013 mappedData(:, :, segIdx) = wlan.internal.wlanConstellationMapper( ... interleavedData(:, :, segIdx), numBPSCS); end % Frequency deparsing, Section 22.3.10.9.3, IEEE Std 802.11ac-2013 ssPerUser(:,i,:) = reshape(wlan.internal.wlanSegmentDeparser( ... mappedData, chanBW, 'Tx'), [], 1, numSS); end else % LDPC tone mapping index as specified in IEEE 802.11ac-2013, Section % 22.3.10.19.2. mappingIndexLDPC = wlan.internal.getToneMappingIndices(chanBW); for i = 1:numOFDMSym for segIdx = 1:numSeg % Frequency segmentation, if needed % Constellation mapping, Section 22.3.10.9, IEEE Std 802.11ac-2013 mappedData(:, :, segIdx) = wlan.internal.wlanConstellationMapper( ... parsedData((i-1)*numCBPSSI + (1:numCBPSSI).', :, segIdx), numBPSCS); % LDPC tone mapping mappedData(:, :, segIdx) = mappedData(mappingIndexLDPC, :, segIdx); end % Frequency deparsing, Section 22.3.10.9.3, IEEE Std 802.11ac-2013 ssPerUser(:,i,:) = reshape(wlan.internal.wlanSegmentDeparser( ... mappedData, chanBW, 'Tx'), [], 1, numSS); end end % STBC encoding, Section 22.3.10.9.4, IEEE Std 802.11ac-2013 if numSTS>numSS y = wlan.internal.wlanSTBCEncode(ssPerUser, numSTS); else y = ssPerUser; end end