nr_pss.c 2.85 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
 */

Guy De Souza's avatar
Guy De Souza committed
22
23

#include "PHY/NR_TRANSPORT/nr_transport.h"
Guy De Souza's avatar
Guy De Souza committed
24

25
//#define NR_PSS_DEBUG
Guy De Souza's avatar
Guy De Souza committed
26
27

int nr_generate_pss(  int16_t *d_pss,
28
                      int32_t *txdataF,
Guy De Souza's avatar
Guy De Souza committed
29
                      int16_t amp,
30
                      uint8_t ssb_start_symbol,
ChenWeiTai's avatar
ChenWeiTai committed
31
                      nfapi_nr_config_request_t* config,
Guy De Souza's avatar
Guy De Souza committed
32
33
                      NR_DL_FRAME_PARMS *frame_parms)
{
34
35
  int i,k,l,m;
  int16_t a;
Guy De Souza's avatar
Guy De Souza committed
36
37
38
  int16_t x[NR_PSS_LENGTH];
  const int x_initial[7] = {0, 1, 1 , 0, 1, 1, 1};

39
  uint8_t Nid2 = config->sch_config.physical_cell_id.value % 3;
Guy De Souza's avatar
Guy De Souza committed
40

41
  /// Sequence generation
Guy De Souza's avatar
Guy De Souza committed
42
43
44
45
46
47
48
  for (i=0; i < 7; i++)
    x[i] = x_initial[i];

  for (i=0; i < (NR_PSS_LENGTH - 7); i++) {
    x[i+7] = (x[i + 4] + x[i]) %2;
  }

49
50
  for (i=0; i < NR_PSS_LENGTH; i++) {
    m = (i + 43*Nid2)%(NR_PSS_LENGTH);
Guy De Souza's avatar
Guy De Souza committed
51
    d_pss[i] = (1 - 2*x[m]) * 23170;
Guy De Souza's avatar
Guy De Souza committed
52
53
  }

Guy De Souza's avatar
Guy De Souza committed
54
#ifdef NR_PSS_DEBUG
Florian Kaltenberger's avatar
WIP    
Florian Kaltenberger committed
55
  write_output("d_pss.m", "d_pss", (void*)d_pss, NR_PSS_LENGTH, 1, 0);
knopp's avatar
knopp committed
56
  printf("PSS: ofdm_symbol_size %d, first_carrier_offset %d\n",frame_parms->ofdm_symbol_size,frame_parms->first_carrier_offset);
Guy De Souza's avatar
Guy De Souza committed
57
58
#endif

59
  /// Resource mapping
60
  a = amp;
Guy De Souza's avatar
Guy De Souza committed
61
62


63
    // PSS occupies a predefined position (subcarriers 56-182, symbol 0) within the SSB block starting from
Guy De Souza's avatar
Guy De Souza committed
64
    k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56; //and
knopp's avatar
knopp committed
65
66
    if (k>= frame_parms->ofdm_symbol_size) k-=frame_parms->ofdm_symbol_size;

67
    l = ssb_start_symbol;
Guy De Souza's avatar
Guy De Souza committed
68
69

    for (m = 0; m < NR_PSS_LENGTH; m++) {
70
      //      printf("pss: writing position k %d / %d\n",k,frame_parms->ofdm_symbol_size);
71
      ((int16_t*)txdataF)[2*(l*frame_parms->ofdm_symbol_size + k)] = (a * d_pss[m]) >> 15;
Guy De Souza's avatar
Guy De Souza committed
72
      k++;
Guy De Souza's avatar
Guy De Souza committed
73

Guy De Souza's avatar
Guy De Souza committed
74
      if (k >= frame_parms->ofdm_symbol_size)
Guy De Souza's avatar
Guy De Souza committed
75
76
77
        k-=frame_parms->ofdm_symbol_size;
    }

Guy De Souza's avatar
Guy De Souza committed
78
#ifdef NR_PSS_DEBUG
knopp's avatar
knopp committed
79
80
81
  LOG_M("pss_0.m", "pss_0", 
	(void*)&txdataF[0][ssb_start_symbol*frame_parms->ofdm_symbol_size], 
	frame_parms->ofdm_symbol_size, 1, 1);
Guy De Souza's avatar
Guy De Souza committed
82
83
#endif

84
  return 0;
Guy De Souza's avatar
Guy De Souza committed
85
}