lte_ul_ref.c 9.11 KB
Newer Older
ghaddab's avatar
ghaddab committed
1
/*******************************************************************************
2
    OpenAirInterface
ghaddab's avatar
ghaddab committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
17
18
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
ghaddab's avatar
ghaddab committed
19
20
21
22
23
   see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
ghaddab's avatar
ghaddab committed
27
28

 *******************************************************************************/
29
30
31
32
33
34
35
36
37
#ifdef MAIN
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#endif
#include "defs.h"

uint16_t dftsizes[33] = {12,24,36,48,60,72,96,108,120,144,180,192,216,240,288,300,324,360,384,432,480,540,576,600,648,720,864,900,960,972,1080,1152,1200};

38
uint16_t ref_primes[33] = {11,23,31,47,59,71,89,107,113,139,179,191,211,239,283,293,317,359,383,431,479,523,571,599,647,719,863,887,953,971,1069,1151,1193};
39
40
41
42
43
44
45
46


int16_t *ul_ref_sigs[30][2][33];
int16_t *ul_ref_sigs_rx[30][2][33]; //these contain the sequences in repeated format and quantized to QPSK ifdef IFFT_FPGA

char ref12[360] = {-1,1,3,-3,3,3,1,1,3,1,-3,3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,-1,-3,-1,1,3,-1,3,-3,-3,-1,-3,3,-3,-3,-3,-1,-1,-3,-1,-3,3,1,3,-3,-1,3,-1,1,-1,3,-3,1,-1,-3,-3,1,1,-1,1,-1,1,-1,3,1,-3,-1,1,-1,1,-1,-1,3,3,-3,-1,1,-3,-3,-1,-3,3,1,-1,-3,-1,-3,-3,3,-3,3,-3,-1,1,3,1,-3,1,3,3,-1,-3,-1,-1,-1,-1,3,3,3,1,3,3,-3,1,3,-1,3,-1,3,3,-3,3,1,-1,3,3,1,-1,3,3,-1,-3,3,-3,-1,-1,3,-1,3,-1,-1,1,1,1,1,-1,-1,-3,-1,3,1,-1,1,-1,3,-1,3,1,1,-1,-1,-3,1,1,-3,1,3,-3,1,1,-3,-3,-1,-1,-3,-1,1,3,1,1,-3,-1,-1,-3,3,-3,3,1,-3,3,-3,1,-1,1,-3,1,1,1,-1,-3,3,3,1,1,3,-1,-3,-1,-1,-1,3,1,-3,-3,-1,3,-3,-1,-3,-1,-3,-1,-1,-3,-1,-1,1,-3,-1,-1,1,-1,-3,1,1,-3,1,-3,-3,3,1,1,-1,3,-1,-1,1,1,-1,-1,-3,-1,3,-1,3,-1,1,3,1,-1,3,1,3,-3,-3,1,-1,-1,1,3
};
49

50
51
void generate_ul_ref_sigs(void)
{
52
53
54
55
  double qbar,phase;
  unsigned int u,v,Msc_RS,q,m,n;

  // These are the Zadoff-Chu sequences (for RB 3-100)
56
57
58
59
60
61
62
63
64
65
66
  for (Msc_RS=2; Msc_RS<33; Msc_RS++) {
    for (u=0; u<30; u++) {
      for (v=0; v<2; v++) {
        qbar = ref_primes[Msc_RS] * (u+1)/(double)31;
        ul_ref_sigs[u][v][Msc_RS] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[Msc_RS]);

        if ((((int)floor(2*qbar))&1) == 0)
          q = (int)(floor(qbar+.5)) - v;
        else
          q = (int)(floor(qbar+.5)) + v;

67
#ifdef MAIN
68
        printf("Msc_RS %d (%d), u %d, v %d -> q %d (qbar %f)\n",Msc_RS,dftsizes[Msc_RS],u,v,q,qbar);
69
#endif
70
71
72
73
74
75

        for (n=0; n<dftsizes[Msc_RS]; n++) {
          m=n%ref_primes[Msc_RS];
          phase = (double)q*m*(m+1)/ref_primes[Msc_RS];
          ul_ref_sigs[u][v][Msc_RS][n<<1]     =(int16_t)(floor(32767*cos(M_PI*phase)));
          ul_ref_sigs[u][v][Msc_RS][1+(n<<1)] =-(int16_t)(floor(32767*sin(M_PI*phase)));
76
#ifdef MAIN
77
78
79
80

          if (Msc_RS<5)
            printf("(%d,%d) ",ul_ref_sigs[u][v][Msc_RS][n<<1],ul_ref_sigs[u][v][Msc_RS][1+(n<<1)]);

81
#endif
82
83
        }

84
#ifdef MAIN
85
86
87
88

        if (Msc_RS<5)
          printf("\n");

89
90
91
92
93
94
#endif
      }
    }
  }

  // These are the sequences for RB 1
95
96
  for (u=0; u<30; u++) {
    ul_ref_sigs[u][0][0] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[0]);
97

98
99
100
    for (n=0; n<dftsizes[0]; n++) {
      ul_ref_sigs[u][0][0][n<<1]    =(int16_t)(floor(32767*cos(M_PI*ref12[(u*12) + n]/4)));
      ul_ref_sigs[u][0][0][1+(n<<1)]=(int16_t)(floor(32767*sin(M_PI*ref12[(u*12) + n]/4)));
101
102
    }

103
104
  }

105
  // These are the sequences for RB 2
106
107
108
109
110
111
  for (u=0; u<30; u++) {
    ul_ref_sigs[u][0][1] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[1]);

    for (n=0; n<dftsizes[1]; n++) {
      ul_ref_sigs[u][0][1][n<<1]    =(int16_t)(floor(32767*cos(M_PI*ref24[(u*24) + n]/4)));
      ul_ref_sigs[u][0][1][1+(n<<1)]=(int16_t)(floor(32767*sin(M_PI*ref24[(u*24) + n]/4)));
112
113
    }

114
115
116
117


  }

118
119
}

120
121
void generate_ul_ref_sigs_rx(void)
{
122
123
124
125
  double qbar,phase;
  unsigned int u,v,Msc_RS,q,m,n;

  // These are the complex conjugated Zadoff-Chu sequences quantized to QPSK stored in repeated format (for RB 3-100)
126
127
128
129
130
131
132
133
134
135
136
  for (Msc_RS=2; Msc_RS<33; Msc_RS++) {
    for (u=0; u<30; u++) {
      for (v=0; v<2; v++) {
        qbar = ref_primes[Msc_RS] * (u+1)/(double)31;
        ul_ref_sigs_rx[u][v][Msc_RS] = (int16_t*)malloc16(4*sizeof(int16_t)*dftsizes[Msc_RS]);

        if ((((int)floor(2*qbar))&1) == 0)
          q = (int)(floor(qbar+.5)) - v;
        else
          q = (int)(floor(qbar+.5)) + v;

137
#ifdef MAIN
138
        printf("Msc_RS %d (%d), u %d, v %d -> q %d (qbar %f)\n",Msc_RS,dftsizes[Msc_RS],u,v,q,qbar);
139
#endif
140
141
142
143
144
145

        for (n=0; n<dftsizes[Msc_RS]; n++) {
          m=n%ref_primes[Msc_RS];
          phase = (double)q*m*(m+1)/ref_primes[Msc_RS];
          ul_ref_sigs_rx[u][v][Msc_RS][n<<1]     =(int16_t)(floor(32767*cos(M_PI*phase)));
          ul_ref_sigs_rx[u][v][Msc_RS][1+(n<<1)] =-(int16_t)(floor(32767*sin(M_PI*phase)));
146
#ifdef MAIN
147
148
149
150

          if (Msc_RS<5)
            printf("(%d,%d) ",ul_ref_sigs_rx[u][v][Msc_RS][n<<2],ul_ref_sigs_rx[u][v][Msc_RS][1+(n<<2)]);

151
#endif
152
153
        }

154
#ifdef MAIN
155
156
157
158

        if (Msc_RS<5)
          printf("\n");

159
160
161
162
163
164
#endif
      }
    }
  }

  // These are the sequences for RB 1
165
166
167
168
169
170
  for (u=0; u<30; u++) {
    ul_ref_sigs_rx[u][0][0] = (int16_t*)malloc16(4*sizeof(int16_t)*dftsizes[0]);

    for (n=0; n<dftsizes[0]; n++) {
      ul_ref_sigs_rx[u][0][0][n<<1]    = (int16_t)(floor(32767*cos(M_PI*ref12[(u*12) + n]/4)));
      ul_ref_sigs_rx[u][0][0][1+(n<<1)]= (int16_t)(floor(32767*sin(M_PI*ref12[(u*12) + n]/4)));
171
    }
172
  }
173
174

  // These are the sequences for RB 2
175
176
177
178
179
180
181
182
  for (u=0; u<30; u++) {
    ul_ref_sigs_rx[u][0][1] = (int16_t*)malloc16(4*sizeof(int16_t)*dftsizes[1]);

    for (n=0; n<dftsizes[1]; n++) {
      ul_ref_sigs_rx[u][0][1][n<<1]    = (int16_t)(floor(32767*cos(M_PI*ref24[(u*24) + n]/4)));
      ul_ref_sigs_rx[u][0][1][1+(n<<1)]= (int16_t)(floor(32767*sin(M_PI*ref24[(u*24) + n]/4)));
      ul_ref_sigs_rx[u][0][1][2+(n<<2)]=-(int16_t)(floor(32767*sin(M_PI*ref24[(u*24) + n]/4)));
      ul_ref_sigs_rx[u][0][1][3+(n<<2)]= (int16_t)(floor(32767*cos(M_PI*ref24[(u*24) + n]/4)));
183
184
    }

185
186
  }

187
188
189
}


190
191
void free_ul_ref_sigs(void)
{
192
193
194

  unsigned int u,v,Msc_RS;

195
196
197
198
199
200
201
202
  for (Msc_RS=2; Msc_RS<33; Msc_RS++) {
    for (u=0; u<30; u++) {
      for (v=0; v<2; v++) {
        if (ul_ref_sigs[u][v][Msc_RS])
          free16(ul_ref_sigs[u][v][Msc_RS],2*sizeof(int16_t)*dftsizes[Msc_RS]);

        if (ul_ref_sigs_rx[u][v][Msc_RS])
          free16(ul_ref_sigs_rx[u][v][Msc_RS],4*sizeof(int16_t)*dftsizes[Msc_RS]);
203
204
205
206
207
208
      }
    }
  }
}

#ifdef MAIN
209
210
main()
{
211
212
213
214
215
216

  generate_ul_ref_sigs();
  generate_ul_ref_sigs_rx();
  free_ul_ref_sigs();
}
#endif