group_hopping.c 4.88 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
 */
21 22 23 24 25 26 27 28 29 30 31

/*! \file PHY/LTE_TRANSPORT/group_hopping.c
* \brief Top-level routines for group/sequence hopping and nPRS sequence generationg for DRS and PUCCH from 36-211, V8.6 2009-03
* \author R. Knopp
* \date 2011
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr
* \note
* \warning
*/
32
#include "PHY/defs_common.h"
knopp's avatar
knopp committed
33
#include "PHY/LTE_REFSIG/lte_refsig.h"
34 35 36

//#define DEBUG_GROUPHOP 1

37 38
void generate_grouphop(LTE_DL_FRAME_PARMS *frame_parms)
{
39

40 41 42
  uint8_t ns;
  uint8_t reset=1;
  uint32_t x1, x2, s=0;
43
  // This is from Section 5.5.1.3
44
  uint32_t fss_pusch = frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH;
45

fnabet's avatar
fnabet committed
46 47
  uint32_t fss_pucch = frame_parms->Nid_cell;

48 49
  x2 = frame_parms->Nid_cell/30;
#ifdef DEBUG_GROUPHOP
50
  printf("[PHY] GroupHop:");
51
#endif
52 53

  for (ns=0; ns<20; ns++) {
54
    if (frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled == 0)
fnabet's avatar
fnabet committed
55
    {
56
      frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[ns] = fss_pusch%30;
fnabet's avatar
fnabet committed
57 58
      frame_parms->pucch_config_common.grouphop[ns]                          = fss_pucch%30;
    }
59 60
    else {
      if ((ns&3) == 0) {
61 62
        s = lte_gold_generic(&x1,&x2,reset);
        reset = 0;
63
      }
64

65
      frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[ns] = (((uint8_t*)&s)[ns&3]+fss_pusch)%30;
fnabet's avatar
fnabet committed
66
      frame_parms->pucch_config_common.grouphop[ns]                          = (((uint8_t*)&s)[ns&3]+fss_pucch)%30;
67
    }
68

69
#ifdef DEBUG_GROUPHOP
70
    printf("%d.",frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[ns]);
71 72
#endif
  }
73

74
#ifdef DEBUG_GROUPHOP
75
  printf("\n");
76 77 78
#endif
}

79 80
void generate_seqhop(LTE_DL_FRAME_PARMS *frame_parms)
{
81

82 83
  uint8_t ns,reset=1;
  uint32_t x1, x2, s=0;
84
  // This is from Section 5.5.1.3
85
  uint32_t fss_pusch = frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH;
86 87 88 89 90

  x2 = (32*(frame_parms->Nid_cell/30) + fss_pusch)%30;

  s = lte_gold_generic(&x1,&x2,reset);
#ifdef DEBUG_GROUPHOP
91
  printf("[PHY] SeqHop:");
92
#endif
93 94 95 96

  for (ns=0; ns<20; ns++) {
    if ((frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled == 0) &&
        (frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled == 1))
97 98 99
      frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[ns] = (s>>(ns&0x1f))&1;
    else
      frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[ns] = 0;
100

101
#ifdef DEBUG_GROUPHOP
102
    printf("%d.",frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[ns]);
103 104
#endif
  }
105

106
#ifdef DEBUG_GROUPHOP
107
  printf("\n");
108 109 110
#endif
}

111 112
void generate_nPRS(LTE_DL_FRAME_PARMS *frame_parms)
{
113

114 115 116
  uint16_t n=0;
  uint8_t reset=1;
  uint32_t x1, x2, s=0;
117
  // This is from Section 5.5.1.3
118
  uint8_t Nsymb_UL = (frame_parms->Ncp_UL == NORMAL) ? 7 : 6;
119 120
  uint16_t next = 0;
  uint8_t ns=0;
121

122 123
  uint32_t fss_pucch = (frame_parms->Nid_cell) % 30;
  uint32_t fss_pusch = (fss_pucch + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH) % 30;
124

125
  x2 = (32*(uint32_t)(frame_parms->Nid_cell/30)) + fss_pusch;
126
#ifdef DEBUG_GROUPHOP
127
  printf("[PHY] nPRS:");
128
#endif
129 130

  for (n=0; n<(20*Nsymb_UL); n++) { //loop over total number of bytes to generate
131 132 133
    if ((n&3) == 0) {
      s = lte_gold_generic(&x1,&x2,reset);
      reset = 0;
134
      //      printf("n %d : s (%d,%d,%d,%d)\n",n,((uint8_t*)&s)[0],((uint8_t*)&s)[1],((uint8_t*)&s)[2],((uint8_t*)&s)[3]);
135
    }
136

137
    if (n == next) {
138
      frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[ns] = ((uint8_t*)&s)[next&3];
139
#ifdef DEBUG_GROUPHOP
140
      printf("%d.",frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[ns]);
141 142 143 144 145
#endif
      ns++;
      next+=Nsymb_UL;
    }
  }
146

147
#ifdef DEBUG_GROUPHOP
148
  printf("\n");
149 150 151
#endif
}

152 153
void init_ul_hopping(LTE_DL_FRAME_PARMS *frame_parms)
{
154 155 156 157 158

  generate_grouphop(frame_parms);
  generate_seqhop(frame_parms);
  generate_nPRS(frame_parms);
}