Function l_all = SOVA (rec_s, G, l_a, ind_dec) % This function implememts soft output Viterbi Algorithm in trace back mode % input: % rec_s: scaled encoded bits. rec_s (K) = 0.5 * l_c (k) * Y (k) % l_c = 4 * a * ES/No, reliability value of the channel % Y: received bits % G: encoder Generator Matrix in binary form, G (1, :) for feedback, g (2, :) for feedforward % l_a: a priori information about the info. bi Ts. extrinsic info. from the previous % component decoder % ind_dec: Index of the component decoder. % = 1: component decoder 1; the trellis is terminated to all zero state % = 2: component decoder 2; the trellis not perfectly terminated. % output: % l_all: log (p (x = 1 | y)/(p (x =-1 | y) % copyright: yufei Wu, Nov. 1998% mprg lab, Virginia Tech % for academic use only % frame size, info. + tail bitsl _ Total = length (l_a); [N, K] = size (g); M = k-1; nstates = 2 ^ m; infty = 1e10; % SOVA window size. make demo-after 'delta' delay. decide bit K when converted ed bits % for BIT (K + delta) are processed. trace back from (K + delta) to K. delta = 30; % set up the trellis defined by G. [next_out, next_state, last_out, last_state] = trellis (g); % initialize path metrics to-inftyfor T = 1: l_total + 1 for State = 1: nsta Tes path_metric (State, t) =-infty; endend % trace forward to compute all the path metricspath_metric (1, 1) = 0; for t = 1: rochelle total y = rec_s (2 * T-1: 2 * t); for State = 1: nstates sym0 = last_out (State,); sym1 = last_out (State ); state0 = last_state (State, 1); state1 = last_state (State, 2); mk0 = y * sym0 '-l_a (T)/2 + path_metric (state0, t ); mk1 = y * sym1 '+ l_a (T)/2 + path_metric (state1, T); If mk0> mk1 path_m Etric (State, t + 1) = mk0; mdiff (State, t + 1) = mk0-mk1; prev_bit (State, t + 1) = 0; else path_metric (state, t + 1) = mk1; mdiff (State, t + 1) = mk1-mk0; prev_bit (State, t + 1) = 1; end endend % for decoder 1, trace back from all zero state, % for decoder two, trace back from the most likely stateif ind_dec = 1 mlstate (l_total + 1) = 1; else mlstate (l_total + 1) = find (path_metric (:, l_total + 1) = max (path_metric (:, l_t Otal + 1); end % trace back to get the estimated bits, and the most likely pathfor T = l_total:-1:1 EST (t) = prev_bit (mlstate (t + 1), t + 1); mlstate (t) = last_state (mlstate (t + 1), EST (t) + 1 ); end % find the minimum Delta that corresponds to a compitition path with different info. bit estimation. % Give the soft outputfor T = 1: l_total LLR = infty; for I = 0: Delta if T + I <l_total + 1 bit = 1-est (t + I); temp_state = L Ast_state (mlstate (t + I + 1), bit + 1); For J = I-1:-1:0 bit = prev_bit (temp_state, T + J + 1 ); temp_state = last_state (temp_state, bit + 1); end if bit ~ = EST (t) LLR = min (LLR, mdiff (mlstate (t + I + 1), t + I + 1); end l_all (t) = (2 * EST (t)-1) * LLR; End