⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c_gamma.m

📁 Space-Time Processing for CDMA Mobile Communications.Written for research students and design engine
💻 M
字号:
% ======================================================================
% C_GAMMA.m
% =========
% Description: This m-file implements the Branch-Metric Calculator (BMC)
%              to be used in the MAP-decoder.
%
% Usage:  [Gamma0,Gamma1] = c_gamma(EnCoded, NSC, PSC, TTN, Lc)
% Inputs:
%         EnCoded: Array containing the received coded data stream
%                  (soft inputs).
%       Extrinsic: Extrinsic inputs.
%             NSC: Next-States-Connected.
%             PSC: Previous-States-Connected.
%             TTN: Transition-To-Next (encoded parity bit).
%              Lc: Channel Reliability Value
%                  (For AWGN channel, Lc = 2/Sigma_Noise).
%     Decr_Number: Indicates which MAP decoder is used.
%                  (First=1, Second=2)
%
% Outputs:
%          Gamma0: The Branch Metrics (BM) for complete trellis for
%                  input bit 0.
%          Gamma1: The Branch Metrics (BM) for complete trellis for
%                  input bit 1.
%
%    Output data format: GammaI(State Number, Trellis Depth Indicator),
%                        where I=0,1 depending on input bit.
% ======================================================================
function [Gamma0,Gamma1] = c_gamma(EnCoded, Extrinsic, NSC, PSC, TTN,...
                                   Lc, Dec_Number)

% --------------
% Initialisation
% --------------
Trellis_Depth = length(EnCoded)/2;    % Aslo, Interleaver Size.
[Number_Of_States, Temp] = size(NSC); % Number of States in trellis.
Receive = zeros(1,2);                 % Rate-k/n RSC encoder: k=1, n=2.

Gamma0 = zeros(Number_Of_States, Trellis_Depth);
Gamma1 = zeros(Number_Of_States, Trellis_Depth);
% -------------------------------------
% M A P: Branch-Metric Calculator (BMC)
% -------------------------------------
NormaliseFactor = 1;
for TD=1:Trellis_Depth
   % Get received bits for specific trellis depth.
   Receive(1) = EnCoded((TD-1)*2 + 1);
   Receive(2) = EnCoded((TD-1)*2 + 2);

   if Dec_Number == 1 % First decoding stage of current iteration
      Delta = Receive(1) + Extrinsic(TD);
   else
      Delta = Extrinsic(TD);
   end

   % Do for all states
   % -----------------
   for S=1:Number_Of_States

      % Do for input bit 0 (-1):
      % -----------------------
      BranchMetric0 = -1 * Delta + TTN(S,1) * Receive(2);

      if (Lc*BranchMetric0) > 200
         Gamma0(S,TD) = exp(200);
      else
         Gamma0(S,TD) = exp(Lc*BranchMetric0);
      end

      % Do for input bit 1:
      % ------------------
      BranchMetric1 = +1 * Delta + TTN(S,2) * Receive(2);
      if (Lc*BranchMetric1) > 200
         Gamma1(S,TD) = exp(200);
      else
         Gamma1(S,TD) = exp(Lc*BranchMetric1);
      end
   end
end
% ======================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -