initial import
[ICEs.git] / bfin-1400 / fe_TestDsp.i
1 # 1 "../fe_TestDsp.c"
2 # 1 "/disk0/scratch/working/src/fe/detector/blackfin//"
3 # 1 "<built-in>"
4 # 1 "<command line>"
5 # 1 "../fe_TestDsp.c"
6
7
8 # 1 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h" 1
9 # 17 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h"
10
11 # 18 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h" 3
12
13
14
15
16
17 # 1 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex_typedef.h" 1 3
18 # 16 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex_typedef.h" 3
19
20
21
22 # 19 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex_typedef.h" 3
23
24
25
26
27
28
29
30 # 1 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/fract_typedef.h" 1 3
31
32
33
34 # 4 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/fract_typedef.h" 3
35 # 25 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/fract_typedef.h" 3
36 typedef short fract16;
37 typedef long fract32;
38 # 27 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex_typedef.h" 2 3
39
40 typedef struct complex_fract16 {
41 fract16 re, im;
42 } __attribute__((aligned(4))) complex_fract16;
43
44
45 typedef union composite_complex_fract16 {
46 struct complex_fract16 x;
47 long raw;
48 } composite_complex_fract16;
49
50
51
52
53
54
55 typedef struct complex_fract32 {
56 fract32 re, im;
57 } complex_fract32;
58
59
60 typedef union composite_complex_fract32 {
61 struct complex_fract32 x;
62 long long raw;
63 } composite_complex_fract32;
64
65
66
67
68
69
70 typedef struct complex_float {
71 float re;
72 float im;
73 } complex_float;
74
75 typedef struct complex_long_double {
76 long double re;
77 long double im;
78 } complex_long_double;
79
80
81
82
83 typedef complex_long_double complex_double;
84 # 24 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h" 2 3
85 # 1 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/fr2x16_typedef.h" 1 3
86
87
88
89 # 4 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/fr2x16_typedef.h" 3
90 # 27 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/fr2x16_typedef.h" 3
91 # 1 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/r2x16_typedef.h" 1 3
92
93
94
95 # 4 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/r2x16_typedef.h" 3
96 # 27 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/r2x16_typedef.h" 3
97 # 1 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/raw_typedef.h" 1 3
98
99
100
101 # 4 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/raw_typedef.h" 3
102 # 25 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/raw_typedef.h" 3
103 typedef char _raw8;
104 typedef short _raw16;
105 typedef int _raw32;
106 typedef int __v2hi __attribute__ ((__mode__ (__V2HI__)));
107 # 28 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/r2x16_typedef.h" 2 3
108
109 typedef __v2hi raw2x16;
110 # 28 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/fr2x16_typedef.h" 2 3
111
112
113
114
115
116 typedef raw2x16 fract2x16;
117 typedef fract2x16 fr2x16;
118 # 25 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h" 2 3
119 # 35 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h" 3
120 float cabsf (complex_float _a) asm("__cabsf");
121
122 long double cabsd (complex_long_double _a) asm("__cabsd");
123
124
125
126
127
128 double cabs (complex_double _a) asm("__cabsd");
129
130
131 fract16 cabs_fr16 (complex_fract16 _a);
132 complex_fract16 conj_fr16 (complex_fract16 _a);
133 # 56 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h" 3
134 static __inline complex_fract16
135 cadd_fr16(complex_fract16 _a, complex_fract16 _b) {
136 complex_fract16 r;
137 fract2x16 i = __builtin_bfin_add_fr2x16(__builtin_bfin_compose_2x16(_a.im, _a.re), __builtin_bfin_compose_2x16(_b.im, _b.re));
138 { r.re = __builtin_bfin_extract_lo(i); r.im = __builtin_bfin_extract_hi(i); };
139 return r;
140 }
141
142
143
144
145
146
147 static __inline complex_fract16
148 csub_fr16(complex_fract16 _a, complex_fract16 _b) {
149 complex_fract16 r;
150 fract2x16 i = __builtin_bfin_sub_fr2x16(__builtin_bfin_compose_2x16(_a.im, _a.re), __builtin_bfin_compose_2x16(_b.im, _b.re));
151 { r.re = __builtin_bfin_extract_lo(i); r.im = __builtin_bfin_extract_hi(i); };
152 return r;
153 }
154 # 98 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h" 3
155 complex_fract16 cmlt_fr16 (complex_fract16 _a, complex_fract16 _b);
156
157
158
159 static __inline complex_fract16 cmac_fr16(complex_fract16 _sum,
160 complex_fract16 _a,
161 complex_fract16 _b){
162 complex_fract16 r;
163 fract2x16 i = __builtin_bfin_cmplx_mac(__builtin_bfin_compose_2x16(_sum.im, _sum.re),
164 __builtin_bfin_compose_2x16(_a.im, _a.re), __builtin_bfin_compose_2x16(_b.im, _b.re));
165 { r.re = __builtin_bfin_extract_lo(i); r.im = __builtin_bfin_extract_hi(i); };
166 return r;
167 }
168
169 static __inline complex_fract16 cmsu_fr16(complex_fract16 _sum,
170 complex_fract16 _a,
171 complex_fract16 _b){
172 complex_fract16 r;
173 fract2x16 i = __builtin_bfin_cmplx_msu(__builtin_bfin_compose_2x16(_sum.im, _sum.re),
174 __builtin_bfin_compose_2x16(_a.im, _a.re), __builtin_bfin_compose_2x16(_b.im, _b.re));
175 { r.re = __builtin_bfin_extract_lo(i); r.im = __builtin_bfin_extract_hi(i); };
176 return r;
177 }
178
179 static __inline fract16 csqu_add_fr16(complex_fract16 _c) {
180 return
181 __builtin_bfin_add_fr1x16(__builtin_bfin_mult_fr1x16(_c.re, _c.re),
182 __builtin_bfin_mult_fr1x16(_c.im, _c.im));
183 }
184
185 static __inline fract32 csqu_add_fr32(complex_fract16 _c) {
186 return
187 __builtin_bfin_add_fr1x32(__builtin_bfin_mult_fr1x32(_c.re, _c.re),
188 __builtin_bfin_mult_fr1x32(_c.im,_c.im));
189 }
190
191 static __inline fract16 cdst_fr16(complex_fract16 _x,
192 complex_fract16 _y) {
193 return __builtin_bfin_add_fr1x16(
194 __builtin_bfin_mult_fr1x16(__builtin_bfin_sub_fr1x16(_x.re,_y.re),
195 __builtin_bfin_sub_fr1x16(_x.re,_y.re)),
196 __builtin_bfin_mult_fr1x16(__builtin_bfin_sub_fr1x16(_x.im,_y.im),
197 __builtin_bfin_sub_fr1x16(_x.im,_y.im)));
198 }
199
200 static __inline fract32 cdst_fr32(complex_fract16 _x,
201 complex_fract16 _y) {
202 return __builtin_bfin_add_fr1x32(
203 __builtin_bfin_mult_fr1x32(__builtin_bfin_sub_fr1x16(_x.re,_y.re),
204 __builtin_bfin_sub_fr1x16(_x.re,_y.re)),
205 __builtin_bfin_mult_fr1x32(__builtin_bfin_sub_fr1x16(_x.im,_y.im),
206 __builtin_bfin_sub_fr1x16(_x.im,_y.im)));
207 }
208 # 166 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h" 3
209 complex_fract16 cdiv_fr16 (complex_fract16 _a, complex_fract16 _b) asm("__cdiv_fr16");
210 # 176 "/disk0/scratch/working/uClinux-dist/lib/libbfdsp/include/complex.h" 3
211 float argf (complex_float _a) asm("__argf");
212
213 fract16 arg_fr16 (complex_fract16 _a);
214 complex_fract16 polar_fr16 (fract16 _magnitude,
215 fract16 _phase);
216
217 fract16 cartesian_fr16 (complex_fract16 _a, fract16* _phase);
218
219
220
221
222
223
224 extern long long __builtin_bfin_conj_fr32(long long);
225 extern int __builtin_bfin_csqu_fr16(int);
226
227 static __inline complex_fract32 ccompose_fr32(fract32 _real, fract32 _imag)
228 {
229 complex_fract32 _x;
230 _x.re = _real;
231 _x.im = _imag;
232 return _x;
233 }
234
235 static __inline fract32 real_fr32(complex_fract32 _a)
236 {
237 return _a.re;
238 }
239
240 static __inline fract32 imag_fr32(complex_fract32 _a)
241 {
242 return _a.im;
243 }
244
245 static __inline complex_fract32 cadd_fr32(complex_fract32 _a,
246 complex_fract32 _b)
247 {
248 complex_fract32 _x;
249 _x.re = __builtin_bfin_add_fr1x32 (_a.re, _b.re);
250 _x.im = __builtin_bfin_add_fr1x32 (_a.im, _b.im);
251 return _x;
252 }
253
254 static __inline complex_fract32 csub_fr32(complex_fract32 _a,
255 complex_fract32 _b)
256 {
257 complex_fract32 _x;
258 _x.re = __builtin_bfin_sub_fr1x32 (_a.re, _b.re);
259 _x.im = __builtin_bfin_sub_fr1x32 (_a.im, _b.im);
260 return _x;
261 }
262
263 static __inline complex_fract32 conj_fr32(complex_fract32 _a)
264 {
265 complex_fract32 _x;
266 _x.im = __builtin_bfin_sub_fr1x32 (0, _a.im);
267 _x.re = _a.re;
268 return _x;
269 }
270
271
272 extern complex_fract32 cmul_fr32(complex_fract32, complex_fract32);
273
274
275 static __inline complex_fract16 csqu_fr16(complex_fract16 _a)
276 {
277 composite_complex_fract16 _x;
278 _x.x.re = _a.re; _x.x.im = _a.im;
279 _x.raw = __builtin_bfin_csqu_fr16(_x.raw);
280 return _x.x;
281 }
282 # 4 "../fe_TestDsp.c" 2
283
284 int main(){
285
286 complex_fract16 c,d;
287 c.re = 5*(1<<12);
288 c.im = 0;
289 d.re = 4*(1<<12);
290 d.im = 0;
291 complex_fract16 answer;
292
293 answer = cmlt_fr16(c,d);
294 return 0;
295 }