Expanding the Viterbi Algorithm
Main: Gluing the Pieces Together
Viterbi Decoder Implementation
For More Information On This Product,
Go to: www.freescale.com
3-17
Again, we read the next (previous) path into A1 using r0, which points to the previous
page, and n0, which points to the correct path in that page. We extract the new path
pointer information, update r0 to the next previous page, and move the path pointer to
n0. Move the path data to the upper byte, OR in the lower byte from x1, and move the
resulting word into memory using r2. The loop continues until we have traced back to
the beginning, and y:DECOUT points to the start of the decoder output.
3.7
MAIN: GLUING THE PIECES TOGETHER
The only thing left is to put the pieces together. In
Examples 3-5
through
3-7
, we present
the main routine. Its function is to initialize registers so everything starts properly, and
to invoke the macros at the needed time.
Example 3-5
begins the Viterbi decoding routine by setting equates for the encoder size
and input data length, and initializing address registers. NUMSTATES is set to the
number of encoder states, which for our example is 32. ENCBITS is the number of bits
used to encode. This includes the input bit as well as the state bits. NoOfAcsButt sets the
number of ACS butterflies for the butterfly loop. For our rate 1/2 code, this is
automatically set to half the number of states. The EVEN flag is used by the assembler to
include an extra half-byte of traceback if the number of input bytes of data is odd.
Example 3-5
Main Viterbi Decoding Routine: Initialization
;***************************MAIN***********************************************
;
NUMSTATESequ
32
ENCBITS
equ
6
NoOfAcsButt
equ
NUMSTATES/2
NUMINPUTSequ
168
EVEN
equ
1-(NUMINPUTS/8)%2 ;EVEN SET TO 1/0 IF NUMINPUTS IS
;
org
p:$400
VITDEC
move
#NUMSTATES/2-1,m2
move
#>3,n2
move
#STATE1,r5
move
#STATE2,r4
move
#NUMSTATES*2-1,m4
move
#NUMSTATES*2-1,m5
move
#NUMSTATES/2,n5
move
#PATHOUT,n0
move
#-1,m3
;
move
#INDATA,r1
;
;most cases=log2(NUMSTATES)+1
EVEN/ODD #BYTES
;r2 points to branch metric table
;increment for branch metric storage
;r5 points to current state metric
;r4 points to updated state metric
;both modulo to flip loc each sym
;input metrics spacing for each butterfly
;n0 points to storage for output paths
;set linear mode, traceback ptr
;r1 points to input data
F
Freescale Semiconductor, Inc.
n
.