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

📄 conv_decoding_soft.m

📁 在MIMO系统中
💻 M
字号:
function output_bit = conv_decoding_soft(input_bit,reset)
% convolutional decoding for IEEE802.11a
% Copy right T-Square Design. All rights reserved.
% Confidential, do not give this program to anyone outside the T2 IEEE802.11a group.
% Current responsible engineer: Antony Lee
% When this file is modified, inform Antony Lee, Simon Qiu, Andy Lu.
% History
%   2002-03-08  Created by Antony Lee.
%   2002-04-26  Modified by Simon Qiu.
%   2002-05-15  Modified by Sabrina Tan for adaption in soft-decision Viterbi algorithm.
%   2002-07-05  Modified by Simon Qiu:
%               Reduced one "for" circulation to accelerate calculation rate.

global RegisterStateLen;
global InputStateLen;
global VITERBI_DELAY;
global AccumulateDistance;
global DelayState; 
global delayPaths;
global curnDelayIndex;
global viterbiClockCounter;

State_Path_Backward=[  0  3 13 14;
                       4  7  9 10;
                       3  0 14 13;
                       7  4 10  9;
                      15 12  2  1;
                      11  8  6  5;
                      12 15  1  2;
                       8 11  5  6;
                      14 13  3  0;
                      10  9  7  4;
                      13 14  0  3;
                       9 10  4  7;
                       1  2 12 15;
                       5  6  8 11;
                       2  1 15 12;
                       6  5 11  8;
                      11  8  6  5;
                      15 12  2  1;
                       8 11  5  6;
                      12 15  1  2;
                       4  7  9 10;
                       0  3 13 14;
                       7  4 10  9;
                       3  0 14 13;
                       5  6  8 11;
                       1  2 12 15;
                       6  5 11  8;
                       2  1 15 12;
                      10  9  7  4;
                      14 13  3  0;
                       9 10  4  7;
                      13 14  0  3;
                      12 15  1  2;
                       8 11  5  6;
                      15 12  2  1;
                      11  8  6  5;
                       3  0 14 13;
                       7  4 10  9;
                       0  3 13 14;
                       4  7  9 10;
                       2  1 15 12;
                       6  5 11  8;
                       1  2 12 15;
                       5  6  8 11;
                      13 14  0  3;
                       9 10  4  7;
                      14 13  3  0;
                      10  9  7  4;
                       7  4 10  9;
                       3  0 14 13;
                       4  7  9 10;
                       0  3 13 14;
                       8 11  5  6;
                      12 15  1  2;
                      11  8  6  5;
                      15 12  2  1;
                       9 10  4  7;
                      13 14  0  3;
                      10  9  7  4;
                      14 13  3  0;
                       6  5 11  8;
                       2  1 15 12;
                       5  6  8 11;
                       1  2 12 15];
                   
State_State_Backward = zeros(4,64);
State_State_Backward(:) = [1:64,1:64,1:64,1:64];
State_State_Backward = State_State_Backward';

State_Input_Backward = zeros(64,4);
State_Input_Backward(17:32,:) = 1;
State_Input_Backward(33:48,:) = 2;
State_Input_Backward(49:64,:) = 3;

StateInitial = [0,8,7,7,7,7,6,6,5,7,6,8,4,6,5,7,3,11,6,6,4,4,7,7,4,6,5,7,5,7,6,8,...
                2,8,9,7,5,7,4,6,3,7,4,8,6,6,7,7,3,9,6,4,4,6,7,9,4,8,5,9,5,5,6,6];
      
if reset == 1	%convolution decoding initial
    RegisterStateLen = 64;   %6-bit states=2^6=64
    InputStateLen = 4;       %1-bit Input Path=1^2=2
    AccumulateDistance = StateInitial * 15;
    DelayState = zeros(RegisterStateLen,VITERBI_DELAY+1); 
    delayPaths = zeros(RegisterStateLen,VITERBI_DELAY+1);
    curnDelayIndex = 1;
    viterbiClockCounter = 1;
    output_bit = zeros(1,2);
else
    CurnAccumulateDistance = AccumulateDistance;
    AccumulateDistance = ones(1,RegisterStateLen) * 2147483647; %2147483647=0x7fffffff
    StateBackward = zeros(RegisterStateLen,1);
    InputBackward = zeros(RegisterStateLen,1);
    for curnPath = 1:InputStateLen    %InputStateLen = 1--4
        tempStateBackward = State_State_Backward(:,curnPath);   %look backward to the State
        tempPathBackward = State_Path_Backward(:,curnPath);     %look backward to the Path
        tempInputBackward = State_Input_Backward(:,curnPath);   %look backward to get the input bit
        %in different rate, the distance computing is different
        curnDistance = zeros(RegisterStateLen,1);
        temp = bitget(tempPathBackward,1);  %get bit1
        if input_bit(1) ~= -1
            curnDistance = curnDistance + abs(input_bit(1) - temp * 15);
        end
        temp = bitget(tempPathBackward,2);  %get bit2
        if input_bit(2) ~= -1
            curnDistance = curnDistance + abs(input_bit(2) - temp * 15);
        end
        temp = bitget(tempPathBackward,3);  %get bit3
        if input_bit(3) ~= -1
            curnDistance = curnDistance + abs(input_bit(3) - temp * 15);
        end
        temp = bitget(tempPathBackward,4);  %get bit4
        if input_bit(4) ~= -1
            curnDistance = curnDistance + abs(input_bit(4) - temp * 15);
        end
        tempAccumulateDistance = CurnAccumulateDistance(tempStateBackward) + curnDistance';  %compute the accumulating hamming distance
        %add the distance of each state
        idx = find(tempAccumulateDistance < AccumulateDistance);
        AccumulateDistance(idx) = tempAccumulateDistance(idx);
        StateBackward(idx) = tempStateBackward(idx);  %select the minimum distance of each state
        %PathBackward=tempPathBackward; %select the minimum distance of each path
        InputBackward(idx) = tempInputBackward(idx);  %select the minimum distance of each input
    end
    DelayState(:,curnDelayIndex) = StateBackward;
    delayPaths(:,curnDelayIndex) = InputBackward;   %save the current input
    %we define the VITERBI_DELAY, when viterbiClockCounter >= VITERBI_DELAY we output
    if viterbiClockCounter >= VITERBI_DELAY+1
        [AccumulateDistanceMin,tempStateBackward] = min(AccumulateDistance);
        %we use these function to avoid AccumulateDistance overflow
        AccumulateDistance = AccumulateDistance - AccumulateDistanceMin;
        %we trace back to find the correct output
        traceDelayIndex = curnDelayIndex;
        for k = 1:VITERBI_DELAY;
            tempStateBackward = DelayState(tempStateBackward,traceDelayIndex);
            traceDelayIndex = traceDelayIndex - 1;
            if traceDelayIndex < 1
                traceDelayIndex = VITERBI_DELAY + 1;
            end
        end
        output_bit = bitget(delayPaths(tempStateBackward,traceDelayIndex),1:2);
    else
        viterbiClockCounter = viterbiClockCounter + 1;
        output_bit = zeros(1,2);
    end
    curnDelayIndex = curnDelayIndex + 1;
    if curnDelayIndex > VITERBI_DELAY+1
        curnDelayIndex = 1;
    end
end

⌨️ 快捷键说明

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