FFTLIB User Guide
FFTLIB_ifft1d_i32fc_c32fc_o32f_ci.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 **+--------------------------------------------------------------------------+**
3 **| **** |**
4 **| **** |**
5 **| ******o*** |**
6 **| ********_///_**** |**
7 **| ***** /_//_/ **** |**
8 **| ** ** (__/ **** |**
9 **| ********* |**
10 **| **** |**
11 **| *** |**
12 **| |**
13 **| Copyright (c) 2017 Texas Instruments Incorporated |**
14 **| ALL RIGHTS RESERVED |**
15 **| |**
16 **| Permission to use, copy, modify, or distribute this software, |**
17 **| whether in part or in whole, for any purpose is forbidden without |**
18 **| a signed licensing agreement and NDA from Texas Instruments |**
19 **| Incorporated (TI). |**
20 **| |**
21 **| TI makes no representation or warranties with respect to the |**
22 **| performance of this computer program, and specifically disclaims |**
23 **| any responsibility for any damages, special or consequential, |**
24 **| connected with the use of this program. |**
25 **| |**
26 **+--------------------------------------------------------------------------+**
27 *******************************************************************************/
28 
29 #include "../../../common/c71/FFTLIB_debug.h"
30 #include "../../FFTLIB_ifft1d_i32fc_c32fc_o32fc/FFTLIB_ifft1d_i32fc_c32fc_o32fc.h"
31 #include "../FFTLIB_ifft1d_i32fc_c32fc_o32f.h"
32 
33 #define SE_PARAM_BASE (0x0000)
34 #define SE0_PARAM_OFFSET (SE_PARAM_BASE)
35 #define SE1_PARAM_OFFSET (SE0_PARAM_OFFSET + SE_PARAM_SIZE)
36 #define SE1_PARAM_OFFSET_LAST (SE1_PARAM_OFFSET + SE_PARAM_SIZE)
37 #define SA0_PARAM_OFFSET (SE1_PARAM_OFFSET_LAST + SE_PARAM_SIZE)
38 #define SA1_PARAM_OFFSET (SA0_PARAM_OFFSET + SE_PARAM_SIZE)
39 
40 typedef typename c7x::cfloat_vec CV;
41 typedef typename c7x::float_vec V;
42 
45  FFTLIB_bufParams1D_t *bufParamsX,
46  FFTLIB_F32 * pW,
47  FFTLIB_bufParams1D_t *bufParamsW,
48  FFTLIB_F32 * pXFFT,
49  FFTLIB_bufParams1D_t *bufParamsXFFT,
50  FFTLIB_F32 * pSf,
51  FFTLIB_bufParams1D_t *bufParamsSf,
52  FFTLIB_F32 * pY,
53  FFTLIB_bufParams1D_t *bufParamsY,
54  void * pBlock)
55 {
57 
58  /* #if defined(FFTLIB_CHECK_PARAMS) || \ */
59  /* defined(FFTLIB_FFT1D_I32FC_C32FC_O32FC_CHECK_PARAMS) */
60  /* status = FFTLIB_ifft1d_i32fc_c32fc_o32f_checkParams ( */
61  /* pX, bufParamsX, pW, bufParamsW, pY, bufParamsY, pBlock); */
62  /* if (status == FFTLIB_SUCCESS) */
63  /* #endif */
64  {
65 
66  uint32_t numPoints;
67  __SE_TEMPLATE_v1 se0_param = __gen_SE_TEMPLATE_v1 ();
68  __SA_TEMPLATE_v1 sa0_param = __gen_SA_TEMPLATE_v1 ();
69 
70  FFTLIB_bufParams1D_t bufParamsX_FFT;
71 
72  numPoints = bufParamsX->dim_x;
73 
74  bufParamsX_FFT.dim_x = numPoints;
75 
77  (FFTLIB_F32 *) pXFFT, &bufParamsX_FFT, (FFTLIB_F32 *) pW,
78  &bufParamsX_FFT, (FFTLIB_F32 *) pY, &bufParamsX_FFT,
79  &((uint8_t *) pBlock)[5 * SE_PARAM_SIZE]);
80 
81  uint32_t elementCount = c7x::element_count_of<CV>::value;
82  uint32_t SEBlocks = (numPoints >> 1) / elementCount;
83  uint32_t offset = numPoints >> 1;
84 
85  se0_param.ICNT0 = elementCount;
86  se0_param.ICNT1 = 2;
87  se0_param.DIM1 = offset;
88  se0_param.ICNT2 = SEBlocks;
89  se0_param.DIM2 = elementCount;
90 
91  se0_param.ELETYPE = __SE_ELETYPE_32BIT_CMPLX_SWAP;
92  se0_param.VECLEN = c7x::se_veclen<CV>::value;
93  se0_param.DIMFMT = __SE_DIMFMT_3D;
94  *((__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE0_PARAM_OFFSET)) =
95  se0_param;
96 
97  sa0_param.ICNT0 = numPoints >> 1;
98  sa0_param.VECLEN = c7x::sa_veclen<CV>::value;
99  sa0_param.DIMFMT = __SA_DIMFMT_1D;
100  *((__SA_TEMPLATE_v1 *) ((uint8_t *) pBlock + SA0_PARAM_OFFSET)) =
101  sa0_param;
102  }
103  return (status);
104 }
105 
108  FFTLIB_bufParams1D_t *bufParamsX,
109  FFTLIB_F32 *restrict pW,
110  FFTLIB_bufParams1D_t *bufParamsW,
111  FFTLIB_F32 *restrict pXFFT,
112  FFTLIB_bufParams1D_t *bufParamsXFFT,
113  FFTLIB_F32 *restrict pSf,
114  FFTLIB_bufParams1D_t *bufParamsSf,
115  FFTLIB_F32 *restrict pY,
116  FFTLIB_bufParams1D_t *bufParamsY,
117  void * pBlock)
118 {
119 
120  FFTLIB_STATUS status = FFTLIB_SUCCESS;
121 
122  uint32_t numPoints;
123  FFTLIB_bufParams1D_t bufParamsX_FFT;
124 
125  numPoints = bufParamsX->dim_x;
126  bufParamsX_FFT.dim_x = numPoints;
127 
128  /* typedef typename c7x::cfloat_vec CV; */
129  /* typedef typename c7x::float_vec V; */
130 
131  __SE_TEMPLATE_v1 se0Params = __gen_SE_TEMPLATE_v1 (); // SE parameter vector
132 
133  __SA_TEMPLATE_v1 sa0Params = __gen_SA_TEMPLATE_v1 ();
134 
135  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE0_PARAM_OFFSET);
136  sa0Params = *(__SA_TEMPLATE_v1 *) ((uint8_t *) pBlock + SA0_PARAM_OFFSET);
137 
138  /* se1ParamsLast = */
139  /* *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE1_PARAM_OFFSET_LAST); */
140 
141  __SE0_OPEN (&(pX[0]), se0Params);
142  __SE1_OPEN (&(pSf[0]), se0Params);
143  __SA0_OPEN (sa0Params);
144  /* __SA1_OPEN (sa1Params); */
145 
146  CV var0, var1;
147  CV temp0, temp1;
148  CV sFA, sFB;
149  CV regStore0;
150 
151  __vpred tmp;
152  CV * addr;
153 
154  uint32_t i = 0;
155  uint32_t elementCount = c7x::element_count_of<CV>::value;
156 
157 #pragma MUST_ITERATE(8, , 8)
158 #pragma UNROLL(8)
159  for (i = 0; i < (numPoints >> 1) / (elementCount); i++) {
160  var0 = c7x::strm_eng<0, CV>::get_adv ();
161  var1 = c7x::strm_eng<0, CV>::get_adv ();
162 
163  sFA = c7x::strm_eng<1, CV>::get_adv ();
164  sFB = c7x::strm_eng<1, CV>::get_adv ();
165 
166  temp0 = (__complex_multiply (var0, c7x::as_cfloat_vec (sFA)));
167  temp1 = (__complex_multiply (var1, c7x::as_cfloat_vec (sFB)));
168 
169  regStore0 = temp0 + temp1;
170  tmp = c7x::strm_agen<0, CV>::get_vpred ();
171  addr = c7x::strm_agen<0, CV>::get_adv (&pXFFT[0]);
172  __vstore_pred (tmp, addr, regStore0);
173  }
174 
175  __SA0_CLOSE ();
176  __SE0_CLOSE ();
177  __SE1_CLOSE ();
178 
179  /* printf ("\nXFFT_ci:\n"); */
180  /* for (i = 0; i < numPoints; i++) { */
181  /* printf ("%.2f ", pXFFT[i]); */
182  /* } */
183 
185  (FFTLIB_F32 *) pXFFT, &bufParamsX_FFT, (FFTLIB_F32 *) pW,
186  &bufParamsX_FFT, (FFTLIB_F32 *) pY, &bufParamsX_FFT,
187  &((uint8_t *) pBlock)[5 * SE_PARAM_SIZE]);
188 
189  return status;
190 }
191 
192 #if (!defined(FFTLIB_REMOVE_CHECK_PARAMS) && \
193  !defined(FFTLIB_FFT1D_I32FC_C32FC_O32FC_REMOVE_CHECK_PARAMS)) || \
194  (defined(FFTLIB_CHECK_PARAMS)) || \
195  (defined(FFTLIB_FFT1D_I32FC_C32FC_O32FC_CHECK_PARAMS))
196 
199  FFTLIB_bufParams1D_t *bufParamsX,
200  FFTLIB_F32 * pW,
201  FFTLIB_bufParams1D_t *bufParamsW,
202  FFTLIB_F32 * pY,
203  FFTLIB_bufParams1D_t *bufParamsY,
204  void * pBlock)
205 {
206  FFTLIB_STATUS status = FFTLIB_SUCCESS;
207 
208  /* if ((pX == NULL) || (pW == NULL) || (pY == NULL)) { */
209  /* status = FFTLIB_ERR_NULL_POINTER; */
210  /* } */
211  /* else if (bufParamsX->dim_x != bufParamsW->dim_x || */
212  /* bufParamsX->dim_x != bufParamsY->dim_x) { */
213  /* status = FFTLIB_ERR_INVALID_DIMENSION; */
214  /* } */
215  /* else if (bufParamsX->dim_x < 64 * 2) { /\* Minimum number of points is 64
216  * *\/ */
217  /* status = FFTLIB_ERR_INVALID_DIMENSION; */
218  /* } */
219  /* else if ((bufParamsX->data_type != FFTLIB_FLOAT32) || */
220  /* (bufParamsW->data_type != FFTLIB_FLOAT32) || */
221  /* (bufParamsY->data_type != FFTLIB_FLOAT32)) { */
222  /* status = FFTLIB_ERR_INVALID_TYPE; */
223  /* } */
224  /* else if (((uint64_t) pX) & 0xFu) { /\* pX must be 16-byte aligned for a
225  * *\/ */
226  /* status = FFTLIB_ERR_NOT_ALIGNED_PTRS_STRIDES; /\* streaming engine */
227  /* configuration *\/ */
228  /* } */
229  /* else { */
230  /* /\* Check if number of pts is a power of 2 *\/ */
231  /* uint32_t k = 0; */
232  /* while (k < 32) { */
233  /* if (bufParamsX->dim_x & (1u << k)) { */
234  /* break; */
235  /* } */
236  /* k++; */
237  /* } */
238  /* if ((1u << k) != bufParamsX->dim_x) { */
239  /* status = FFTLIB_ERR_INVALID_DIMENSION; */
240  /* } */
241  /* } */
242  return (status);
243 }
244 
245 #endif
c7x::cfloat_vec CV
c7x::cfloat_vec CV
FFTLIB_STATUS FFTLIB_ifft1d_i32fc_c32fc_o32f_init(FFTLIB_F32 *pX, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_F32 *pW, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_F32 *pXFFT, FFTLIB_bufParams1D_t *bufParamsXFFT, FFTLIB_F32 *pSf, FFTLIB_bufParams1D_t *bufParamsSf, FFTLIB_F32 *pY, FFTLIB_bufParams1D_t *bufParamsY, void *pBlock)
This function should be called before the FFTLIB_ifft1d_i32fc_c32fc_o32f_kernel function is called....
c7x::float_vec V
FFTLIB_STATUS FFTLIB_ifft1d_i32fc_c32fc_o32f_kernel(FFTLIB_F32 *restrict pX, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_F32 *restrict pW, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_F32 *restrict pXFFT, FFTLIB_bufParams1D_t *bufParamsXFFT, FFTLIB_F32 *restrict pSf, FFTLIB_bufParams1D_t *bufParamsSf, FFTLIB_F32 *restrict pY, FFTLIB_bufParams1D_t *bufParamsY, void *pBlock)
This function is the main kernel compute function.
FFTLIB_STATUS FFTLIB_ifft1d_i32fc_c32fc_o32f_checkParams(FFTLIB_F32 *pX, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_F32 *pW, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_F32 *pY, FFTLIB_bufParams1D_t *bufParamsY, void *pBlock)
This function checks the validity of the parameters passed to FFTLIB_ifft1d_i32fc_c32fc_o32f_init and...
FFTLIB_STATUS_NAME
The enumeration of all status codes.
Definition: FFTLIB_types.h:169
@ FFTLIB_SUCCESS
Definition: FFTLIB_types.h:170
float FFTLIB_F32
Single precision floating point.
Definition: FFTLIB_types.h:166
FFTLIB_STATUS FFTLIB_ifft1d_i32fc_c32fc_o32fc_init(FFTLIB_F32 *pX, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_F32 *pW, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_F32 *pY, FFTLIB_bufParams1D_t *bufParamsY, void *pBlock)
This function should be called before the FFTLIB_ifft1d_i32fc_c32fc_o32fc_kernel function is called....
FFTLIB_STATUS FFTLIB_ifft1d_i32fc_c32fc_o32fc_kernel(FFTLIB_F32 *pX, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_F32 *pW, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_F32 *pY, FFTLIB_bufParams1D_t *bufParamsY, void *pBlock)
This function is the main kernel compute function.
A structure for a 1 dimensional buffer descriptor.
uint32_t dim_x
Width of buffer in X dimension in elements.