From b44c49bc3048fb8707eb521fbb9a64f9045fafe5 Mon Sep 17 00:00:00 2001
From: Florian Kaltenberger <florian.kaltenberger@eurecom.fr>
Date: Tue, 7 Feb 2017 21:58:39 +0100
Subject: [PATCH] adjusting power levels in alamouti receiver and dlsim. now
 TM2 dlsim tests pass again.

Conflicts:
	openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c
	openair1/PHY/impl_defs_top.h
---
 openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c | 9 +++++++--
 openair1/SIMULATION/LTE_PHY/dlsim.c             | 5 +++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c
index 041e59adae..529bfe1438 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c
@@ -3817,14 +3817,15 @@ void dlsch_alamouti(LTE_DL_FRAME_PARMS *frame_parms,
 #if defined(__x86_64__)||defined(__i386__)
 
   short *rxF0,*rxF1;
-  __m128i *ch_mag0,*ch_mag1,*ch_mag0b,*ch_mag1b, amp, *rxF0_128;
+  __m128i *ch_mag0,*ch_mag1,*ch_mag0b,*ch_mag1b, *rxF0_128;
   unsigned char rb,re;
   int jj = (symbol*frame_parms->N_RB_DL*12);
   uint8_t symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
   uint8_t pilots = ((symbol_mod==0)||(symbol_mod==(4-frame_parms->Ncp))) ? 1 : 0;
   rxF0_128 = (__m128i*) &rxdataF_comp[0][jj];
 
-  amp = _mm_set1_epi16(ONE_OVER_SQRT2_Q15);
+  //amp = _mm_set1_epi16(ONE_OVER_SQRT2_Q15);
+  //amp = _mm_set1_epi16(ONE_OVER_2_Q15);
 
   //    printf("Doing alamouti!\n");
   rxF0     = (short*)&rxdataF_comp[0][jj];  //tx antenna 0  h0*y
@@ -3861,6 +3862,7 @@ void dlsch_alamouti(LTE_DL_FRAME_PARMS *frame_parms,
     ch_mag0b[1] = _mm_adds_epi16(ch_mag0b[1],ch_mag1b[1]);
 
     // account for 1/sqrt(2) scaling at transmission
+    /*
     ch_mag0[0] = _mm_srai_epi16(ch_mag0[0],1);
     ch_mag0[1] = _mm_srai_epi16(ch_mag0[1],1);
     ch_mag0b[0] = _mm_srai_epi16(ch_mag0b[0],1);
@@ -3870,16 +3872,19 @@ void dlsch_alamouti(LTE_DL_FRAME_PARMS *frame_parms,
     rxF0_128[0] = _mm_slli_epi16(rxF0_128[0],1);
     rxF0_128[1] = _mm_mulhi_epi16(rxF0_128[1],amp);
     rxF0_128[1] = _mm_slli_epi16(rxF0_128[1],1);
+    */
 
     if (pilots==0) {
       ch_mag0[2] = _mm_adds_epi16(ch_mag0[2],ch_mag1[2]);
       ch_mag0b[2] = _mm_adds_epi16(ch_mag0b[2],ch_mag1b[2]);
 
+      /*
       ch_mag0[2] = _mm_srai_epi16(ch_mag0[2],1);
       ch_mag0b[2] = _mm_srai_epi16(ch_mag0b[2],1);
 
       rxF0_128[2] = _mm_mulhi_epi16(rxF0_128[2],amp);
       rxF0_128[2] = _mm_slli_epi16(rxF0_128[2],1);
+      */
 
       ch_mag0+=3;
       ch_mag1+=3;
diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c
index af1b1a6aef..4109307ba9 100644
--- a/openair1/SIMULATION/LTE_PHY/dlsim.c
+++ b/openair1/SIMULATION/LTE_PHY/dlsim.c
@@ -233,8 +233,9 @@ void DL_channel(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_flag,dou
   }
 
   //AWGN
-  // This is the SNR on the PDSCH for OFDM symbols without pilots -> rho_A
-  sigma2_dB = 10*log10((double)tx_lev) +10*log10((double)eNB->frame_parms.ofdm_symbol_size/(double)(eNB->frame_parms.N_RB_DL*12)) - SNR - get_pa_dB(eNB->pdsch_config_dedicated);
+  // tx_lev is the average energy over the whole subframe
+  // but SNR should be better defined wrt the energy in the reference symbols
+  sigma2_dB = 10*log10((double)tx_lev) +10*log10((double)eNB->frame_parms.ofdm_symbol_size/(double)(eNB->frame_parms.N_RB_DL*12)) - SNR;
   sigma2 = pow(10,sigma2_dB/10);
 
   for (i=0; i<2*UE->frame_parms.samples_per_tti; i++) {
-- 
GitLab