lte_gold.c 5.3 KB
Newer Older
1 2 3 4 5
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */
ghaddab's avatar
ghaddab committed
21

22
#include "lte_refsig.h"
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44


/* c(n) = x1(n+Nc) + x2(n+Nc) mod 2
x1(n+31) = (x1(n+3)+x1(n))mod 2
x2(n+31) = (x2(n+3)+x2(n+2)+x2(n+1)+x2(n))mod 2
x1(0)=1,x1(n)=0,n=1...30
x2 <=> cinit = sum_{i=0}^{30} x2(i)2^i

equivalent
x1(n) = x1(n-28) + x1(n-31)
x2(n) = x2(n-28) + x2(n-29) + x2(n-30) + x2(n-31)
x1(0)=1,x1(1)=0,...x1(30)=0,x1(31)=1
x2 <=> cinit, x2(31) = x2(3)+x2(2)+x2(1)+x2(0)

N_RB^{max,DL}=110
c_init = 2^1 * (7(n_s + 1) + l + 1)*(2N_{ID}^{cell} + 1) + 2*N_{ID}^{cell} + N_CP
N_{ID}^{cell = 0..503
*/

//unsigned int lte_gold_table[3][20][2][14];  // need 55 bytes for sequence
// slot index x pilot within slot x sequence

45 46
void lte_gold(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table[20][2][14],uint16_t Nid_cell)
{
47 48 49
  unsigned char ns,l,Ncp=1-frame_parms->Ncp;
  unsigned int n,x1,x2;//,x1tmp,x2tmp;

50
  for (ns=0; ns<20; ns++) {
51

52 53 54 55
    for (l=0; l<2; l++) {

      x2 = Ncp +
           (Nid_cell<<1) +
56
       (((1+(Nid_cell<<1))*(1 + (((frame_parms->Ncp==0)?4:3)*l) + (7*(1+ns))))<<10); //cinit
57 58 59 60
      //x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit
      //n = 0
      x1 = 1+ (1<<31);
      x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
61

62
      // skip first 50 double words (1600 bits)
63 64 65 66 67
      for (n=1; n<50; n++) {
        x1 = (x1>>1) ^ (x1>>4);
        x1 = x1 ^ (x1<<31) ^ (x1<<28);
        x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4);
        x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28);
68
      }
69 70 71 72 73 74 75

      for (n=0; n<14; n++) {
        x1 = (x1>>1) ^ (x1>>4);
        x1 = x1 ^ (x1<<31) ^ (x1<<28);
        x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4);
        x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28);
        lte_gold_table[ns][l][n] = x1^x2;
76 77 78 79 80 81 82
      }

    }

  }
}

83
void lte_gold_ue_spec(uint32_t lte_gold_uespec_table[2][20][2][21],uint16_t Nid_cell, uint16_t *n_idDMRS)
84
{
Raymond Knopp's avatar
 
Raymond Knopp committed
85 86 87 88 89

  unsigned char ns,l;
  unsigned int n,x1,x2;//,x1tmp,x2tmp;
  int nscid;
  int nid;
90 91

  for (nscid=0; nscid<2; nscid++) {
Raymond Knopp's avatar
 
Raymond Knopp committed
92 93 94 95
    if (n_idDMRS)
      nid = n_idDMRS[nscid];
    else
      nid = Nid_cell;
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

    for (ns=0; ns<20; ns++) {

      for (l=0; l<2; l++) {


        x2 = ((((ns>>1)+1)*((nid<<1)+1))<<16) + nscid;
        //x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit
        //n = 0
        //      printf("cinit (ns %d, l %d) => %d\n",ns,l,x2);
        x1 = 1+ (1<<31);
        x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);

        // skip first 50 double words (1600 bits)
        //printf("n=0 : x1 %x, x2 %x\n",x1,x2);
        for (n=1; n<50; n++) {
          x1 = (x1>>1) ^ (x1>>4);
          x1 = x1 ^ (x1<<31) ^ (x1<<28);
          x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4);
          x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28);
          //  printf("x1 : %x, x2 : %x\n",x1,x2);
        }

        for (n=0; n<14; n++) {
          x1 = (x1>>1) ^ (x1>>4);
          x1 = x1 ^ (x1<<31) ^ (x1<<28);
          x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4);
          x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28);
          lte_gold_uespec_table[nscid][ns][l][n] = x1^x2;
          //  printf("n=%d : c %x\n",n,x1^x2);
        }

Raymond Knopp's avatar
 
Raymond Knopp committed
128 129 130 131 132
      }
    }
  }
}

133
void lte_gold_ue_spec_port5(uint32_t lte_gold_uespec_port5_table[20][38],uint16_t Nid_cell, uint16_t n_rnti)
134 135
{

Xiwen JIANG's avatar
Xiwen JIANG committed
136
  unsigned char ns;
137 138 139 140 141
  unsigned int n,x1,x2;


  for (ns=0; ns<20; ns++) {

142 143 144
    x2 = ((((ns>>1)+1)*((Nid_cell<<1)+1))<<16) + n_rnti;
    //x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit
    //n = 0
Xiwen JIANG's avatar
Xiwen JIANG committed
145
    //printf("cinit (ns %d, l %d) => %d\n",ns,l,x2);
146 147
    x1 = 1+ (1<<31);
    x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
148

Xiwen JIANG's avatar
Xiwen JIANG committed
149
    //skip first 50 double words (1600 bits)
150 151 152 153 154 155
    //printf("n=0 : x1 %x, x2 %x\n",x1,x2);
    for (n=1; n<50; n++) {
      x1 = (x1>>1) ^ (x1>>4);
      x1 = x1 ^ (x1<<31) ^ (x1<<28);
      x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4);
      x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28);
Xiwen JIANG's avatar
Xiwen JIANG committed
156
      //printf("x1 : %x, x2 : %x\n",x1,x2);
157
    }
158

159 160 161 162 163 164
    for (n=0; n<38; n++) {
      x1 = (x1>>1) ^ (x1>>4);
      x1 = x1 ^ (x1<<31) ^ (x1<<28);
      x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4);
      x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28);
      lte_gold_uespec_port5_table[ns][n] = x1^x2;
Xiwen JIANG's avatar
Xiwen JIANG committed
165
      //printf("n=%d : c %x\n",n,x1^x2);
166
    }
167

168 169 170
  }
}

171
#ifdef LTE_GOLD_MAIN
172 173
main()
{
174 175 176 177 178 179

  lte_gold(423,0);

}
#endif