Subversion Repositories FuelGauge

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/*
2
 * Copyright (C) 2010-2018 Arm Limited or its affiliates. All rights reserved.
3
 *
4
 * SPDX-License-Identifier: Apache-2.0
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the License); you may
7
 * not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
 
19
/* ----------------------------------------------------------------------
20
 * Project:      CMSIS NN Library
21
 * Title:        arm_q7_to_q15_no_shift.c
22
 * Description:  Converts the elements of the Q7 vector to Q15 vector without left-shift
23
 *
24
 * $Date:        17. January 2018
25
 * $Revision:    V.1.0.0
26
 *
27
 * Target Processor:  Cortex-M cores
28
 *
29
 * -------------------------------------------------------------------- */
30
 
31
#include "arm_nnsupportfunctions.h"
32
 
33
/**    
34
 * @ingroup groupSupport    
35
 */
36
 
37
/**    
38
 * @addtogroup nndata_convert    
39
 * @{    
40
 */
41
 
42
/**    
43
 * @brief Converts the elements of the Q7 vector to Q15 vector without left-shift
44
 * @param[in]       *pSrc points to the Q7 input vector    
45
 * @param[out]      *pDst points to the Q15 output vector  
46
 * @param[in]       blockSize length of the input vector    
47
 * @return none.    
48
 *    
49
 * \par Description:    
50
 *    
51
 * The equation used for the conversion process is:    
52
 *  
53
 * <pre>    
54
 *      pDst[n] = (q15_t) pSrc[n];   0 <= n < blockSize.    
55
 * </pre>    
56
 *  
57
 */
58
 
59
void arm_q7_to_q15_no_shift(const q7_t * pSrc, q15_t * pDst, uint32_t blockSize)
60
{
61
    const q7_t *pIn = pSrc;     /* Src pointer */
62
    uint32_t  blkCnt;           /* loop counter */
63
 
64
#ifndef ARM_MATH_CM0_FAMILY
65
    q31_t     in;
66
    q31_t     in1, in2;
67
    q31_t     out1, out2;
68
 
69
    /* Run the below code for Cortex-M4 and Cortex-M3 */
70
 
71
    /*loop Unrolling */
72
    blkCnt = blockSize >> 2u;
73
 
74
    /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.    
75
     ** a second loop below computes the remaining 1 to 3 samples. */
76
    while (blkCnt > 0u)
77
    {
78
        /* C = (q15_t) A << 8 */
79
        /* convert from q7 to q15 and then store the results in the destination buffer */
80
        in = *__SIMD32(pIn)++;
81
 
82
        /* rotatate in by 8 and extend two q7_t values to q15_t values */
83
        in1 = __SXTB16(__ROR(in, 8));
84
 
85
        /* extend remainig two q7_t values to q15_t values */
86
        in2 = __SXTB16(in);
87
 
88
#ifndef ARM_MATH_BIG_ENDIAN
89
 
90
        out2 = __PKHTB(in1, in2, 16);
91
        out1 = __PKHBT(in2, in1, 16);
92
 
93
#else
94
 
95
        out1 = __PKHTB(in1, in2, 16);
96
        out2 = __PKHBT(in2, in1, 16);
97
 
98
#endif
99
 
100
        *__SIMD32(pDst)++ = out1;
101
        *__SIMD32(pDst)++ = out2;
102
 
103
        /* Decrement the loop counter */
104
        blkCnt--;
105
    }
106
 
107
    /* If the blockSize is not a multiple of 4, compute any remaining output samples here.    
108
     ** No loop unrolling is used. */
109
    blkCnt = blockSize % 0x4u;
110
 
111
#else
112
 
113
    /* Run the below code for Cortex-M0 */
114
 
115
    /* Loop over blockSize number of values */
116
    blkCnt = blockSize;
117
 
118
#endif                          /* #ifndef ARM_MATH_CM0_FAMILY */
119
 
120
    while (blkCnt > 0u)
121
    {
122
        /* C = (q15_t) A << 8 */
123
        /* convert from q7 to q15 and then store the results in the destination buffer */
124
        *pDst++ = (q15_t) * pIn++;
125
 
126
        /* Decrement the loop counter */
127
        blkCnt--;
128
    }
129
 
130
}
131
 
132
/**    
133
 * @} end of nndata_convert group  
134
 */