COM-1209ASOFT High-Speed Dvb-S2 BCH Code Decoder & Encoder VHDL Source Code Overview
COM-1209ASOFT High-Speed Dvb-S2 BCH Code Decoder & Encoder VHDL Source Code Overview
Speed
FPGA
Clock
(max)
Spartan-3
Virtex-5
83 MHz
131 MHz
Encoder
I/Os
Outputs
Inputs
CLK
SYNC_RESET
DATA_IN[7:0]
SAMPLE_CLK_IN
SOF_IN
SAMPLE_CLK_IN_REQ
DATA_OUT[7:0]
SAMPLE_CLK_OUT
SOF_OUT
SAMPLE_CLK_OUT_REQ
Controls
CONTROL[1:0]
KBCH[15:0]
Encoder
output
data rate
(max)
650 Mbits/s
1 Gbits/s
672
258
1268
0
0
1
482
265
964
0
0
1
Decoder
I/Os
Inputs
Outputs
CLK
SYNC_RESET
DATA_IN[7:0]
SAMPLE_CLK_IN
SOF_IN
SAMPLE_CLK_IN_REQ
DATA_OUT[7:0]
SAMPLE_CLK_OUT
SOF_OUT
EOF_OUT
SAMPLE_CLK_OUT_REQ
Controls
Monitoring
N_CORRECTED[3:0]
GOOD_FRAME
CONTROL[1:0]
NBCH[15:0]
KBCH[15:0]
Speed
FPGA
Spartan-3
Virtex-5
Clock
(max)
73 MHz
166 MHz
4906
5002
7910
9
0
1
679,436
2626
4995
6919
5
0
1
423 Mbits/s
(58320,58192,8)
DVB-S2 BCH
810 Mbits/s
(51840,51648,12)
963 Mbits/s
(58320,58192,8)
Frame
normal
normal
normal
Normal
short
Syndromes
To compute a syndrome Si , one must first divide
the input block by the twelve polynomials gj(x),
where gj(x) represent the minimum polynomials of
i .for i = 1 to 2t (see table below). The twelve
minimum polynomials gj(x) are listed in the DVBS2 specifications in Tables 6a and 6b.
alpha = gf(2,16,prim_poly16);
p1 = [alpha^16191 1];
p2 = [alpha^16184 1];
elp = conv(p1,p2);
Matlab:
prim_poly16 = primpoly(16,min);
Flow Control
The decoder input first goes through an input elastic buffer to regulate the flow.
The buffer output data flow is sent to two components: the syndrome computation bch_syndromes.vhd and the
error correction bch_ec.vhd. Thus, both components are able to control the data flow from the input elastic
buffer using their flow control signals SAMPLE0A_CLK_REQ and SAMPLE0B_CLK_REQ respectively.
Syndromes computation is performed on the fly. Upon reading the last frame byte from the input elastic buffer,
bch_syndromes.vhd exercises its SAMPLE0A_CLK_REQ flow control signal to immediately stop the input
flow before a new start of frame. The end of syndromes computation is marked by the availability of the
syndromes (SYNDROME1 through 24) and a pulse SYNDROME_SAMPLE_CLK. At this point
bch_syndromes.vhd is ready for the next input frame.
The syndromes are passed to bcherrorlocator.vhd to compute the error location polynomials. The computation
is triggered by the SYNDROME_SAMPLE_CLK pulse and ends at the ELP_CLK pulse. The resulting error
location polynomials are available in ELP1 through 12. In the special case of an error-free frame, there is no
need to compute the error location polynomials. The ALL_ZERO_SYNDROMES net goes high when this
happens.
The final decoding step, error correction, is implemented within the bch_ec.vhd component. This component
includes a 128 Kbit elastic buffer large enough receive a new frame while processing the previous one. The
purpose of the SAMPLE0B_CLK_REQ flow control flag is stop the input data flow unless at least 1/32th of the
internal elastic buffer is available.
Typical bch_dec.vhd capture. Includes input frames with correctable and uncorrectable errors.
The flow control is primarily located within bch_ec.vhd. It is a little bit complex. There are five key events in
the life of a BCH frame decoding, in the order of occurrence:
- input start of frame pulse SOF_IN
- received all input data (excluding parity bits) INPUT_DATA_COMPLETE
- syndrome ready pulse SYNDROME_SAMPLE_CLK
- error location ready pulse ELP_CLK_IN
- all decoded bytes sent out OUTPUT_DATA_COMPLETE
Note: the error location computation is skipped if ALL_ZERO_SYNDROMES is high.
0 idle
Syndromes
ready (1)
SOF_IN (1)
all-zero
syndromes
?
Input
complete (2)
yes
no
Syndromes
ready (1)
Syndromes
ready (1)
SOF_IN(2)
5
all-zero
syndromes
?
4
yes
all-zero
syndromes
?
yes
no
no
SOF_IN (2)
Output
complete (1)
SOF_IN (2)
Input
complete (2)
1 frame processed
0 frame pending
Output
complete (1)
1 frame processed
1 frame pending
Input
complete (2)
Output
complete (1)
1 frame processed
1 frame pending
Typical bch_ec.vhd capture. Includes frames with correctable and uncorrectable errors.
Configuration Management
Reference documents
[1] ETSI EN 302 307, Section 5.3 FEC encoding
[2] Shift-Register Synthesis and BCH Decoding,
James L. Massey, IEEE Transactions on
Information Theory, January 1969.
[3] Error Control Coding, Fundamentals and
Applications, Shu Lin / Daniel Costello.
Target FPGA
The VHDL code is ready-to-use with Xilinx
Spartan-4, Virtex-4 and Virtex-5 FGPAs. Other
FPGAs may need very minor adjustments.
Xilinx-specific code
The VHDL source code was written in generic
VHDL with few Xilinx primitives. No Xilinx
CORE is used. The Xilinx primitives are:
- BUFG
- RAMB16_S9_S9
7
Decoder
Encoder
Clock / Timing
The software uses a single master clock (CLK)
which serves as input clock, output clock and signal
processing clock.
Test Benches
Several test benches are included for end-to-end
and component-level VHDL simulation:
tbbchencdec2.vhd: end-to-end simulation
including encoder, decoder and added bit
errors.
Contact Information
MSS 18221-A Flower Hill Way
Gaithersburg, Maryland 20879 U.S.A.
Telephone: (240) 631-1111
Facsimile: (240) 631-1676
E-mail: [email protected]