Commit 40338296 authored by Raymond Knopp's avatar Raymond Knopp

Merge branch 'l1-sidelink' of https://gitlab.eurecom.fr/matzakos/LTE-D2D into l1-sidelink

parents 07349091 e07db38f
This diff is collapsed.
...@@ -50,23 +50,21 @@ int initial_syncSL(PHY_VARS_UE *ue) { ...@@ -50,23 +50,21 @@ int initial_syncSL(PHY_VARS_UE *ue) {
&index, &index,
&psslevel, &psslevel,
&avglevel); &avglevel);
printf("index %d, psslevel %lld dB avglevel %lld dB => %d sample offset\n", printf("index %d, psslevel %d dB avglevel %d dB => %d sample offset\n",
index,dB_fixed(psslevel),dB_fixed(avglevel),ue->rx_offsetSL); index,dB_fixed64((uint64_t)psslevel),dB_fixed64((uint64_t)avglevel),ue->rx_offsetSL);
if (ue->rx_offsetSL >= 0) { if (ue->rx_offsetSL >= 0) {
int32_t sss_metric; int32_t sss_metric;
int32_t phase_max; int32_t phase_max;
rx_slsss(ue,&sss_metric,&phase_max,index); rx_slsss(ue,&sss_metric,&phase_max,index);
generate_sl_grouphop(ue); generate_sl_grouphop(ue);
if (rx_psbch(ue) == -1) { if (rx_psbch(ue) == -1) {
ue->slbch_errors++; ue->slbch_errors++;
/*
write_output("rxsig0.m","rxs0",&ue->common_vars.rxdata_syncSL[0][0],40*ue->frame_parms.samples_per_tti,1,1); write_output("rxsig0.m","rxs0",&ue->common_vars.rxdata_syncSL[0][0],40*ue->frame_parms.samples_per_tti,1,1);
write_output("corr0.m","rxsync0",sync_corr_ue0,40*ue->frame_parms.samples_per_tti,1,2); write_output("corr0.m","rxsync0",sync_corr_ue0,40*ue->frame_parms.samples_per_tti,1,2);
write_output("corr1.m","rxsync1",sync_corr_ue1,40*ue->frame_parms.samples_per_tti,1,2); write_output("corr1.m","rxsync1",sync_corr_ue1,40*ue->frame_parms.samples_per_tti,1,2);
exit(-1); exit(-1);
*/
return(-1); return(-1);
} }
else { else {
......
...@@ -359,10 +359,10 @@ int rx_slsss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *phase_max,int Nid2) ...@@ -359,10 +359,10 @@ int rx_slsss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *phase_max,int Nid2)
0); 0);
// write_output("rxdataF0.m","rxF0",&rxdataF[0][0],2*14*ue->frame_parms.ofdm_symbol_size,1,1); // write_output("rxdataF0.m","rxF0",&rxdataF[0][0],2*14*ue->frame_parms.ofdm_symbol_size,1,1);
/* write_output("pss0_ext.m","pss0ext",pss0_ext,72,1,1); write_output("pss0_ext.m","pss0ext",pss0_ext,72,1,1);
write_output("sss0_ext.m","sss0ext",sss0_ext,72,1,1); write_output("sss0_ext.m","sss0ext",sss0_ext,72,1,1);
write_output("pss1_ext.m","pss1ext",pss1_ext,72,1,1); write_output("pss1_ext.m","pss1ext",pss1_ext,72,1,1);
write_output("sss1_ext.m","sss1ext",sss1_ext,72,1,1); */ write_output("sss1_ext.m","sss1ext",sss1_ext,72,1,1);
...@@ -400,9 +400,10 @@ int rx_slsss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *phase_max,int Nid2) ...@@ -400,9 +400,10 @@ int rx_slsss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *phase_max,int Nid2)
sss0_comp16[i] = (int16_t)(sss0comp[i]>>shift); sss0_comp16[i] = (int16_t)(sss0comp[i]>>shift);
sss1_comp16[i] = (int16_t)(sss1comp[i]>>shift); sss1_comp16[i] = (int16_t)(sss1comp[i]>>shift);
} }
/*write_output("sss0_comp0.m","sss0comp0",sss0_comp16,72,1,1); /*
write_output("sss1_comp0.m","sss1comp0",sss1_comp16,72,1,1);*/ write_output("sss0_comp0.m","sss0comp0",sss0_comp16,72,1,1);
// exit(-1); write_output("sss1_comp0.m","sss1comp0",sss1_comp16,72,1,1);
exit(-1); */
// now do the SSS detection based on the precomputed sequences in PHY/LTE_TRANSPORT/sss.h // now do the SSS detection based on the precomputed sequences in PHY/LTE_TRANSPORT/sss.h
*tot_metric = -99999999; *tot_metric = -99999999;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "defs.h" #include "defs.h"
#include "PHY/sse_intrin.h" #include "PHY/sse_intrin.h"
#include <stdio.h>
// returns the complex dot product of x and y // returns the complex dot product of x and y
#ifdef MAIN #ifdef MAIN
...@@ -30,7 +30,7 @@ void print_shorts(char *s,__m128i *x); ...@@ -30,7 +30,7 @@ void print_shorts(char *s,__m128i *x);
void print_bytes(char *s,__m128i *x); void print_bytes(char *s,__m128i *x);
#endif #endif
int32_t dot_product(int16_t *x, int64_t dot_product(int16_t *x,
int16_t *y, int16_t *y,
uint32_t N, //must be a multiple of 8 uint32_t N, //must be a multiple of 8
uint8_t output_shift) uint8_t output_shift)
...@@ -40,7 +40,6 @@ int32_t dot_product(int16_t *x, ...@@ -40,7 +40,6 @@ int32_t dot_product(int16_t *x,
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
__m128i *x128,*y128,mmtmp1,mmtmp2,mmtmp3,mmcumul,mmcumul_re,mmcumul_im; __m128i *x128,*y128,mmtmp1,mmtmp2,mmtmp3,mmcumul,mmcumul_re,mmcumul_im;
__m64 mmtmp7;
__m128i minus_i = _mm_set_epi16(-1,1,-1,1,-1,1,-1,1); __m128i minus_i = _mm_set_epi16(-1,1,-1,1,-1,1,-1,1);
int32_t result; int32_t result;
...@@ -52,37 +51,37 @@ int32_t dot_product(int16_t *x, ...@@ -52,37 +51,37 @@ int32_t dot_product(int16_t *x,
for (n=0; n<(N>>2); n++) { for (n=0; n<(N>>2); n++) {
//printf("n=%d, x128=%p, y128=%p\n",n,x128,y128); // printf("n=%d, x128=%p, y128=%p\n",n,x128,y128);
// print_shorts("x",&x128[0]); // print_shorts("x",&x128[0]);
// print_shorts("y",&y128[0]); // print_shorts("y",&y128[0]);
// this computes Re(z) = Re(x)*Re(y) + Im(x)*Im(y) // this computes Re(z) = Re(x)*Re(y) + Im(x)*Im(y)
mmtmp1 = _mm_madd_epi16(x128[0],y128[0]); mmtmp1 = _mm_madd_epi16(x128[0],y128[0]);
// print_ints("re",&mmtmp1); // print_ints("retmp",&mmtmp1);
// mmtmp1 contains real part of 4 consecutive outputs (32-bit) // mmtmp1 contains real part of 4 consecutive outputs (32-bit)
// shift and accumulate results // shift and accumulate results
mmtmp1 = _mm_srai_epi32(mmtmp1,output_shift); mmtmp1 = _mm_srai_epi32(mmtmp1,output_shift);
mmcumul_re = _mm_add_epi32(mmcumul_re,mmtmp1); mmcumul_re = _mm_add_epi32(mmcumul_re,mmtmp1);
// print_ints("re",&mmcumul_re); //print_ints("re",&mmcumul_re);
// this computes Im(z) = Re(x)*Im(y) - Re(y)*Im(x) // this computes Im(z) = Re(x)*Im(y) - Re(y)*Im(x)
mmtmp2 = _mm_shufflelo_epi16(y128[0],_MM_SHUFFLE(2,3,0,1)); mmtmp2 = _mm_shufflelo_epi16(y128[0],_MM_SHUFFLE(2,3,0,1));
// print_shorts("y",&mmtmp2); //print_shorts("y",&mmtmp2);
mmtmp2 = _mm_shufflehi_epi16(mmtmp2,_MM_SHUFFLE(2,3,0,1)); mmtmp2 = _mm_shufflehi_epi16(mmtmp2,_MM_SHUFFLE(2,3,0,1));
// print_shorts("y",&mmtmp2); //print_shorts("y",&mmtmp2);
mmtmp2 = _mm_sign_epi16(mmtmp2,minus_i); mmtmp2 = _mm_sign_epi16(mmtmp2,minus_i);
// print_shorts("y",&mmtmp2); // print_shorts("y",&mmtmp2);
mmtmp3 = _mm_madd_epi16(x128[0],mmtmp2); mmtmp3 = _mm_madd_epi16(x128[0],mmtmp2);
// print_ints("im",&mmtmp3); //print_ints("imtmp",&mmtmp3);
// mmtmp3 contains imag part of 4 consecutive outputs (32-bit) // mmtmp3 contains imag part of 4 consecutive outputs (32-bit)
// shift and accumulate results // shift and accumulate results
mmtmp3 = _mm_srai_epi32(mmtmp3,output_shift); mmtmp3 = _mm_srai_epi32(mmtmp3,output_shift);
mmcumul_im = _mm_add_epi32(mmcumul_im,mmtmp3); mmcumul_im = _mm_add_epi32(mmcumul_im,mmtmp3);
// print_ints("im",&mmcumul_im); //print_ints("im",&mmcumul_im);
x128++; x128++;
y128++; y128++;
...@@ -90,24 +89,18 @@ int32_t dot_product(int16_t *x, ...@@ -90,24 +89,18 @@ int32_t dot_product(int16_t *x,
// this gives Re Re Im Im // this gives Re Re Im Im
mmcumul = _mm_hadd_epi32(mmcumul_re,mmcumul_im); mmcumul = _mm_hadd_epi32(mmcumul_re,mmcumul_im);
// print_ints("cumul1",&mmcumul); //print_ints("cumul1",&mmcumul);
// this gives Re Im Re Im // this gives Re Im Re Im
mmcumul = _mm_hadd_epi32(mmcumul,mmcumul); mmcumul = _mm_hadd_epi32(mmcumul,mmcumul);
// print_ints("cumul2",&mmcumul); //print_ints("cumul2",&mmcumul);
//mmcumul = _mm_srai_epi32(mmcumul,output_shift); //mmcumul = _mm_srai_epi32(mmcumul,output_shift);
// extract the lower half // extract the lower half
mmtmp7 = _mm_movepi64_pi64(mmcumul); result = _mm_extract_epi64(mmcumul,0);
// print_ints("mmtmp7",&mmtmp7); //printf("result: (%d,%d)\n",((int32_t*)&result)[0],((int32_t*)&result)[1]);
// pack the result
mmtmp7 = _mm_packs_pi32(mmtmp7,mmtmp7);
// print_shorts("mmtmp7",&mmtmp7);
// convert back to integer
result = _mm_cvtsi64_si32(mmtmp7);
_mm_empty(); _mm_empty();
_m_empty(); _m_empty();
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
// Approximate 10*log10(x) in fixed point : x = 0...(2^32)-1 // Approximate 10*log10(x) in fixed point : x = 0...(2^32)-1
int8_t dB_table[256] = { uint8_t dB_table[256] = {
0, 0,
3, 3,
5, 5,
...@@ -282,7 +282,7 @@ int8_t dB_table[256] = { ...@@ -282,7 +282,7 @@ int8_t dB_table[256] = {
24 24
}; };
int16_t dB_table_times10[256] = { uint16_t dB_table_times10[256] = {
0, 0,
30, 30,
47, 47,
...@@ -571,9 +571,9 @@ int8_t dB_fixed(int x) { ...@@ -571,9 +571,9 @@ int8_t dB_fixed(int x) {
} }
*/ */
int16_t dB_fixed_times10(uint32_t x) uint16_t dB_fixed_times10(uint32_t x)
{ {
int16_t dB_power=0; uint8_t dB_power=0;
if (x==0) { if (x==0) {
...@@ -597,10 +597,17 @@ int16_t dB_fixed_times10(uint32_t x) ...@@ -597,10 +597,17 @@ int16_t dB_fixed_times10(uint32_t x)
return dB_power; return dB_power;
} }
int8_t dB_fixed(uint32_t x) uint8_t dB_fixed64(uint64_t x)
{ {
int8_t dB_power=0; if (x<(((uint64_t)1)<<32)) return(dB_fixed((uint32_t)x));
else return(4*dB_table[255] + dB_fixed(x>>32));
}
uint8_t dB_fixed(uint32_t x)
{
uint8_t dB_power=0;
if (x==0) { if (x==0) {
...@@ -624,7 +631,7 @@ int8_t dB_fixed(uint32_t x) ...@@ -624,7 +631,7 @@ int8_t dB_fixed(uint32_t x)
return dB_power; return dB_power;
} }
int8_t dB_fixed2(uint32_t x, uint32_t y) uint8_t dB_fixed2(uint32_t x, uint32_t y)
{ {
if ((x>0) && (y>0) ) if ((x>0) && (y>0) )
......
...@@ -347,16 +347,18 @@ Compensate the phase rotation of the RF. WARNING: This function is currently unu ...@@ -347,16 +347,18 @@ Compensate the phase rotation of the RF. WARNING: This function is currently unu
*/ */
int8_t dB_fixed(uint32_t x); uint8_t dB_fixed(uint32_t x);
int8_t dB_fixed2(uint32_t x,uint32_t y); uint8_t dB_fixed2(uint32_t x,uint32_t y);
int16_t dB_fixed_times10(uint32_t x); uint8_t dB_fixed64(uint64_t x);
uint16_t dB_fixed_times10(uint32_t x);
int32_t phy_phase_compensation_top (uint32_t pilot_type, uint32_t initial_pilot, int32_t phy_phase_compensation_top (uint32_t pilot_type, uint32_t initial_pilot,
uint32_t last_pilot, int32_t ignore_prefix); uint32_t last_pilot, int32_t ignore_prefix);
int32_t dot_product(int16_t *x, int64_t dot_product(int16_t *x,
int16_t *y, int16_t *y,
uint32_t N, //must be a multiple of 8 uint32_t N, //must be a multiple of 8
uint8_t output_shift); uint8_t output_shift);
......
...@@ -60,11 +60,11 @@ extern short primary_synch1SL[144]; ...@@ -60,11 +60,11 @@ extern short primary_synch1SL[144];
extern unsigned char primary_synch0_tab[72]; extern unsigned char primary_synch0_tab[72];
extern unsigned char primary_synch1_tab[72]; extern unsigned char primary_synch1_tab[72];
extern unsigned char primary_synch2_tab[72]; extern unsigned char primary_synch2_tab[72];
extern const int16_t *primary_synch0_time; //!< index: [0..ofdm_symbol_size*2[ extern int16_t *primary_synch0_time; //!< index: [0..ofdm_symbol_size*2[
extern const int16_t *primary_synch1_time; //!< index: [0..ofdm_symbol_size*2[ extern int16_t *primary_synch1_time; //!< index: [0..ofdm_symbol_size*2[
extern const int16_t *primary_synch2_time; //!< index: [0..ofdm_symbol_size*2[ extern int16_t *primary_synch2_time; //!< index: [0..ofdm_symbol_size*2[
extern const int16_t *primary_synch0SL_time; extern int16_t *primary_synch0SL_time;
extern const int16_t *primary_synch1SL_time; extern int16_t *primary_synch1SL_time;
extern int16_t *primary_synch0SL_time_rx; extern int16_t *primary_synch0SL_time_rx;
extern int16_t *primary_synch1SL_time_rx; extern int16_t *primary_synch1SL_time_rx;
......
...@@ -33,13 +33,13 @@ char* namepointer_log2; ...@@ -33,13 +33,13 @@ char* namepointer_log2;
#include "PHY/LTE_REFSIG/primary_synch.h" #include "PHY/LTE_REFSIG/primary_synch.h"
#include "PHY/LTE_REFSIG/primary_synch_SL.h" #include "PHY/LTE_REFSIG/primary_synch_SL.h"
const int16_t *primary_synch0_time; int16_t *primary_synch0_time;
const int16_t *primary_synch1_time; int16_t *primary_synch1_time;
const int16_t *primary_synch2_time; int16_t *primary_synch2_time;
const int16_t *primary_synch0SL_time; int16_t *primary_synch0SL_time;
const int16_t *primary_synch1SL_time; int16_t *primary_synch1SL_time;
int16_t *primary_synch0SL_time_rx; int16_t *primary_synch0SL_time_rx;
int16_t *primary_synch1SL_time_rx; int16_t *primary_synch1SL_time_rx;
......
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