From 4dbb91047f4c7983aee1ef2fe391ce92a1c7118b Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Thu, 7 May 2020 22:24:48 -0400 Subject: [PATCH] Wraparound buffer for BCDEI decoders --- lib/decoder.f90 | 52 +++++++++++++++++++++++++++++++++++++---- lib/js8/js8a_params.f90 | 4 ++-- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/lib/decoder.f90 b/lib/decoder.f90 index 593086b..81f7ee1 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -88,7 +88,18 @@ subroutine multimode_decoder(ss,id2,params,nfsample) pos = max(0,params%kposI) sz = max(0,params%kszI) id0=0 - id0(1:sz+1)=id2(pos+1:pos+sz+1) + imax=int(NTMAX*12000) + + if((imax-pos).lt.sz) then + ! this means that the first part of the id0 is at the end of the buffer + ! and the second half is at the beginning of the buffer + firstsize=int(imax-pos)-1 + secondsize=int(sz-firstsize)+1 + id0(1:firstsize+1)=id2(pos+1:pos+firstsize+1) + id0(firstsize+1:firstsize+secondsize+1)=id2(1:secondsize+1) + else + id0(1:sz+1)=id2(pos+1:pos+sz+1) + endif call my_js8i%decode(js8i_decoded,id0,params%nQSOProgress,params%nfqso, & params%nftx,newdat,params%nutc,params%nfa,params%nfb, & @@ -111,7 +122,18 @@ subroutine multimode_decoder(ss,id2,params,nfsample) pos = max(0,params%kposE) sz = max(0,params%kszE) id0=0 - id0(1:sz+1)=id2(pos+1:pos+sz+1) + imax=int(NTMAX*12000) + + if((imax-pos).lt.sz) then + ! this means that the first part of the id0 is at the end of the buffer + ! and the second half is at the beginning of the buffer + firstsize=int(imax-pos)-1 + secondsize=int(sz-firstsize)+1 + id0(1:firstsize+1)=id2(pos+1:pos+firstsize+1) + id0(firstsize+1:firstsize+secondsize+1)=id2(1:secondsize+1) + else + id0(1:sz+1)=id2(pos+1:pos+sz+1) + endif call my_js8e%decode(js8e_decoded,id0,params%nQSOProgress,params%nfqso, & params%nftx,newdat,params%nutc,params%nfa,params%nfb, & @@ -134,7 +156,18 @@ subroutine multimode_decoder(ss,id2,params,nfsample) pos = max(0,params%kposC) sz = max(0,params%kszC) id0=0 - id0(1:sz+1)=id2(pos+1:pos+sz+1) + imax=int(NTMAX*12000) + + if((imax-pos).lt.sz) then + ! this means that the first part of the id0 is at the end of the buffer + ! and the second half is at the beginning of the buffer + firstsize=int(imax-pos)-1 + secondsize=int(sz-firstsize)+1 + id0(1:firstsize+1)=id2(pos+1:pos+firstsize+1) + id0(firstsize+1:firstsize+secondsize+1)=id2(1:secondsize+1) + else + id0(1:sz+1)=id2(pos+1:pos+sz+1) + endif call my_js8c%decode(js8c_decoded,id0,params%nQSOProgress,params%nfqso, & params%nftx,newdat,params%nutc,params%nfa,params%nfb, & @@ -157,7 +190,18 @@ subroutine multimode_decoder(ss,id2,params,nfsample) pos = max(0,params%kposB) sz = max(0,params%kszB) id0=0 - id0(1:sz+1)=id2(pos+1:pos+sz+1) + imax=int(NTMAX*12000) + + if((imax-pos).lt.sz) then + ! this means that the first part of the id0 is at the end of the buffer + ! and the second half is at the beginning of the buffer + firstsize=int(imax-pos)-1 + secondsize=int(sz-firstsize)+1 + id0(1:firstsize+1)=id2(pos+1:pos+firstsize+1) + id0(firstsize+1:firstsize+secondsize+1)=id2(1:secondsize+1) + else + id0(1:sz+1)=id2(pos+1:pos+sz+1) + endif call my_js8b%decode(js8b_decoded,id0,params%nQSOProgress,params%nfqso, & params%nftx,newdat,params%nutc,params%nfa,params%nfb, & diff --git a/lib/js8/js8a_params.f90 b/lib/js8/js8a_params.f90 index 0092ae7..788c6c2 100644 --- a/lib/js8/js8a_params.f90 +++ b/lib/js8/js8a_params.f90 @@ -3,11 +3,11 @@ parameter (NSUBMODE=0) parameter (NCOSTAS=1) !Which JS8 Costas Arrays to use (1=original, 2=three symmetrical costas) -parameter (NSPS=1920, NTXDUR=15, NDOWNSPS=32, NDD=100, JZ=36) ! 50 Hz 6.250 baud 16 wpm -25.0dB (1.0Eb/N0) 12.64s +parameter (NSPS=1920, NTXDUR=15, NDOWNSPS=32, NDD=100, JZ=62) ! 50 Hz 6.250 baud 16 wpm -25.0dB (1.0Eb/N0) 12.64s parameter (AZ=12000.0/(1.0*NSPS)*0.64d0) !Dedupe overlap in Hz parameter (ASTART=0.5) !Start delay in seconds -parameter (ASYNCMIN=2) !Minimum Sync +parameter (ASYNCMIN=1.5) !Minimum Sync parameter (KK=87) !Information bits (75 + CRC12) parameter (ND=58) !Data symbols