DSP2812浮点运算库.docx

上传人:b****6 文档编号:3282685 上传时间:2022-11-21 格式:DOCX 页数:117 大小:25.43KB
下载 相关 举报
DSP2812浮点运算库.docx_第1页
第1页 / 共117页
DSP2812浮点运算库.docx_第2页
第2页 / 共117页
DSP2812浮点运算库.docx_第3页
第3页 / 共117页
DSP2812浮点运算库.docx_第4页
第4页 / 共117页
DSP2812浮点运算库.docx_第5页
第5页 / 共117页
点击查看更多>>
下载资源
资源描述

DSP2812浮点运算库.docx

《DSP2812浮点运算库.docx》由会员分享,可在线阅读,更多相关《DSP2812浮点运算库.docx(117页珍藏版)》请在冰豆网上搜索。

DSP2812浮点运算库.docx

DSP2812浮点运算库

//###########################################################################

//

//FILE:

IQmathLib.h

//

//TITLE:

IQMathlibraryfunctionsdefinitions.

//

//###########################################################################

//

//Ver|dd-mmm-yyyy|Who|Descriptionofchanges

//=====|=============|=======|==============================================

//1.3|19Nov2001|A.T.|OriginalRelease.

//-----|-------------|-------|----------------------------------------------

//1.4|17May2002|A.T.|Addednewfunctionsandsupportfor

//|||intrinsicsIQmpy,IQxmpy,IQsat.

//-----|-------------|-------|----------------------------------------------

//1.4a|12Jun2002|A.T.|Fixedproblemwith_IQ()operationon

//|||variables.

//-----|-------------|-------|----------------------------------------------

//1.4b|18Jun2002|A.T.|Fixedbugwith_IQtoIQN()and_IQNtoIQ()

//|||operations.

//-----|-------------|-------|----------------------------------------------

//1.4d|30Mar2003|DA/SD|1.Addedmacroparametersinparentheses

//|||innumberofplaceswhereitmatters

//|||2.Addedmacrodefinitiontoincludeheader

//|||filemultipletimesintheprogram.

//-----|-------------|-------|----------------------------------------------

//

//###########################################################################

//

//Userneedstoconfigure"MATH_TYPE"and"GLOBAL_Q"values:

//

//---------------------------------------------------------------------------

//Selectmathtype,IQ_MATHorFLOAT_MATH:

//

#ifndef__IQMATHLIB_H_INCLUDED__

#define__IQMATHLIB_H_INCLUDED__

#defineFLOAT_MATH1

#defineIQ_MATH0

#ifndefMATH_TYPE

#defineMATH_TYPEIQ_MATH

#endif

//---------------------------------------------------------------------------

//SelectglobalQvalueandscaling.TheQvalueislimitedtothe

//followingrangeforallfunctions:

//

//30<=GLOBAL_Q<=1

//

#ifndefGLOBAL_Q

#defineGLOBAL_Q24

#endif

//---------------------------------------------------------------------------

//VariousUsefullConstantDefinitions:

//

#defineQGGLOBAL_Q

#defineQ3030

#defineQ2929

#defineQ2828

#defineQ2727

#defineQ2626

#defineQ2525

#defineQ2424

#defineQ2323

#defineQ2222

#defineQ2121

#defineQ2020

#defineQ1919

#defineQ1818

#defineQ1717

#defineQ1616

#defineQ1515

#defineQ1414

#defineQ1313

#defineQ1212

#defineQ1111

#defineQ1010

#defineQ99

#defineQ88

#defineQ77

#defineQ66

#defineQ55

#defineQ44

#defineQ33

#defineQ22

#defineQ11

#defineMAX_IQ_POS2147483647

#defineMAX_IQ_NEG-2147483648

#defineMIN_IQ_POS1

#defineMIN_IQ_NEG-1

//###########################################################################

#ifMATH_TYPE==IQ_MATH

//###########################################################################

//IfIQ_MATHisused,thefollowingIQmathlibraryfunctiondefinitions

//areused:

//===========================================================================

typedeflong_iq;

typedeflong_iq30;

typedeflong_iq29;

typedeflong_iq28;

typedeflong_iq27;

typedeflong_iq26;

typedeflong_iq25;

typedeflong_iq24;

typedeflong_iq23;

typedeflong_iq22;

typedeflong_iq21;

typedeflong_iq20;

typedeflong_iq19;

typedeflong_iq18;

typedeflong_iq17;

typedeflong_iq16;

typedeflong_iq15;

typedeflong_iq14;

typedeflong_iq13;

typedeflong_iq12;

typedeflong_iq11;

typedeflong_iq10;

typedeflong_iq9;

typedeflong_iq8;

typedeflong_iq7;

typedeflong_iq6;

typedeflong_iq5;

typedeflong_iq4;

typedeflong_iq3;

typedeflong_iq2;

typedeflong_iq1;

//---------------------------------------------------------------------------

#define_IQ30(A)(long)((A)*1073741824.0L)

#define_IQ29(A)(long)((A)*536870912.0L)

#define_IQ28(A)(long)((A)*268435456.0L)

#define_IQ27(A)(long)((A)*134217728.0L)

#define_IQ26(A)(long)((A)*67108864.0L)

#define_IQ25(A)(long)((A)*33554432.0L)

#define_IQ24(A)(long)((A)*16777216.0L)

#define_IQ23(A)(long)((A)*8388608.0L)

#define_IQ22(A)(long)((A)*4194304.0L)

#define_IQ21(A)(long)((A)*2097152.0L)

#define_IQ20(A)(long)((A)*1048576.0L)

#define_IQ19(A)(long)((A)*524288.0L)

#define_IQ18(A)(long)((A)*262144.0L)

#define_IQ17(A)(long)((A)*131072.0L)

#define_IQ16(A)(long)((A)*65536.0L)

#define_IQ15(A)(long)((A)*32768.0L)

#define_IQ14(A)(long)((A)*16384.0L)

#define_IQ13(A)(long)((A)*8192.0L)

#define_IQ12(A)(long)((A)*4096.0L)

#define_IQ11(A)(long)((A)*2048.0L)

#define_IQ10(A)(long)((A)*1024.0L)

#define_IQ9(A)(long)((A)*512.0L)

#define_IQ8(A)(long)((A)*256.0L)

#define_IQ7(A)(long)((A)*128.0L)

#define_IQ6(A)(long)((A)*64.0L)

#define_IQ5(A)(long)((A)*32.0L)

#define_IQ4(A)(long)((A)*16.0L)

#define_IQ3(A)(long)((A)*8.0L)

#define_IQ2(A)(long)((A)*4.0L)

#define_IQ1(A)(long)((A)*2.0L)

#ifGLOBAL_Q==30

#define_IQ(A)_IQ30(A)

#endif

#ifGLOBAL_Q==29

#define_IQ(A)_IQ29(A)

#endif

#ifGLOBAL_Q==28

#define_IQ(A)_IQ28(A)

#endif

#ifGLOBAL_Q==27

#define_IQ(A)_IQ27(A)

#endif

#ifGLOBAL_Q==26

#define_IQ(A)_IQ26(A)

#endif

#ifGLOBAL_Q==25

#define_IQ(A)_IQ25(A)

#endif

#ifGLOBAL_Q==24

#define_IQ(A)_IQ24(A)

#endif

#ifGLOBAL_Q==23

#define_IQ(A)_IQ23(A)

#endif

#ifGLOBAL_Q==22

#define_IQ(A)_IQ22(A)

#endif

#ifGLOBAL_Q==21

#define_IQ(A)_IQ21(A)

#endif

#ifGLOBAL_Q==20

#define_IQ(A)_IQ20(A)

#endif

#ifGLOBAL_Q==19

#define_IQ(A)_IQ19(A)

#endif

#ifGLOBAL_Q==18

#define_IQ(A)_IQ18(A)

#endif

#ifGLOBAL_Q==17

#define_IQ(A)_IQ17(A)

#endif

#ifGLOBAL_Q==16

#define_IQ(A)_IQ16(A)

#endif

#ifGLOBAL_Q==15

#define_IQ(A)_IQ15(A)

#endif

#ifGLOBAL_Q==14

#define_IQ(A)_IQ14(A)

#endif

#ifGLOBAL_Q==13

#define_IQ(A)_IQ13(A)

#endif

#ifGLOBAL_Q==12

#define_IQ(A)_IQ12(A)

#endif

#ifGLOBAL_Q==11

#define_IQ(A)_IQ11(A)

#endif

#ifGLOBAL_Q==10

#define_IQ(A)_IQ10(A)

#endif

#ifGLOBAL_Q==9

#define_IQ(A)_IQ9(A)

#endif

#ifGLOBAL_Q==8

#define_IQ(A)_IQ8(A)

#endif

#ifGLOBAL_Q==7

#define_IQ(A)_IQ7(A)

#endif

#ifGLOBAL_Q==6

#define_IQ(A)_IQ6(A)

#endif

#ifGLOBAL_Q==5

#define_IQ(A)_IQ5(A)

#endif

#ifGLOBAL_Q==4

#define_IQ(A)_IQ4(A)

#endif

#ifGLOBAL_Q==3

#define_IQ(A)_IQ3(A)

#endif

#ifGLOBAL_Q==2

#define_IQ(A)_IQ2(A)

#endif

#ifGLOBAL_Q==1

#define_IQ(A)_IQ1(A)

#endif

//---------------------------------------------------------------------------

externfloat_IQ30toF(longA);

externfloat_IQ29toF(longA);

externfloat_IQ28toF(longA);

externfloat_IQ27toF(longA);

externfloat_IQ26toF(longA);

externfloat_IQ25toF(longA);

externfloat_IQ24toF(longA);

externfloat_IQ23toF(longA);

externfloat_IQ22toF(longA);

externfloat_IQ21toF(longA);

externfloat_IQ20toF(longA);

externfloat_IQ19toF(longA);

externfloat_IQ18toF(longA);

externfloat_IQ17toF(longA);

externfloat_IQ16toF(longA);

externfloat_IQ15toF(longA);

externfloat_IQ14toF(longA);

externfloat_IQ13toF(longA);

externfloat_IQ12toF(longA);

externfloat_IQ11toF(longA);

externfloat_IQ10toF(longA);

externfloat_IQ9toF(longA);

externfloat_IQ8toF(longA);

externfloat_IQ7toF(longA);

externfloat_IQ6toF(longA);

externfloat_IQ5toF(longA);

externfloat_IQ4toF(longA);

externfloat_IQ3toF(longA);

externfloat_IQ2toF(longA);

externfloat_IQ1toF(longA);

#ifGLOBAL_Q==30

#define_IQtoF(A)_IQ30toF(A)

#endif

#ifGLOBAL_Q==29

#define_IQtoF(A)_IQ29toF(A)

#endif

#ifGLOBAL_Q==28

#define_IQtoF(A)_IQ28toF(A)

#endif

#ifGLOBAL_Q==27

#define_IQtoF(A)_IQ27toF(A)

#endif

#ifGLOBAL_Q==26

#define_IQtoF(A)_IQ26toF(A)

#endif

#ifGLOBAL_Q==25

#define_IQtoF(A)_IQ25toF(A)

#endif

#ifGLOBAL_Q==24

#define_IQtoF(A)_IQ24toF(A)

#endif

#ifGLOBAL_Q==23

#define_IQtoF(A)_IQ23toF(A)

#endif

#ifGLOBAL_Q==22

#define_IQtoF(A)_IQ22toF(A)

#endif

#ifGLOBAL_Q==21

#define_IQtoF(A)_IQ21toF(A)

#endif

#ifGLOBAL_Q==20

#define_IQtoF(A)_IQ20toF(A)

#endif

#ifGLOBAL_Q==19

#define_IQtoF(A)_IQ19toF(A)

#endif

#ifGLOBAL_Q==18

#define_IQtoF(A)_IQ18toF(A)

#endif

#ifGLOBAL_Q==17

#define_IQtoF(A)_IQ17toF(A)

#endif

#ifGLOBAL_Q==16

#define_IQtoF(A)_IQ16toF(A)

#endif

#ifGLOBAL_Q==15

#define_IQtoF(A)_IQ15toF(A)

#endif

#ifGLOBAL_Q==14

#define_IQtoF(A)_IQ14toF(A)

#endif

#ifGLOBAL_Q==13

#define_IQtoF(A)_IQ13toF(A)

#endif

#ifGLOBAL_Q==12

#define_IQtoF(A)_IQ12toF(A)

#endif

#ifGLOBAL_Q==11

#define_IQtoF(A)_IQ11toF(A)

#endif

#ifGLOBAL_Q==10

#define_IQtoF(A)_IQ10toF(A)

#endif

#ifGLOBAL_Q==9

#define_IQtoF(A)_IQ9toF(A)

#endif

#ifGLOBAL_Q==8

#define_IQtoF(A)_IQ8toF(A)

#endif

#ifGLOBAL_Q==7

#define_IQtoF(A)_IQ7toF(A)

#endif

#ifGLOBAL_Q==6

#define_IQtoF(A)_IQ6toF(A)

#endif

#ifGLOBAL_Q==5

#define_IQtoF(A)_IQ5toF(A)

#endif

#ifGLOBAL_Q==4

#define_IQtoF(A)_IQ4toF(A)

#endif

#ifGLOBAL_Q==3

#define_IQtoF(A)_IQ3toF(A)

#endif

#ifGLOBAL_Q==2

#define_IQtoF(A)_IQ2toF(A)

#endif

#ifGLOBAL_Q==1

#define_IQtoF(A)_IQ1toF(A)

#endif

//---------------------------------------------------------------------------

#define_IQsat(A,Pos,Neg)__IQsat(A,Pos,Neg)

//---------------------------------------------------------------------------

#define_IQtoIQ30(A)((long)(A)<<(30-GLOBAL_Q))

#define_IQ30toIQ(A)((long)(A)>>(30-GLOBAL_Q))

#define_IQtoIQ29(A)((GLOBAL_Q>=29)?

((long)(A)>>(GLOBAL_Q-29)):

((long)(A)<<(29-GLOBAL_Q)))

#define_IQ29toIQ(A)((GLOBAL_Q>=29)?

((long)(A)<<(GLOBAL_Q-29)):

((long)(A)>>(29-GLOBAL_Q)))

#d

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1