gusucode.com > wlan工具箱matlab源码程序 > wlan/wlan/+wlan/+internal/s1gSIG.m

    function [y, bits] = s1gSIG(cfgS1G)
%s1gSIG S1G SIGNAL (S1G-SIG) field
%
%   Note: This is an internal undocumented function and its API and/or
%   functionality may change in subsequent releases.
%
%   [Y,BITS] = s1gSIG(CFGS1G) generates the S1G SIGNAL (S1G-SIG) field
%   time-domain waveform for the S1G transmission format.
%
%   Y is the time-domain SIG 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 signaling bits used for the S1G SIGNAL field. It is an
%   int8-typed, binary column vector of length 48.
%
%   CFGS1G is the format configuration object of type <a href="matlab:help('wlanS1GConfig')">wlanS1GConfig</a> which
%   specifies the parameters for the S1G format.
%
%   Example: 
%   %  Generate the S1G SIG waveform for a 4MHz transmission format
%
%      cfgS1G = wlanS1GConfig;              % Format configuration
%      cfgS1G.ChannelBandwidth = 'CBW4';    % Set to 4MHz
%      sigOut = s1gSIG(cfgS1G);
%
%   See also wlanS1GConfig.

%   Copyright 2016 The MathWorks, Inc.

%#codegen

% Validate input
validateattributes(cfgS1G,{'wlanS1GConfig'},{'scalar'},mfilename,'S1G format configuration object');

% Bits 0-36 are either signaling bits or the CMAC body based on
% NDPIndication. Only support signaling bits at preset.
bodyBits = wlan.internal.s1gSignalingBits(cfgS1G);

% Generate the CRC
numBits = 4; % IEEE P802.11ah/D5.0, Section 24.3.8.2.1.5
crc = wlan.internal.wlanCRCGenerate(bodyBits,numBits);

% Concatenate signaling bits, NDP indication bit, CRC bits and tail bits
bits = [bodyBits; crc; zeros(6,1,'int8')];

% Get OFDM parameters
chanBW = cfgS1G.ChannelBandwidth;
numSTS = cfgS1G.NumSpaceTimeStreams(1);
cfgOFDM = wlan.internal.s1gOFDMConfig(chanBW,'Long','SIG',numSTS);

if isS1G1MConfig(cfgS1G) % 1 MHz SIG
    % Encode according to Section 18.3.5.6
    encodedSIG  = wlan.internal.wlanBCCEncode(bits,'1/2');

    % Repetition coding according to Section 24.3.9.5
    repeatedSIG = wlan.internal.repetitionForMCS10(encodedSIG);

    % Interleaving according to 1 MHz MCS 10 flow
    numSym = 6;   % Number of OFDM symbols
    numBPSCS = 1; % Modulation order
    numCBPS = 24; % Number of coded bits per symbol; 144 bits in 6 symbols
    interleaveFormat = 'VHT'; % VHT interleaver
    chanBWMHz = 1; % Interleaver for 1 MHz mode (Table 24-20)
    Nss = 1; % 1 spatial stream
    interleavedData = zeros(numCBPS,numSym);
    for i = 1:numSym
        interleavedData(:,i) = wlan.internal.wlanBCCInterleave( ...
            repeatedSIG((i-1)*numCBPS+(1:numCBPS),:), ...
            interleaveFormat,numCBPS,numBPSCS,chanBWMHz,Nss);
    end

    % BSPK constellation mapping according to Section 18.3.5.8
    dataSym = wlan.internal.wlanConstellationMapper(interleavedData,numBPSCS);

    n = (0:numSym-1).';
    z = 0; % First pilot
    pilots = wlan.internal.vhtPilots(n,z,chanBW,Nss);
else % Short preamble >= 2 MHz SIG
    % Encoding, interleaving and constellation mapping according to Section
    % 18.3.5.6/7/8
    phRot = pi/2; % Both symbols rotated: [QBPSK QBPSK]
    dataSym = wlan.internal.vhtSIGAEncodeInterleaveMap(bits,phRot);
    % Pilots according to Section 18.3.5.9
    numSym = 2;
    z = 0; % First pilot
    pilots = wlan.internal.nonHTPilots(numSym,z);
end

% Pilot insertion, duplication over bandwidth and phase rotation
sym = complex(zeros(cfgOFDM.FFTLength,numSym)); 
Nsubchan = ceil(cfgOFDM.FFTLength/64);
sym(cfgOFDM.DataIndices,:) = repmat(dataSym(:,:,1),Nsubchan,1); % Index for codegen
sym(cfgOFDM.PilotIndices,:) = repmat(pilots(:,:,1),Nsubchan,1); % Index for codegen
sym = bsxfun(@times,sym,cfgOFDM.CarrierRotations);

% Get P_HTLTF mapping matrix
Phtltf = wlan.internal.mappingMatrix(numSTS);
Pd = Phtltf(1:numSTS,1).'; % First column of P matrix

% Perform segment replication, orthogonal mapping, CSD and spatial mapping
sigSpatialMapped = complex(zeros(cfgOFDM.FFTLength,numSym,cfgS1G.NumTransmitAntennas));
csh = wlan.internal.getCyclicShiftVal('S1G',numSTS,wlan.internal.cbwStr2Num(chanBW));
for i = 1:numSym
    % Replicate SIG field over multiple space-time streams
    sigMIMO = repmat(sym(:,i),1,numSTS);
    
    % Apply orthogonal mapping matrix
    sigMIMO = bsxfun(@times,sigMIMO,Pd);
    
    % Cyclic shift addition per space-time stream
    sigCycShift = wlan.internal.wlanCyclicShift(sigMIMO,csh,cfgOFDM.FFTLength,'Tx');

    % Apply spatial mapping
    sigSpatialMapped(:,i,:) = wlan.internal.wlanSpatialMapping(sigCycShift, ...
        cfgS1G.SpatialMapping,cfgS1G.NumTransmitAntennas,cfgS1G.SpatialMappingMatrix);
end

% OFDM Modulation
y = wlan.internal.wlanOFDMModulate(sigSpatialMapped, ...
    cfgOFDM.CyclicPrefixLength)*cfgOFDM.NormalizationFactor;

end