Professional Documents
Culture Documents
Implementation of Viterbi Encoder and Decoder On Fpga: Batch 28 Pramod M and Makarand K Patil
Implementation of Viterbi Encoder and Decoder On Fpga: Batch 28 Pramod M and Makarand K Patil
FPGA
A Project Report
Submitted for
Digital System Design with FPGAs
(E3: 231)
by
Batch 28
Pramod M and Makarand K Patil
November 2009
i
Batch 28
Pramod M and Makarand K Patil
November 2009
Acknowledgements
We would like to thank Prof. Kuruvilla Varghese for his guidance and support. We also
thank him for providing us with an opportunity to work with CAD tools. We thank
Mrs. Vedavalli for her support in the course of the project.
ii
Abstract
In this project, Viterbi Encoder and Decoder is implemented on Sparten-3e FPGA. The
transmitter is of constraint length 3 and uses a two state encoder of rate 1/2. The
decoder implements trace back algorithm on a set of 16 bits of received sequence. The
Viterbi decoder can operate at a frequency of 82.7 MHz. It is implemented on FPGA
operation at a frequency of 50 MHz.
iii
Contents
1 Introduction 2
1.1 Viterbi Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Error Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Encoder Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.1 Rate of Encoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.2 Constraint length (K) . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Encoder Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Implementation Options of Decoder on Hardware . . . . . . . . . . . . . 3
1.5.1 Register Exchange Method . . . . . . . . . . . . . . . . . . . . . . 4
1.5.2 Trace Back Method . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Implementation of Decoder 5
2.1 Branch Metric Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Accumulate Compare Unit . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Normalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Path Metric Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.5 Predictor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.6 LIFO Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.7 Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Performance 11
3.1 Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.1 Timing Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.2 Timing Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Resource Utilization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1
Chapter 1
Introduction
2
3. Hard decision decoding
4. g00 = (111)
5. g01 = (011)
6. Trellis truncation : 16
X1X0
+ + S0 00 (00)
X0
Din S1 11
01 (01)
D Q0 D Q1
10
11
S2 (10)
00
X1
+
10
CLK
S3 01 (11)
Figure 1.1: Rate 1/2 Viterbi Encoder with Constraint length of 3 along with correspond-
ing trellis diagram
3
1.5.1 Register Exchange Method
The register exchange (RE) method is the simplest conceptually and a commonly used
technique. Its disadvantage is the large power consumption and large area required in
VLSI Implementations. The RE method is not practical when K is large.
Channel
Source Encoder + Decoder Destination
Noise
(a)
(b)
Figure 1.2: (a) Communication system scenario (b) Block diagram implementation of
Trace back Viterbi decoder
4
Chapter 2
Implementation of Decoder
The decoder contains the following blocks. The function of each of the blocks will be
discussed in subsequent sections.
1. Branch metric unit
2. Accumulate compare select unit
3. Normalizer
4. Path metric memory
5. Predictor
6. Last in first out (LIFO) unit
7. Controller
5
y(1:0)
0 0 1 0 1 0 2 0
1 1 0 1 2 1 1 1
1 2 2 2 0 2 1 2
2 3 1 3 1 3 0 3
H0 H1 H2 H3
pmu pmd
bmu bmd
+ +
A B
Decision
A<B
1 0
Din
load 1 0
pm_unreg
rst clk
3-bit reg
pm
2.3 Normalizer
When the decoder runs continuously, the weight of the branches keeps adding to the reg-
ister of the ACS. When the registers has the maximum value, there may be an overflow.
An overflow can cause erroneous results. Hence a normaliser unit needs to be used. This
unit shifts the contents of all the inputs by one bit left if any of the inputs is greater
than 6.
The path metric calculator unit with the normaliser, branch metric unit and ACS
unit is shown in Fig. 2.3. Each of the ACS units store the accumulated path metric
for each state in the trellis. The Min State Decoder show in Fig. 2.3 is a unit that
picks up the state with minimum accumulated weight and gives a two bit output. This
6
Decision
input
BMU
clk
Normalizer
Min state
decoder
information is used by the Predictor Unit (Sec. 2.5) to decode the bits.
din(3:0)
re Path metric dout
we memory
clk 32x4
units. An upper path is encoded as ’1’ and a lower path by a ’0’. The data is written in
7
forward direction (location 0 to location 31) while the data is read in reverse direction.
This operation avoids simultaneous read and write of same memory location.
2.5 Predictor
This unit (shown in Fig. 2.5) is a state machine that is loaded with the state with
minimum accumulated path metric after every 16 clock cycles. This unit uses the state
value to access a bit from the path metric memory unit (PMM), the column address is
provided by the counter. The rows of PMM are accessed in reverse order during trace
back. The bit that is accessed from the PMM is used by the output decoder to predict
the value of the transmitted data. This bit also serves as an input to the next state
decoder. The state diagram is also shown in Fig. 2.5.
=1
rst din
from min_state_decoder
S0 dout=0
=0
din
din
1 0
din=1 load NSD dout
=1
dout=1 S3 S1 dout=1 OD
clk
1
n=
rst
di
n=
S2
n=
di
0
dout=0 Reg(1:0)
(column address for path memory)
Figure 2.5: Predictor unit which determines the decoded bit using the present state and
the input din. Here din is acccesed from the PMM unit while the state gets refreshed
every 16 clock cycles.
2.7 Controller
A controller is used to synchronize between the different modules described in Sec. 2.2 to
Sec. 2.6. The state diagram of the controller is shown in Fig. 2.7. The complete viterbi
8
COUNT(4)
Left_Shift/Right_shift
0 REG(15:0)1 rst
dout
1
REG(15:0)2
Din
load=0
start=0 we=0
rst=1 ce=0
re=0
S0
0
sta
rt=
rt=
sta
load=0
we=1 S2 S1 load=1
ce=1 we=0
re=1 ce=0
start=1 re=0
9
VITERBI DECODER
Sec. 2.7
ACS(3:0)
Normalizer
Dout_decoded
Min_State_Decoder
Din(1:0)
Din(1:0)
LIFO
rst rst
load
clk clk
din
minstate(1:0)
Decision(3:0)
clk
4
count(4)
10
clk clk load
data
32x4
min_state
waddr
dout
rraddr
rcaddr
start
5
CE din
clk
32-count
Predictor
Max_count/2 Mod 32 Counter
clk
laod dout
Figure 2.8: Viterbi Decoder which includes all the modules described in Sec. 2.2 to
Chapter 3
Performance
3.1 Timing
3.1.1 Timing Constraints
Timing c o n s t r a i n t :
Data S h e e t r e p o r t :
−−−−−−−−−−−−−−−−−
A l l v a l u e s d i s p l a y e d i n n a n o s e c o n d s ( ns )
Setup / Hold t o c l o c k c l k
−−−−−−−−−−−−+−−−−−−−−−−−−+−−−−−−−−−−−−+−−−−−−−−−−−−−−−−−−+−−−−−−−−+
| Setup t o | Hold t o | | Clock |
Source | c l k ( edge ) | c l k ( edge ) | I n t e r n a l Clock ( s ) | Phase |
−−−−−−−−−−−−+−−−−−−−−−−−−+−−−−−−−−−−−−+−−−−−−−−−−−−−−−−−−+−−−−−−−−+
rst | 1 . 9 8 9 (R ) | 1 . 0 9 5 (R ) | clk BUFGP | 0.000|
start | 2 . 0 1 9 (R ) | −0.190(R ) | clk BUFGP | 0.000|
−−−−−−−−−−−−+−−−−−−−−−−−−+−−−−−−−−−−−−+−−−−−−−−−−−−−−−−−−+−−−−−−−−+
Clock c l k t o Pad
−−−−−−−−−−−−+−−−−−−−−−−−−+−−−−−−−−−−−−−−−−−−+−−−−−−−−+
| c l k ( edge ) | | Clock |
Destination | t o PAD | I n t e r n a l Clock ( s ) | Phase |
−−−−−−−−−−−−+−−−−−−−−−−−−+−−−−−−−−−−−−−−−−−−+−−−−−−−−+
dout<0> | 8 . 6 5 6 (R ) | clk BUFGP | 0.000|
dout<1> | 8 . 9 1 4 (R ) | clk BUFGP | 0.000|
dout<2> | 8 . 5 7 6 (R ) | clk BUFGP | 0.000|
dout<3> | 8 . 5 2 6 (R ) | clk BUFGP | 0.000|
dout<4> | 8 . 5 2 9 (R ) | clk BUFGP | 0.000|
dout<5> | 8 . 5 9 8 (R ) | clk BUFGP | 0.000|
dout<6> | 8 . 9 2 7 (R ) | clk BUFGP | 0.000|
dout<7> | 8 . 5 7 8 (R ) | clk BUFGP | 0.000|
−−−−−−−−−−−−+−−−−−−−−−−−−+−−−−−−−−−−−−−−−−−−+−−−−−−−−+
Clock t o Setup on d e s t i n a t i o n c l o c k c l k
−−−−−−−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+
11
| Src : Rise | Src : F a l l | Src : Rise | Src : F a l l |
S o u r c e Clock | Dest : R i s e | Dest : R i s e | Dest : F a l l | Dest : F a l l |
−−−−−−−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+
clk | 12.079| | | |
−−−−−−−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+
De s ig n s t a t i s t i c s :
Minimum p e r i o d : 1 2 . 0 7 9 ns {1} (Maximum f r e q u e n c y : 8 2 . 7 8 8MHz)
Minimum i n p u t r e q u i r e d time b e f o r e c l o c k : 2 . 0 1 9 ns
Minimum output r e q u i r e d time a f t e r c l o c k : 8 . 9 2 7 ns
Macro S t a t i s t i c s
# ROMs : 2
4x2−b i t ROM : 1
4x8−b i t ROM : 1
# Adders / S u b t r a c t o r s : 9
3− b i t adder : 8
5− b i t adder : 1
# C ou n ter s : 2
5− b i t up c o u n t e r : 1
12
7− b i t up c o u n t e r : 1
# Registers : 224
F l i p −F l o p s : 224
# Comparators : 7
3− b i t comparator l e s s : 3
3− b i t comparator l e s s e q u a l : 4
# Multiplexers : 1
4− b i t 32−to −1 m u l t i p l e x e r : 1
# Xors : 3
1− b i t x o r 2 : 3
=========================================================================
D e v i c e u t i l i z a t i o n summary :
−−−−−−−−−−−−−−−−−−−−−−−−−−−
S e l e c t e d D e v i c e : 3 s 5 0 0 e f g 3 2 0 −5
Conclusion
Viterbi Encoder and Decoder is implemented on Sparten-3e FPGA. A rate 1/2 encoder
with constraint length 3 is used. The decoder uses Trace Back approach for decoding
since it is less demanding on hardware resources. The decoder is capable of correcting two
bits for every 16 bits of transmitted information. The whole communication system can
operate at a frequency of 82.7 MHz. The design is implemented on an FPGA operating
at 50 MHz. A total of 237 Slices out of 4656 (5%) is used for the implementation.
13
Bibliography
[1] C. Bhargav and HKS Randhawa. Design and Implementation of Viterbi Decoder
Using FPGA. Soft Computing, page 387.
[2] P.J. Black and T.H. Meng. A 1-Gb/s, four-state, sliding block Viterbi decoder.
IEEE Journal of Solid-State Circuits, 32(6):797–805, 1997.
[4] O. Collins and F. Pollara. Memory management in traceback Viterbi decoders. TDA
Prog. Rep, pages 42–99, 1989.
[6] G. Feygin and P. Gulak. Architectural tradeoffs for survivor sequence memory man-
agement in Viterbi decoders. IEEE Transactions on Communications, 41(3):425–
429, 1993.
[7] H.L. Lou. Implementing the Viterbi algorithm. IEEE Signal processing magazine,
12(5):42–52, 1995.
[8] B. Pandita and SK Roy. Design and implementation of a Viterbi decoder using
FPGAs. In Proceedings of the IEEE International Conference on VLSI Design,
pages 611–614.
[9] J.G. Proakis and M. Salehi. Digital communications. McGraw-hill New York, 1995.
[10] S.S. Shah, F. Suleman, S. Yaqub, and C. Logics. VITERBI DECODING IN FIELD
PROGRAMMABLE GATE ARRAYs (FPGAs).
[11] F.L. Vargas, R.D.R. Fagundes, and D. Junior. A FPGA-based Viterbi algorithm
implementation for speech recognition systems. In IEEE INTERNATIONAL CON-
FERENCE ON ACOUSTICS SPEECH AND SIGNAL PROCESSING, volume 2.
Citeseer, 2001.
14