File: tfsk_llr.c

package info (click to toggle)
codec2 1.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 121,056 kB
  • sloc: ansic: 414,118; sh: 2,612; objc: 2,574; python: 2,105; cpp: 2,091; asm: 683; makefile: 598
file content (66 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*---------------------------------------------------------------------------*\

  FILE........: tfsk_llr.c
  AUTHOR......: David Rowe
  DATE CREATED: July 2020

  Simple test program for 4FSK LLR routines.

\*---------------------------------------------------------------------------*/

#include <stdio.h>
#include <math.h>
#include "mpdecode_core.h"

#define M       4
#define BPS     2
#define NSYM     5
#define V_EST    2
#define SNR_EST 10

/* Generated test vectors with:

   octave:100> init_cml('~/cml/');
   octave:101> rx_filt=[1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1]
   octave:102> symL = DemodFSK(rx_filt,10,1); -Somap(symL)
*/

/* one col per symbol:
       0    1    2    3    4 */
 float rx_filt[] = {
     1.0, 0.0, 0.0, 0.0, 1.0,  /* filter 0 */
     0.0, 1.0, 0.0, 0.0, 0.0,  /* filter 1 */
     0.0, 0.0, 1.0, 0.0, 0.0,  /* filter 2 */
     0.0, 0.0, 0.0, 1.0, 0.0   /* filter 3 */
};

float llrs_target[] = {
     7.3252,   7.3252,  /* bit 0, 1      */
     7.3252,  -7.3252,  /*     2, 3, ... */
    -7.3252,   7.3252,
    -7.3252,  -7.3252,
     7.3252,   7.3252
};

int main(void) { 
    float llrs[BPS*NSYM] = {0};
    
    fsk_rx_filt_to_llrs(llrs, rx_filt, V_EST, SNR_EST, M, NSYM);

    float error = 0.0;
    for(int i=0; i<NSYM*BPS; i++) {
        fprintf(stderr,"% f\n",llrs[i]);
        error += pow(llrs[i]-llrs_target[i],2.0);
    }

    if (error < 1E-3) {
        fprintf(stderr, "PASS\n");
        return 0;
    }
    else {
        fprintf(stderr, "FAIL\n");
        return 1;
    }
}