📄 diffenc.c
字号:
/***********************************************************************************/
/* IS54 Baseband Simulation Software */
/* */
/* File Description : IS54 DQPSK Differential Encoder */
/* File Name : diffenc.c */
/* Date : 12/30/93 */
/* : July, 20001 - Modified for TMS320C55x project */
/* */
/* Differential Encoder for IS-54 DQPSK */
/* */
/* This encoder receives two bits from the data stream, and encodes them */
/* into DQPSK modulation. It outputs I and Q for each input symbol pair. */
/* */
/* The input symbols and their bit relationship and phase changes */
/* are listed below: */
/* */
/* input data phase changes */
/* */
/* 00 pi/4, pi/4 */
/* 01 -pi/4, pi/4 */
/* 10 -pi/4,-pi/4 */
/* 11 pi/4,-pi/4 */
/* */
/* Inputs : */
/* packed : Pointer to array containing 384 symbol */
/* bits to be encoded. Note that each element */
/* of the array consists of a single bit (i.e. */
/* a 0 or 1 only) */
/* */
/* Outputs : */
/* out_I : Pointer to floating point array where */
/* 192 modulation vector I-components shall */
/* be stored. */
/* */
/* out_Q : Pointer to floating point array where */
/* 192 modulation vector Q-components shall */
/* be stored. */
/* */
/* Return Value : */
/* NONE */
/* */
/***********************************************************************************/
/* Include Files */
#include <intrindefs.h>
/* Defines */
#define Z 0x5a82 /* Q15 format of 0.70710678 */
/* Function Prototypes */
void diffenc( unsigned*, int*, int* );
/* External Function Prototypes */
/* Data */
/* External Data */
/* Code */
void diffenc( unsigned *packed, int *out_I, int *out_Q )
{
long ltemp;
int i, phase_i, phase_r, i_old, q_old;
*(out_I) = 0x7fff;
*(out_Q) = 0;
for (i = 192 ; i > 0 ; i--)
{
i_old = *(out_I++);
q_old = *(out_Q++);
phase_i = Z;
phase_r = Z; /* assume both bits are zero */
if( *(packed++) != 0 )
phase_i = -Z; /* 1st bit determines imag phase */
if( *(packed++) != 0 )
phase_r = -Z; /* 2nd bit determines real phase */
ltemp = _lsmpy(i_old, phase_r);
ltemp = _smas(ltemp, q_old, phase_i);
*(out_I) = (ltemp>>16); /* *(out_I) = i_old*phase_r - q_old*phase_i; */
ltemp = _lsmpy(i_old, phase_i);
ltemp = _smac(ltemp, q_old, phase_r);
*(out_Q) = (ltemp>>16); /* *(out_Q) = i_old*phase_i + q_old*phase_r; */
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -