VLSI Solution Oy / MegaLib Documentation

vstypes.h

Go to the documentation of this file.
00001 
00010 #ifndef __VS_TYPES_H__
00011 #define __VS_TYPES_H__
00012 
00013 /* Definitions that are common to C and assembly language */
00015 #define MR_NONE 0
00016 
00017 #define MR_INT  0x200
00018 
00019 #define MR_SAT  0x400
00020 
00021 #ifdef ASM      /* ASM definitions */
00022 #include <vsasm.h> /* hide preprocessor tokens that only vsa understands */
00023 #endif /* ASM */
00024 
00025 
00026 #ifndef ASM     /* C only definitions */
00027 
00029 typedef short s_int16;
00031 typedef unsigned short u_int16;
00032 
00034 #define FMT_S16 "d"
00035 
00036 #define FMT_U16 "u"
00037 
00038 #define FMT_H16 "x"
00039 
00040 
00041 #ifndef __VSDSP__
00042 
00044 typedef int s_int32;
00046 typedef unsigned int u_int32;
00047 
00049 #define FMT_S32 "d"
00050 
00051 #define FMT_U32 "u"
00052 
00053 #define FMT_H32 "x"
00054 
00055 
00056 /* Remove VSDSP specific special keywords to make code compatible */
00057 #define register
00058 #define __reg_a
00059 #define __reg_b
00060 #define __reg_c
00061 #define __reg_d
00062 #define __a0
00063 #define __a1
00064 #define __b0
00065 #define __b1
00066 #define __c0
00067 #define __c1
00068 #define __d0
00069 #define __d1
00070 #define __i0
00071 #define __i1
00072 #define __i2
00073 #define __i3
00074 #define __mem_x
00075 #define __y
00076 #define __near
00077 #define __far
00078 #define auto
00079 
00080 #if 0
00081 typedef float  f_int16;
00082 typedef double f_int32;
00083 #else
00084 
00093 typedef s_int16 f_int16;
00102 typedef s_int32 f_int32;
00104 #define FMUL32(a,b) (f_int32)((long long)(f_int32)(a) * (f_int32)(b) >> 31)
00105 
00106 #define FMUL16(a,b) (f_int16)((long)(f_int16)(a) * (f_int16)(b) >> 15)
00107 
00108 #define FDIV32(a,b) (f_int32)(((long long)(f_int32)(a)<<31) / (f_int32)(b))
00109 
00110 #define FDIV16(a,b) (f_int16)(((long)(f_int16)(a)<<15) / (f_int16)(b))
00111 
00112 #define DBL2F32(a)  (f_int32)((a)*(32768.0*65536.0))
00113 
00114 #define DBL2F16(a)  (f_int16)((a)*32768.0)
00115 #endif
00116 
00117 
00118 /* for compatibility with math.h */
00119 #define SqrtI(a) ((u_int16)sqrt(a))
00120 #define SqrtI32(a) ((u_int32)(sqrt(a)*65536.0))
00121 
00122 
00123 
00124 #else /*else !__VSDSP__*/
00125 
00126 #define __mem_x __x
00127 
00129 typedef long s_int32;
00131 typedef unsigned long u_int32;
00132 
00134 #define FMT_S32 "ld"
00135 
00136 #define FMT_U32 "lu"
00137 
00138 #define FMT_H32 "lx"
00139 
00140 #define __reg_a __a
00141 #define __reg_b __b
00142 #define __reg_c __c
00143 #define __reg_d __d
00144 
00145 typedef __fract short f_int16;
00146 typedef __fract long f_int32;
00147 #define FMUL32(a,b) ((f_int32)(a) * (f_int32)(b))
00148 #define FMUL16(a,b) ((f_int16)(a) * (f_int16)(b))
00149 #define FDIV32(a,b) ((f_int32)(a) / (f_int32)(b))
00150 #define FDIV16(a,b) ((f_int16)(a) / (f_int16)(b))
00151 #define DBL2F32(a)  (a)
00152 #define DBL2F16(a)  (a)
00153 #endif /*__VSDSP__*/
00154 
00155 #ifndef USEX
00156 
00157 #define USEX(x) *((__x volatile u_int16 *)(u_int16)(x))
00158 #endif 
00159 #ifndef USEY
00160 
00161 #define USEY(x) *((__y volatile u_int16 *)(u_int16)(x))
00162 #endif 
00164 #endif 
00166 #endif /*__VS_TYPES_H__*/

All software copyright 2005-2006 VLSI Solution OY. Redistribution of this software is strictly forbidden.