Professional Documents
Culture Documents
On
SUBMITTED BY,
2: CONVOLUTIONAL ENCODER..……………………………………………….…03
7 : REFERENCES…………………………………………………………....................28
1 Introduction and Definitions
In block coding, the encoder accepts a k-bit message block and generates
an n-bit code word. Thus, code words are produced on a block by block basis. A
provision has to be made in the encoder to buffer an entire message block buffer
generating the associated code word. Generally, we have the message coming in serially
rather than in blocks, in which case the use of the buffer may be undesirable. In such
situations, convolutional coding might be preferred.
A convolutional code is generated by passing the information sequence to
be transmitted through a linear finite state shift register. Hence, the block of n code digits
generated by a convolutional encoder at a time depends not only on the block of K-
message bits at that time, but also on N-1 previous blocks of data.
An advantage of convolutional coding is that it can be applied to a
continuous data stream as well as to blocks of data. Like block codes, convolutional
codes can be designed to either detect or correct errors. However, as data is retransmitted
in blocks, block codes are better suited for error detection and convolutional codes are
mainly used for error correction.
• First, select the state having the smallest accumulated error metric and save the
state number of that state.
• Iteratively perform the following step until the beginning of the trellis is reached:
Working backward through the state history table, for the selected state, select a
new state which is listed in the state history table as being the predecessor to that
state. Save the state number of each selected state. This step is called trace back.
• Now work forward through the list of selected states saved in the previous steps.
Look up what input bit corresponds to a transition from each predecessor state to
its successor state. That is the bit that must have been encoded by the
convolutional encoder
4 Viterbi Decoder Implementation
This section discusses the different parts of the Viterbi decoder. Analog
signals are quantized and converted into digital signals in the quantization block. The
synchronization block detects the frame boundaries of code words and symbol
boundaries. We assumed that the Viterbi decoder receives successive code symbols, in
which the boundaries of the symbols and the frames have been identified.
4.1: WORKING OF THE VITERBI ALGORITHM
The major tasks in the Viterbi decoding process are as follows:
1. Branch metric computation.
2. State metric update
3. Survivor path recording
4. Output decision generation
The whole program for the convolutional encoder and Viterbi decoder can
be summarized as shown in the following flowchart
(Input data)
ENCODER
(Encoded Data)
BRANCH METRIC
GENERATOR
(Branch
Metric Values)
PATH METRIC
GENERATOR
( Path
D Metric Values)
COMPARE
SELECT UNIT
(Selection Bits)
DECISION
LOGIC CIRCUIT
(SURVIVAL PATH
GENERATOR)
(Decoded Output)
5.3 HARDWARE DESCRIPTION OF VARIOUS MODULES
1) TOP MODULE
`timescale 1ns/1ps
module trellis_codec(out,input_data,clk,reset) ;
output out ;
input input_data,clk,reset ;
wire [1:0] encoded_data ;
wire [15:0] bm_value ;
wire [3:0] pm_new00,pm_new01,pm_new10,pm_new11 ;
wire [3:0] pm_old00,pm_old01,pm_old10,pm_old11 ;
wire [3:0] sel ;
// Module which generates branch metric value for the encoded output
bmu_memory module_branch_metric_unit
(
bm_value,encoded_data,clk
) ;
// Module which generates the path metric values for all the states
new_pm_generator path_metric_generate_unit
(
sel,
pm_new00,pm_new01,pm_new10,pm_new11,
pm_old00,pm_old01,pm_old10,pm_old11,
bm_value,clk
) ;
// Module which stores the path metric values for all the states
register_set path_metric_store_unit
(
pm_old00,pm_old01,pm_old10,pm_old11,
pm_new00,pm_new01,pm_new10,pm_new11,
clk,reset
) ;
endmodule
2) CONVOLUTIONAL ENCODER
module encoder(y,x,clk,reset) ;
output [1:0] y ;
reg [1:0] y ;
input x ;
input clk,reset ;
wire x_1,x_2 ;
initial
y=2'b0 ;
always @
(posedge clk)
if(reset==1)
y=2'b0 ;
else
begin
y[0] = x ^ x_2 ;
y[1] = x_1 ^ x_2 ^ x ;
end
endmodule
2.1) D-FLIPFLOP
module dff(Q,D,clk) ;
output Q ;
input D,clk ;
reg Q ;
initial
Q=0 ;
always @
(posedge clk)
Q = D ;
endmodule
3) BRANCH METRIC UNIT
module bmu_memory(bm_out,encoded_input,clk);
output [15:0] bm_out ;
reg [15:0] bm_out ;
input [1:0] encoded_input ;
input clk ;
initial
bm_out=16'b0000000000000000 ;
always@(negedge clk)
begin
end
endmodule
4) PATH METRIC UNIT
module new_pm_generator
(
sel_bit,
pm_new00,pm_new01,pm_new10,pm_new11,
pm_old00,pm_old01,pm_old10,pm_old11,
bm_value,clk
) ;
assign sum10=pm_old10+bm_value[7:6] ;
assign sum11=pm_old11+bm_value[5:4] ;
assign sum20=pm_old00+bm_value[11:10] ;
assign sum21=pm_old01+bm_value[9:8] ;
assign sum30=pm_old10+bm_value[15:14] ;
assign sum31=pm_old11+bm_value[13:12] ;
initial
begin
pm_new00=4'b0000 ;
pm_new01=4'b1000 ;
pm_new10=4'b1000 ;
pm_new11=4'b1000 ;
sel_bit=0 ;
end
always@
(posedge clk)
begin
if(sum00<=sum01)
begin
pm_new00=sum00 ;
sel_bit[0]=0 ;
end
else
begin
pm_new00=sum01 ;
sel_bit[0]=1 ;
end
if(sum10<=sum11)
begin
pm_new01=sum10 ;
sel_bit[1]=0 ;
end
else
begin
pm_new01=sum11 ;
sel_bit[1]=1 ;
end
if(sum20<=sum21)
begin
pm_new10=sum20 ;
sel_bit[2]=0 ;
end
else
begin
pm_new10=sum21 ;
sel_bit[2]=1 ;
end
if(sum30<=sum31)
begin
pm_new11=sum30 ;
sel_bit[3]=0 ;
end
else
begin
pm_new11=sum31 ;
sel_bit[3]=1 ;
end
end
endmodule
5) PATH METRIC MEMORY
module register_set
(
pm_out00,pm_out01,pm_out10,pm_out11,
pm_in00 ,pm_in01 ,pm_in10 ,pm_in11 ,
clk,reset
) ;
initial
begin
pm_out00=4'b0000 ;
pm_out01=4'b1000 ;
pm_out10=4'b1000 ;
pm_out11=4'b1000 ;
end
always@(negedge clk)
begin
if(reset==1)
begin
pm_out00=4'b0000 ;
pm_out01=4'b1000 ;
pm_out10=4'b1000 ;
pm_out11=4'b1000 ;
end
else
begin
pm_out00=pm_in00 ;
pm_out01=pm_in01 ;
pm_out10=pm_in10 ;
pm_out11=pm_in11 ;
end
end
endmodule
6) SURVIVAL PATH UNIT
module pnph(out,sel,clk) ;
output out ;
reg out ;
input [3:0] sel ;
input clk ;
wire sel00,sel01,sel02,sel03 ;
wire sel10,sel11,sel12,sel13 ;
wire sel20,sel21,sel22,sel23 ;
wire sel30,sel31,sel32,sel33 ;
wire sel40,sel41,sel42,sel43 ;
wire sel50,sel51,sel52,sel53 ;
wire sel60,sel61,sel62,sel63 ;
wire sel70,sel71,sel72,sel73 ;
wire sel81,sel82,sel83 ;
wire sel91,sel93 ;
spblock_1 dev0_0(q0_00,q0_01,sel00,sel[0],clk) ;
spblock_1 dev0_1(q0_10,q0_11,sel01,sel[2],clk) ;
spblock_1 dev0_2(q0_20,q0_21,sel02,sel[1],clk) ;
spblock_1 dev0_3(q0_30,q0_31,sel03,sel[3],clk) ;
spblock dev1_0(q1_00,q1_01,sel10,q0_00,q0_10,sel00,clk) ;
spblock dev1_1(q1_10,q1_11,sel11,q0_20,q0_30,sel01,clk) ;
spblock dev1_2(q1_20,q1_21,sel12,q0_01,q0_11,sel02,clk) ;
spblock dev1_3(q1_30,q1_31,sel13,q0_21,q0_31,sel03,clk) ;
spblock dev2_0(q2_00,q2_01,sel20,q1_00,q1_10,sel10,clk) ;
spblock dev2_1(q2_10,q2_11,sel21,q1_20,q1_30,sel11,clk) ;
spblock dev2_2(q2_20,q2_21,sel22,q1_01,q1_11,sel12,clk) ;
spblock dev2_3(q2_30,q2_31,sel23,q1_21,q1_31,sel13,clk) ;
spblock dev3_0(q3_00,q3_01,sel30,q2_00,q2_10,sel20,clk) ;
spblock dev3_1(q3_10,q3_11,sel31,q2_20,q2_30,sel21,clk) ;
spblock dev3_2(q3_20,q3_21,sel32,q2_01,q2_11,sel22,clk) ;
spblock dev3_3(q3_30,q3_31,sel33,q2_21,q2_31,sel23,clk) ;
spblock dev4_0(q4_00,q4_01,sel40,q3_00,q3_10,sel30,clk) ;
spblock dev4_1(q4_10,q4_11,sel41,q3_20,q3_30,sel31,clk) ;
spblock dev4_2(q4_20,q4_21,sel42,q3_01,q3_11,sel32,clk) ;
spblock dev4_3(q4_30,q4_31,sel43,q3_21,q3_31,sel33,clk) ;
spblock dev5_0(q5_00,q5_01,sel50,q4_00,q4_10,sel40,clk) ;
spblock dev5_1(q5_10,q5_11,sel51,q4_20,q4_30,sel41,clk) ;
spblock dev5_2(q5_20,q5_21,sel52,q4_01,q4_11,sel42,clk) ;
spblock dev5_3(q5_30,q5_31,sel53,q4_21,q4_31,sel43,clk) ;
spblock dev6_0(q6_00,q6_01,sel60,q5_00,q5_10,sel50,clk) ;
spblock dev6_1(q6_10,q6_11,sel61,q5_20,q5_30,sel51,clk) ;
spblock dev6_2(q6_20,q6_21,sel62,q5_01,q5_11,sel52,clk) ;
spblock dev6_3(q6_30,q6_31,sel63,q5_21,q5_31,sel53,clk) ;
spblock dev7_0(q7_00,q7_01,sel70,q6_00,q6_10,sel60,clk) ;
spblock dev7_1(q7_10,q7_11,sel71,q6_20,q6_30,sel61,clk) ;
spblock dev7_2(q7_20,q7_21,sel72,q6_01,q6_11,sel62,clk) ;
spblock dev7_3(q7_30,q7_31,sel73,q6_21,q6_31,sel63,clk) ;
spblock dev8_1(q8_10,q8_11,sel81,q7_20,q7_30,sel71,clk) ;
spblock dev8_2(q8_20,q8_21,sel82,q7_01,q7_11,sel72,clk) ;
spblock dev8_3(q8_30,q8_31,sel83,q7_21,q7_31,sel73,clk) ;
spblock dev9_1(q9_10,q9_11,sel91,q8_20,q8_30,sel81,clk) ;
spblock dev9_3(q9_30,q9_31,sel93,q8_21,q8_31,sel83,clk) ;
always@
(q9_10 , q9_11 , q9_30 , q9_31)
out = q9_10 | q9_11 | q9_30 | q9_31 ;
endmodule
output q0,q1,sel_out ;
input sel_in,clk ;
wire in=1'b1 ;
dff dev1(sel_out,sel_in,clk) ;
dmux dev2(q0,q1,in,sel_out) ;
endmodule
module spblock(q0,q1,sel_out,d0,d1,sel_in,clk) ;
output q0,q1,sel_out ;
input d0,d1,sel_in,clk ;
endmodule
output q0,q1 ;
input in,sel ;
assign q0 = in &(~sel) ;
assign q1 = in & sel ;
endmodule
6 Experimental Results and Conclusions
The entire code has been compiled and synthesized using xilinx ise8.1.
We have used modelsim to simulate the modules. Finally, we have used virtex to
practically check out the correctness of the entire program.
=========================================================================
* Synthesis Options Summary *
=========================================================================
Input File Name : "trellis_codec.prj"
Input Format : mixed
Target Device : xc2vp30-7-ff896
=========================================================================
HDL Synthesis Report
=========================================================================
Macro Statistics
# ROMs : 01
4x16-bit ROM : 01
# Adders/Subtractors : 08
4-bit adder : 08
# Registers : 54
1-bit register : 45
16-bit register : 01
4-bit register : 08
# Comparators : 04
4-bit comparator lessequal : 04
# Xors : 02
1-bit xor2 : 02
=========================================================================
* Advanced HDL Synthesis Report *
=========================================================================
Macro Statistics
# ROMs : 01
4x16-bit ROM : 01
# Adders/Subtractors : 08
4-bit adder : 08
# Registers : 55
Flip-Flops : 55
# Comparators : 04
4-bit comparator lessequal : 04
# Xors : 02
1-bit xor2 : 02
=========================================================================
Device utilization summary:
=========================================================================
Timing Summary : Speed Grade: -7
1)encoder output :
6.4 CONCLUSIONS :
⋅ From the graphs, it is clear that the efficiency of the decoder decreases
with increases in channel noise.
⋅ The latency of the decoder is 200ns (equal to the no of stages in the
pnph unit time’s clock period).
⋅ The maximum frequency at which the decoder works is 125.878MHz (from
synthesis report).
⋅ As an extension to this work, we can look at pipelining the ACS unit and
can think of reconfigurable architecture for implementing convolutional
encoders with different code rates simultaneously.
7 References
1. Anh Dinh, Ralph Mason and Joe Toth,” HIGH SPEED V.32 TRELLIS ENCODER &
DECODER IMPLEMENTATION USING FPGA,”in IEEE transactions on
communications,1999
6. S. Lin and D. J. Costello, Error Control Coding. Englewood Cliffs, NJ: Prentice Hall,
1982