Subversion Repositories testOled

Rev

Details | Last modification | View Log | RSS feed

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