DSPLIB User Guide
DSPLIB_q15tofl.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * *
3  * module name :DSPLIB *
4  * *
5  * module descripton :Digital Signal Processing Library module for C7x+MMA *
6  * *
7  * Copyright (C) 2017-2018 Texas Instruments Incorporated - https://www.ti.com/ *
8  * ALL RIGHTS RESERVED *
9  * *
10  ******************************************************************************/
11 
23 #include "DSPLIB_q15tofl_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_q15tofl_PrivArgs);
28 
29  DSPLIB_DEBUGPRINTFN(0, "privBufSize: %d\n", privBufSize);
30 
31  return privBufSize;
32 }
33 
35  const DSPLIB_bufParams1D_t *bufParamsIn,
36  const DSPLIB_bufParams1D_t *bufParamsOut,
37  const DSPLIB_q15tofl_InitArgs *pKerInitArgs)
38 {
39  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering Function");
40 
42 
43  if (handle == NULL) {
44  status = DSPLIB_ERR_NULL_POINTER;
45  }
46 
47  if (status == DSPLIB_SUCCESS) {
48  if ((bufParamsIn->data_type != DSPLIB_INT16)) {
49  status = DSPLIB_ERR_INVALID_TYPE;
50  }
51  else if ((bufParamsOut->data_type != DSPLIB_FLOAT32) && (bufParamsOut->data_type != DSPLIB_FLOAT64)) {
52  status = DSPLIB_ERR_INVALID_TYPE;
53  }
54  else {
55  /* Nothing to do here */
56  }
57  }
58 
59  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
60 
61  return status;
62 }
63 
65 DSPLIB_q15tofl_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
66 {
67  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
68 
69  DSPLIB_STATUS status;
70 
71  if ((pIn == NULL) || (pOut == NULL)) {
72  status = DSPLIB_ERR_NULL_POINTER;
73  }
74  else {
75  status = DSPLIB_SUCCESS;
76  }
77  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
78 
79  return status;
80 }
81 
83  DSPLIB_bufParams1D_t *bufParamsIn,
84  DSPLIB_bufParams1D_t *bufParamsOut,
85  const DSPLIB_q15tofl_InitArgs *pKerInitArgs)
86 {
87  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
88 
90  DSPLIB_q15tofl_PrivArgs *pKerPrivArgs = (DSPLIB_q15tofl_PrivArgs *) handle;
91 
92  pKerPrivArgs->blockSize = pKerInitArgs->dataSize;
93 
94  DSPLIB_DEBUGPRINTFN(0, "pKerInitArgs->funcStyle: %d bufParamsOut->data_type: %d\n", pKerInitArgs->funcStyle,
95  bufParamsOut->data_type);
96 
97  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
98  if (bufParamsOut->data_type == DSPLIB_FLOAT32) {
99  pKerPrivArgs->execute = DSPLIB_q15tofl_exec_cn<float>;
100  status = DSPLIB_q15tofl_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
101  }
102  else if (bufParamsOut->data_type == DSPLIB_FLOAT64) {
103  pKerPrivArgs->execute = DSPLIB_q15tofl_exec_cn<double>;
104  status = DSPLIB_q15tofl_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
105  }
106  else {
107  status = DSPLIB_ERR_INVALID_TYPE;
108  }
109  }
110  else {
111  if (bufParamsOut->data_type == DSPLIB_FLOAT32) {
112  pKerPrivArgs->execute = DSPLIB_q15tofl_exec_ci<float>;
113  status = DSPLIB_q15tofl_init_ci<float>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
114  }
115  else if (bufParamsOut->data_type == DSPLIB_FLOAT64) {
116  pKerPrivArgs->execute = DSPLIB_q15tofl_exec_ci<double>;
117  status = DSPLIB_q15tofl_init_ci<double>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
118  }
119  else {
120  status = DSPLIB_ERR_INVALID_TYPE;
121  }
122  }
123 
124  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
125 
126  return status;
127 }
128 
129 DSPLIB_STATUS DSPLIB_q15tofl_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
130 {
131  DSPLIB_STATUS status;
132 
133  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
134 
135  DSPLIB_q15tofl_PrivArgs *pKerPrivArgs = (DSPLIB_q15tofl_PrivArgs *) handle;
136 
137  DSPLIB_DEBUGPRINTFN(0, "pKerPrivArgs->blockSize %d\n", pKerPrivArgs->blockSize);
138 
139  status = pKerPrivArgs->execute(handle, pIn, pOut);
140 
141  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
142 
143  return status;
144 }
template DSPLIB_STATUS DSPLIB_q15tofl_exec_ci< float >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_q15tofl_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_q15tofl_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_q15tofl_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_q15tofl_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_q15tofl_exec_ci< double >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_q15tofl_exec_cn< float >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_q15tofl_exec_cn< double >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_q15tofl_init_cn(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_q15tofl_InitArgs *pKerInitArgs)
This function is the initialization function for the natural C implementation of the kernel....
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_q15tofl.
#define DSPLIB_DEBUGPRINTFN(N, fmt,...)
Definition: DSPLIB_types.h:83
DSPLIB_STATUS_NAME
The enumeration of all status codes.
Definition: DSPLIB_types.h:151
void * DSPLIB_kernelHandle
Handle type for DSPLIB operations.
Definition: DSPLIB_types.h:172
@ DSPLIB_FUNCTION_NATC
Definition: DSPLIB_types.h:176
@ DSPLIB_INT16
@ DSPLIB_FLOAT32
@ DSPLIB_FLOAT64
@ DSPLIB_SUCCESS
Definition: DSPLIB_types.h:152
@ DSPLIB_ERR_NULL_POINTER
Definition: DSPLIB_types.h:157
@ DSPLIB_ERR_INVALID_TYPE
Definition: DSPLIB_types.h:155
DSPLIB_STATUS DSPLIB_q15tofl_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
This function is the main kernel compute function.
int32_t DSPLIB_q15tofl_getHandleSize(DSPLIB_q15tofl_InitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
DSPLIB_STATUS DSPLIB_q15tofl_init(DSPLIB_kernelHandle handle, DSPLIB_bufParams1D_t *bufParamsIn, DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_q15tofl_InitArgs *pKerInitArgs)
This function should be called before the DSPLIB_q15tofl_exec function is called. This function takes...
DSPLIB_STATUS DSPLIB_q15tofl_init_checkParams(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_q15tofl_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_q15tofl_init function....
DSPLIB_STATUS DSPLIB_q15tofl_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
This function checks the validity of the parameters passed to DSPLIB_q15tofl_exec function....
A structure for a 1 dimensional buffer descriptor.
uint32_t data_type
Values are of type DSPLIB_data_type_e.
Structure containing the parameters to initialize the kernel.
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
uint32_t dataSize
Size of input data
Structure that is reserved for internal use by the kernel.
pFxnDSPLIB_q15tofl_exec execute
Function pointer to point to the right execution variant between DSPLIB_q15tofl_exec_cn and DSPLIB_q1...
int32_t blockSize
Size of input buffer for different batches DSPLIB_q15tofl_init that will be retrieved and used by DSP...