WIP on RS utilities.

This commit is contained in:
Joe Taylor 2024-02-02 11:29:21 -05:00
parent 2535a24481
commit 3bfbe4deb4
3 changed files with 27 additions and 28 deletions

View File

@ -15,17 +15,18 @@ CFLAGS= -O9 -Wall
%.o: %.F90
${FC} ${FFLAGS} -c $<
all: rstest rs_125_49
all: rs_sf.a rstest rs_125_49
OBJS1 = rstest.o init_rs_sf.o encode_rs_sf.o decode_rs_sf.o \
rs_sf.o ran1.o
OBJS1 = rstest.o ran1.o
rstest: $(OBJS1)
$(FC) -o rstest $(OBJS1)
$(FC) -o rstest $(OBJS1) rs_sf.a
OBJS2 = rs_125_49.o init_rs_sf.o encode_rs_sf.o decode_rs_sf.o \
rs_sf.o ran1.o get_crc14.o
OBJS2 = rs_125_49.o ran1.o get_crc14.o
rs_125_49: $(OBJS2)
$(FC) -o rs_125_49 $(OBJS2)
$(FC) -o rs_125_49 $(OBJS2) rs_sf.a
rs_sf.a: init_rs_sf.o encode_rs_sf.o decode_rs_sf.o rs_sf.o
ar -crs rs_sf.a init_rs_sf.o encode_rs_sf.o decode_rs_sf.o rs_sf.o
init_rs_sf.o: init_rs.c
gcc -DBIGSYM=1 $(CFLAGS) -c -o $@ $^
@ -36,4 +37,4 @@ decode_rs_sf.o: decode_rs.c
.PHONY : clean
clean:
-rm -f *.o rstest.exe
-rm -f *.o *.a *.exe

View File

@ -10,7 +10,7 @@ program rs_125_49
! integer dat(KK) !Decoded data, i*4
integer dat(256) !Decoded data, i*4
integer era(NN)
character c357*357,c14*14
character c357*357,c14*14,chkmsg*15
nargs=iargc()
if(nargs.ne.1) then
@ -60,18 +60,16 @@ program rs_125_49
nera=0
call rs_decode_sf(gsym,era,nera,dat,nfixed)
write(*,1008)
1008 format(/'Decoded result:')
write(*,1002) dat(1:KK)
if(nfixed.ge.0) write(*,1100) nerr,nfixed
1100 format(/'nerr:',i3,' nfixed:',i3)
if(nfixed.lt.0) write(*,1102) nerr,nfixed
1102 format(/'nerr:',i3,' nfixed:',i3,', decode failed.')
write(c357,'(51b7.7)') dat(1:KK)
read(c357,'(357i1)') dgen1
call get_crc14(dgen1,7*KK,ncrc)
if(ncrc.ne.0) print*,'CRC check failed'
if(ncrc.eq.0) print*,'CRC check is OK'
write(*,1008)
1008 format(/'Decoded result:')
chkmsg='Decode failed'
if(nfixed.ge.0 .and. ncrc.eq.0) chkmsg='CRC check OK'
write(*,1002) dat(1:KK)
write(*,1100) nerr,nfixed,trim(chkmsg)
1100 format(/'nerr:',i3,' nfixed:',i3,', ',a)
999 end program rs_125_49

View File

@ -5,6 +5,7 @@ program rstest
integer gsym0(255) !Encoded data, Karn
integer gsym(255) !Encoded data with errors
integer dat(235) !Decoded data, i*4
integer iera(0:200) !Positions of erasures
nargs=iargc()
if(nargs.ne.4) then
@ -21,7 +22,7 @@ program rstest
read(arg,*) kk
call getarg(4,arg)
read(arg,*) nerr
! Initialize the Karn codec
nq=2**mm
nfz=3
@ -29,7 +30,7 @@ program rstest
! Generate and random symbols with values 0 to nq-1
do i=1,kk
dgen(i)=(nq-0.0001)*ran1(idum)
dgen(i)=int(nq*ran1(idum))
enddo
write(*,1000)
@ -50,16 +51,15 @@ program rstest
1006 format(/'Recovered channel symbols, with errors:')
write(*,1002) gsym(1:nn)
call rs_decode_sf(gsym,era,0,dat,nfixed)
ibad=0
do i=1,kk
if(dat(i).ne.dgen(i)) ibad=ibad+1
enddo
nera=0
iera=0
call rs_decode_sf(gsym,iera,nera,dat,nfixed)
ibad=count(dat(1:kk).ne.dgen(1:kk))
write(*,1008)
1008 format(/'Decoded result:')
write(*,1002) dat(1:kk)
write(*,1100) nerr,nfixed,ibad
1100 format(/'nerr:',i3,' nfixed:',i3,' ibad:',i3)
write(*,1100) nerr,nfixed
1100 format(/'nerr:',i3,' nfixed:',i3)
999 end program rstest