adding signal_energy_amp_shift function
This commit is contained in:
committed by
Thomas Schlichter
parent
2628b7418d
commit
c38a485949
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tools_defs.h"
|
#include "tools_defs.h"
|
||||||
|
#include "PHY/impl_defs_top.h"
|
||||||
#include "PHY/sse_intrin.h"
|
#include "PHY/sse_intrin.h"
|
||||||
|
|
||||||
// Compute Energy of a complex signal vector, removing the DC component!
|
// Compute Energy of a complex signal vector, removing the DC component!
|
||||||
@@ -84,7 +84,7 @@ int32_t signal_energy(int32_t *input,uint32_t length)
|
|||||||
mm1 = in[i];
|
mm1 = in[i];
|
||||||
mm2 = mm1;
|
mm2 = mm1;
|
||||||
mm1 = _m_pmaddwd(mm1,mm1);
|
mm1 = _m_pmaddwd(mm1,mm1);
|
||||||
mm1 = _m_psradi(mm1,9);//shift);// shift any 32 bits blocs of the word by the value shift
|
mm1 = _m_psradi(mm1,shift);// shift any 32 bits blocs of the word by the value shift
|
||||||
mm0 = _m_paddd(mm0,mm1);// add the two 64 bits words 4 bytes by 4 bytes
|
mm0 = _m_paddd(mm0,mm1);// add the two 64 bits words 4 bytes by 4 bytes
|
||||||
// mm2 = _m_psrawi(mm2,shift_DC);
|
// mm2 = _m_psrawi(mm2,shift_DC);
|
||||||
mm3 = _m_paddw(mm3,mm2);// add the two 64 bits words 2 bytes by 2 bytes
|
mm3 = _m_paddw(mm3,mm2);// add the two 64 bits words 2 bytes by 2 bytes
|
||||||
@@ -95,7 +95,7 @@ int32_t signal_energy(int32_t *input,uint32_t length)
|
|||||||
mm0 = _m_paddd(mm0,mm1);
|
mm0 = _m_paddd(mm0,mm1);
|
||||||
temp = _m_to_int(mm0);
|
temp = _m_to_int(mm0);
|
||||||
temp/=length;
|
temp/=length;
|
||||||
//temp<<=shift; // this is the average of x^2
|
temp<<=shift; // this is the average of x^2
|
||||||
|
|
||||||
|
|
||||||
// now remove the DC component
|
// now remove the DC component
|
||||||
@@ -104,7 +104,6 @@ int32_t signal_energy(int32_t *input,uint32_t length)
|
|||||||
mm2 = _m_psrlqi(mm3,32);
|
mm2 = _m_psrlqi(mm3,32);
|
||||||
mm2 = _m_paddw(mm2,mm3);
|
mm2 = _m_paddw(mm2,mm3);
|
||||||
mm2 = _m_pmaddwd(mm2,mm2);
|
mm2 = _m_pmaddwd(mm2,mm2);
|
||||||
mm2 = _m_psradi(mm2,9); // fixed point representation of elements
|
|
||||||
temp2 = _m_to_int(mm2);
|
temp2 = _m_to_int(mm2);
|
||||||
temp2/=(length*length);
|
temp2/=(length*length);
|
||||||
// temp2<<=(2*shift_DC);
|
// temp2<<=(2*shift_DC);
|
||||||
@@ -116,6 +115,52 @@ int32_t signal_energy(int32_t *input,uint32_t length)
|
|||||||
return((temp>0)?temp:1);
|
return((temp>0)?temp:1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t signal_energy_amp_shift(int32_t *input,uint32_t length)
|
||||||
|
{
|
||||||
|
|
||||||
|
int32_t i;
|
||||||
|
int32_t temp,temp2;
|
||||||
|
register __m64 mm0,mm1,mm2,mm3;
|
||||||
|
__m64 *in = (__m64 *)input;
|
||||||
|
|
||||||
|
mm0 = _mm_setzero_si64();
|
||||||
|
mm3 = _mm_setzero_si64();
|
||||||
|
|
||||||
|
for (i=0; i<length>>1; i++) {
|
||||||
|
|
||||||
|
mm1 = in[i];
|
||||||
|
mm2 = mm1;
|
||||||
|
mm1 = _m_pmaddwd(mm1,mm1);
|
||||||
|
mm1 = _m_psradi(mm1,AMP_SHIFT);// shift any 32 bits blocs of the word by the value shift_p9
|
||||||
|
mm0 = _m_paddd(mm0,mm1);// add the two 64 bits words 4 bytes by 4 bytes
|
||||||
|
mm3 = _m_paddw(mm3,mm2);// add the two 64 bits words 2 bytes by 2 bytes
|
||||||
|
}
|
||||||
|
|
||||||
|
mm1 = mm0;
|
||||||
|
mm0 = _m_psrlqi(mm0,32);
|
||||||
|
mm0 = _m_paddd(mm0,mm1);
|
||||||
|
temp = _m_to_int(mm0);
|
||||||
|
temp/=length; // this is the average of x^2
|
||||||
|
|
||||||
|
|
||||||
|
// now remove the DC component
|
||||||
|
|
||||||
|
|
||||||
|
mm2 = _m_psrlqi(mm3,32);
|
||||||
|
mm2 = _m_paddw(mm2,mm3);
|
||||||
|
mm2 = _m_pmaddwd(mm2,mm2);
|
||||||
|
mm2 = _m_psradi(mm2,AMP_SHIFT); // fixed point representation of elements
|
||||||
|
temp2 = _m_to_int(mm2);
|
||||||
|
temp2/=(length*length);
|
||||||
|
|
||||||
|
temp -= temp2;
|
||||||
|
|
||||||
|
_mm_empty();
|
||||||
|
_m_empty();
|
||||||
|
|
||||||
|
return((temp>0)?temp:1);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t signal_energy_nodc(int32_t *input,uint32_t length)
|
int32_t signal_energy_nodc(int32_t *input,uint32_t length)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -295,6 +295,13 @@ void mmxcopy(void *dest,void *src,int size);
|
|||||||
*/
|
*/
|
||||||
int32_t signal_energy(int32_t *,uint32_t);
|
int32_t signal_energy(int32_t *,uint32_t);
|
||||||
|
|
||||||
|
/*!\fn int32_t signal_energy_fixed_p9(int *input, uint32_t length);
|
||||||
|
\brief Computes the signal energy per subcarrier
|
||||||
|
\ the input signal has a fixed point representation of AMP_SHIFT bits
|
||||||
|
\ the ouput energy has a fixed point representation of AMP_SHIFT bits
|
||||||
|
*/
|
||||||
|
int32_t signal_energy_amp_shift(int32_t *input, uint32_t length);
|
||||||
|
|
||||||
#ifdef LOCALIZATION
|
#ifdef LOCALIZATION
|
||||||
/*!\fn int32_t signal_energy(int *,uint32_t);
|
/*!\fn int32_t signal_energy(int *,uint32_t);
|
||||||
\brief Computes the signal energy per subcarrier
|
\brief Computes the signal energy per subcarrier
|
||||||
|
|||||||
@@ -716,7 +716,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
txlev = (double) signal_energy(&txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0],
|
txlev = (double) signal_energy_amp_shift(&txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0],
|
||||||
frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples);
|
frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples);
|
||||||
|
|
||||||
txlev = txlev/512.0; // output of signal_energy is fixed point representation
|
txlev = txlev/512.0; // output of signal_energy is fixed point representation
|
||||||
|
|||||||
Reference in New Issue
Block a user