From 5a0a582193490961ce43500a89735cfef8670500 Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Fri, 29 Jul 2016 19:04:42 +0000 Subject: [PATCH] genmsk40: (32,16) code with 8-bit sync word. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6965 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/genmsk40.f90 | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lib/genmsk40.f90 diff --git a/lib/genmsk40.f90 b/lib/genmsk40.f90 new file mode 100644 index 000000000..89bb4e240 --- /dev/null +++ b/lib/genmsk40.f90 @@ -0,0 +1,80 @@ +subroutine genmsk32(msg,msgsent,ichk,itone,itype) + + use hashing + character*22 msg,msgsent,hashmsg + character*4 crpt,rpt(0:63) + logical first + integer itone(144) + integer ig32(0:65536-1) !Codewords for LDPC (32,16) code (PEG generated, regular, col wt 3) + integer*1 codeword(32),bitseq(40) + integer*1 s8r(8) + data s8r/1,0,1,1,0,0,0,1/ + data first/.true./ + save first,rpt,ig32 + + if(first) then + call ldpc32_table(ig32) !Define the Golay(24,12) codewords + do i=0,30 + if( i.lt.5 ) then + write(rpt(i),'(a1,i2.2,a1)') '-',abs(i-5) + write(rpt(i+31),'(a2,i2.2,a1)') 'R-',abs(i-5) + else + write(rpt(i),'(a1,i2.2,a1)') '+',i-5 + write(rpt(i+31),'(a2,i2.2,a1)') 'R+',i-5 + endif + enddo + rpt(62)='RRR ' + rpt(63)='73 ' + first=.false. + endif + + itype=-1 + msgsent='*** bad message ***' + itone=0 + i1=index(msg,'>') + if(i1.lt.9) go to 900 + call fmtmsg(msg,iz) + crpt=msg(i1+2:i1+5) + do i=0,63 + if(crpt.eq.rpt(i)) go to 10 + enddo + go to 900 + +10 irpt=i !Report index, 0-31 + if(ichk.lt.10000) then + hashmsg=msg(2:i1-1)//' '//crpt + call hash(hashmsg,22,ihash) + ihash=iand(ihash,1023) !10-bit hash + ig=64*ihash + irpt !6-bit report + else + ig=ichk-10000 + endif + + ncodeword=ig32(ig) + +! write(*,*) 'codeword is: ',ncodeword,'message is: ',ig,'report index: ',irpt,'hash: ',ihash + + do i=1,32 + codeword(i)=iand(1,ishft(ncodeword,1-i)) + enddo + + bitseq(1:8)=s8r + bitseq(9:40)=codeword + bitseq=2*bitseq-1 + +! Map I and Q to tones. + itone=0 + do i=1, 20 + itone(2*i-1)=(bitseq(2*i)*bitseq(2*i-1)+1)/2; + itone(2*i)=-(bitseq(2*i)*bitseq(mod(2*i,32)+1)-1)/2; + enddo + +! Flip polarity + itone=-itone+1 + + msgsent=msg + itype=7 + +900 return +end subroutine genmsk32 +