1 /******************************************************************************\r
2 * FILE PURPOSE: \r
3 * \r
4 ******************************************************************************\r
5 * FILE NAME: vpesim.h\r
6 *\r
7 * DESCRIPTION: Based on compiler switch, include platform specific profile file\r
8 *\r
9 * Copyright (c) 2007 \96 2013 Texas Instruments Incorporated
10 *
11 * All rights reserved not granted herein.
12 *
13 * Limited License.
14 *
15 * Texas Instruments Incorporated grants a world-wide, royalty-free,
16 * non-exclusive license under copyrights and patents it now or hereafter owns
17 * or controls to make, have made, use, import, offer to sell and sell
18 * ("Utilize") this software subject to the terms herein. With respect to the
19 * foregoing patent license, such license is granted solely to the extent that
20 * any such patent is necessary to Utilize the software alone. The patent
21 * license shall not apply to any combinations which include this software,
22 * other than combinations with devices manufactured by or for TI (\93TI
23 * Devices\94). No hardware patent is licensed hereunder.
24 *
25 * Redistributions must preserve existing copyright notices and reproduce this
26 * license (including the above copyright notice and the disclaimer and (if
27 * applicable) source code license limitations below) in the documentation
28 * and/or other materials provided with the distribution
29 *
30 * Redistribution and use in binary form, without modification, are permitted
31 * provided that the following conditions are met:
32 *
33 * * No reverse engineering, decompilation, or disassembly of this software
34 * is permitted with respect to any software provided in binary form.
35 *
36 * * any redistribution and use are licensed by TI for use only with TI
37 * Devices.
38 *
39 * * Nothing shall obligate TI to provide you with source code for the
40 * software licensed and provided to you in object code.
41 *
42 * If software source code is provided to you, modification and redistribution
43 * of the source code are permitted provided that the following conditions are
44 * met:
45 *
46 * * any redistribution and use of the source code, including any resulting
47 * derivative works, are licensed by TI for use only with TI Devices.
48 *
49 * * any redistribution and use of any object code compiled from the source
50 * code and any resulting derivative works, are licensed by TI for use only
51 * with TI Devices.
52 *
53 * Neither the name of Texas Instruments Incorporated nor the names of its
54 * suppliers may be used to endorse or promote products derived from this
55 * software without specific prior written permission.
56 *
57 * DISCLAIMER.
58 *
59 * THIS SOFTWARE IS PROVIDED BY TI AND TI\92S LICENSORS "AS IS" AND ANY EXPRESS
60 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
61 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
62 * DISCLAIMED. IN NO EVENT SHALL TI AND TI\92S LICENSORS BE LIABLE FOR ANY
63 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
64 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
65 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
66 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
69 * DAMAGE. \r
70 *****************************************************************************/\r
71 #ifndef _VPESIM_H\r
72 #define _VPESIM_H\r
73 \r
74 #include <stdio.h>\r
75 #include <stdlib.h>\r
76 #include <string.h>\r
77 #include <xdc/std.h>\r
78 \r
79 /* RTSC headers */\r
80 #include <ti/mas/types/types.h>\r
81 #include <ti/mas/fract/fract.h>\r
82 #include <ti/mas/types/const.h>\r
83 #include <ti/mas/util/ecomem.h>\r
84 \r
85 /* for signal generator */\r
86 #include <ti/mas/sdk/sgn.h>\r
87 \r
88 /* VPE component and simulation headers */\r
89 #include <ti/mas/vpe/hlc.h>\r
90 #include <ti/mas/vpe/slm.h>\r
91 #include <ti/mas/vpe/snl.h>\r
92 #include <ti/mas/vpe/svd.h>\r
93 #include <ti/mas/vpe/sfc.h>\r
94 #include <ti/mas/vpe/pcm.h>\r
95 #include <ti/mas/vpe/asnr.h>\r
96 \r
97 #ifdef ti_targets_C54\r
98 #define _VPESIM_C54 1\r
99 #else\r
100 #define _VPESIM_C54 0\r
101 #endif\r
102 \r
103 #ifdef ti_targets_C55 \r
104 #define _VPESIM_C55 1\r
105 #else\r
106 #define _VPESIM_C55 0\r
107 #endif\r
108 \r
109 #ifdef ti_targets_C55_large\r
110 #define _VPESIM_C55L 1\r
111 #else\r
112 #define _VPESIM_C55L 0\r
113 #endif\r
114 \r
115 #ifdef ti_targets_C64\r
116 #define _VPESIM_C64 1\r
117 #else\r
118 #define _VPESIM_C64 0\r
119 #endif\r
120 \r
121 #ifdef ti_targets_C64_big_endian\r
122 #define _VPESIM_C64_BIG_ENDIAN 1\r
123 #else\r
124 #define _VPESIM_C64_BIG_ENDIAN 0\r
125 #endif\r
126 \r
127 #ifdef ti_targets_C64P\r
128 #define _VPESIM_C64P 1\r
129 #else\r
130 #define _VPESIM_C64P 0\r
131 #endif\r
132 \r
133 #ifdef ti_targets_C64P_big_endian\r
134 #define _VPESIM_C64P_BIG_ENDIAN 1\r
135 #else\r
136 #define _VPESIM_C64P_BIG_ENDIAN 0\r
137 #endif\r
138 \r
139 #ifdef ti_targets_C66\r
140 #define _VPESIM_C66 1\r
141 #else\r
142 #define _VPESIM_C66 0\r
143 #endif\r
144 \r
145 #ifdef ti_targets_C66_big_endian\r
146 #define _VPESIM_C66_BIG_ENDIAN 1\r
147 #else\r
148 #define _VPESIM_C66_BIG_ENDIAN 0\r
149 #endif\r
150 \r
151 /* Simulation error identifiers */\r
152 #define vpe_SIM_ERR_1 ( 1) // \r
153 #define vpe_SIM_ERR_2 ( 2) // \r
154 #define vpe_SIM_ERR_3 ( 4) // \r
155 #define vpe_SIM_ERR_4 ( 5) // \r
156 #define vpe_SIM_ERR_5 ( 6) // \r
157 #define vpe_SIM_ERR_6 ( 7) // \r
158 #define vpe_SIM_ERR_7 ( 8) // \r
159 #define vpe_SIM_ERR_8 ( 9) // \r
160 #define vpe_SIM_ERR_9 (10) // \r
161 #define vpe_SIM_ERR_10 (11) // \r
162 #define vpe_SIM_ERR_11 (12) // \r
163 #define vpe_SIM_ERR_12 (13) // \r
164 #define vpe_SIM_ERR_13 (14) // \r
165 #define vpe_SIM_ERR_14 (15) // \r
166 #define vpe_SIM_ERR_15 (16) // \r
167 #define vpe_SIM_ERR_16 (17) // \r
168 #define vpe_SIM_ERR_17 (18) // \r
169 #define vpe_SIM_ERR_18 (19) // \r
170 \r
171 /* Simulation constraints */\r
172 #define vpe_SIM_MAX_SAMPLES 320 // Maximum frame_size\r
173 #define vpe_SIM_MAX_ECOBUFS 12 // Maximum module buffers\r
174 #define vpe_SIM_MAX_STRING 256 // Maximum string size\r
175 \r
176 /* Simulation file open actions */\r
177 #define vpe_SIM_FILEIO_READ ( 0) // Open file for read (binary)\r
178 #define vpe_SIM_FILEIO_WRITE ( 1) // Open file for write (binary)\r
179 \r
180 #define VPE_SIM_SAMPLE_FREQ_16000 16000 // Sampling frequency\r
181 #define VPE_SIM_SAMPLE_FREQ_8000 8000 // Sampling frequency\r
182 #define VPE_SIM_FRAME_SIZE_16000 160 /* 160 samples for a 10 msec frame */\r
183 #define VPE_SIM_FRAME_SIZE_8000 80 /* 80 samples for a 10 msec frame */\r
184 \r
185 #define VPE_SIM_DECIM_FILT_DEL (sfc_DEF_FILT_LEN-1)\r
186 #define VPE_SIM_DECIM_DELAY_LEN (VPE_SIM_DECIM_FILT_DEL + VPE_SIM_FRAME_SIZE_16000)\r
187 #define VPE_SIM_INTERP_FILT_DEL ((sfc_DEF_FILT_LEN-1)/2)\r
188 #define VPE_SIM_INTERP_DELAY_LEN (VPE_SIM_INTERP_FILT_DEL + VPE_SIM_FRAME_SIZE_16000)\r
189 \r
190 /* Simulation PCM format enumeration */\r
191 typedef enum {\r
192 vpe_SIM_PCM_ALAW = const_COMP_ALAW_8, // 8-bit ulaw PCM\r
193 vpe_SIM_PCM_ULAW = const_COMP_MULAW_8, // 8-bit alaw PCM\r
194 vpe_SIM_PCM_LIN = const_COMP_LINEAR // Linear PCM\r
195 } vpeSimPcm_e;\r
196 \r
197 typedef struct {\r
198 tbool fio; // TRUE: Get/put samples from/to file\r
199 tbool eof; // TRUE: End of file reached\r
200 FILE *fptr; // File pointer for read/write\r
201 char fname[vpe_SIM_MAX_STRING]; // File name to open/close\r
202 } vpeSimFileIo_t;\r
203 \r
204 /* Signal Generator Parameters */\r
205 typedef struct {\r
206 tbool state; /* TRUE: generator is on. */\r
207 linSample dcoffset; /* dc offset (Q0 format) */\r
208 tint wftype; /* one of sgn_WFT_'s */\r
209 tint f1; /* the first frequency in Hz */\r
210 tint f2; /* the second frequency in Hz */\r
211 linSample amp1; /* amplitude of the first component (Q0) */\r
212 linSample amp2; /* amplitude of the second component (Q0) */\r
213 tint nlevel; /* idle noise level in dBm0 */\r
214 tulong nseed; /* idle noise seed */\r
215 tint ntype; /* noise type SGN_NT_xxx */\r
216 tint pow_level; /* Hoth or CSS power level in dBm0 */\r
217 tulong hoth_seed; /* Hoth noise seed */\r
218 } vpeSGNPars_t;\r
219 \r
220 /* ASNR parameters */\r
221 typedef struct {\r
222 tint samp_rate;\r
223 tint delay; \r
224 tint band_bin1;\r
225 tint band_bin2;\r
226 tint band1_max_atten;\r
227 tint band2_max_atten;\r
228 tint band3_max_atten;\r
229 tint sig_upd_rate_max;\r
230 tint sig_upd_rate_min; \r
231 tint noise_thresh; \r
232 tint noise_hangover; \r
233 } vpeASNRPars_t;\r
234 \r
235 /* Simulation configuration structure */\r
236 typedef struct {\r
237 tbool exec; /* TRUE: Provide verbose progress info */\r
238 tbool hlc_on; /* Hlc enable bit */\r
239 tbool slm_on; /* Slim enable bit */\r
240 tbool snl_on; /* SNL enable bit */\r
241 tbool svd_on; /* SVD enable bit */\r
242 tbool nr_on; /* NR enable bit */\r
243 tbool decim_on;\r
244 tbool interp_on;\r
245 tbool ulaw_enc_on;\r
246 tbool ulaw_dec_on;\r
247 tbool alaw_enc_on;\r
248 tbool alaw_dec_on;\r
249 tlong sample_cnt; /* Sample count */\r
250 tulong sample_bp; /* Break (halt) after this sample is reached */\r
251 tbool sgn; /* whether to use sgn, TRUE: use sgn */\r
252 tbool cfg_sgn; /* TRUE: configure SGN */\r
253 tbool cfg_hlc; /* TRUE: configure HLC */\r
254 tbool cfg_slm; /* TRUE: configure SLM */\r
255 tint slm_mod; /* SLM mode, 0: disable, 1~5: enable */\r
256 tint Fs; /* Sampling rate in Hz */ \r
257 hlcControl_t hlc_ctrl; /* HLC control structure */\r
258 vpeASNRPars_t asnrParam; /* ASNR parameters */\r
259 vpeSGNPars_t sgnParam; /* Parameters used to configure sgn */\r
260 vpeSimFileIo_t sigIn; /* Signal in file I/O structure */\r
261 vpeSimFileIo_t sigOut; /* Signal out file I/O structure */\r
262 vpeSimFileIo_t config; /* VPE simulation configuration I/O */\r
263 vpeSimPcm_e pcmin_format; /* Input PCM format */\r
264 vpeSimPcm_e pcmout_format; /* Output PCM format */\r
265 tbool data; /* Flag indicating more samples for simulation*/\r
266 tuint error_id; /* Error identifier */\r
267 tuint frame_size_in; /* Simulation frame size, input */\r
268 tuint frame_size_out; /* Simulation frame size, output */\r
269 char baseDir[vpe_SIM_MAX_STRING]; /* Base directory for file I/O */\r
270 } vpeSimConfig_t;\r
271 \r
272 \r
273 extern void vpe_sim_fileio_init (vpeSimFileIo_t *fioptr, tuint code);\r
274 extern void vpe_sim_fileio_end (vpeSimFileIo_t *fioptr);\r
275 extern void vpe_sim_init ();\r
276 extern void vpe_init (void);\r
277 extern tbool vpe_sim_fread (linSample *buf, tint buf_size, vpeSimFileIo_t *fioptr);\r
278 extern void vpe_sim_fwrite (linSample *buf, tint buf_size, vpeSimFileIo_t *fioptr);\r
279 extern void vpe_sim_input_mux (void);\r
280 extern void vpe_sim_output_mux (void);\r
281 extern void vpe_print (char *str);\r
282 extern void vpe_iprint (char *str, tlong ivar);\r
283 extern void vpe_sprint (char *str, char *svar);\r
284 extern void vpe_sim_open_sgn (void *inst);\r
285 extern void vpe_sim_set_sgn (void *inst, vpeSGNPars_t *sgn, tint Fs);\r
286 extern void vpe_sim_gen_frame (void *inst, tint frame_size, linSample *frame);\r
287 extern sgnFileIo_t *vpe_sim_in_file(sgnFileIo_t *dsc);\r
288 extern sgnFileIo_t *vpe_sim_in_file(sgnFileIo_t *dsc);\r
289 extern void vpe_instantiate_nr(tint srate);\r
290 extern void vpe_config_nr(vpeASNRPars_t *asnr_params);\r
291 extern void vpe_deinstantiate_nr();\r
292 extern void vpe_halt (tbool *exec);\r
293 extern void vpe_sim_flush_cache();\r
294 extern void vpe_sim_read_cfg();\r
295 \r
296 #endif /* _VPESIM_H */\r
297 \r
298 /* Nothing past this point */\r