aplicação em comunicações ópticas, os seguintes trabalhos ainda necessitam ser realizados:
a) Estudo, construção e análise do desempenho de outros códigos estruturados tais como os códigos LDPC quase-cíclicos (QC-LDPC);
b) Estudo de códigos estruturados não-binários;
c) Estudo de outros algoritmos sub-ótimos de decodificação de códigos LDPC;
d) Implementação de arquiteturas do decodificador LDPC que utilizem menor quantidade de elementos lógicos na placa FPGA;
e) Modelagem mais precisa do canal óptico;
f) Representação com menor número de bits da notação em ponto fixo dos números envolvi- dos no cálculo da decodificação dos códigos LDPC;
g) Estudo e implementação de código corretores de erro conjuntamente com modulação não binária (BPSK);
h) Desenvolvimento da interface óptica-elétrica necessária para a validação em hardware do codificador e do decodificador LDPC sintetizados em FPGA.
REFERÊNCIAS BIBLIOGRÁFICAS
[1] I. Djordjevic, W. Ryan and B. Vasic, Coding for optical channels. New York: Springer, 2010. [2] Wada, H., et al. FEC Considerations for 10Gbps EPON System. September 18, 2006. Disponível em: <http://www.ieee802.org/3/av/public/2006_09/3av_0609_wada_1.pdf> Acesso em: 17 ago.2010. [3] J. Castiñeira Moreira and P. Farrell, Essentials of error-control coding. West Sussex, England: John Wiley & Sons, 2006.
[4] Sae-Young Chung; Forney, G.D., Jr.; Richardson, T.J.; Urbanke, R., "On the design of low-density parity-check codes within 0.0045 dB of the Shannon limit," in Communications Letters, IEEE , vol.5, no.2, pp.58-60, Feb 2001.
[5] IEEE Unapproved Draft Std P802.11n/D11.0, Jun. 2009.
[6] M. Jobes. A VLSI Architecture and the FPGA Implementation for multi-rate LDPC Decoding, MASc thesis, McMaster University, 2009.
[7] M. Karkooti. Semi-Parallel Architectures for Real-Time LDPC Coding, MASc thesis, Rice University, 2004.
[8] W. E. Ryan. An Introduction to LDPC codes. Disponível em:
<http://www.telecom.tuc.gr/~alex/papers/ryan.pdf> Acesso em: 13 fev.2011.
[9] J. Teubner and L. Woods, Data processing on FPGAs. San Rafael, Calif.: Morgan & Claypool, 2013. [10] Virtex-5 FPGA User Guide. Disponível em:
<http://www.xilinx.com/support/documentation/user_guides/ug190.pdf> Acesso em: 22 jun. de 2012. [11] Karkooti, M.; Cavallaro, J.R., "Semi-parallel reconfigurable architectures for real-time LDPC decoding," Information Technology: Coding and Computing, 2004. Proceedings. ITCC 2004. International Conference on , vol.1, no., pp.579,585 Vol.1, 5-7 April 2004.
[12] Mansour, M.M.; Shanbhag, N.R., "Low-power VLSI decoder architectures for LDPC codes," in Low Power Electronics and Design, 2002. ISLPED '02. Proceedings of the 2002 International Symposium on, vol., no., pp.284-289, 2002.
[13] L. Yang. An area-efficient architecture for the implementation of LDPC decoder, MASc thesis, Case Western Reserve University, 2011.
[14] Xiao-Yu Hu; Eleftheriou, E.; Arnold, D.-M.; Dholakia, A., "Efficient implementations of the sum- product algorithm for decoding LDPC codes," in Global Telecommunications Conference, 2001. GLOBECOM '01. IEEE , vol.2, no., pp.1036-1036E vol.2, 2001.
of an LDPC decoder for unstructured codes," in Signals, Circuits and Systems, 2008. SCS 2008. 2nd International Conference on , vol., no., pp.1-6, 7-9 Nov. 2008.
[16] Darabiha, A.; Carusone, A.C.; Kschischang, F.R., "A bit-serial approximate min-sum LDPC decoder and FPGA implementation," in Circuits and Systems, 2006. ISCAS 2006. Proceedings. 2006 IEEE International Symposium on , vol., no., pp.4 pp.-, 21-24 May 2006.
[17] Kamiya, N.; Shioiri, S., "Concatenated QC-LDPC and SPC codes for 100 Gbps ultra long-haul optical transmission systems," in Optical Fiber Communication (OFC), collocated National Fiber Optic Engineers Conference, 2010 Conference on (OFC/NFOEC), vol., no., pp.1-3, 21-25 March 2010. [18] Djordjevic, I.B.; Arabaci, M.; Minkov, L.L., "Next Generation FEC for High-Capacity Communication in Optical Transport Networks," in Lightwave Technology, Journal of, vol.27, no.16, pp.3518-3530, Aug.15, 2009.
[19] Yun Chen; Xiang Chen; Yifei Zhao; Chunhui Zhou; Jing Wang, "Design and implementation of multi-mode QC-LDPC decoder," in Communication Technology (ICCT), 2010 12th IEEE International Conference on, vol., no., pp.1145-1148, 11-14 Nov. 2010.
[20] Spagnol, C.; Marnane, W., "A class of quasi-cyclic LDPC codes over GF(2m)," in Communications, IEEE Transactions on, vol.57, no.9, pp.2524-2527, September 2009.
[21] Chung-Jin Tsai; Mu-Chung Chen, "Efficient LDPC decoder implementation for DVB-S2 system," in VLSI Design Automation and Test (VLSI-DAT), 2010 International Symposium on, vol., no., pp.37- 40, 26-29 April 2010.
[22] Zhengya Zhang; Dolecek, L.; Lee, P.; Anantharam, V.; Wainwright, M.J.; Richards, B.; Nikolic, B., "Low error rate LDPC decoders," in Signals, Systems and Computers, 2009 Conference Record of the Forty-Third Asilomar Conference on , vol., no., pp.1278-1282, 1-4 Nov. 2009.
[23] Jie Jin; Chi-ying Tsui, "A low power layered decoding architecture for LDPC decoder implementation for IEEE 802.11n LDPC codes," in Low Power Electronics and Design (ISLPED), 2008 ACM/IEEE International Symposium on , vol., no., pp.253-258, 11-13 Aug. 2008.
[24] Fanucci, L.; Rossi, F., "A throughput/complexity analysis for the VLSI implementation of LDPC decoder," in Signal Processing and Information Technology, 2004. Proceedings of the Fourth IEEE International Symposium on , vol., no., pp.409-412, 18-21 Dec. 2004.
[25] Hong Ding; Shuai Yang; Wu Luo; Mingke Dong, "Design and Implementation for High Speed LDPC Decoder with Layered Decoding," in Communications and Mobile Computing, 2009. CMC '09. WRI International Conference on , vol.1, no., pp.156-160, 6-8 Jan. 2009.
[26] Guilloud, F.; Boutillon, E.; Tousch, J.; Danger, J.-L., "Generic Description and Synthesis of LDPC Decoders," in Communications, IEEE Transactions on , vol.55, no.11, pp.2084-2091, Nov. 2007. [27] Bhatt, T., Narayanan, K., & Kehtarnavaz, N. (2000, October). Fixed point DSP implementation of low-density parity check codes. In Proc. Ninth DSP Workshop, Hunt, Texas.
[28] Brack, T.; Alles, M.; Lehnigk-Emden, T.; Kienle, F.; Wehn, N.; L'Insalata, N.E.; Rossi, F.; Rovini, M.; Fanucci, L., "Low Complexity LDPC Code Decoders for Next Generation Standards," in Design, Automation & Test in Europe Conference & Exhibition, 2007. DATE '07 , vol., no., pp.1-6, 16-20 April 2007.
[29] Beuschel, C.; Pfleiderer, Hans-Jörg, "FPGA implementation of a flexible decoder for long LDPC codes," in Field Programmable Logic and Applications, 2008. FPL 2008. International Conference on , vol., no., pp.185-190, 8-10 Sept. 2008.
[30] Mizuochi, T.; Konishi, Y.; Miyata, Y.; Inoue, T.; Onohara, K.; Kametani, S.; Sugihara, T.; Kubo, K.; Kobayashi, T.; Yoshida, H.; Ichikawa, T., "FPGA based prototyping of next generation forward error correction," in Optical Communication, 2009. ECOC '09. 35th European Conference on , vol., no., pp.1-4, 20-24 Sept. 2009.
[31] Yongyi Mao; Banihashemi, A.H., "A heuristic search for good low-density parity-check codes at short block lengths," in Communications, 2001. ICC 2001. IEEE International Conference on, vol.1, no., pp.41-44 vol.1, 11-14 Jun 2001.
[32] Sae-Young Chung; Richardson, T.J.; Urbanke, R.L., "Analysis of sum-product decoding of low- density parity-check codes using a Gaussian approximation," in Information Theory, IEEE Transactions on , vol.47, no.2, pp.657-670, Feb 2001.
[33] W. P. de S. Guimarães, Decodificação híbrida para códigos LDPC, Tese (Doutorado em Eng. Elétrica), Programa de Pós-Graduação em Engenharia Elétrica da Universidade Federal de Pernambuco, Recife, PE, 2013.
[34] M. A. C. Gomes, Códigos binários definidos por matrizes de teste de paridade esparsas algoritmos de descodificação, MASc thesis,Universidade de Coimbra, 2003.
[35] LDPC code using MATLAB and C MEX. Disponível em
<http://sites.google.com/site/bsnugroho/ldpc>. Acesso em: 3 set. 2011.
[36] Soares, André. “Desafios das próximas gerações de Redes Ópticas de Transporte.” UFPI.
ENUCOMP 2013. Disponível em
ANEXO A – Código-fonte dos arquivos desenvolvidos para realizar a análise do desempenho dos algoritmos log-SP e SM utilizando os códigos IE-LDPC construídos
% ---
%% ldpd_top.m %%
% Script to test dec_logSP_f.
clear; clc;
tic;
%% File for the results fid = fopen('ber_res.txt','w');
%% Signal-to-noise ratio SNR_dB = 0:.5:7; %SNR_dB = 2;
%% Initializations
% error number for log-SP algorithm n1_err = zeros(1,length(SNR_dB));
% error number for SM algorithm n2_err = zeros(1,length(SNR_dB));
% number of transmitted words %N = 10^4;
%N = 10^3
N_vec = [10^3 10^3 10^3 10^3 10^3 10^4 10^4 10^4 10^5 10^5 10^5 10^6 10^6 10^7 10^7]; n_min_err = [100 100 100 50 50 50 25 25 25 25 10 10 10 10 10];
%% generating parity-check and generator matrix n = 2000;
k = 1000;
dim = 500; % identity matrix dimension
[H, G] = gen_mat_f(n,k,dim);
% number of errors n1_err = zeros(1,length(SNR_dB)); n2_err = zeros(1,length(SNR_dB)); % number of iterations niter1 = zeros(1,length(SNR_dB)); niter2 = zeros(1,length(SNR_dB)); for ii = 1:length(SNR_dB) err1 = 0; err2 = 0; for ll = 1:N_vec(ii) %% Monte Carlo loop
if ((n1_err(ii) < n_min_err(ii)) && (n2_err(ii) < n_min_err(ii))) %% LDPC encoding m = randint(1,k,[0,1]); c = ldpc_enc_f(m,G); %% Modulation x = 1 - 2*c;
%% Transmitting over a AWGN channel [y, sigma] = awgn_channel_f(x,SNR_dB(ii)); %y = x;
%% LDPC decoding
fprintf('Decoding %d word for %0.1f dB\n',ll,SNR_dB(ii));
% number of iterations iter = 5;
% log-SP decoding
[logSP_c_hat, logSP_ok] = dec_logSP_f(y,H,iter,n,k,sigma); %c
%logSP_c_hat
% SM decoding
[SM_c_hat, SM_ok] = dec_SM_f(y,H,iter,n,k); %c
%SM_c_hat
%% Error computation
err1 = err1 + biterr(c,logSP_c_hat); err2 = err2 + biterr(c,SM_c_hat); niter1 = ll;
n1_err(ii) = err1; n2_err(ii) = err2; n1_iter(ii) = niter1; n2_iter(ii) = niter2; % BER ber1(ii) = n1_err(ii)/(n1_iter(ii)*length(y)); %ber1(ii) = n1_err(ii)/(N*length(y)); ber2(ii) = n2_err(ii)/(n2_iter(ii)*length(y)); %ber2(ii) = n1_err(ii)/(N*length(y));
fprintf('ber1: %d ber2: %d \n',n1_err(ii),n2_err(ii)); fprintf(fid,'ber1: %d ber2: %d \n',n1_err(ii),n2_err(ii)); else break; end end end %% BER plot
figure('Color',[1 1 1]); % change background color set(gca, 'Fontsize', 16)
semilogy(SNR_dB, ber1, 'rd-.', 'Linewidth', 3, 'Markersize', 8); hold all;
semilogy(SNR_dB, ber2, 'bo-.', 'Linewidth', 3, 'Markersize', 8); hold all; xlabel('Eb/N0(dB)'); ylabel('BER'); grid on legend('log-SP','SM',1); %grid on; hold off; n1_err n2_err n1_iter n2_iter ber1 ber2 %% File fclose(fid); toc; % ---
%% gen_mat_f.m %%
% This function generates a matrix H based on its colunm number (n), its % line number (k) and the dimension of its basic matrix (dim).
function [H, G] = gen_mat_f(n,k,dim)
% There will be used ((n-k)/dim)*(k/dim) rotated matrices. % The matrices are a prime number shifted.
% Initializing the matrix.
% Pt = transpose matrix of parity matrix Pt = zeros((n-k),k);
% Prime number set. The value 20000 was chosen because for LDPC(4000,2000) % and dim = 50, it is necessary 1600 shift values.
Prime_set = primes(200000);
% index of the prime number set element index = 1;
% x1 is the column index inside matrix Mat
% x2 is the line index inside matrix Mat
for i=1:(n-k)/dim for j=1:k/dim % shift number nrot = Prime_set(index); % shifted matrix Mrot = rot_mat_f(dim,nrot); x1 = dim*(j-1)+ 1; x2 = dim*(i-1)+ 1; Pt(x2:x2+dim-1,x1:x1+dim-1) = Mrot; index = index + 1; end end % parity-check matrix H = [eye(n-k) Pt]; % parity matrix P = Pt'; % generator matrix G = [P eye(k)];
% ---
%% rot_mat_f.m %%
% This function generates a matrix from the identity matrix shifted nrot % colunms to the right.
% dim = identity matrix dimension % nrot = right shift number
function Mrot = rot_mat_f(dim,nrot)
Meye = eye(dim);
P = [Meye(:,dim) Meye(:,1:dim-1)];
% initialized with the identity matrix Mrot = P; if nrot == 0 Mrot = eye(dim); else if nrot == 1 Mrot = P; else for i=1:mod(nrot-1,dim) Mrot = Mrot*P; end end end % --- %% ldpc_enc_f.m %% % LDPC encoder % m : word to be encoded % G : generator matrix function c = ldpc_enc_f(m,G) % G = k x n % m = 1 x k
% It is necessary to use m' at the multiplication
% Multiplication done at GF(2) gf_m = gf(m',2);
% G' = n x k m' = k x 1 % Multiplication G' and m' --> n x 1 gf_c = gf_G*gf_m; % encoded word c(gf_c == 1) = 1; c(gf_c == 0) = 0; % --- %% awgn_channel_f.m %% % AWGN channel
function [y, sigma] = awgn_channel_f(x,SNR)
N0 = 10^-(0.1*SNR); sigma = sqrt(N0/2); noise = sigma*randn(1,length(x)); y = x + noise; % --- %% dec_logSP_f.m %%
% Implementation of LDPC decoding algorithm log-SP. % y: received word
% H: parity-check matrix % iter: iteration number
function [c_hat, ok] = dec_logSP_f(y,H,iter,n,k,sigma)
% number of iterations done by the loop it = 0;
ok = 1;
while (ok ~= 0 && it < iter)
if (it == 0)
% finding Hzon
[Hzon, wc_vec, wc] = hzon_f(H,n); %Hzon
% finding Hver
[Hver, wr_vec, wr] = hver_f(H,k); %Hver % initialization [Lc, Lq] = logSP_init_f(y,sigma,n,wc); end % Horizontal step Lr = logSP_Hstep_f(Lq,Hzon,Hver,k,wr,wr_vec,wc_vec); % Vertical step Lq = Vstep_f(Lr,Lc,Hzon,Hver,n,wc,wc_vec,wr_vec); % Q calculation Q = Qcalc_f(Lr,Lc,Hzon,Hver,n,wc_vec,wr_vec); % Decision c_hat = decision_f(Q,n); % Syndrome synd = synd_f(c_hat, H); ok = sum(synd.x); it = it + 1; end % --- %% hzon_f.m %%
% The matrix Hzon stores the columns of the matrix H where there are % non-zero elements.
function [Hzon, wc_vec, wc] = hzon_f(H,n)
% column and line positions for H(1,1) == 1 [row, col] = find(H == 1);
% vector with wc for all columns wc_vec = zeros(1,n);
% determining wc max_wc = 0;
for i=1:n % number of 1s in a column n_wc = 0; for j=1:length(col) if col(j) == i n_wc = n_wc + 1; end end wc_vec(i) = n_wc; if n_wc >= max_wc max_wc = n_wc; end end wc = max_wc; % initializing Hzon Hzon = zeros(wc,n); for i=1:n
% row inside Hzon jrow = 0; for j=1:size(col) if col(j) == i jrow = jrow + 1; Hzon(jrow,i)= row(j); end end end % --- %% hver_f.m %%
% The matrix Hver stores the lines of the matrix H where there are non-zero % elements.
function [Hver, wr_vec, wr] = hver_f(H,k)
% Finding line and column positions for H(i,j) == 1 [row, col] = find(H == 1);
% vector with wr for all rows wr_vec = zeros(1,k);
% determining wr max_wr = 0;
for j=1:k % number of 1s in a line n_wr = 0; for i=1:length(row) if row(i) == j n_wr = n_wr + 1; end end wr_vec(j) = n_wr; if n_wr >= max_wr max_wr = n_wr; end end wr = max_wr; % initializing Hver Hver = zeros(k,wr); for j=1:k
% row inside Hzon icol = 0; for i=1:length(row) if row(i) == j icol = icol + 1; Hver(j,icol)= col(i); end end end % --- %% logSP_init_f.m %%
% log-SP algorithm initialization of Lc and Lq vectors.
function [Lc, Lq] = logSP_init_f(y,sigma,n,wc) Lc = zeros(1,n); Lq = zeros(wc,n); for i=1:n Lc(i) = (2*y(i))/(sigma^2); for j=1:wc Lq(j,i) = Lc(i);
end end
% ---
%% logSP_Hstep_f.m %%
% Function to calculate horizontal step for log-SP algorithm.
function Lr = logSP_Hstep_f(Lq,Hzon,Hver,k,wr,wr_vec,wc_vec) Lr = zeros(k,wr); % line loop for j=1:k % column loop for i=1:wr_vec(j) alfa = 1; sum_beta = 0;
% elements in the line loop for l =1:wr_vec(j) if(l ~= i)
col_Lq = Hver(j,l); % loop inside Hzon column for ll=1:wc_vec(col_Lq) if (Hzon(ll,col_Lq) == j) line_Lq = ll; end end alfa = alfa*sign(Lq(line_Lq,col_Lq)); beta = abs(Lq(line_Lq,col_Lq)); sum_beta = sum_beta + alfa_f(beta); end end Lr(j,i) = alfa*alfa_f(sum_beta); end end % --- %% Vstep_f.m %%
% Function that performs Vertical Step of LDPC decodification
function Lq = Vstep_f(Lr,Lc,Hzon,Hver,n,wc,wc_vec,wr_vec)
% column loop for i=1:n % line loop for j=1:wc_vec(i) sum_Lr = 0;
% elements in the column loop for l=1:wc_vec(i) if (j~=l) line_Lr = Hzon(l,i); for ll=1:wr_vec(line_Lr) if (Hver(line_Lr,ll) == i) col_Lr = ll; end end
sum_Lr = sum_Lr + Lr(line_Lr,col_Lr); end
end
Lq(j,i) = Lc(i) + sum_Lr; end
end
% ---
%% Qcalc_f.m %%
% Function that performs Vertical Step of LDPC decodification
function Q = Qcalc_f(Lr,Lc,Hzon,Hver,n,wc_vec,wr_vec)
Q = zeros(1,n);
for i=1:n sum_Q = 0; for j=1:wc_vec(i)
% elements in the column loop line_Lr = Hzon(j,i); for ll=1:wr_vec(line_Lr) if (Hver(line_Lr,ll) == i) col_Lr = ll; end end
sum_Q = sum_Q + Lr(line_Lr,col_Lr); end
Q(i) = Lc(i) + sum_Q; end
% ---
%% decision_f.m %%
% Function to calculate the decoded word.
function c_hat = decision_f(Q,n)
% decoded word c_hat = zeros(1,n); c_hat(Q < 0) = 1; c_hat(Q >= 0) = 0; % --- %% synd_f.m %%
% Function that calculates the syndrome of the decoded word.
function synd = synd_f(c_hat, H)
% Transforming c_hat to GF(2) to perform matrix multiplication gf_c_hat = gf(c_hat',2);
synd = H*gf_c_hat;
% ---
%% dec_SM_f.m %%
% Implementation of LDPC decoding algorithm log-SP. % y: received word
% H: parity-check matrix % iter: iteration number
function [c_hat, ok] = dec_SM_f(y,H,iter,n,k)
% number of iterations done by the loop it = 0;
ok = 1;
while (ok ~= 0 && it < iter)
if (it == 0)
[Hzon, wc_vec, wc] = hzon_f(H,n); %Hzon
% finding Hver
[Hver, wr_vec, wr] = hver_f(H,k); %Hver % initialization [Lc, Lq] = SM_init_f(y,n,wc); end % Horizontal step Lr = SM_Hstep_f(Lq,Hzon,Hver,k,wr,wr_vec,wc_vec); % Vertical step Lq = Vstep_f(Lr,Lc,Hzon,Hver,n,wc,wc_vec,wr_vec); % Q calculation Q = Qcalc_f(Lr,Lc,Hzon,Hver,n,wc_vec,wr_vec); % Decision c_hat = decision_f(Q,n); % Syndrome synd = synd_f(c_hat, H); ok = sum(synd.x); it = it + 1; end % --- %% SM_init_f.m %%
% SM algorithm initialization of Lc and Lq vectors.
function [Lc, Lq] = SM_init_f(y,n,wc) Lc = zeros(1,n); Lq = zeros(wc,n); for i=1:n Lc(i) = y(i); for j=1:wc
Lq(j,i) = Lc(i); end
end
% --- %% SM_Hstep_f.m %%
% Function to calculate horizontal step for log-SP algorithm.
function Lr = SM_Hstep_f(Lq,Hzon,Hver,k,wr,wr_vec,wc_vec) Lr = zeros(k,wr); % line loop for j=1:k % column loop for i=1:wr_vec(j) alfa = 1; % first iteration first = 0;
% elements in the line loop for l=1:wr_vec(j) if(i~=l)
col_Lq = Hver(j,l); % loop inside Hzon clolumn for ll=1:wc_vec(col_Lq) if (Hzon(ll,col_Lq) == j) line_Lq = ll; end
end
alfa = alfa * sign(Lq(line_Lq,col_Lq)); beta = abs(Lq(line_Lq,col_Lq)); if first == 0 mim_beta = beta; else if beta < mim_beta mim_beta = beta; end end first = 1; end end Lr(j,i)= alfa*mim_beta; end end % ---
ANEXO B - Código-fonte dos arquivos desenvolvidos para a implementação em VHDL do codificador e do decodificador dos códigos IE-LDPC construídos
# ---
-- Package that store the functions that performs sum and gives the minimum -- value of two numbers.
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; use ieee.numeric_std.all; package rasc_pkg is
-- NOTE: I use to instead of downto for Lq_t e Lr_t to facilitate validation -- using MATLAB.
-- LDPC dimensions constant n_c : integer := 8; constant k_c : integer := 4;
-- number of bit per value constant bit_c : integer := 12;
constant zero_c : std_logic_vector(bit_c-1 downto 0):= conv_std_logic_vector(0,bit_c);
-- Hzon
constant nrow_Hzon_c : integer := k_c; constant ncol_Hzon_c : integer := 4;
-- Hver
constant nrow_Hver_c : integer := n_c; constant ncol_Hver_c : integer := 2;
type row_t is array(n_c-1 downto 0) of std_logic_vector(bit_c-1 downto 0);
-- Lq
type row_Hzon_t is array(0 to ncol_Hzon_c-1) of std_logic_vector(bit_c-1 downto 0); type Lq_t is array(0 to k_c-1) of row_Hzon_t;
-- Hzon
-- Hzon matrix
constant Hzon_c : Hzon_matrix_t := ( (1,3,6,7), (2,5,6,8), (2,3,4,5), (1,4,7,8) ); -- Lr
type row_Hver_t is array(0 to ncol_Hver_c-1) of std_logic_vector(bit_c-1 downto 0); type Lr_t is array(0 to n_c-1) of row_Hver_t;
-- Hver
type Hver_matrix_t is array(1 to nrow_Hver_c, 1 to ncol_Hver_c) of integer;
-- Hver matrix
constant Hver_c : Hver_matrix_t := ( (1,4), (2,3), (1,3), (3,4), (2,3), (1,2), (1,4), (2,4) ); -- LDPC encoder
function ldpc_enc_f(data_i: std_logic_vector(k_c-1 downto 0)) return std_logic_vector;
-- sum of two numbers
function sum_f(a_v: std_logic_vector(bit_c-1 downto 0); b_v: std_logic_vector(bit_c-1 downto 0)) return std_logic_vector;
-- minimum of two numbers
function min_f(a_v: std_logic_vector(bit_c-1 downto 0); b_v: std_logic_vector(bit_c-1 downto 0)) return std_logic_vector;
-- LDPC decision
function decision_f(a_v: std_logic_vector(bit_c-1 downto 0)) return std_logic;
package body rasc_pkg is
-- LDPC encoder
function ldpc_enc_f(data_i: std_logic_vector(k_c-1 downto 0)) return std_logic_vector is
variable data_v : std_logic_vector(n_c-1 downto 0); variable aux_v : std_logic := '0';
-- message data_v(0 to k_c-1) = data_i(0 to k_c-1); aux_v := 0; for j in k_c to n_c-1 loop data_v(j) := 0;
for i in 1 to ncol_Hver_c loop if Hver_c(j,i) /= 1 then
data_v(j) := data_v(j) xor data_i(Hver_c(j,i)-1); end if;
end loop; end loop;
-- data_v : encoded data
return data_v; end ldpc_enc_f;
-- sum function
function sum_f(a_v : std_logic_vector(bit_c-1 downto 0); b_v: std_logic_vector(bit_c-1 downto 0)) return std_logic_vector is
-- The factors have size of 12 bits
-- It is necessary to truncate the number when the result is bigger -- than 127 or littler than -128.
-- maximum value: 127 -- minimum value: - 128
-- Bitwise operation is performed
variable res_v: std_logic_vector(bit_c-1 downto 0); variable carry_v: std_logic_vector(bit_c-1 downto 0);
variable result_v: std_logic_vector(bit_c-1 downto 0); variable underflow_v : std_logic;
begin
res_v(0) := a_v(0) xor b_v(0); carry_v(0) := a_v(0) and b_v(0); for j in 1 to 11 loop
carry_v(j) := (a_v(j) and b_v(j)) or (a_v(j) and carry_v(j-1)) or (b_v(j) and carry_v(j-1)); res_v(j) := a_v(j) xor b_v(j) xor carry_v(j-1);
end loop;
-- I have to use the predecessors, so it is to instead of downto. -- carry_v(11) will signalized if there is overflow or underflow.
-- overflow: both positive and carry(msb) = '1'
-- underflow: both negative and carry(msb) xor carry(msb-1) = '1' underflow_v := carry_v(11) xor carry_v(10);
-- overflow detection
if a_v(11) = '0' and b_v(11) = '0' and carry_v(10) = '1' then -- 127 Remember that the four lsb are the fractional part result_v := conv_std_logic_vector(2032,12);
-- underflow detection
elsif (a_v(11) = '1' and b_v(11) = '1') and underflow_v = '1' then -- -128 Remember that the four lsb are the fractional part result_v := conv_std_logic_vector(2048,12); else result_v := res_v; end if; return result_v; end sum_f;
-- minimum value function
function min_f(a_v: std_logic_vector(bit_c-1 downto 0); b_v: std_logic_vector(bit_c-1 downto 0)) return std_logic_vector is
-- integer values
variable a_int_v : integer range 0 to 2047; variable b_int_v : integer range 0 to 2047;
-- minimum value
variable min_value_v : std_logic_vector(bit_c-1 downto 0);
-- both positive
if a_v(11) = '0' and b_v(11) = '0' then a_int_v := conv_integer(a_v(10 downto 0));
b_int_v := conv_integer(b_v(10 downto 0)); if a_int_v > b_int_v then
min_value_v := b_v; else
min_value_v := a_v; end if;
-- a < 0 and b >= 0
elsif a_v(11) = '1' and b_v(11) = '0' then min_value_v := a_v;
-- a >= 0 and b < 0
elsif a_v(11) = '0' and b_v(11) = '1' then min_value_v := b_v;
-- both negative else
a_int_v := conv_integer(a_v(10 downto 0)); b_int_v := conv_integer(b_v(10 downto 0)); if a_int_v < b_int_v then
min_value_v := a_v; else min_value_v := b_v; end if; end if; return min_value_v; end min_f; -- LDPC decision
function decision_f(a_v: std_logic_vector(bit_c-1 downto 0)) return std_logic is
-- result
variable res_v : std_logic;
begin
-- If a_v is positive, res_v = '1', otherwise, res_v = '0' if a_v(bit_c-1) = '0' then res_v := '1'; else res_v := '0'; end if; return res_v;
end function decision_f;
end package body rasc_pkg;
# --- library ieee; use ieee.std_logic_1164.all; use IEEE.std_logic_arith.all; use IEEE.numeric_std.all; library ldpc_lp; use ldpc_lp.rasc_pkg.all;
-- Encoder for an LDPC binary code. entity ldpc_encoder_top is port(
rst_i : in std_logic; mclk_i : in std_logic; en_i : in std_logic;
data_i : in std_logic_vector(k_c-1 downto 0); data_o : out std_logic_vector(n_c-1 downto 0) );
end ldpc_encoder_top;
-- The codeword is obtained by msg * H.
architecture rtl of ldpc_encoder_top is begin process(rst_i, mclk_i) begin if rst_i = '1' then data_o <= (others => '0');
elsif mclk_i'event and mclk_i = '1' then if en_i = '1' then
for j in n_c-1 downto 0 loop data_o <= ldpc_enc_f(data_i); end loop; end if; end if; end process; end rtl; # ---
library ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_arith.all; use ieee.numeric_std.all; library ldpc_lib; use ldpc_lib.rasc_pkg.all;
-- This is the implementation of a ldpc decoder.
entity ldpc_decoder_top is port( rst_i : in std_logic; mclk_i : in std_logic; en_i : in std_logic; -- input new_word_i : in std_logic; rx_i : in row_t; -- output
dec_data_o : out std_logic_vector(n_c-1 downto 0) );
end ldpc_decoder_top;
-- new_word_i : flag to indicate a incoming data.
-- rx_i : ldpc word. It is a array of n_c elements of bit_c bits. -- It stores corresponds to values in the [-1,1] interval.
-- dec_data_o : decoded ldpc word.
-- This code version implemented a three-iteratin LDPC decoder.
architecture rtl of ldpc_decoder_top is -- first iteration component ldpc_first_iter_block is port( rst_i : in std_logic; mclk_i : in std_logic; en_i : in std_logic; -- input rx_i : in row_t; new_word_i : in std_logic; -- output
Lc_o : out row_t; Lq_o : out Lq_t; Lr_o : out Lr_t;
dec_rx_o : out std_logic_vector(n_c-1 downto 0) );
end component;
-- output signals for the inner iteration block signal Lc_first_s : row_t;
signal Lq_first_s : Lq_t; signal Lr_first_s : Lr_t; -- inner iterations component ldpc_middle_iter_block is port( rst_i : in std_logic; mclk_i : in std_logic; en_i : in std_logic; -- input new_word_i : in std_logic; Lc_i : in row_t; Lr_i : in Lr_t; -- output Lr_o : out Lr_t;
dec_rx_o : out std_logic_vector(n_c-1 downto 0) );
end component;
-- output for the last iteration block signal Lc_inner_s : row_t; signal Lq_inner_s : Lq_t; signal Lr_inner_s : Lr_t; -- last iteration component ldpc_last_iter_block is port( rst_i : in std_logic; mclk_i : in std_logic; en_i : in std_logic; -- input
new_word_i : in std_logic; Lc_i : in row_t;
Lr_i : in Lr_t;
-- output
dec_data_o : out std_logic_vector(n_c-1 downto 0)