%% MAP algorithm test
% BPSK transmission of 64-state rate-1/2 802.11a std code over AWGN
%
% Written by Kee-Bong Song
% 
% May/13/2003
%


clear;
sigma = 0.5;
N_IN = 1;
N_OUT = 2;
N_STATE = 64;
G = [bin2dec('1101101'),bin2dec('1001111')];
[next_state,output] = trellis(G);
[prev_state_index, input_index, trellis_out, A] = siva_init ( next_state, output, N_IN , N_OUT );

% input bit
input_message = [ 0 1 0 1 0 1 1 0 0 1];
% coded bit
encoded_message = conv_enc(input_message,next_state,output,1,2,64);

% BPSK modulation for transmission
x = 2*encoded_message - 1;

% AWGN
noise = sigma*randn(1,length(x));

% channel output
y = x + noise;

[APP alpha beta gamma]= MAP_AWGN( y, sigma, next_state, prev_state_index, trellis_out );

