nr_gold_ue.c 3.99 KB
Newer Older
Hongzhi Wang's avatar
Hongzhi Wang committed
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
/*
 * 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
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
 * 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
 */

#include "refsig_defs_ue.h"

void nr_gold_pbch(PHY_VARS_NR_UE* ue)
{
  unsigned int n, x1, x2;
Guy De Souza's avatar
Guy De Souza committed
27
  unsigned int Nid, i_ssb, i_ssb2;
Hongzhi Wang's avatar
Hongzhi Wang committed
28
  unsigned char Lmax, l, n_hf, N_hf;
29
  uint8_t reset;
Hongzhi Wang's avatar
Hongzhi Wang committed
30 31

  Nid = ue->frame_parms.Nid_cell;
32
  Lmax = ue->frame_parms.Lmax;
Hongzhi Wang's avatar
Hongzhi Wang committed
33 34 35 36 37 38
  N_hf = (Lmax == 4)? 2:1;

  for (n_hf = 0; n_hf < N_hf; n_hf++) {

    for (l = 0; l < Lmax ; l++) {
      i_ssb = l & (Lmax-1);
39
      i_ssb2 = i_ssb + (n_hf<<2);
Hongzhi Wang's avatar
Hongzhi Wang committed
40

41
      reset = 1;
Hongzhi Wang's avatar
Hongzhi Wang committed
42 43
      x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3);

44
      for (n=0; n<NR_PBCH_DMRS_LENGTH_DWORD; n++) {
45 46
        ue->nr_gold_pbch[n_hf][l][n] = lte_gold_generic(&x1, &x2, reset);
        reset = 0;
Hongzhi Wang's avatar
Hongzhi Wang committed
47 48 49 50 51 52 53
      }

    }
  }

}

54
void nr_gold_pdcch(PHY_VARS_NR_UE* ue,
55
                   unsigned short nid)
56 57 58
{
  unsigned char ns,l;
  unsigned int n,x1,x2,x2tmp0;
59
  uint8_t reset;
60

61
  for (ns=0; ns<ue->frame_parms.slots_per_frame; ns++) {
62

63
    for (l=0; l<ue->frame_parms.symbols_per_slot; l++) {
64

65 66
      reset = 1;
      x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17;
67
      x2 = (x2tmp0+(nid<<1))%(1<<31);  //cinit
68 69 70 71 72
      
      for (n=0; n<NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD; n++) {
        ue->nr_gold_pdcch[0][ns][l][n] = lte_gold_generic(&x1, &x2, reset);
        reset = 0;
      }    
73
    }
74
  }
75 76
}

77
void nr_gold_pdsch(PHY_VARS_NR_UE* ue,
78
                   unsigned short *n_idDMRS)
Hongzhi Wang's avatar
Hongzhi Wang committed
79
{
80
  unsigned char l;
81
  unsigned int n,x1,x2,x2tmp0,ns;
Hongzhi Wang's avatar
Hongzhi Wang committed
82 83
  int nscid;
  unsigned int nid;
84
  uint8_t reset;
Hongzhi Wang's avatar
Hongzhi Wang committed
85 86

  /// to be updated from higher layer
Hongzhi Wang's avatar
Hongzhi Wang committed
87
  //unsigned short lbar = 0;
Hongzhi Wang's avatar
Hongzhi Wang committed
88 89

  for (nscid=0; nscid<2; nscid++) {
90
    for (ns=0; ns<ue->frame_parms.slots_per_frame; ns++) {
Hongzhi Wang's avatar
Hongzhi Wang committed
91

92
      nid = n_idDMRS[nscid];
Hongzhi Wang's avatar
Hongzhi Wang committed
93

94
      for (l=0; l<ue->frame_parms.symbols_per_slot; l++) {
Hongzhi Wang's avatar
Hongzhi Wang committed
95

96 97
        reset = 1;
        x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17;
98
        x2 = (x2tmp0+(nid<<1)+nscid)%(1<<31);  //cinit
99
        LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid);
100

Sakthivel Velumani's avatar
Sakthivel Velumani committed
101
        for (n=0; n<NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD; n++) {
102 103 104
          ue->nr_gold_pdsch[0][ns][l][nscid][n] = lte_gold_generic(&x1, &x2, reset);
          reset = 0;
        }
Hongzhi Wang's avatar
Hongzhi Wang committed
105 106 107 108
      }
    }
  }
}
109

110
void nr_init_pusch_dmrs(PHY_VARS_NR_UE* ue,
yilmazt's avatar
yilmazt committed
111 112
                        uint16_t *N_n_scid,
                        uint8_t n_scid)
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
{
  uint32_t x1, x2, n;
  uint8_t reset, slot, symb, q;
  NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
  uint32_t ****pusch_dmrs = ue->nr_gold_pusch_dmrs;

  for (slot=0; slot<fp->slots_per_frame; slot++) {

    for (symb=0; symb<fp->symbols_per_slot; symb++) {

      reset = 1;
      x2 = ((1<<17) * (fp->symbols_per_slot*slot+symb+1) * ((N_n_scid[n_scid]<<1)+1) +((N_n_scid[n_scid]<<1)+n_scid));

      for (n=0; n<NR_MAX_PUSCH_DMRS_INIT_LENGTH_DWORD; n++) {
        pusch_dmrs[slot][symb][0][n] = lte_gold_generic(&x1, &x2, reset);
        reset = 0;
      }

      for (q = 1; q < NR_MAX_NB_CODEWORDS; q++)
        memcpy(pusch_dmrs[slot][symb][q],pusch_dmrs[slot][symb][0],sizeof(uint32_t)*NR_MAX_PUSCH_DMRS_INIT_LENGTH_DWORD);
    }
  }
}