From 08bf465a47c59f64ec66ecbb56f619dc8589a2e6 Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Wed, 24 Feb 2016 01:50:57 +0000 Subject: [PATCH] More work on calling ldpc encoder/decoder from fortran. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6492 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/ldpc/dec.c | 15 +++++++++++++-- lib/ldpc/enc.c | 11 ++++++++++- lib/ldpc/enc.h | 1 - lib/ldpc/msksim.f90 | 28 +++++++++++++++++----------- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/lib/ldpc/dec.c b/lib/ldpc/dec.c index 63c2bebcd..2a5e21479 100755 --- a/lib/ldpc/dec.c +++ b/lib/ldpc/dec.c @@ -384,8 +384,19 @@ void iterprp } } -void ldpc_decode_ ( mod2sparse *H, double *lratio, char *dblk, char *pchk, double *bprb ) +void ldpc_decode_ ( double *lratio, char *dblk, char *pchk, double *bprb ) { - int n; + int i, n; n = prprp_decode ( H, lratio, dblk, pchk, bprb ); + printf("in ldpc_decode n=%d\n"); + printf("dblk: "); + for( i=0; i<128; i++) { + printf("%d",dblk[i]); + } + printf("\n"); + printf("pchk: "); + for( i=0; i<46; i++) { + printf("%d",pchk[i]); + } + printf("\n"); } diff --git a/lib/ldpc/enc.c b/lib/ldpc/enc.c index df04d5a83..dd758017d 100755 --- a/lib/ldpc/enc.c +++ b/lib/ldpc/enc.c @@ -155,9 +155,18 @@ void mixed_encode // Wrapper for calling sparse_encode from fortran void ldpc_encode_( -char msg[72], +char msg[82], char cdw[128] ){ + int i; + printf("msg: "); + for (i=0; i<82; i++) { + printf("%d", msg[i]); } + printf("\n"); sparse_encode(msg,cdw); + printf("cdw: "); + for (i=0; i<128; i++) { + printf("%d", cdw[i]); } + printf("\n"); } diff --git a/lib/ldpc/enc.h b/lib/ldpc/enc.h index 083b5f52f..c36e92927 100755 --- a/lib/ldpc/enc.h +++ b/lib/ldpc/enc.h @@ -16,4 +16,3 @@ void sparse_encode (char *, char *); void dense_encode (char *, char *, mod2dense *, mod2dense *); void mixed_encode (char *, char *, mod2dense *, mod2dense *); -void ldpc_encode_ (char *, char *); diff --git a/lib/ldpc/msksim.f90 b/lib/ldpc/msksim.f90 index d3ae91b01..8a1cb3563 100644 --- a/lib/ldpc/msksim.f90 +++ b/lib/ldpc/msksim.f90 @@ -2,22 +2,28 @@ program msksim use, intrinsic :: iso_c_binding -parameter (N=128, M=46, K=82) -character(1) message(1:K) -character(1) codeword(1:N) -character(1) decoded(1:N) -real lratio(N), bitprobs(N) -character(1) pchk +parameter (N=128, M=46, K=82) ! M and N are global variables on the C side. +integer(1) message(1:K) +integer(1) codeword(1:N) +integer(1) decoded(1:N) +integer(1) pchk(1:M) +real*8 lratio(N), bitprobs(N) write(*,*) "calling init_ldpc" call init_ldpc() -message(1:K)=char(0) -write(*,*) "message: ",message +message(1:K)=0 +message(10)=1 write(*,*) "calling ldpc_encode" call ldpc_encode(message,codeword) -write(*,*) "codeword: ",codeword +write(*,*) "calling ldpc_decode" +do i=1,N +lratio(i)=exp(2.0*(codeword(i)-0.5)) +enddo +lratio(10)=10.0 +bitprobs(1:N)=0.0 ! shouldn't need this call ldpc_decode(lratio, decoded, pchk, bitprobs) -write(*,*) decoded - +do i=1,N +write(*,*) i,bitprobs(i), lratio(i) +enddo end program msksim