diff options
| author | Christoph Berg <myon@debian.org> | 2026-04-07 19:02:45 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-04-07 19:02:45 +0200 |
| commit | f647d78463c1250ce9c99af664615fafccf5e959 (patch) | |
| tree | 5b00428cef68aef1c9d407e2d4535687422419b6 /lib/encode_128_90.f90 | |
| parent | 0a13f1fdb9928b6d012569dd65f7f6ef18fac2f8 (diff) | |
New upstream version 3.0.0upstream/3.0.0
Diffstat (limited to 'lib/encode_128_90.f90')
| -rw-r--r--[-rwxr-xr-x] | lib/encode_128_90.f90 | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/lib/encode_128_90.f90 b/lib/encode_128_90.f90 index 6e535bcf..e59cf11b 100755..100644 --- a/lib/encode_128_90.f90 +++ b/lib/encode_128_90.f90 @@ -1,58 +1,58 @@ -subroutine encode_128_90(message77,codeword)
-!
-! Add a 13-bit CRC to a 77-bit message and return a 128-bit codeword
-!
-use, intrinsic :: iso_c_binding
-use iso_c_binding, only: c_loc,c_size_t
-use crc
-
-integer, parameter:: N=128, K=90, M=N-K
-character*90 tmpchar
-integer*1 codeword(N)
-integer*1 gen(M,K)
-integer*1 message77(77),message(K)
-integer*1 pchecks(M)
-integer*1, target :: i1MsgBytes(12)
-include "ldpc_128_90_generator.f90"
-logical first
-data first/.true./
-save first,gen
-
-if( first ) then ! fill the generator matrix
- gen=0
- do i=1,M
- do j=1,23
- read(g(i)(j:j),"(Z1)") istr
- ibmax=4
- if(j.eq.23) ibmax=2
- do jj=1, ibmax
- icol=(j-1)*4+jj
- if( btest(istr,4-jj) ) gen(i,icol)=1
- enddo
- enddo
- enddo
-first=.false.
-endif
-
-! Add 13 bit CRC to form 90-bit message+CRC13
-write(tmpchar,'(77i1)') message77
-tmpchar(78:80)='000'
-i1MsgBytes=0
-read(tmpchar,'(10b8)') i1MsgBytes(1:10)
-ncrc13 = crc13 (c_loc (i1MsgBytes), 12)
-write(tmpchar(78:90),'(b13)') ncrc13
-read(tmpchar,'(90i1)') message
-
-do i=1,M
- nsum=0
- do j=1,K
- nsum=nsum+message(j)*gen(i,j)
- enddo
- pchecks(i)=mod(nsum,2)
-enddo
-
-codeword(1:K)=message
-codeword(K+1:N)=pchecks
-
-return
-end subroutine encode_128_90
+subroutine encode_128_90(message77,codeword) +! +! Add a 13-bit CRC to a 77-bit message and return a 128-bit codeword +! +use, intrinsic :: iso_c_binding +use iso_c_binding, only: c_loc,c_size_t +use crc + +integer, parameter:: N=128, K=90, M=N-K +character*90 tmpchar +integer*1 codeword(N) +integer*1 gen(M,K) +integer*1 message77(77),message(K) +integer*1 pchecks(M) +integer*1, target :: i1MsgBytes(12) +include "ldpc_128_90_generator.f90" +logical first +data first/.true./ +save first,gen + +if( first ) then ! fill the generator matrix + gen=0 + do i=1,M + do j=1,23 + read(g(i)(j:j),"(Z1)") istr + ibmax=4 + if(j.eq.23) ibmax=2 + do jj=1, ibmax + icol=(j-1)*4+jj + if( btest(istr,4-jj) ) gen(i,icol)=1 + enddo + enddo + enddo +first=.false. +endif + +! Add 13 bit CRC to form 90-bit message+CRC13 +write(tmpchar,'(77i1)') message77 +tmpchar(78:80)='000' +i1MsgBytes=0 +read(tmpchar,'(10b8)') i1MsgBytes(1:10) +ncrc13 = crc13 (c_loc (i1MsgBytes), 12) +write(tmpchar(78:90),'(b13)') ncrc13 +read(tmpchar,'(90i1)') message + +do i=1,M + nsum=0 + do j=1,K + nsum=nsum+message(j)*gen(i,j) + enddo + pchecks(i)=mod(nsum,2) +enddo + +codeword(1:K)=message +codeword(K+1:N)=pchecks + +return +end subroutine encode_128_90 |
