|
| 1 | +/* |
| 2 | + * Copyright (c) 2022 Synopsys |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#ifndef SUBSYS_MATH_ARC_BACKEND_PUBLIC_ZDSP_BACKEND_DSP_H_ |
| 8 | +#define SUBSYS_MATH_ARC_BACKEND_PUBLIC_ZDSP_BACKEND_DSP_H_ |
| 9 | + |
| 10 | +#ifdef __cplusplus |
| 11 | +extern "C" { |
| 12 | +#endif |
| 13 | + |
| 14 | +/* This include MUST be done before arm_math.h so we can let the arch specific |
| 15 | + * logic set up the right #define values for arm_math.h |
| 16 | + */ |
| 17 | +#include <zephyr/kernel.h> |
| 18 | + |
| 19 | +#include <arm_math.h> |
| 20 | +#include "dsplib.h" |
| 21 | + |
| 22 | +static inline void zdsp_mult_q7(const DSP_DATA q7_t *src_a, const DSP_DATA q7_t *src_b, |
| 23 | + DSP_DATA q7_t *dst, uint32_t block_size) |
| 24 | +{ |
| 25 | + dsp_mult_q7(src_a, src_b, dst, block_size); |
| 26 | +} |
| 27 | +static inline void zdsp_mult_q15(const DSP_DATA q15_t *src_a, const DSP_DATA q15_t *src_b, |
| 28 | + DSP_DATA q15_t *dst, uint32_t block_size) |
| 29 | +{ |
| 30 | + dsp_mult_q15(src_a, src_b, dst, block_size); |
| 31 | +} |
| 32 | +static inline void zdsp_mult_q31(const DSP_DATA q31_t *src_a, const DSP_DATA q31_t *src_b, |
| 33 | + DSP_DATA q31_t *dst, uint32_t block_size) |
| 34 | +{ |
| 35 | + dsp_mult_q31(src_a, src_b, dst, block_size); |
| 36 | +} |
| 37 | +static inline void zdsp_mult_f32(const DSP_DATA float32_t *src_a, const DSP_DATA float32_t *src_b, |
| 38 | + DSP_DATA float32_t *dst, uint32_t block_size) |
| 39 | +{ |
| 40 | + dsp_mult_f32(src_a, src_b, dst, block_size); |
| 41 | +} |
| 42 | + |
| 43 | +static inline void zdsp_add_q7(const DSP_DATA q7_t *src_a, const DSP_DATA q7_t *src_b, |
| 44 | + DSP_DATA q7_t *dst, uint32_t block_size) |
| 45 | +{ |
| 46 | + dsp_add_q7(src_a, src_b, dst, block_size); |
| 47 | +} |
| 48 | +static inline void zdsp_add_q15(const DSP_DATA q15_t *src_a, const DSP_DATA q15_t *src_b, |
| 49 | + DSP_DATA q15_t *dst, uint32_t block_size) |
| 50 | +{ |
| 51 | + dsp_add_q15(src_a, src_b, dst, block_size); |
| 52 | +} |
| 53 | +static inline void zdsp_add_q31(const DSP_DATA q31_t *src_a, const DSP_DATA q31_t *src_b, |
| 54 | + DSP_DATA q31_t *dst, uint32_t block_size) |
| 55 | +{ |
| 56 | + dsp_add_q31(src_a, src_b, dst, block_size); |
| 57 | +} |
| 58 | +static inline void zdsp_add_f32(const DSP_DATA float32_t *src_a, const DSP_DATA float32_t *src_b, |
| 59 | + DSP_DATA float32_t *dst, uint32_t block_size) |
| 60 | +{ |
| 61 | + dsp_add_f32(src_a, src_b, dst, block_size); |
| 62 | +} |
| 63 | + |
| 64 | +static inline void zdsp_sub_q7(const DSP_DATA q7_t *src_a, const DSP_DATA q7_t *src_b, |
| 65 | + DSP_DATA q7_t *dst, uint32_t block_size) |
| 66 | +{ |
| 67 | + dsp_sub_q7(src_a, src_b, dst, block_size); |
| 68 | +} |
| 69 | +static inline void zdsp_sub_q15(const DSP_DATA q15_t *src_a, const DSP_DATA q15_t *src_b, |
| 70 | + DSP_DATA q15_t *dst, uint32_t block_size) |
| 71 | +{ |
| 72 | + dsp_sub_q15(src_a, src_b, dst, block_size); |
| 73 | +} |
| 74 | +static inline void zdsp_sub_q31(const DSP_DATA q31_t *src_a, const DSP_DATA q31_t *src_b, |
| 75 | + DSP_DATA q31_t *dst, uint32_t block_size) |
| 76 | +{ |
| 77 | + dsp_sub_q31(src_a, src_b, dst, block_size); |
| 78 | +} |
| 79 | +static inline void zdsp_sub_f32(const DSP_DATA float32_t *src_a, const DSP_DATA float32_t *src_b, |
| 80 | + DSP_DATA float32_t *dst, uint32_t block_size) |
| 81 | +{ |
| 82 | + dsp_sub_f32(src_a, src_b, dst, block_size); |
| 83 | +} |
| 84 | + |
| 85 | +static inline void zdsp_scale_q7(const DSP_DATA q7_t *src, q7_t scale_fract, int8_t shift, |
| 86 | + DSP_DATA q7_t *dst, uint32_t block_size) |
| 87 | +{ |
| 88 | + dsp_scale_q7(src, scale_fract, shift, dst, block_size); |
| 89 | +} |
| 90 | +static inline void zdsp_scale_q15(const DSP_DATA q15_t *src, q15_t scale_fract, int8_t shift, |
| 91 | + DSP_DATA q15_t *dst, uint32_t block_size) |
| 92 | +{ |
| 93 | + dsp_scale_q15(src, scale_fract, shift, dst, block_size); |
| 94 | +} |
| 95 | +static inline void zdsp_scale_q31(const DSP_DATA q31_t *src, q31_t scale_fract, int8_t shift, |
| 96 | + DSP_DATA q31_t *dst, uint32_t block_size) |
| 97 | +{ |
| 98 | + dsp_scale_q31(src, scale_fract, shift, dst, block_size); |
| 99 | +} |
| 100 | + |
| 101 | +static inline void zdsp_scale_f32(const DSP_DATA float32_t *src, float32_t scale, |
| 102 | + DSP_DATA float32_t *dst, uint32_t block_size) |
| 103 | +{ |
| 104 | + dsp_scale_f32(src, scale, dst, block_size); |
| 105 | +} |
| 106 | + |
| 107 | +static inline void zdsp_abs_q7(const DSP_DATA q7_t *src, DSP_DATA q7_t *dst, uint32_t block_size) |
| 108 | +{ |
| 109 | + dsp_abs_q7(src, dst, block_size); |
| 110 | +} |
| 111 | +static inline void zdsp_abs_q15(const DSP_DATA q15_t *src, DSP_DATA q15_t *dst, uint32_t block_size) |
| 112 | +{ |
| 113 | + dsp_abs_q15(src, dst, block_size); |
| 114 | +} |
| 115 | +static inline void zdsp_abs_q31(const DSP_DATA q31_t *src, DSP_DATA q31_t *dst, uint32_t block_size) |
| 116 | +{ |
| 117 | + dsp_abs_q31(src, dst, block_size); |
| 118 | +} |
| 119 | +static inline void zdsp_abs_f32(const DSP_DATA float32_t *src, DSP_DATA float32_t *dst, |
| 120 | + uint32_t block_size) |
| 121 | +{ |
| 122 | + dsp_abs_f32(src, dst, block_size); |
| 123 | +} |
| 124 | + |
| 125 | +static inline void zdsp_negate_q7(const DSP_DATA q7_t *src, DSP_DATA q7_t *dst, uint32_t block_size) |
| 126 | +{ |
| 127 | + dsp_negate_q7(src, dst, block_size); |
| 128 | +} |
| 129 | +static inline void zdsp_negate_q15(const DSP_DATA q15_t *src, DSP_DATA q15_t *dst, |
| 130 | + uint32_t block_size) |
| 131 | +{ |
| 132 | + dsp_negate_q15(src, dst, block_size); |
| 133 | +} |
| 134 | +static inline void zdsp_negate_q31(const DSP_DATA q31_t *src, DSP_DATA q31_t *dst, |
| 135 | + uint32_t block_size) |
| 136 | +{ |
| 137 | + dsp_negate_q31(src, dst, block_size); |
| 138 | +} |
| 139 | +static inline void zdsp_negate_f32(const DSP_DATA float32_t *src, DSP_DATA float32_t *dst, |
| 140 | + uint32_t block_size) |
| 141 | +{ |
| 142 | + dsp_negate_f32(src, dst, block_size); |
| 143 | +} |
| 144 | + |
| 145 | +static inline void zdsp_dot_prod_q7(const DSP_DATA q7_t *src_a, const DSP_DATA q7_t *src_b, |
| 146 | + uint32_t block_size, DSP_DATA q31_t *dst) |
| 147 | +{ |
| 148 | + dsp_dot_prod_q7(src_a, src_b, block_size, dst); |
| 149 | +} |
| 150 | +static inline void zdsp_dot_prod_q15(const DSP_DATA q15_t *src_a, const DSP_DATA q15_t *src_b, |
| 151 | + uint32_t block_size, DSP_DATA q63_t *dst) |
| 152 | +{ |
| 153 | + dsp_dot_prod_q15(src_a, src_b, block_size, dst); |
| 154 | +} |
| 155 | +static inline void zdsp_dot_prod_q31(const DSP_DATA q31_t *src_a, const DSP_DATA q31_t *src_b, |
| 156 | + uint32_t block_size, DSP_DATA q63_t *dst) |
| 157 | +{ |
| 158 | + dsp_dot_prod_q31(src_a, src_b, block_size, dst); |
| 159 | +} |
| 160 | +static inline void zdsp_dot_prod_f32(const DSP_DATA float32_t *src_a, |
| 161 | + const DSP_DATA float32_t *src_b, uint32_t block_size, |
| 162 | + DSP_DATA float32_t *dst) |
| 163 | +{ |
| 164 | + dsp_dot_prod_f32(src_a, src_b, block_size, dst); |
| 165 | +} |
| 166 | + |
| 167 | +static inline void zdsp_shift_q7(const DSP_DATA q7_t *src, int8_t shift_bits, DSP_DATA q7_t *dst, |
| 168 | + uint32_t block_size) |
| 169 | +{ |
| 170 | + dsp_shift_q7(src, shift_bits, dst, block_size); |
| 171 | +} |
| 172 | +static inline void zdsp_shift_q15(const DSP_DATA q15_t *src, int8_t shift_bits, DSP_DATA q15_t *dst, |
| 173 | + uint32_t block_size) |
| 174 | +{ |
| 175 | + dsp_shift_q15(src, shift_bits, dst, block_size); |
| 176 | +} |
| 177 | +static inline void zdsp_shift_q31(const DSP_DATA q31_t *src, int8_t shift_bits, DSP_DATA q31_t *dst, |
| 178 | + uint32_t block_size) |
| 179 | +{ |
| 180 | + dsp_shift_q31(src, shift_bits, dst, block_size); |
| 181 | +} |
| 182 | + |
| 183 | +static inline void zdsp_offset_q7(const DSP_DATA q7_t *src, q7_t offset, DSP_DATA q7_t *dst, |
| 184 | + uint32_t block_size) |
| 185 | +{ |
| 186 | + dsp_offset_q7(src, offset, dst, block_size); |
| 187 | +} |
| 188 | +static inline void zdsp_offset_q15(const DSP_DATA q15_t *src, q15_t offset, DSP_DATA q15_t *dst, |
| 189 | + uint32_t block_size) |
| 190 | +{ |
| 191 | + dsp_offset_q15(src, offset, dst, block_size); |
| 192 | +} |
| 193 | +static inline void zdsp_offset_q31(const DSP_DATA q31_t *src, q31_t offset, DSP_DATA q31_t *dst, |
| 194 | + uint32_t block_size) |
| 195 | +{ |
| 196 | + dsp_offset_q31(src, offset, dst, block_size); |
| 197 | +} |
| 198 | +static inline void zdsp_offset_f32(const DSP_DATA float32_t *src, float32_t offset, |
| 199 | + DSP_DATA float32_t *dst, uint32_t block_size) |
| 200 | +{ |
| 201 | + dsp_offset_f32(src, offset, dst, block_size); |
| 202 | +} |
| 203 | + |
| 204 | +static inline void zdsp_clip_q7(const DSP_DATA q7_t *src, DSP_DATA q7_t *dst, q7_t low, q7_t high, |
| 205 | + uint32_t num_samples) |
| 206 | +{ |
| 207 | + arm_clip_q7(src, dst, low, high, num_samples); |
| 208 | +} |
| 209 | +static inline void zdsp_clip_q15(const DSP_DATA q15_t *src, DSP_DATA q15_t *dst, q15_t low, |
| 210 | + q15_t high, uint32_t num_samples) |
| 211 | +{ |
| 212 | + arm_clip_q15(src, dst, low, high, num_samples); |
| 213 | +} |
| 214 | +static inline void zdsp_clip_q31(const DSP_DATA q31_t *src, DSP_DATA q31_t *dst, q31_t low, |
| 215 | + q31_t high, uint32_t num_samples) |
| 216 | +{ |
| 217 | + arm_clip_q31(src, dst, low, high, num_samples); |
| 218 | +} |
| 219 | +static inline void zdsp_clip_f32(const DSP_DATA float32_t *src, DSP_DATA float32_t *dst, |
| 220 | + float32_t low, float32_t high, uint32_t num_samples) |
| 221 | +{ |
| 222 | + arm_clip_f32(src, dst, low, high, num_samples); |
| 223 | +} |
| 224 | + |
| 225 | +static inline void zdsp_and_u8(const DSP_DATA uint8_t *src_a, const DSP_DATA uint8_t *src_b, |
| 226 | + DSP_DATA uint8_t *dst, uint32_t block_size) |
| 227 | +{ |
| 228 | + arm_and_u8(src_a, src_b, dst, block_size); |
| 229 | +} |
| 230 | +static inline void zdsp_and_u16(const DSP_DATA uint16_t *src_a, const DSP_DATA uint16_t *src_b, |
| 231 | + DSP_DATA uint16_t *dst, uint32_t block_size) |
| 232 | +{ |
| 233 | + arm_and_u16(src_a, src_b, dst, block_size); |
| 234 | +} |
| 235 | +static inline void zdsp_and_u32(const DSP_DATA uint32_t *src_a, const DSP_DATA uint32_t *src_b, |
| 236 | + DSP_DATA uint32_t *dst, uint32_t block_size) |
| 237 | +{ |
| 238 | + arm_and_u32(src_a, src_b, dst, block_size); |
| 239 | +} |
| 240 | + |
| 241 | +static inline void zdsp_or_u8(const DSP_DATA uint8_t *src_a, const DSP_DATA uint8_t *src_b, |
| 242 | + DSP_DATA uint8_t *dst, uint32_t block_size) |
| 243 | +{ |
| 244 | + arm_or_u8(src_a, src_b, dst, block_size); |
| 245 | +} |
| 246 | +static inline void zdsp_or_u16(const DSP_DATA uint16_t *src_a, const DSP_DATA uint16_t *src_b, |
| 247 | + DSP_DATA uint16_t *dst, uint32_t block_size) |
| 248 | +{ |
| 249 | + arm_or_u16(src_a, src_b, dst, block_size); |
| 250 | +} |
| 251 | +static inline void zdsp_or_u32(const DSP_DATA uint32_t *src_a, const DSP_DATA uint32_t *src_b, |
| 252 | + DSP_DATA uint32_t *dst, uint32_t block_size) |
| 253 | +{ |
| 254 | + arm_or_u32(src_a, src_b, dst, block_size); |
| 255 | +} |
| 256 | + |
| 257 | +static inline void zdsp_xor_u8(const DSP_DATA uint8_t *src_a, const DSP_DATA uint8_t *src_b, |
| 258 | + DSP_DATA uint8_t *dst, uint32_t block_size) |
| 259 | +{ |
| 260 | + arm_xor_u8(src_a, src_b, dst, block_size); |
| 261 | +} |
| 262 | +static inline void zdsp_xor_u16(const DSP_DATA uint16_t *src_a, const DSP_DATA uint16_t *src_b, |
| 263 | + DSP_DATA uint16_t *dst, uint32_t block_size) |
| 264 | +{ |
| 265 | + arm_xor_u16(src_a, src_b, dst, block_size); |
| 266 | +} |
| 267 | +static inline void zdsp_xor_u32(const DSP_DATA uint32_t *src_a, const DSP_DATA uint32_t *src_b, |
| 268 | + DSP_DATA uint32_t *dst, uint32_t block_size) |
| 269 | +{ |
| 270 | + arm_xor_u32(src_a, src_b, dst, block_size); |
| 271 | +} |
| 272 | + |
| 273 | +static inline void zdsp_not_u8(const DSP_DATA uint8_t *src, DSP_DATA uint8_t *dst, |
| 274 | + uint32_t block_size) |
| 275 | +{ |
| 276 | + arm_not_u8(src, dst, block_size); |
| 277 | +} |
| 278 | +static inline void zdsp_not_u16(const DSP_DATA uint16_t *src, DSP_DATA uint16_t *dst, |
| 279 | + uint32_t block_size) |
| 280 | +{ |
| 281 | + arm_not_u16(src, dst, block_size); |
| 282 | +} |
| 283 | +static inline void zdsp_not_u32(const DSP_DATA uint32_t *src, DSP_DATA uint32_t *dst, |
| 284 | + uint32_t block_size) |
| 285 | +{ |
| 286 | + arm_not_u32(src, dst, block_size); |
| 287 | +} |
| 288 | + |
| 289 | +#ifdef __cplusplus |
| 290 | +} |
| 291 | +#endif |
| 292 | + |
| 293 | +#endif /* SUBSYS_MATH_ARC_BACKEND_PUBLIC_ZDSP_BACKEND_DSP_H_ */ |
0 commit comments