Commit a6136177 authored by rmagueta's avatar rmagueta

Fix preamble shift at gNB for RA works with all preambles

parent 22fa28e7
...@@ -678,19 +678,10 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, ...@@ -678,19 +678,10 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
} }
else { else {
preamble_shift -= NCS;
// FIXME: It is working, but we need to differentiate between odd and even preamble index if (preamble_shift < 0)
// Check why preamble_shift does not match with UE preamble_shift+=((N_ZC/NCS)*NCS);
// TS 38.211 Section 6.3.3.1 Sequence generation
if(preamble_index%2==0) {
preamble_shift = (NCS==0)? 0 : (preamble_index % (N_ZC/NCS));
preamble_shift *= NCS;
} else {
preamble_shift -= 2*NCS;
if (preamble_shift < 0)
preamble_shift+=N_ZC;
}
} }
} else { // This is the high-speed case } else { // This is the high-speed case
new_dft = 0; new_dft = 0;
......
...@@ -257,6 +257,8 @@ typedef struct { ...@@ -257,6 +257,8 @@ typedef struct {
uint8_t RA_attempt_number; uint8_t RA_attempt_number;
/// Random-access procedure flag /// Random-access procedure flag
uint8_t RA_active; uint8_t RA_active;
/// Random-access preamble index
int ra_PreambleIndex;
/// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot /// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot
uint8_t generate_nr_prach; uint8_t generate_nr_prach;
......
...@@ -64,6 +64,8 @@ void init_RA(module_id_t mod_id, ...@@ -64,6 +64,8 @@ void init_RA(module_id_t mod_id,
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
ra->RA_active = 1; ra->RA_active = 1;
ra->ra_PreambleIndex = -1;
ra->RA_usedGroupA = 1;
ra->RA_RAPID_found = 0; ra->RA_RAPID_found = 0;
ra->preambleTransMax = 0; ra->preambleTransMax = 0;
ra->first_Msg3 = 1; ra->first_Msg3 = 1;
...@@ -251,7 +253,7 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t ...@@ -251,7 +253,7 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
int messageSizeGroupA = 0; int messageSizeGroupA = 0;
int sizeOfRA_PreamblesGroupA = 0; int sizeOfRA_PreamblesGroupA = 0;
int messagePowerOffsetGroupB = 0; int messagePowerOffsetGroupB = 0;
int PLThreshold; int PLThreshold = 0;
long deltaPreamble_Msg3 = 0; long deltaPreamble_Msg3 = 0;
uint8_t noGroupB = 0; uint8_t noGroupB = 0;
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
...@@ -354,37 +356,34 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t ...@@ -354,37 +356,34 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
} }
/* Msg3 has not been transmitted yet */ /* Msg3 has not been transmitted yet */
if (ra->first_Msg3) { if (ra->first_Msg3) {
if (noGroupB) { if(ra->ra_PreambleIndex < 0 || ra->ra_PreambleIndex > 63) {
// use Group A preamble if (noGroupB) {
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb); // use Group A preamble
ra->RA_usedGroupA = 1; ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
} else if ((ra->Msg3_size < messageSizeGroupA) && (dl_pathloss > PLThreshold)) { ra->RA_usedGroupA = 1;
// Group B is configured and RA preamble Group A is used } else if ((ra->Msg3_size < messageSizeGroupA) && (dl_pathloss > PLThreshold)) {
// - todo add condition on CCCH_sdu_size for initiation by CCCH // Group B is configured and RA preamble Group A is used
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA); // - todo add condition on CCCH_sdu_size for initiation by CCCH
ra->RA_usedGroupA = 1; ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
} else { ra->RA_usedGroupA = 1;
// Group B preamble is configured and used } else {
// the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A // Group B preamble is configured and used
// the remaining belong to RA Preambles Group B // the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA)); // the remaining belong to RA Preambles Group B
ra->RA_usedGroupA = 0; ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
ra->RA_usedGroupA = 0;
}
} }
// TODO: Remove to generate random ra_PreambleIndex
printf("prach_resources->ra_PreambleIndex = %i\n", prach_resources->ra_PreambleIndex);
prach_resources->ra_PreambleIndex = 21;
ra->RA_usedGroupA = 1;
} else { // Msg3 is being retransmitted } else { // Msg3 is being retransmitted
if (ra->RA_usedGroupA && noGroupB) { if (ra->RA_usedGroupA && noGroupB) {
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb); ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
} else if (ra->RA_usedGroupA && !noGroupB){ } else if (ra->RA_usedGroupA && !noGroupB){
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA); ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
} else { } else {
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA)); ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
} }
} }
prach_resources->ra_PreambleIndex = ra->ra_PreambleIndex;
} }
// RA-RNTI computation (associated to PRACH occasion in which the RA Preamble is transmitted) // RA-RNTI computation (associated to PRACH occasion in which the RA Preamble is transmitted)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment