nr_gold.c 2.41 KB
Newer Older
Guy De Souza's avatar
Guy De Souza committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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
 */

22
#include "nr_refsig.h"
Guy De Souza's avatar
Guy De Souza committed
23 24 25

void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB)
{
26
  unsigned int x1, x2;
27
  uint16_t Nid, i_ssb, i_ssb2;
Guy De Souza's avatar
Guy De Souza committed
28
  unsigned char Lmax, l, n_hf, N_hf;
WEI-TAI CHEN's avatar
WEI-TAI CHEN committed
29
  nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
Guy De Souza's avatar
Guy De Souza committed
30
  NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
Guy De Souza's avatar
Guy De Souza committed
31
  uint8_t reset;
Guy De Souza's avatar
Guy De Souza committed
32 33 34 35 36 37 38 39

  Nid = cfg->sch_config.physical_cell_id.value;

  Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8;
  N_hf = (Lmax == 4)? 2:1;

  for (n_hf = 0; n_hf < N_hf; n_hf++) {
    for (l = 0; l < Lmax ; l++) {
40
      i_ssb = l & (Lmax-1);
Guy De Souza's avatar
Guy De Souza committed
41 42
      i_ssb2 = (i_ssb<<2) + n_hf;

Guy De Souza's avatar
Guy De Souza committed
43
      reset = 1;
Guy De Souza's avatar
Guy De Souza committed
44 45
      x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3);

46 47 48
      for (uint8_t n=0; n<NR_PBCH_DMRS_LENGTH_DWORD; n++) {
        gNB->nr_gold_pbch_dmrs[n_hf][l][n] = lte_gold_generic(&x1, &x2, reset);
        reset = 0;
Guy De Souza's avatar
Guy De Souza committed
49 50 51 52 53 54
      }

    }
  }

}
55 56 57 58

void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid)
{

Guy De Souza's avatar
Guy De Souza committed
59
  uint32_t x1, x2;
Guy De Souza's avatar
Guy De Souza committed
60
  uint8_t reset;
61 62 63
  NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
  uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs;

Guy De Souza's avatar
Guy De Souza committed
64 65
  for (uint8_t slot=0; slot<fp->slots_per_frame; slot++) {
    for (uint8_t symb=0; symb<fp->symbols_per_slot; symb++) {
66

Guy De Souza's avatar
Guy De Souza committed
67
      reset = 1;
68
      x2 = ((1<<17) * (14*slot+symb+1) * ((Nid<<1)+1) + (Nid<<1))&(((uint32_t)1<<31)-1);
69

Guy De Souza's avatar
Guy De Souza committed
70
      for (uint32_t n=0; n<NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD; n++) {
71 72 73 74 75 76 77
        pdcch_dmrs[slot][symb][n] = lte_gold_generic(&x1, &x2, reset);
        reset = 0;
      }
    }  
  }

}