defs_nr_common.h 11.3 KB
Newer Older
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 27 28 29 30 31 32 33 34 35
/*
 * 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
 */

/*! \file PHY/defs_nr_common.h
 \brief Top-level defines and structure definitions
 \author Guy De Souza
 \date 2018
 \version 0.1
 \company Eurecom
 \email: desouza@eurecom.fr
 \note
 \warning
*/

#ifndef __PHY_DEFS_NR_COMMON__H__
#define __PHY_DEFS_NR_COMMON__H__

Jacques's avatar
Jacques committed
36
#include "PHY/impl_defs_top.h"
37
#include "defs_common.h"
Raymond Knopp's avatar
Raymond Knopp committed
38
#include "nfapi_nr_interface_scf.h"
39
#include "impl_defs_nr.h"
Guy De Souza's avatar
Guy De Souza committed
40
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
41 42

#define nr_subframe_t lte_subframe_t
43
#define nr_slot_t lte_subframe_t
44 45

#define MAX_NUM_SUBCARRIER_SPACING 5
46
#define NR_MAX_OFDM_SYMBOL_SIZE 4096
47

Laurent THOMAS's avatar
Laurent THOMAS committed
48
#define NR_SYMBOLS_PER_SLOT NR_NUMBER_OF_SYMBOLS_PER_SLOT
49 50 51 52

#define ONE_OVER_SQRT2_Q15 23170
#define ONE_OVER_TWO_Q15 16384

53
#define NR_MOD_TABLE_SIZE_SHORT 686
Guy De Souza's avatar
Guy De Souza committed
54 55
#define NR_MOD_TABLE_BPSK_OFFSET 1
#define NR_MOD_TABLE_QPSK_OFFSET 3
56 57 58
#define NR_MOD_TABLE_QAM16_OFFSET 7
#define NR_MOD_TABLE_QAM64_OFFSET 23
#define NR_MOD_TABLE_QAM256_OFFSET 87
59

Guy De Souza's avatar
Guy De Souza committed
60 61 62
#define NR_PSS_LENGTH 127
#define NR_SSS_LENGTH 127

63 64
#define NR_MAX_PRS_LENGTH 3264 //272*6(max allocation per RB)*2(QPSK)
#define NR_MAX_PRS_INIT_LENGTH_DWORD 102 // ceil(NR_MAX_CSI_RS_LENGTH/32)
65
#define NR_MAX_NUM_PRS_SYMB 12
66
#define NR_MAX_PRS_COMB_SIZE 12
67 68
#define NR_MAX_PRS_RESOURCES_PER_SET 64
#define NR_MAX_PRS_MUTING_PATTERN_LENGTH 32
69

Guy De Souza's avatar
Guy De Souza committed
70
#define NR_PBCH_DMRS_LENGTH 144 // in mod symbols
71
#define NR_PBCH_DMRS_LENGTH_DWORD 10 // ceil(2(QPSK)*NR_PBCH_DMRS_LENGTH/32)
72

Guy De Souza's avatar
Guy De Souza committed
73 74
/*used for the resource mapping*/
#define NR_MAX_PDCCH_DMRS_LENGTH 576 // 16(L)*2(QPSK)*3(3 DMRS symbs per REG)*6(REG per CCE)
75
#define NR_MAX_PDCCH_SIZE 8192 // It seems it is the max polar coded block size
76
#define NR_MAX_DCI_PAYLOAD_SIZE 64
Guy De Souza's avatar
Guy De Souza committed
77
#define NR_MAX_DCI_SIZE 1728 //16(L)*2(QPSK)*9(12 RE per REG - 3(DMRS))*6(REG per CCE)
Guy De Souza's avatar
Guy De Souza committed
78
#define NR_MAX_DCI_SIZE_DWORD 54 // ceil(NR_MAX_DCI_SIZE/32)
Guy De Souza's avatar
Guy De Souza committed
79

80
#define NR_MAX_PDCCH_AGG_LEVEL 16 // 3GPP TS 38.211 V15.8 Section 7.3.2 Table 7.3.2.1-1: Supported PDCCH aggregation levels
81

82
#define NR_MAX_NB_LAYERS 4 // 8
83 84
#define NR_MAX_NB_PORTS 32

85
#define NR_MAX_PDSCH_TBS 3824
Guy De Souza's avatar
Guy De Souza committed
86

87 88 89
#define MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER 36

#define MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER 34
90

91
#define MAX_NUM_NR_RE (4*14*273*12)
92

93
#define MAX_NUM_NR_SRS_SYMBOLS 4
94
#define MAX_NUM_NR_SRS_AP 4
95

96 97
#define NR_NB_NSCID 2

98 99
#define MAX_UL_DELAY_COMP 20

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
typedef enum {
  NR_MU_0=0,
  NR_MU_1,
  NR_MU_2,
  NR_MU_3,
  NR_MU_4,
} nr_numerology_index_e;

typedef enum{
  nr_ssb_type_A = 0,
  nr_ssb_type_B,
  nr_ssb_type_C,
  nr_ssb_type_D,
  nr_ssb_type_E
} nr_ssb_type_e;

rmagueta's avatar
rmagueta committed
116
typedef struct {
117
  uint8_t k_0_p[MAX_NUM_NR_SRS_AP][MAX_NUM_NR_SRS_SYMBOLS];
118
  uint8_t srs_generated_signal_bits;
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
119
  int32_t **srs_generated_signal;
120
  nfapi_nr_srs_pdu_t srs_pdu;
rmagueta's avatar
rmagueta committed
121 122
} nr_srs_info_t;

123 124 125 126 127 128 129 130 131
typedef struct {
  uint16_t csi_gold_init;
  uint32_t ***nr_gold_csi_rs;
  uint8_t csi_rs_generated_signal_bits;
  int32_t **csi_rs_generated_signal;
  bool csi_im_meas_computed;
  uint32_t interference_plus_noise_power;
} nr_csi_info_t;

132 133
typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS;

laurent's avatar
laurent committed
134 135
typedef uint32_t (*get_samples_per_slot_t)(int slot, const NR_DL_FRAME_PARMS *fp);
typedef uint32_t (*get_slot_from_timestamp_t)(openair0_timestamp timestamp_rx, const NR_DL_FRAME_PARMS *fp);
136

laurent's avatar
laurent committed
137
typedef uint32_t (*get_samples_slot_timestamp_t)(int slot, const NR_DL_FRAME_PARMS *fp, uint8_t sl_ahead);
138 139

struct NR_DL_FRAME_PARMS {
Guy De Souza's avatar
Guy De Souza committed
140 141
  /// frequency range
  nr_frequency_range_e freq_range;
142 143
  //  /// Placeholder to replace overlapping fields below
  //  nfapi_nr_rf_config_t rf_config;
Raymond Knopp's avatar
Raymond Knopp committed
144
  /// Placeholder to replace SSB overlapping fields below
145
  //  nfapi_nr_sch_config_t sch_config;
146
  /// Number of resource blocks (RB) in DL
Raymond Knopp's avatar
Raymond Knopp committed
147
  int N_RB_DL;
148
  /// Number of resource blocks (RB) in UL
Raymond Knopp's avatar
Raymond Knopp committed
149
  int N_RB_UL;
150 151
  /// Number of resource blocks (RB) in SL
  int N_RB_SL;
152 153 154 155
  ///  total Number of Resource Block Groups: this is ceil(N_PRB/P)
  uint8_t N_RBG;
  /// Total Number of Resource Block Groups SubSets: this is P
  uint8_t N_RBGS;
156 157
  /// NR Band
  uint16_t nr_band;
158
  /// DL carrier frequency
159
  uint64_t dl_CarrierFreq;
160
  /// UL carrier frequency
161
  uint64_t ul_CarrierFreq;
162 163
  /// SL carrier frequency
  uint64_t sl_CarrierFreq;
164 165 166 167 168
  /// TX attenuation
  uint32_t att_tx;
  /// RX attenuation
  uint32_t att_rx;
  ///  total Number of Resource Block Groups: this is ceil(N_PRB/P)
169
  /// Frame type (0 FDD, 1 TDD)
francescomani's avatar
francescomani committed
170
  frame_type_t frame_type;
171
  uint8_t tdd_config;
172 173
  /// Sidelink Cell ID
  uint16_t Nid_SL;
174 175
  /// Cell ID
  uint16_t Nid_cell;
176
  /// subcarrier spacing (15,30,60,120)
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
  uint32_t subcarrier_spacing;
  /// 3/4 sampling
  uint8_t threequarter_fs;
  /// Size of FFT
  uint16_t ofdm_symbol_size;
  /// Number of prefix samples in all but first symbol of slot
  uint16_t nb_prefix_samples;
  /// Number of prefix samples in first symbol of slot
  uint16_t nb_prefix_samples0;
  /// Carrier offset in FFT buffer for first RE in PRB0
  uint16_t first_carrier_offset;
  /// Number of OFDM/SC-FDMA symbols in one slot
  uint16_t symbols_per_slot;
  /// Number of slots per subframe
  uint16_t slots_per_subframe;
192
  /// Number of slots per frame
193
  uint16_t slots_per_frame;
194 195
  /// Number of samples in a subframe
  uint32_t samples_per_subframe;
196 197
  /// Number of samples in current slot
  get_samples_per_slot_t get_samples_per_slot;
Rakesh's avatar
Rakesh committed
198 199
  /// slot calculation from timestamp
  get_slot_from_timestamp_t get_slot_from_timestamp;
200 201 202 203 204 205
  /// Number of samples before slot
  get_samples_slot_timestamp_t get_samples_slot_timestamp;
  /// Number of samples in 0th and center slot of a subframe
  uint32_t samples_per_slot0;
  /// Number of samples in other slots of the subframe
  uint32_t samples_per_slotN0;
206 207 208 209
  /// Number of samples in a radio frame
  uint32_t samples_per_frame;
  /// Number of samples in a subframe without CP
  uint32_t samples_per_subframe_wCP;
210 211
  /// Number of samples in a slot without CP
  uint32_t samples_per_slot_wCP;
212 213
  /// Number of samples in a radio frame without CP
  uint32_t samples_per_frame_wCP;
214 215
  /// NR numerology index [0..5] as specified in 38.211 Section 4 (mu). 0=15khZ SCS, 1=30khZ, 2=60kHz, etc
  uint8_t numerology_index;
216
  /// Number of Physical transmit antennas in node (corresponds to nrOfAntennaPorts)
217 218 219 220
  uint8_t nb_antennas_tx;
  /// Number of Receive antennas in node
  uint8_t nb_antennas_rx;
  /// Number of common transmit antenna ports in eNodeB (1 or 2)
221
  uint8_t nb_antenna_ports_gNB;
222 223
  /// Cyclic Prefix for DL (0=Normal CP, 1=Extended CP)
  lte_prefix_type_t Ncp;
224
  /// sequence which is computed based on carrier frequency and numerology to rotate/derotate each OFDM symbol according to Section 5.3 in 38.211
225 226
  /// First dimension is for the direction of the link (0 DL, 1 UL, 2 SL)
  c16_t symbol_rotation[3][224];
227 228
  /// sequence used to compensate the phase rotation due to timeshifted OFDM symbols
  /// First dimenstion is for different CP lengths
229
  c16_t timeshift_symbol_rotation[4096*2] __attribute__ ((aligned (16)));
230 231
  /// Table used to apply the delay compensation in UL
  c16_t ul_delay_table[2 * MAX_UL_DELAY_COMP + 1][NR_MAX_OFDM_SYMBOL_SIZE * 2];
Hongzhi Wang's avatar
Hongzhi Wang committed
232 233
  /// shift of pilot position in one RB
  uint8_t nushift;
234 235
  /// SRS configuration from TS 38.331 RRC
  SRS_NR srs_nr;
236 237
  /// Power used by SSB in order to estimate signal strength and path loss
  int ss_PBCH_BlockPower;
238 239 240 241 242
  /// for NR TDD management
  TDD_UL_DL_configCommon_t  *p_tdd_UL_DL_Configuration;

  TDD_UL_DL_configCommon_t  *p_tdd_UL_DL_ConfigurationCommon2;

243
  TDD_UL_DL_SlotConfig_t *p_TDD_UL_DL_ConfigDedicated;
244 245

  /// TDD configuration
Jacques's avatar
Jacques committed
246
  uint16_t tdd_uplink_nr[2*NR_MAX_SLOTS_PER_FRAME]; /* this is a bitmap of symbol of each slot given for 2 frames */
247

248 249
  uint8_t half_frame_bit;

250
  //SSB related params
251 252
  /// Start in Subcarrier index of the SSB block
  uint16_t ssb_start_subcarrier;
Guy De Souza's avatar
Guy De Souza committed
253
  /// SSB type
254
  nr_ssb_type_e ssb_type;
255 256
  /// Max number of SSB in frame
  uint8_t Lmax;
257
  /// SS block pattern (max 64 ssb, each bit is on/off ssb)
258
  uint64_t L_ssb;
259 260
  /// Total number of SSB transmitted
  uint8_t N_ssb;
261 262
  /// SSB index
  uint8_t ssb_index;
263 264
  /// OFDM symbol offset divisor for UL
  uint32_t ofdm_offset_divisor;
265 266
  uint16_t tdd_slot_config;
  uint8_t tdd_period;
267
};
268

269
// PRS config structures
270
typedef struct {
271 272 273 274 275 276 277
    uint16_t PRSResourceSetPeriod[2];   // [slot period, slot offset] of a PRS resource set
    uint16_t PRSResourceOffset;         // Slot offset of each PRS resource defined relative to the slot offset of the PRS resource set (0...511)
    uint8_t  PRSResourceRepetition;     // Repetition factor for all PRS resources in resource set (1 /*default*/, 2, 4, 6, 8, 16, 32)
    uint8_t  PRSResourceTimeGap;        // Slot offset between two consecutive repetition indices of all PRS resources in a PRS resource set (1 /*default*/, 2, 4, 6, 8, 16, 32)
    uint16_t NumRB;                     // Number of PRBs allocated to all PRS resources in a PRS resource set (<= 272 and multiples of 4)
    uint8_t  NumPRSSymbols;             // Number of OFDM symbols in a slot allocated to each PRS resource in a PRS resource set
    uint8_t  SymbolStart;               // Starting OFDM symbol of each PRS resource in a PRS resource set
278
    uint16_t RBOffset;                  // Starting PRB index of all PRS resources in a PRS resource set
279
    uint8_t  CombSize;                  // RE density of all PRS resources in a PRS resource set (2, 4, 6, 12)
280 281 282 283
    uint8_t  REOffset;                  // Starting RE offset in the first OFDM symbol of each PRS resource in a PRS resource set
    uint32_t MutingPattern1[32];        // Muting bit pattern option-1, specified as [] or a binary-valued vector of length 2, 4, 6, 8, 16, or 32
    uint32_t MutingPattern2[32];        // Muting bit pattern option-2, specified as [] or a binary-valued vector of length 2, 4, 6, 8, 16, or 32
    uint8_t  MutingBitRepetition;       // Muting bit repetition factor, specified as 1, 2, 4, or 8
284 285
    uint16_t NPRSID;                    // Sequence identity of each PRS resource in a PRS resource set, specified in the range [0, 4095]
} prs_config_t;
286

287 288 289 290 291
typedef struct {
    int8_t  gNB_id;
    int32_t sfn;
    int8_t  slot;
    int8_t  rxAnt_idx;
292
    float   dl_toa;
293
    int32_t dl_aoa;
294 295 296
    float   snr;
    float   rsrp;
    float   rsrp_dBm;
297 298 299
    int32_t reserved;
} prs_meas_t;

300 301 302 303 304 305 306 307
// rel16 prs k_prime table as per ts138.211 sec.7.4.1.7.2
#define K_PRIME_TABLE_ROW_SIZE 4
#define K_PRIME_TABLE_COL_SIZE 12
#define PRS_K_PRIME_TABLE { {0,1,0,1,0,1,0,1,0,1,0,1}, \
                            {0,2,1,3,0,2,1,3,0,2,1,3}, \
                            {0,3,1,4,2,5,0,3,1,4,2,5}, \
                            {0,6,3,9,1,7,4,10,2,8,5,11} };

308 309 310
#define KHz (1000UL)
#define MHz (1000*KHz)

311
#endif