Texas Instruments Inc., 2002-2008 1
C28x IQmath Library
A Virtual Floating Point Engine
V1.5
July 8, 2008
Module user’s Guide
C28x Foundation Software
Texas Instruments Inc., 2002-2008 2
IMPORTANT NOTICE
Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or
to discontinue any product or service without notice, and advise customers to obtain the latest
version of relevant information to verify, before placing orders, that information being relied on is
current and complete. All products are sold subject to the terms and conditions of sale supplied at
the time of order acknowledgement, including those pertaining to warranty, patent infringement,
and limitation of liability.
TI warrants performance of its semiconductor products to the specifications applicable at the time
of sale in accordance with TI’s standard warranty. Testing and other quality control techniques
are utilized to the extent TI deems necessary to support this warranty. Specific testing of all
parameters of each device is not necessarily performed, except those mandated by government
requirements.
Customers are responsible for their applications using TI components.
In order to minimize risks associated with the customer’s applications, adequate design and
operating safeguards must be provided by the customer to minimize inherent or procedural
hazards.
TI assumes no liability for applications assistance or customer product design. TI does not
warrant or represent that any license, either express or implied, is granted under any patent right,
copyright, mask work right, or other intellectual property right of TI covering or relating to any
combination, machine, or process in which such products or services might be or are used. TI’s
publication of information regarding any third party’s products or services does not constitute TI’s
approval, license, warranty or endorsement thereof.
Reproduction of information in TI data books or data sheets is permissible only if reproduction is
without alteration and is accompanied by all associated warranties, conditions, limitations and
notices. Representation or reproduction of this information with alteration voids all warranties
provided for an associated TI product or service, is an unfair and deceptive business practice,
and TI is not responsible or liable for any such use.
Resale of TI’s products or services with statements different from or beyond the parameters
stated by TI for that products or service voids all express and any implied warranties for the
associated TI product or service, is an unfair and deceptive business practice, and TI is not
responsible nor liable for any such use.
Also see: Standard Terms and Conditions of Sale for Semiconductor Products.
www.ti.com/sc/docs/stdterms.htm
Mailing Address:
Texas Instruments
Post Office Box 655303
Dallas, Texas 75265
Copyright 2002, Texas Instruments Incorporated
Texas Instruments Inc., 2002-2008 3
Trademarks
TMS320 is the trademark of Texas Instruments Incorporated.
All other trademarks mentioned herein are property of their respective companies
Acronyms
C28x+FPU: Refers to devices with the C28x plus floating-point-unit.
IQmath: High Accuracy Mathematical Functions (32-bit implementation).
QMATH: Fixed Point Mathematical computation
Texas Instruments Inc., 2002-2008 4
Chapter 1. Introduction ................................................................................................ 6
1.1. Introduction..................................................................................................................... 6
Chapter 2. Installing the IQmath Library.................................................................... 7
2.1. IQmath Package Contents ............................................................................................. 7
2.2. How to Install the IQmath Library............................................................................... 8
Chapter 3. Using the IQmath Library.......................................................................... 9
3.1. IQmath Arguments and Data Types ............................................................................. 9
3.2. IQmath Data type: Range & Resolution..................................................................... 10
3.3. Calling an IQmath Function from C........................................................................... 11
3.4. Calling an IQmath function from C++ ....................................................................... 11
3.5. IQmath Section and Lookup Tables............................................................................ 12
3.6. IQmath Naming Conventions ...................................................................................... 15
3.7. Selecting the GLOBAL_Q format............................................................................... 16
3.8. Using the IQmath GEL file for Debugging................................................................. 17
3.9. Converting an IQmath Application to Floating-Point............................................... 19
3.10. The IQmath C-Calling Convention ......................................................................... 19
Chapter 4. Libraries Available.................................................................................... 20
Chapter 5. Function Summary................................................................................... 21
5.1. Arguments and Conventions Used .............................................................................. 21
5.2. IQmath Function Overview ......................................................................................... 22
Format conversion Utilities.............................................................................................. 22
Arithmetic Operations ..................................................................................................... 22
Trigonometric Functions: ................................................................................................ 23
Mathematical Functions: ................................................................................................. 23
Miscellaneous ................................................................................................................. 23
5.3. C28x IQmath Library Benchmarks ............................................................................ 24
Chapter 6. Function Descriptions .............................................................................. 26
6.1. Conversion Utilities....................................................................................................... 26
IQN.................................................................................................................................. 26
IQNtoF............................................................................................................................. 28
atoIQN............................................................................................................................. 29
IQNtoa............................................................................................................................. 30
IQNint .............................................................................................................................. 32
IQNfrac............................................................................................................................ 33
IQtoIQN ........................................................................................................................... 34
IQNtoIQ ........................................................................................................................... 35
IQtoQN ............................................................................................................................ 36
QNtoIQ ............................................................................................................................ 37
Texas Instruments Inc., 2002-2008 5
6.2. Arithmetic Operations.................................................................................................. 38
IQNmpy........................................................................................................................... 38
IQNrmpy.......................................................................................................................... 39
IQNrsmpy........................................................................................................................ 40
IQNmpyI32...................................................................................................................... 41
IQNmpyIQX..................................................................................................................... 44
IQNdiv ............................................................................................................................. 45
6.3. Trigonometric Functions.............................................................................................. 48
IQNasin ........................................................................................................................... 48
IQNsin ............................................................................................................................. 49
IQNsinPU ........................................................................................................................ 51
IQNacos .......................................................................................................................... 53
IQNcos ............................................................................................................................ 54
IQNcosPU ....................................................................................................................... 56
IQNatan2......................................................................................................................... 58
IQNatan2PU.................................................................................................................... 60
IQNatan........................................................................................................................... 62
6.4. Mathematical Utilities .................................................................................................. 63
IQNexp ............................................................................................................................ 63
IQNsqrt............................................................................................................................ 64
IQNisqrt ........................................................................................................................... 66
IQNmag........................................................................................................................... 69
6.5. Miscellaneous Utilities .................................................................................................. 70
IQNabs ............................................................................................................................ 70
IQsat................................................................................................................................ 71
Chapter 7. Revision History........................................................................................ 72