From 684696417099d73ebe7d889dd7fe017136473314 Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Thu, 14 Jun 2018 15:38:58 -0500 Subject: [PATCH] Add 'code b' - a better (128,90) code. Code b has irregular column weights - 80% weight 3 and 20% weight 4. --- lib/bpdecode128_90.f90 | 22 +-- lib/encode128_90.f90 | 2 +- lib/ldpc_128_90_b_generator.f90 | 41 ++++++ lib/ldpc_128_90_b_reordered_parity.f90 | 184 +++++++++++++++++++++++++ 4 files changed, 237 insertions(+), 12 deletions(-) create mode 100644 lib/ldpc_128_90_b_generator.f90 create mode 100644 lib/ldpc_128_90_b_reordered_parity.f90 diff --git a/lib/bpdecode128_90.f90 b/lib/bpdecode128_90.f90 index b3948d828..05ae51032 100644 --- a/lib/bpdecode128_90.f90 +++ b/lib/bpdecode128_90.f90 @@ -5,18 +5,18 @@ subroutine bpdecode128_90(llr,apmask,maxiterations,decoded,cw,nharderror,iter) integer, parameter:: N=128, K=90, M=N-K integer*1 codeword(N),cw(N),apmask(N) integer*1 decoded(K) -integer Nm(11,M) -integer Mn(3,N) ! 3 checks per bit +integer Nm(12,M) +integer Mn(4,N) integer synd(M) -real tov(3,N) -real toc(11,M) -real tanhtoc(11,M) +real tov(4,N) +real toc(12,M) +real tanhtoc(12,M) real zn(N) real llr(N) real Tmn -integer nrw(M),ncw +integer nrw(M),ncw(N) -include "ldpc_128_90_reordered_parity.f90" +include "ldpc_128_90_b_reordered_parity.f90" decoded=0 toc=0 @@ -36,7 +36,7 @@ do iter=0,maxiterations ! Update bit log likelihood ratios (tov=0 in iteration 0). do i=1,N if( apmask(i) .ne. 1 ) then - zn(i)=llr(i)+sum(tov(1:ncw,i)) + zn(i)=llr(i)+sum(tov(1:ncw(i),i)) else zn(i)=llr(i) endif @@ -84,7 +84,7 @@ do iter=0,maxiterations do i=1,nrw(j) ibj=Nm(i,j) toc(i,j)=zn(ibj) - do kk=1,ncw ! subtract off what the bit had received from the check + do kk=1,4 ! subtract off what the bit had received from the check if( Mn(kk,ibj) .eq. j ) then toc(i,j)=toc(i,j)-tov(kk,ibj) endif @@ -94,11 +94,11 @@ do iter=0,maxiterations ! send messages from check nodes to variable nodes do i=1,M - tanhtoc(1:11,i)=tanh(-toc(1:11,i)/2) + tanhtoc(1:12,i)=tanh(-toc(1:12,i)/2) enddo do j=1,N - do i=1,ncw + do i=1,ncw(j) ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) call platanh(-Tmn,y) diff --git a/lib/encode128_90.f90 b/lib/encode128_90.f90 index 48a13fbfb..c6daaa8c0 100644 --- a/lib/encode128_90.f90 +++ b/lib/encode128_90.f90 @@ -10,7 +10,7 @@ integer*1 codeword(N) integer*1 gen(M,K) integer*1 message(K) integer*1 pchecks(M) -include "ldpc_128_90_generator.f90" +include "ldpc_128_90_b_generator.f90" logical first data first/.true./ save first,gen diff --git a/lib/ldpc_128_90_b_generator.f90 b/lib/ldpc_128_90_b_generator.f90 new file mode 100644 index 000000000..97cb2b85f --- /dev/null +++ b/lib/ldpc_128_90_b_generator.f90 @@ -0,0 +1,41 @@ +character*23 g(38) + +data g/ & + "c555076254d8161b5cf0d3c", & + "de721b14e8339ab48de8e54", & + "e72d0efb6ca44934a896ca0", & + "631b7cc783a5e626c360598", & + "7050206b9b2e40439d17d94", & + "2f31c22ab472282d65cde44", & + "822baa20e8bcd6487d34268", & + "f9a85b9d103459b8ac34830", & + "60335e63618f9e59e031a5c", & + "b106c464771df41ab75884c", & + "3936fcebf87320d200e6b1c", & + "00135e63218f1c59c031e5c", & + "554abf55a1605425b8e8248", & + "2211850e5b32c02e42c85ec", & + "853e66d64fdf2f5cf4237a8", & + "90592d932a0c8e8190e6c50", & + "d0cdf8954d48457b6a43df0", & + "83714b5735b5bcd718887f0", & + "3146c024731df43a3750844", & + "a231a50e5232c0ae40c8dac", & + "8f5f0d73fab5d0d57bb9c48", & + "5650a8094847925466e560c", & + "5842d5c55ff32151f36ca3c", & + "0f571d7bfab4d0c57bfbcc8", & + "bb68edb9987ea6a4f56a214", & + "9d7cb35b100c0e8d07cff80", & + "6774a36c46e8d7b518780b0", & + "b07ca6f22cc3db62ca73fac", & + "d6610575c99c82edcddd028", & + "e64c7bb5d67de03d1fb0824", & + "e9bb04fe35bb65a16e856ec", & + "6c5c41bc591174e3b81e950", & + "49b480238e0623d1dd61e08", & + "c48ae6d581d94c8c2b4a8a0", & + "a16ace594ec778f95e5020c", & + "ef2cd3309b2a4e8e9a98614", & + "06008a62f368d236fbf2998", & + "015fe1f7dd017a9f67be59c"/ diff --git a/lib/ldpc_128_90_b_reordered_parity.f90 b/lib/ldpc_128_90_b_reordered_parity.f90 new file mode 100644 index 000000000..c46719b44 --- /dev/null +++ b/lib/ldpc_128_90_b_reordered_parity.f90 @@ -0,0 +1,184 @@ +data Mn/ & + 10, 25, 37, 0, & + 1, 19, 20, 0, & + 20, 27, 29, 0, & + 3, 22, 36, 0, & + 4, 26, 30, 0, & + 5, 15, 28, 0, & + 6, 21, 23, 0, & + 7, 16, 32, 0, & + 9, 31, 38, 0, & + 10, 13, 18, 0, & + 11, 20, 37, 0, & + 12, 24, 33, 0, & + 14, 25, 33, 0, & + 15, 17, 32, 0, & + 1, 9, 14, 0, & + 2, 16, 17, 0, & + 3, 5, 18, 0, & + 4, 23, 38, 0, & + 6, 24, 37, 0, & + 7, 25, 35, 0, & + 8, 29, 33, 0, & + 10, 30, 36, 0, & + 11, 27, 28, 0, & + 12, 22, 32, 0, & + 13, 17, 21, 0, & + 10, 19, 31, 0, & + 18, 26, 34, 0, & + 1, 5, 30, 0, & + 2, 19, 25, 0, & + 3, 9, 21, 0, & + 4, 8, 11, 0, & + 6, 35, 38, 0, & + 7, 13, 29, 0, & + 12, 20, 26, 0, & + 14, 24, 27, 0, & + 15, 23, 34, 0, & + 16, 31, 37, 0, & + 10, 22, 28, 0, & + 28, 34, 36, 0, & + 1, 37, 38, 0, & + 2, 5, 13, 0, & + 3, 7, 14, 0, & + 4, 16, 19, 0, & + 6, 18, 29, 0, & + 8, 17, 23, 0, & + 9, 33, 36, 0, & + 11, 12, 35, 0, & + 15, 25, 27, 0, & + 20, 30, 32, 0, & + 21, 24, 26, 0, & + 22, 31, 33, 0, & + 1, 3, 17, 0, & + 2, 8, 36, 0, & + 4, 14, 34, 0, & + 5, 20, 24, 0, & + 6, 12, 30, 0, & + 7, 19, 37, 0, & + 9, 22, 23, 0, & + 10, 27, 35, 0, & + 11, 25, 38, 0, & + 13, 28, 31, 0, & + 11, 15, 29, 0, & + 16, 18, 21, 0, & + 26, 27, 32, 0, & + 1, 4, 10, 0, & + 2, 9, 29, 32, & + 3, 6, 20, 33, & + 5, 21, 31, 34, & + 7, 8, 15, 30, & + 12, 13, 14, 16, & + 17, 22, 26, 37, & + 15, 18, 36, 38, & + 19, 22, 24, 35, & + 12, 23, 25, 28, & + 1, 13, 32, 33, & + 2, 11, 14, 18, & + 3, 10, 26, 38, & + 4, 24, 31, 32, & + 5, 6, 17, 25, & + 7, 9, 24, 28, & + 8, 9, 34, 37, & + 16, 20, 23, 35, & + 19, 21, 27, 30, & + 16, 26, 29, 36, & + 1, 22, 25, 29, & + 2, 3, 15, 37, & + 4, 12, 21, 36, & + 5, 8, 14, 19, & + 6, 7, 10, 34, & + 11, 17, 19, 33, & + 1, 12, 31, 0, & + 2, 4, 33, 0, & + 3, 16, 30, 0, & + 1, 2, 24, 0, & + 5, 23, 27, 0, & + 6, 28, 32, 0, & + 7, 17, 36, 0, & + 8, 22, 38, 0, & + 9, 18, 20, 0, & + 10, 21, 29, 0, & + 11, 13, 34, 0, & + 4, 20, 22, 0, & + 7, 11, 21, 0, & + 14, 35, 37, 0, & + 15, 19, 26, 0, & + 3, 28, 29, 0, & + 9, 13, 35, 0, & + 14, 17, 30, 0, & + 10, 15, 33, 0, & + 5, 12, 37, 0, & + 18, 25, 32, 0, & + 8, 16, 27, 0, & + 19, 34, 38, 0, & + 24, 25, 36, 0, & + 2, 28, 35, 0, & + 19, 23, 36, 0, & + 3, 12, 34, 0, & + 9, 15, 16, 0, & + 4, 5, 7, 0, & + 1, 8, 21, 0, & + 6, 13, 22, 0, & + 11, 24, 30, 0, & + 8, 26, 35, 0, & + 6, 26, 31, 0, & + 14, 32, 38, 0, & + 18, 23, 33, 0, & + 2, 27, 34, 0, & + 17, 29, 31, 0/ + +data Nm/ & + 2, 15, 28, 40, 52, 65, 75, 85, 91, 94, 120, 0, & + 16, 29, 41, 53, 66, 76, 86, 92, 94, 115, 127, 0, & + 4, 17, 30, 42, 52, 67, 77, 86, 93, 106, 117, 0, & + 5, 18, 31, 43, 54, 65, 78, 87, 92, 102, 119, 0, & + 6, 17, 28, 41, 55, 68, 79, 88, 95, 110, 119, 0, & + 7, 19, 32, 44, 56, 67, 79, 89, 96, 121, 124, 0, & + 8, 20, 33, 42, 57, 69, 80, 89, 97, 103, 119, 0, & + 21, 31, 45, 53, 69, 81, 88, 98, 112, 120, 123, 0, & + 9, 15, 30, 46, 58, 66, 80, 81, 99, 107, 118, 0, & + 1, 10, 22, 26, 38, 59, 65, 77, 89, 100, 109, 0, & + 11, 23, 31, 47, 60, 62, 76, 90, 101, 103, 122, 0, & + 12, 24, 34, 47, 56, 70, 74, 87, 91, 110, 117, 0, & + 10, 25, 33, 41, 61, 70, 75, 101, 107, 121, 0, 0, & + 13, 15, 35, 42, 54, 70, 76, 88, 104, 108, 125, 0, & + 6, 14, 36, 48, 62, 69, 72, 86, 105, 109, 118, 0, & + 8, 16, 37, 43, 63, 70, 82, 84, 93, 112, 118, 0, & + 14, 16, 25, 45, 52, 71, 79, 90, 97, 108, 128, 0, & + 10, 17, 27, 44, 63, 72, 76, 99, 111, 126, 0, 0, & + 2, 26, 29, 43, 57, 73, 83, 88, 90, 105, 113, 116, & + 2, 3, 11, 34, 49, 55, 67, 82, 99, 102, 0, 0, & + 7, 25, 30, 50, 63, 68, 83, 87, 100, 103, 120, 0, & + 4, 24, 38, 51, 58, 71, 73, 85, 98, 102, 121, 0, & + 7, 18, 36, 45, 58, 74, 82, 95, 116, 126, 0, 0, & + 12, 19, 35, 50, 55, 73, 78, 80, 94, 114, 122, 0, & + 1, 13, 20, 29, 48, 60, 74, 79, 85, 111, 114, 0, & + 5, 27, 34, 50, 64, 71, 77, 84, 105, 123, 124, 0, & + 3, 23, 35, 48, 59, 64, 83, 95, 112, 127, 0, 0, & + 6, 23, 38, 39, 61, 74, 80, 96, 106, 115, 0, 0, & + 3, 21, 33, 44, 62, 66, 84, 85, 100, 106, 128, 0, & + 5, 22, 28, 49, 56, 69, 83, 93, 108, 122, 0, 0, & + 9, 26, 37, 51, 61, 68, 78, 91, 124, 128, 0, 0, & + 8, 14, 24, 49, 64, 66, 75, 78, 96, 111, 125, 0, & + 12, 13, 21, 46, 51, 67, 75, 90, 92, 109, 126, 0, & + 27, 36, 39, 54, 68, 81, 89, 101, 113, 117, 127, 0, & + 20, 32, 47, 59, 73, 82, 104, 107, 115, 123, 0, 0, & + 4, 22, 39, 46, 53, 72, 84, 87, 97, 114, 116, 0, & + 1, 11, 19, 37, 40, 57, 71, 81, 86, 104, 110, 0, & + 9, 18, 32, 40, 60, 72, 77, 98, 113, 125, 0, 0/ + +data nrw/ & +11,11,11,11,11,11,11,11,11,11,11,11,10,11,11,11, & +11,10,12,10,11,11,10,11,11,11,10,10,11,10,10,11, & +11,11,10,11,11,10/ + +data ncw/ & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, & +4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, & +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3/