www.gusucode.com > wlan工具箱matlab源码程序 > wlan/wlan/wlanVHTSIGA.m
function [y, bits] = wlanVHTSIGA(cfgVHT) %WLANVHTSIGA VHT Signal A (VHT-SIG-A) field % % [Y, BITS] = wlanVHTSIGA(CFGVHT) generates the VHT Signal A % (VHT-SIG-A) field time-domain waveform for the VHT transmission format. % % Y is the time-domain VHT-SIG-A field signal. It is a complex matrix of % size Ns-by-Nt, where Ns represents the number of time-domain samples % and Nt represents the number of transmit antennas. % % BITS is the VHT-SIG-A signaling bits. It is an int8-typed, binary column % vector of length 48. % % CFGVHT is the format configuration object of type <a href="matlab:help('wlanVHTConfig')">wlanVHTConfig</a> which % specifies the parameters for the VHT format. % % Example: % % Generate the VHT-SIG-A waveform for a VHT 80 MHz transmission format % % cfgVHT = wlanVHTConfig; % VHT Format configuration % cfgVHT.ChannelBandwidth = 'CBW80'; % Set to 80 MHz % vSigAOut = wlanVHTSIGA(cfgVHT); % % returns a complex output of 640 samples for the two OFDM symbols % % of length 320 samples each. % % See also wlanVHTConfig, wlanLSIG, wlanVHTSTF, wlanVHTSIGARecover. % Copyright 2015-2016 The MathWorks, Inc. %#codegen validateattributes(cfgVHT, {'wlanVHTConfig'}, {'scalar'}, mfilename, ... 'VHT format configuration object'); cfgInfo = validateConfig(cfgVHT, 'SpatialMCSGID'); coder.varsize('channelCoding',[1,4]); channelCoding = getChannelCoding(cfgVHT); % VHT-SIG-A1 structure - Table 22-12, IEEE Std 802.11ac-2013 % BW field switch cfgVHT.ChannelBandwidth case 'CBW20' bw = [0 0]; case 'CBW40' bw = [1 0]; % right-msb orientation case 'CBW80' bw = [0 1]; % right-msb orientation otherwise % 'CBW160', 'CBW80+80' bw = [1 1]; end % STBC, NSTS/Partial AID fields if cfgVHT.NumUsers == 1 STBC = double(cfgVHT.STBC); STSAndPAID = [de2bi(cfgVHT.NumSpaceTimeStreams(1)-1, 3), ... de2bi(cfgVHT.PartialAID, 9)]; else STBC = 0; STSAndPAID = zeros(1, 12); for u = 1:cfgVHT.NumUsers STSAndPAID(3*cfgVHT.UserPositions(u)+(1:3)) = ... de2bi(cfgVHT.NumSpaceTimeStreams(u), 3); end end % Preset TransmitPowerSaveNotAllowed to false TransmitPowerSaveNotAllowed = 0; % Assemble fields with reserved bits vhtsiga1 = int8([bw 1 STBC de2bi(cfgVHT.GroupID, 6), ... STSAndPAID, TransmitPowerSaveNotAllowed 1].'); % VHT-SIG-A2 structure - Table 22-12, IEEE Std 802.11ac-2013 % Guard interval bits if strcmp(cfgVHT.GuardInterval, 'Long') b0_2 = 0; b1_2 = 0; else % Short GI Nsym = cfgInfo.NumDataSymbols; b0_2 = 1; b1_2 = double((mod(Nsym, 10)==9)); end % Channel coding bits % Update b3 for LDPC coding, once enabled if cfgVHT.NumUsers == 1 if strcmp(channelCoding{1}, 'BCC') b2_2 = 0; b3_2 = 0; else % LDPC b2_2 = 1; b3_2 = cfgInfo.ExtraLDPCSymbol; end b2Tob7 = [b2_2; b3_2; de2bi(cfgVHT.MCS(1), 4, 'right-msb').']; else MUCoding = ones(4, 1); for u = 1:cfgVHT.NumUsers MUCoding(cfgVHT.UserPositions(u)+1) = ... double(strcmp(channelCoding{u}, 'LDPC')); end b2Tob7 = [MUCoding(1); cfgInfo.ExtraLDPCSymbol; MUCoding(2:4); 1]; end % Set BEAMFORMED bit b8 = ((cfgVHT.NumUsers == 1) && strcmp(cfgVHT.SpatialMapping, 'Custom') ... && cfgVHT.Beamforming) || (cfgVHT.NumUsers > 1); % Concatenate the first 0-9 bits vhtsiga2_09 = int8([b0_2; b1_2; b2Tob7; b8; 1]); % Generate the CRC crc = wlan.internal.wlanCRCGenerate([vhtsiga1; vhtsiga2_09]); % VHT-SIG-A2 bits vhtsiga2 = [vhtsiga2_09; crc; zeros(6,1,'int8')]; % 24 bits % Concatenate the SIG-A1 and A2 fields together - 48 bits bits = [vhtsiga1; vhtsiga2]; %% Process VHT-SIG-A bits % Get OFDM parameters numTx = cfgVHT.NumTransmitAntennas; cfgOFDM = wlan.internal.wlanGetOFDMConfig(cfgVHT.ChannelBandwidth, ... 'Long', 'Legacy', numTx); FFTLen = cfgOFDM.FFTLength; num20 = FFTLen/64; % Cyclic shift addition % The format is set to OFDM due to legacy mode. The cyclic shift is % applied on each transmit antenna. csh = wlan.internal.getCyclicShiftVal('OFDM', numTx, 20*num20); % Encoding, interleaving, constellation mapping according to Section 18.3.5 phRot = [0 pi/2]; % Rotate only 2nd symbol dataSym = wlan.internal.vhtSIGAEncodeInterleaveMap(bits, phRot); % Add pilot subcarriers, IEEE Std 802.11ac-2013, Eqn 22-28 z = 1; % 2nd and 3rd pilot symbols numSym = 2; pilots = wlan.internal.nonHTPilots(numSym, z); % Pilot insertion according to Section 18.3.5.9, duplication and phase % rotation sym = complex(zeros(FFTLen, numSym)); sym(cfgOFDM.DataIndices,:) = repmat(dataSym, num20, 1); sym(cfgOFDM.PilotIndices,:) = repmat(pilots, num20, 1); SymAll = bsxfun(@times,sym,cfgOFDM.CarrierRotations); % Apply to both sym % Cyclic shift addition vhtCycShift = complex(zeros(FFTLen, numSym, numTx)); for i = 1:numSym % Replicate VHT-SIG-A field over multiple antennas vhtsigMIMO = repmat(SymAll(:,i), 1, numTx); % Cyclic shift addition % The cyclic shift is applied per transmit antenna. vhtCycShift(:,i,:) = wlan.internal.wlanCyclicShift(vhtsigMIMO, csh, FFTLen, 'Tx'); end wout = wlan.internal.wlanOFDMModulate(vhtCycShift, cfgOFDM.CyclicPrefixLength); y = wout * cfgOFDM.NormalizationFactor; end