mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
206 lines
5.0 KiB
C
206 lines
5.0 KiB
C
11 years ago
|
/**
|
||
|
*
|
||
|
* \section COPYRIGHT
|
||
|
*
|
||
9 years ago
|
* Copyright 2013-2015 Software Radio Systems Limited
|
||
11 years ago
|
*
|
||
|
* \section LICENSE
|
||
11 years ago
|
*
|
||
10 years ago
|
* This file is part of the srsLTE library.
|
||
11 years ago
|
*
|
||
10 years ago
|
* srsLTE is free software: you can redistribute it and/or modify
|
||
10 years ago
|
* it under the terms of the GNU Affero General Public License as
|
||
11 years ago
|
* published by the Free Software Foundation, either version 3 of
|
||
|
* the License, or (at your option) any later version.
|
||
|
*
|
||
10 years ago
|
* srsLTE is distributed in the hope that it will be useful,
|
||
11 years ago
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
10 years ago
|
* GNU Affero General Public License for more details.
|
||
11 years ago
|
*
|
||
10 years ago
|
* A copy of the GNU Affero General Public License can be found in
|
||
11 years ago
|
* the LICENSE file in the top-level directory of this distribution
|
||
|
* and at http://www.gnu.org/licenses/.
|
||
|
*
|
||
11 years ago
|
*/
|
||
|
|
||
11 years ago
|
|
||
11 years ago
|
#include <stdint.h>
|
||
|
#include <complex.h>
|
||
|
#include <math.h>
|
||
|
|
||
10 years ago
|
#include "srslte/modem/demod_hard.h"
|
||
11 years ago
|
#include "hard_demod_lte.h"
|
||
|
|
||
10 years ago
|
|
||
11 years ago
|
/**
|
||
|
* @ingroup Hard BPSK demodulator
|
||
|
*
|
||
|
*LTE-BPSK constellation:
|
||
|
* Q
|
||
|
* | 0
|
||
|
*---------> I
|
||
|
*1 |
|
||
|
* \param in input symbols (_Complex float)
|
||
10 years ago
|
* \param out output symbols (uint8_ts)
|
||
11 years ago
|
* \param N Number of input symbols
|
||
|
* \param modulation Modulation type
|
||
|
*/
|
||
10 years ago
|
inline void hard_bpsk_demod(const cf_t* in, uint8_t* out, uint32_t N)
|
||
11 years ago
|
{
|
||
10 years ago
|
uint32_t s;
|
||
11 years ago
|
|
||
11 years ago
|
for (s=0; s<N; s++) { /* received symbols */
|
||
|
if (__real__ in[s] > 0) {
|
||
|
if ((__imag__ in[s] > 0) || (__real__ in[s] > -__imag__ in[s])) {
|
||
|
out[s] = 0x0;
|
||
|
} else {
|
||
|
out[s] = 0x1;
|
||
|
}
|
||
|
} else {
|
||
|
if ((__imag__ in[s] < 0) || (__imag__ in[s] < -__real__ in[s])) {
|
||
|
out[s] = 0x1;
|
||
|
} else {
|
||
|
out[s] = 0x0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
11 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* @ingroup Hard QPSK demodulator
|
||
|
*
|
||
|
* LTE-QPSK constellation:
|
||
|
* Q
|
||
|
*10 | 00
|
||
|
*-----------> I
|
||
|
*11 | 01
|
||
|
*
|
||
|
* \param in input symbols (_Complex float)
|
||
10 years ago
|
* \param out output symbols (uint8_ts)
|
||
11 years ago
|
* \param N Number of input symbols
|
||
|
* \param modulation Modulation type
|
||
|
*/
|
||
10 years ago
|
inline void hard_qpsk_demod(const cf_t* in, uint8_t* out, uint32_t N)
|
||
11 years ago
|
{
|
||
10 years ago
|
uint32_t s;
|
||
11 years ago
|
|
||
11 years ago
|
for (s=0; s<N; s++) {
|
||
|
if (__real__ in[s] > 0) {
|
||
|
out[2*s] = 0x0;
|
||
|
} else {
|
||
|
out[2*s] = 0x1;
|
||
|
}
|
||
|
if (__imag__ in[s] > 0) {
|
||
|
out[2*s+1] = 0x0;
|
||
|
} else {
|
||
|
out[2*s+1] = 0x1;
|
||
|
}
|
||
|
}
|
||
11 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* @ingroup Hard 16QAM demodulator
|
||
|
*
|
||
|
* LTE-16QAM constellation:
|
||
|
* Q
|
||
|
* 1011 1001 | 0001 0011
|
||
|
* 1010 1000 | 0000 0010
|
||
|
*---------------------------------> I
|
||
|
* 1110 1100 | 0100 0110
|
||
|
* 1111 1101 | 0101 0111
|
||
|
*
|
||
|
* \param in input symbols (_Complex float)
|
||
10 years ago
|
* \param out output symbols (uint8_ts)
|
||
11 years ago
|
* \param N Number of input symbols
|
||
|
* \param modulation Modulation type
|
||
|
*/
|
||
10 years ago
|
inline void hard_qam16_demod(const cf_t* in, uint8_t* out, uint32_t N)
|
||
11 years ago
|
{
|
||
10 years ago
|
uint32_t s;
|
||
11 years ago
|
|
||
11 years ago
|
for (s=0; s<N; s++) {
|
||
|
if (__real__ in[s] > 0) {
|
||
|
out[4*s] = 0x0;
|
||
|
} else {
|
||
|
out[4*s] = 0x1;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
if ((__real__ in[s] > QAM16_THRESHOLD) || (__real__ in[s] < -QAM16_THRESHOLD)) {
|
||
|
out[4*s+2] = 0x1;
|
||
|
} else {
|
||
|
out[4*s+2] = 0x0;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
if (__imag__ in[s] > 0) {
|
||
|
out[4*s+1] = 0x0;
|
||
|
} else {
|
||
|
out[4*s+1] = 0x1;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
if ((__imag__ in[s] > QAM16_THRESHOLD) || (__imag__ in[s] < -QAM16_THRESHOLD)) {
|
||
|
out[4*s+3] = 0x1;
|
||
|
} else {
|
||
|
out[4*s+3] = 0x0;
|
||
|
}
|
||
|
}
|
||
11 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* @ingroup Hard 64QAM demodulator
|
||
|
*
|
||
|
* LTE-64QAM constellation:
|
||
|
* see [3GPP TS 36.211 version 10.5.0 Release 10, Section 7.1.4]
|
||
|
*
|
||
|
* \param in input symbols (_Complex float)
|
||
10 years ago
|
* \param out output symbols (uint8_ts)
|
||
11 years ago
|
* \param N Number of input symbols
|
||
|
* \param modulation Modulation type
|
||
|
*/
|
||
10 years ago
|
inline void hard_qam64_demod(const cf_t* in, uint8_t* out, uint32_t N)
|
||
11 years ago
|
{
|
||
10 years ago
|
uint32_t s;
|
||
11 years ago
|
|
||
11 years ago
|
for (s=0; s<N; s++) {
|
||
|
/* bits associated with/obtained from in-phase component: b0, b2, b4 */
|
||
|
if (__real__ in[s] > 0){
|
||
|
out[6*s] = 0x0;
|
||
|
} else {
|
||
|
out[6*s] = 0x1;
|
||
|
}
|
||
|
if ((__real__ in[s] > QAM64_THRESHOLD_3) || (__real__ in[s] < -QAM64_THRESHOLD_3)) {
|
||
|
out[6*s+2] = 0x1;
|
||
|
out[6*s+4] = 0x1;
|
||
|
} else if ((__real__ in[s] > QAM64_THRESHOLD_2) || (__real__ in[s] < -QAM64_THRESHOLD_2)) {
|
||
|
out[6*s+2] = 0x1;
|
||
|
out[6*s+4] = 0x0;
|
||
|
} else if ((__real__ in[s] > QAM64_THRESHOLD_1) || (__real__ in[s] < -QAM64_THRESHOLD_1)) {
|
||
|
out[6*s+2] = 0x0;
|
||
|
out[6*s+4] = 0x0;
|
||
|
} else {
|
||
|
out[6*s+2] = 0x0;
|
||
|
out[6*s+4] = 0x1;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
/* bits associated with/obtained from quadrature component: b1, b3, b5 */
|
||
|
if (__imag__ in[s] > 0){
|
||
|
out[6*s+1] = 0x0;
|
||
|
} else {
|
||
|
out[6*s+1] = 0x1;
|
||
|
}
|
||
|
if ((__imag__ in[s] > QAM64_THRESHOLD_3) || (__imag__ in[s] < -QAM64_THRESHOLD_3)) {
|
||
|
out[6*s+3] = 0x1;
|
||
|
out[6*s+5] = 0x1;
|
||
|
} else if ((__imag__ in[s] > QAM64_THRESHOLD_2) || (__imag__ in[s] < -QAM64_THRESHOLD_2)) {
|
||
|
out[6*s+3] = 0x1;
|
||
|
out[6*s+5] = 0x0;
|
||
|
} else if ((__imag__ in[s] > QAM64_THRESHOLD_1) || (__imag__ in[s] < -QAM64_THRESHOLD_1)) {
|
||
|
out[6*s+3] = 0x0;
|
||
|
out[6*s+5] = 0x0;
|
||
|
} else {
|
||
|
out[6*s+3] = 0x0;
|
||
|
out[6*s+5] = 0x1;
|
||
|
}
|
||
|
}
|
||
11 years ago
|
}
|