
A-8
Viterbi Decoder Implementation
For More Information On This Product,
Go to: www.freescale.com
Basic Algorithm Program Listing
;***************************MAIN***********************************************
NUMSTATESequ
32
ENCBITS
equ
6
NoOfAcsButtequ
NUMSTATES/2
NUMINPUTSequ
168
EVEN
equ
1-(NUMINPUTS/8)%2
;
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
fly
move
#PATHOUT,n0
move
#-1,m3
move
#INDATA,r1
;***********************PREPARATION LOOP*************************
;
This loop iterates by the number of bits used in the
;
encoder to pre load the bit decisions. Thereafter,
;
the paths are updated and stored off in bytes. We need
;
the preload bits so that the stored path metrics point
;
correctly to their previous paths for traceback
;****************************************************************
do
#ENCBITS-1,PRELP
;
FindMetrics
ACS
PRELP
;*****************MAIN LOOP--PROCESS BYTES OF DATA*****************
do
#NUMINPUTS/8-1,DATALP
do
#8,SYMLP
;
FindMetrics
ACS
SYMLP
STOREPATHS#NUMSTATES
DATALP
;********POSTPROCESSING,LAST INFO BYTE ********************************
;
; ENCBITS-1 PREPROCESSED, SO WE HAVE 8-ENCBITS+1 BITS LEFT.
; FOR THIS EXAMPLE, WE HAVE 3 INPUTS LEFT TO PROCESS
;**********************************************************************
; THE LAST THREE BITS------
do
#8-ENCBITS+1,FLSH1
FindMetrics
ACS
FLSH1
;*******Traceback the path data to obtain the decoder output**********
TRACEBACK
FIN
nop
;most cases=log2(NUMSTATES)+1
;EVEN SET TO 1/0 IF NUMINPUTS IS
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 butter-
;n0 points to storage for output paths
;set linear mode, traceback ptr
;r1 points to input data
;once for each encoder bit
;process bytes of output
;8 bits per byte
;process last 3 bits to get last byte
Example A-1
Basic 16-Bit Implementation of a Viterbi Decoder (Continued)
F
Freescale Semiconductor, Inc.
n
.