# Iterative decoding with viterbi decoder

Started by December 3, 2003
```Hi , i'm trying to do iterative decoding using vitdec from matlab, i
would like to know how can i get the metrics of the bits to intruce
them in the demodulator again, using the function vitdec. The output
of this function is the final sequence , but i just want the metrics
of the bits. Thank you
TA
```
```you can get the final weighting vectors from that function to estimate the
soft metrics, but if you want an actual soft-input soft-output viterbi
decoder you will have to write you own, or look in mathworks' library.

julius

On Wed, 3 Dec 2003, Ta wrote:

> Hi , i'm trying to do iterative decoding using vitdec from matlab, i
> would like to know how can i get the metrics of the bits to intruce
> them in the demodulator again, using the function vitdec. The output
> of this function is the final sequence , but i just want the metrics
> of the bits. Thank you
> TA
>

--
The most rigorous proofs will be shown by vigorous handwaving.
http://www.mit.edu/~kusuma

opinion of author is not necessarily of the institute
```
```thank you , but in fact i haven't understood you. I think that i hev
not explained well what i want to know. This is the code that i use to
get the sequence without iterative decoding:

%BICM simulates a system with a transmitter, channel and receiver
using Bit
%Interleaved Coded Modulation.

%TRANSMITTER

frameLength = 1296;

N = 1;
numSymb = N*frameLength;
%Random source generation
for i=0:N-1
seed(1) = 654321 + i*frameLength;
seed(2) = 123456 + i*frameLength;
rand('state', seed(1));  randn('state', seed(2));
msg_orig(i*frameLength+1:(i+1)*frameLength,1) =
end
%Convolutional encoder
constlen = ; codegen = [133 171]; codeRate = 1/2;
trel = poly2trellis(constlen, codegen);
%Interleaver
depthIL = frameLength/codeRate;
%Modulation
labelling = 'Gray';
modulation = 'PSK';
M = 8;
Initial_phase = 0;
%Sample frequency of convolutionally encoded signal
Fd = 1;
%Sample frequency of msg_tx
Fs = 1;

%CHANNEL
k = log2(M);
SNRpBit = ; SNR = SNRpBit + 10*log10(k);
SNR= SNR -10*log10(1/codeRate)-10*log10(Fs/Fd);

channelType = 'RAYL'; %AWGN or RAYL
RaylType = 'uncorr'; %'uncorr' OR 'correl'
DoppMax = 10;
Tmax = 1;%Choose a logical Tmax, taking into account the Tx rates
%we want to work with and the number of symbls we are
transmiting

%quantization of metrics
Res = 8; %the computed metrics will have 256 levels.
%soft-input VITERBI decoder
tblen = frameLength;  %trace-back of the viterbi decoder

%LOOP for TX frame by frame, N different channels and Performance
averaged

msg_dec = zeros(frameLength*length(SNR), N);
for index = 0:N-1

currentFrame = msg_orig(index*frameLength+1:(index+1)*frameLength,1);
[msg_enc_bi final_state] = convenc(currentFrame, trel);
[msg_IL RandIndexVector]= BitInterleaver(msg_enc_bi, depthIL);

%Mapping and transmission
%Options QPSK,8-PSK,16-QAM,64-QAM
msg_TX = mapping(msg_IL, modulation, M, labelling, Fd, Fs,
Initial_phase);

%Normalization of the TX signal, to have E[|x|^2] = 1. Due to
Interleaving
%we can assume equiprobable TX symbols. For PSK M=4 or 8 the TX
signal has
%always E[|x|2] = 1; for multi-level modulation QAM we have to
normalize.
if M == 16
msg_TX = msg_TX/3.1623; %/sqrt(10)
elseif M ==64
msg_TX = msg_TX/6.4807;%/sqrt(42)
end
disp(sprintf('%s %d %s %d','Frame TX number',index+1,'of',N))

msg_decTemp = [];
%LOOP, for each frame generate a LOOP of transmitted and decoded
frames for
%different values of SNR at the receiver.
for SNRindex = 1:length(SNR)

[msg_RX,raylEnv,raylPhase] = channelBICM(msg_TX, channelType,
SNR(SNRindex), DoppMax, Tmax, RaylType);

msg_demod = demod(msg_RX, modulation, channelType, M, labelling,
SNR(SNRindex), Fd, Fs, Initial_phase, raylEnv, raylPhase);

%the pseudo-random sequence of Interleaving at the Transmitter and
%interleaving depth, length(RandIndexVector), are known at the
msg_deIL = metricsDeinterleaver(msg_demod, RandIndexVector);

maxVal = mean(msg_deIL) + 0.4*var(msg_deIL);%max(msg_deIL);
%~8;%select linear values for max and min of saturation.
minVal = mean(msg_deIL) - 0.4*var(msg_deIL);%min(msg_deIL);
%~1.001;
%case QAM64, maxVal and minVal are better:
%maxVal = mean(abs(msg_deIL))+2*sqrt(var(abs(msg_deIL)))
msg_input_dec = qntizer(msg_deIL, Res, maxVal, minVal);

msg_decSNR = vitdec(msg_input_dec, trel, tblen, 'term', 'soft',
Res);
msg_decTemp = cat(1,msg_decTemp,msg_decSNR);
clear msg_decSNR;
end
msg_dec(:,index+1)= msg_decTemp;
clear msg_decSNR;
end

------------------------------------------------------------------------
I just generate the sequence, poly2trellis , then convenc, then apply
an interleaver, mapping, then the channel, ... in the demodulation i
get the ratios of the bits, after deinterleaving and making the
quantification of the ratios i apply vitdec, then i get the sequence.
But i don't know how to make this process iterative, i don't after the
vitdec but i should do get the a posteriori probabilities. Could you
help me?

Julius Kusuma <kusuma@mit.edu> wrote in message news:<Pine.GSO.4.55L.0312041008340.1355@biohazard-cafe.mit.edu>...
> you can get the final weighting vectors from that function to estimate the
> soft metrics, but if you want an actual soft-input soft-output viterbi
> decoder you will have to write you own, or look in mathworks' library.
>
> julius
>
>
> On Wed, 3 Dec 2003, Ta wrote:
>
> > Hi , i'm trying to do iterative decoding using vitdec from matlab, i
> > would like to know how can i get the metrics of the bits to intruce
> > them in the demodulator again, using the function vitdec. The output
> > of this function is the final sequence , but i just want the metrics
> > of the bits. Thank you
> > TA
> >
```
```i'm including the vitdec help information below.  what i said was that you
can use "finalmetric", "finalstates", and "finalinputs" from this function
to get some sort of soft output from the viterbi algorithm.

here is the help file:

vitdec
Convolutionally decode binary data using the Viterbi algorithm
Syntax

decoded = vitdec(code,trellis,tblen,opmode,dectype);
decoded = vitdec(code,trellis,tblen,opmode,'soft',nsdec);
decoded = vitdec(...,'cont',...,initmetric,initstates,initinputs);
[decoded,finalmetric,finalstates,finalinputs] =...
vitdec(...,'cont',...);

On Thu, 4 Dec 2003, Ta wrote:

[long code snipped]

--
The most rigorous proofs will be shown by vigorous handwaving.
http://www.mit.edu/~kusuma

opinion of author is not necessarily of the institute
```
```On Thu, 4 Dec 2003 23:27:18 -0500, Julius Kusuma <kusuma@mit.edu>
wrote:

>i'm including the vitdec help information below.

I know also that such kinds of SI-SO algorithms are used in a
Turbo-code / a Turbo-equalizer. You can find some decoders for them in
IT++ (http://itpp.sourceforge.net) as long as you are also interested
in the c++ language.

BR,
------
James K. (txdiversity@hotmail.com)
- Any remarks, proposal and/or indicator would be greatly respected.
- Private opinions: These are not the opinions from my affiliation.
[Home] http://home.naver.com/txdiversity
```