00001 /*This file is prepared for Doxygen automatic documentation generation.*/ 00017 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00018 * 00019 * Redistribution and use in source and binary forms, with or without 00020 * modification, are permitted provided that the following conditions are met: 00021 * 00022 * 1. Redistributions of source code must retain the above copyright notice, this 00023 * list of conditions and the following disclaimer. 00024 * 00025 * 2. Redistributions in binary form must reproduce the above copyright notice, 00026 * this list of conditions and the following disclaimer in the documentation 00027 * and/or other materials provided with the distribution. 00028 * 00029 * 3. The name of Atmel may not be used to endorse or promote products derived 00030 * from this software without specific prior written permission. 00031 * 00032 * 4. This software may only be redistributed and used in connection with an Atmel 00033 * AVR product. 00034 * 00035 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00036 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00037 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00038 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00039 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00040 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00041 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00042 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00043 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00044 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00045 * 00046 */ 00047 00048 #include "dsp.h" 00049 #include "preprocessor.h" 00050 00051 #if defined(FORCE_ALL_GENERICS) || \ 00052 defined(FORCE_GENERIC_VECT32_DOTMUL) || \ 00053 !defined(TARGET_SPECIFIC_VECT32_DOTMUL) 00054 00055 #define DSP32_DOTMULTIPLICATION(x_num, data) \ 00056 vect1[x_num] = ((S64) vect2[x_num] * (S64) vect3[x_num]) >> DSP32_QB; 00057 00058 /********************************************************************************************* 00059 * This function is the ending function of the dot multiplication. It is used to multiply the last items of a vector. 00060 *********************************************************************************************/ 00061 #define DSP32_DOTMUL_KERNEL_X_FCT(x_num, data) \ 00062 static void TPASTE2(dsp32_vect_dotmul_kernel_x, x_num)(dsp32_t *vect1, dsp32_t *vect2, dsp32_t *vect3) \ 00063 { \ 00064 MREPEAT(x_num, DSP32_DOTMULTIPLICATION, ""); \ 00065 } 00066 /*********************************************************************************************/ 00067 00068 DSP32_DOTMUL_KERNEL_X_FCT(0, "") 00069 DSP32_DOTMUL_KERNEL_X_FCT(1, "") 00070 DSP32_DOTMUL_KERNEL_X_FCT(2, "") 00071 DSP32_DOTMUL_KERNEL_X_FCT(3, "") 00072 00073 void dsp32_vect_dotmul(dsp32_t *vect1, dsp32_t *vect2, dsp32_t *vect3, int size) 00074 { 00075 typedef void (*dotmul_kernel_opti_t)(dsp32_t *, dsp32_t *, dsp32_t *); 00076 static const dotmul_kernel_opti_t dotmul_end_kernel_opti[4] = { 00077 dsp32_vect_dotmul_kernel_x0, 00078 dsp32_vect_dotmul_kernel_x1, 00079 dsp32_vect_dotmul_kernel_x2, 00080 dsp32_vect_dotmul_kernel_x3 00081 }; 00082 int n; 00083 00084 for(n=0; n<size-3; n+=4) 00085 { 00086 vect1[n] = ((S64) vect2[n] * (S64) vect3[n]) >> DSP32_QB; 00087 vect1[n+1] = ((S64) vect2[n+1] * (S64) vect3[n+1]) >> DSP32_QB; 00088 vect1[n+2] = ((S64) vect2[n+2] * (S64) vect3[n+2]) >> DSP32_QB; 00089 vect1[n+3] = ((S64) vect2[n+3] * (S64) vect3[n+3]) >> DSP32_QB; 00090 } 00091 00092 // Jump on different functions depending on the length of the vectors to compute 00093 dotmul_end_kernel_opti[size&0x3](&vect1[n], &vect2[n], &vect3[n]); 00094 } 00095 00096 #endif