mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-07-22 03:25:22 -04:00
Progress toward a working ldpc128_90 simulator. Compiles, but does not yet work.
This commit is contained in:
parent
41920af89a
commit
3ac119fb99
@ -313,12 +313,14 @@ set (wsjtx_CXXSRCS
|
|||||||
set (wsjt_CXXSRCS
|
set (wsjt_CXXSRCS
|
||||||
lib/crc10.cpp
|
lib/crc10.cpp
|
||||||
lib/crc12.cpp
|
lib/crc12.cpp
|
||||||
|
lib/crc13.cpp
|
||||||
lib/crc14.cpp
|
lib/crc14.cpp
|
||||||
)
|
)
|
||||||
# deal with a GCC v6 UB error message
|
# deal with a GCC v6 UB error message
|
||||||
set_source_files_properties (
|
set_source_files_properties (
|
||||||
lib/crc10.cpp
|
lib/crc10.cpp
|
||||||
lib/crc12.cpp
|
lib/crc12.cpp
|
||||||
|
lib/crc13.cpp
|
||||||
lib/crc14.cpp
|
lib/crc14.cpp
|
||||||
PROPERTIES COMPILE_FLAGS -fpermissive)
|
PROPERTIES COMPILE_FLAGS -fpermissive)
|
||||||
|
|
||||||
@ -371,6 +373,7 @@ set (wsjt_FSRCS
|
|||||||
lib/ft8/baseline.f90
|
lib/ft8/baseline.f90
|
||||||
lib/bpdecode40.f90
|
lib/bpdecode40.f90
|
||||||
lib/bpdecode144.f90
|
lib/bpdecode144.f90
|
||||||
|
lib/bpdecode128_90.f90
|
||||||
lib/fsk4hf/bpdecode120.f90
|
lib/fsk4hf/bpdecode120.f90
|
||||||
lib/fsk4hf/bpdecode168.f90
|
lib/fsk4hf/bpdecode168.f90
|
||||||
lib/ft8/bpdecode174.f90
|
lib/ft8/bpdecode174.f90
|
||||||
@ -409,6 +412,7 @@ set (wsjt_FSRCS
|
|||||||
lib/encode4.f90
|
lib/encode4.f90
|
||||||
lib/encode_msk40.f90
|
lib/encode_msk40.f90
|
||||||
lib/encode_msk144.f90
|
lib/encode_msk144.f90
|
||||||
|
lib/encode128_90.f90
|
||||||
lib/fsk4hf/encode120.f90
|
lib/fsk4hf/encode120.f90
|
||||||
lib/fsk4hf/encode168.f90
|
lib/fsk4hf/encode168.f90
|
||||||
lib/ft8/encode174.f90
|
lib/ft8/encode174.f90
|
||||||
@ -420,6 +424,7 @@ set (wsjt_FSRCS
|
|||||||
lib/extract.f90
|
lib/extract.f90
|
||||||
lib/extract4.f90
|
lib/extract4.f90
|
||||||
lib/extractmessage144.f90
|
lib/extractmessage144.f90
|
||||||
|
lib/extractmessage128_90.f90
|
||||||
lib/fsk4hf/extractmessage168.f90
|
lib/fsk4hf/extractmessage168.f90
|
||||||
lib/ft8/extractmessage174.f90
|
lib/ft8/extractmessage174.f90
|
||||||
lib/ft8/extractmessage174_91.f90
|
lib/ft8/extractmessage174_91.f90
|
||||||
@ -502,6 +507,7 @@ set (wsjt_FSRCS
|
|||||||
lib/jt9fano.f90
|
lib/jt9fano.f90
|
||||||
lib/jtmsg.f90
|
lib/jtmsg.f90
|
||||||
lib/ldpcsim144.f90
|
lib/ldpcsim144.f90
|
||||||
|
lib/ldpcsim128_90.f90
|
||||||
lib/fsk4hf/ldpcsim120.f90
|
lib/fsk4hf/ldpcsim120.f90
|
||||||
lib/fsk4hf/ldpcsim168.f90
|
lib/fsk4hf/ldpcsim168.f90
|
||||||
lib/ft8/ldpcsim174.f90
|
lib/ft8/ldpcsim174.f90
|
||||||
@ -1248,6 +1254,9 @@ target_link_libraries (ldpcsim174_91 wsjt_fort wsjt_cxx)
|
|||||||
add_executable (ldpcsim144 lib/ldpcsim144.f90 wsjtx.rc)
|
add_executable (ldpcsim144 lib/ldpcsim144.f90 wsjtx.rc)
|
||||||
target_link_libraries (ldpcsim144 wsjt_fort wsjt_cxx)
|
target_link_libraries (ldpcsim144 wsjt_fort wsjt_cxx)
|
||||||
|
|
||||||
|
add_executable (ldpcsim128_90 lib/ldpcsim128_90.f90 wsjtx.rc)
|
||||||
|
target_link_libraries (ldpcsim128_90 wsjt_fort wsjt_cxx)
|
||||||
|
|
||||||
add_executable (ldpcsim168 lib/fsk4hf/ldpcsim168.f90 wsjtx.rc)
|
add_executable (ldpcsim168 lib/fsk4hf/ldpcsim168.f90 wsjtx.rc)
|
||||||
target_link_libraries (ldpcsim168 wsjt_fort wsjt_cxx)
|
target_link_libraries (ldpcsim168 wsjt_fort wsjt_cxx)
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ do iter=0,maxiterations
|
|||||||
|
|
||||||
! send messages from check nodes to variable nodes
|
! send messages from check nodes to variable nodes
|
||||||
do i=1,M
|
do i=1,M
|
||||||
tanhtoc(1:7,i)=tanh(-toc(1:7,i)/2)
|
tanhtoc(1:11,i)=tanh(-toc(1:11,i)/2)
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
do j=1,N
|
do j=1,N
|
||||||
|
16
lib/crc.f90
16
lib/crc.f90
@ -18,6 +18,22 @@ module crc
|
|||||||
integer (c_int), value :: length
|
integer (c_int), value :: length
|
||||||
end function crc14_check
|
end function crc14_check
|
||||||
|
|
||||||
|
function crc13 (data, length) bind (C, name="crc13")
|
||||||
|
use, intrinsic :: iso_c_binding, only: c_short, c_ptr, c_int
|
||||||
|
implicit none
|
||||||
|
integer (c_short) :: crc13
|
||||||
|
type (c_ptr), value :: data
|
||||||
|
integer (c_int), value :: length
|
||||||
|
end function crc13
|
||||||
|
|
||||||
|
function crc13_check (data, length) bind (C, name="crc14_check")
|
||||||
|
use, intrinsic :: iso_c_binding, only: c_bool, c_ptr, c_int
|
||||||
|
implicit none
|
||||||
|
logical (c_bool) :: crc13_check
|
||||||
|
type (c_ptr), value :: data
|
||||||
|
integer (c_int), value :: length
|
||||||
|
end function crc13_check
|
||||||
|
|
||||||
function crc12 (data, length) bind (C, name="crc12")
|
function crc12 (data, length) bind (C, name="crc12")
|
||||||
use, intrinsic :: iso_c_binding, only: c_short, c_ptr, c_int
|
use, intrinsic :: iso_c_binding, only: c_short, c_ptr, c_int
|
||||||
implicit none
|
implicit none
|
||||||
|
@ -7,20 +7,25 @@ subroutine extractmessage128_90(decoded,msgreceived,ncrcflag)
|
|||||||
character*90 cbits
|
character*90 cbits
|
||||||
integer*1 decoded(90)
|
integer*1 decoded(90)
|
||||||
integer*1, target:: i1Dec8BitBytes(12)
|
integer*1, target:: i1Dec8BitBytes(12)
|
||||||
|
integer*2 icrc13
|
||||||
integer*4 i4Dec6BitWords(12)
|
integer*4 i4Dec6BitWords(12)
|
||||||
|
|
||||||
! Write decoded bits into cbits: 77-bit message plus 13-bit CRC
|
! Write decoded bits into cbits: 77-bit message plus 13-bit CRC
|
||||||
write(cbits,1000) decoded
|
write(cbits,1000) decoded
|
||||||
1000 format(90i1)
|
1000 format(90i1)
|
||||||
|
write(*,*) cbits
|
||||||
read(cbits,1001) i1Dec8BitBytes
|
read(cbits,1001) i1Dec8BitBytes
|
||||||
1001 format(12b8)
|
1001 format(12b8)
|
||||||
read(cbits,1002) ncrc13 !Received CRC12
|
read(cbits,1002) ncrc13 !Received CRC12
|
||||||
1002 format(77x,b13)
|
1002 format(77x,b13)
|
||||||
|
|
||||||
i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32+16+8)
|
i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32+16+8)
|
||||||
|
write(*,*) i1Dec8BitBytes
|
||||||
i1Dec8BitBytes(11:12)=0
|
i1Dec8BitBytes(11:12)=0
|
||||||
icrc13=crc13(c_loc(i1Dec8BitBytes),12) !CRC13 computed from 77 msg bits
|
icrc13=crc13(c_loc(i1Dec8BitBytes),12) !CRC13 computed from 77 msg bits
|
||||||
|
|
||||||
|
write(*,'(b13,3x,b13)') ncrc13,icrc13
|
||||||
|
|
||||||
if(ncrc13.eq.icrc13 .or. sum(decoded(57:87)).eq.0) then !### Kludge ### ???
|
if(ncrc13.eq.icrc13 .or. sum(decoded(57:87)).eq.0) then !### Kludge ### ???
|
||||||
! CRC13 checks out --- unpack 72-bit message
|
! CRC13 checks out --- unpack 72-bit message
|
||||||
read(cbits,'(12b6)') i4Dec6BitWords
|
read(cbits,'(12b6)') i4Dec6BitWords
|
||||||
|
@ -11,11 +11,14 @@ character*96 tmpchar
|
|||||||
character*8 arg
|
character*8 arg
|
||||||
integer*1, allocatable :: codeword(:), decoded(:), message(:)
|
integer*1, allocatable :: codeword(:), decoded(:), message(:)
|
||||||
integer*1, target:: i1Msg8BitBytes(12)
|
integer*1, target:: i1Msg8BitBytes(12)
|
||||||
|
integer*1 apmask(N),cw(N)
|
||||||
integer*1 i1hash(4)
|
integer*1 i1hash(4)
|
||||||
integer*1 msgbits(80)
|
integer*1 msgbits(90)
|
||||||
|
integer*2 checksum
|
||||||
integer*4 i4Msg6BitWords(13)
|
integer*4 i4Msg6BitWords(13)
|
||||||
integer ihash
|
integer ihash
|
||||||
integer nerrtot(N),nerrdec(N),nmpcbad(K)
|
integer nerrtot(0:N),nerrdec(0:N),nmpcbad(0:K)
|
||||||
|
logical checksumok
|
||||||
real*8, allocatable :: lratio(:), rxdata(:), rxavgd(:)
|
real*8, allocatable :: lratio(:), rxdata(:), rxavgd(:)
|
||||||
real, allocatable :: yy(:), llr(:)
|
real, allocatable :: yy(:), llr(:)
|
||||||
equivalence(ihash,i1hash)
|
equivalence(ihash,i1hash)
|
||||||
@ -41,7 +44,6 @@ read(arg,*) ntrials
|
|||||||
call getarg(4,arg)
|
call getarg(4,arg)
|
||||||
read(arg,*) s
|
read(arg,*) s
|
||||||
|
|
||||||
! don't count hash bits as data bits
|
|
||||||
rate=real(K)/real(N)
|
rate=real(K)/real(N)
|
||||||
|
|
||||||
write(*,*) "rate: ",rate
|
write(*,*) "rate: ",rate
|
||||||
@ -51,30 +53,30 @@ write(*,*) "niter= ",max_iterations," navg= ",navg," s= ",s
|
|||||||
allocate ( codeword(N), decoded(K), message(K) )
|
allocate ( codeword(N), decoded(K), message(K) )
|
||||||
allocate ( lratio(N), rxdata(N), rxavgd(N), yy(N), llr(N) )
|
allocate ( lratio(N), rxdata(N), rxavgd(N), yy(N), llr(N) )
|
||||||
|
|
||||||
msg="K9AN K1JT EN50"
|
!msg="K9AN K1JT EN50"
|
||||||
|
msg="G4WJS K1JT FN20"
|
||||||
call packmsg(msg,i4Msg6BitWords,itype,.false.) !Pack into 12 6-bit bytes
|
call packmsg(msg,i4Msg6BitWords,itype,.false.) !Pack into 12 6-bit bytes
|
||||||
call unpackmsg(i4Msg6BitWords,msgsent,.false.,' ') !Unpack to get msgsent
|
call unpackmsg(i4Msg6BitWords,msgsent,.false.,' ') !Unpack to get msgsent
|
||||||
write(*,*) "message sent ",msgsent
|
write(*,*) "message sent ",msgsent
|
||||||
|
|
||||||
tmpchar=' '
|
tmpchar=' '
|
||||||
write(tmpchar,'(12b6.6)') i4Msg6BitWords
|
write(tmpchar,'(12b6)') i4Msg6BitWords(1:12)
|
||||||
tmpchar(73:77)="00000" !i5bit
|
tmpchar(73:77)="00000" !i5bit
|
||||||
write(*,*) tmpchar
|
|
||||||
|
|
||||||
read(tmpchar,'(10b8)') i1Msg8BitBytes(1:10)
|
read(tmpchar,'(10b8)') i1Msg8BitBytes(1:10)
|
||||||
write(*,*) i1Msg8BitBytes
|
write(*,*) i1Msg8BitBytes
|
||||||
|
|
||||||
i1Msg8BitBytes(10:12)=0
|
i1Msg8BitBytes(10:12)=0
|
||||||
checksum = crc13 (c_loc (i1Msg8ZBitZBytes), 12)
|
checksum = crc13 (c_loc (i1Msg8BitBytes), 12)
|
||||||
i1Msg8BitBytes(11)=checksum/256
|
write(*,'(i6,3x,b13)') checksum,checksum
|
||||||
i1Msg8BitBytes(12)=iand (checksum,255)
|
|
||||||
checksumok = crc13_check(c_loc (i1Msg8ZBitBytes), 12)
|
|
||||||
if( checksumok ) write(*,*) 'Good checksum'
|
|
||||||
|
|
||||||
write(tmpchar,'(12b8.8)') i1Msg8BitBytes(1:9)
|
write(tmpchar(78:90),'(b13)') checksum
|
||||||
read(tmpchar,'(77b)') msgbits(1:77)
|
read(tmpchar,'(90i1)') msgbits(1:90)
|
||||||
read(tmpchar(84:96),'(6b)') msgbits(78:90)
|
|
||||||
call encode_128_90(msgbits,codeword)
|
write(*,*) 'msgbits'
|
||||||
|
write(*,'(28i1,1x,28i1,1x,16i1,1x,5i1,1x,13i1)') msgbits
|
||||||
|
|
||||||
|
call encode128_90(msgbits,codeword)
|
||||||
|
|
||||||
call init_random_seed()
|
call init_random_seed()
|
||||||
|
|
||||||
@ -103,13 +105,10 @@ do idb = -6, 14
|
|||||||
enddo
|
enddo
|
||||||
nerrtot(nerr)=nerrtot(nerr)+1
|
nerrtot(nerr)=nerrtot(nerr)+1
|
||||||
|
|
||||||
! Correct signal normalization is important for this decoder.
|
|
||||||
rxav=sum(rxdata)/N
|
rxav=sum(rxdata)/N
|
||||||
rx2av=sum(rxdata*rxdata)/N
|
rx2av=sum(rxdata*rxdata)/N
|
||||||
rxsig=sqrt(rx2av-rxav*rxav)
|
rxsig=sqrt(rx2av-rxav*rxav)
|
||||||
rxdata=rxdata/rxsig
|
rxdata=rxdata/rxsig
|
||||||
! To match the metric to the channel, s should be set to the noise standard deviation.
|
|
||||||
! For now, set s to the value that optimizes decode probability near threshold.
|
|
||||||
! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of
|
! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of
|
||||||
! magnitude in UER
|
! magnitude in UER
|
||||||
if( s .lt. 0 ) then
|
if( s .lt. 0 ) then
|
||||||
@ -122,13 +121,15 @@ do idb = -6, 14
|
|||||||
lratio=exp(llr)
|
lratio=exp(llr)
|
||||||
yy=rxdata
|
yy=rxdata
|
||||||
|
|
||||||
|
apmask=0
|
||||||
! max_iterations is max number of belief propagation iterations
|
! max_iterations is max number of belief propagation iterations
|
||||||
call bpdecode128_90(llr, apmask, max_iterations, decoded, cw, nharderrors, niterations)
|
call bpdecode128_90(llr, apmask, max_iterations, decoded, cw, nharderrors, niterations)
|
||||||
|
|
||||||
! If the decoder finds a valid codeword, nharderrors will be .ge. 0.
|
! If the decoder finds a valid codeword, nharderrors will be .ge. 0.
|
||||||
if( nharderrors .ge. 0 ) then
|
if( nharderrors .ge. 0 ) then
|
||||||
call extractmessage1128_90(decoded,msgreceived,ncrcflag)
|
call extractmessage128_90(decoded,msgreceived,ncrcflag)
|
||||||
if( nncrcflag .ne. 1 ) then
|
write(*,*) 'crc check flag ',ncrcflag
|
||||||
|
if( ncrcflag .ne. 1 ) then
|
||||||
nbadcrc=nbadcrc+1
|
nbadcrc=nbadcrc+1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -140,17 +141,17 @@ do idb = -6, 14
|
|||||||
nerrmpc=nerrmpc+1
|
nerrmpc=nerrmpc+1
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
if(nerrmpc.ge.1) nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1
|
nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1
|
||||||
if( ncrcflag .eq. 1) then
|
if( ncrcflag .eq. 1) then
|
||||||
ngood=ngood+1
|
ngood=ngood+1
|
||||||
if(nerr.ge.1) nerrdec(nerr)=nerrdec(nerr)+1
|
nerrdec(nerr)=nerrdec(nerr)+1
|
||||||
else if(nueflag .eq. 1 ) then
|
else if(nueflag .eq. 1 ) then
|
||||||
nue=nue+1;
|
nue=nue+1;
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
snr2500=db-3.5
|
snr2500=db-3.5
|
||||||
pberr=real(nberr)/real(ntrials*N)
|
pberr=real(nerr)/real(ntrials*N)
|
||||||
write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr
|
write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr
|
||||||
|
|
||||||
enddo
|
enddo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user