TI-DSP user guide-spru031f
770 Pages

TI-DSP user guide-spru031f

Course: EE 545, Fall 2009

School: Carnegie Mellon

Word Count: 138236

Rating:

Document Preview

TMS320C3x User's Guide Literature Number: SPRU031F 2558539-9761 revision L March 2004 IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements, and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should obtain the latest relevant information...

Unformatted Document Excerpt
Coursehero >> Pennsylvania >> Carnegie Mellon >> EE 545

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

User's TMS320C3x Guide Literature Number: SPRU031F 2558539-9761 revision L March 2004 IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements, and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should obtain the latest relevant information before placing orders and should verify that such information is current and complete. All products are sold subject to TI's terms and conditions of sale supplied at the time of order acknowledgment. TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TI's standard warranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where mandated by government requirements, testing of all parameters of each product is not necessarily performed. TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products and applications using TI components. To minimize the risks associated with customer products and applications, customers should provide adequate design and operating safeguards. TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right, or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information published by TI regarding third-party products or services does not constitute a license from TI to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI. 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. Reproduction of this information with alteration is an unfair and deceptive business practice. TI is not responsible or liable for such altered documentation. Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids all express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is not responsible or liable for any such statements. Following are URLs where you can obtain information on other Texas Instruments products and application solutions: Products Amplifiers Data Converters DSP Interface Logic Power Mgmt Microcontrollers Applications Audio Automotive Broadband Digital Control Military Optical Networking Security Telephony Video & Imaging Wireless amplifier.ti.com dataconverter.ti.com dsp.ti.com interface.ti.com logic.ti.com power.ti.com microcontroller.ti.com www.ti.com/audio www.ti.com/automotive www.ti.com/broadband www.ti.com/digitalcontrol www.ti.com/military www.ti.com/opticalnetwork www.ti.com/security www.ti.com/telephony www.ti.com/video www.ti.com/wireless Mailing Address: Texas Instruments Post Office Box 655303 Dallas, Texas 75265 Copyright 2004, Texas Instruments Incorporated Preface Read This First About This Manual This user's guide serves as an applications reference book for the TMS320C3x generation of digital signal processors (DSPs). These include the TMS320C30, TMS320C31, TMS320LC31, TMS320C32, and TMS320VC33. Throughout the book, all references to 'C3x refer collectively to the 'C30, 'C31/VC33, 'LC31 and 'C32. This book provides information to assist managers and hardware/software engineers in application development. It includes example code and hardware connections for various applications. The guide shows how to use the instructions set, the architecture, and the 'C3x interface. It presents examples for frequently used applications and discusses more involved examples and applications. It also defines the principles involved in many applications and gives the corresponding assembly language code for instructional purposes and for immediate use. Whenever the detailed explanation of the underlying theory is too extensive to be included in this manual, appropriate references are given for further information. Notational Conventions This document uses the following conventions. - Program listings, program examples, and interactive displays are shown in a special typeface. Examples use a bold version of the special typeface for emphasis; interactive displays use a bold version of the special typeface to distinguish commands that you enter from items that the system displays (such as prompts, command output, error messages, etc.). Here is a sample program listing: 0011 0012 0013 0014 0005 0005 0005 0006 0001 0003 0006 .field .field .field .even 1, 2 3, 4 6, 3 iii Notational Conventions Here is an example of a system prompt and a command that you might enter: C: csr -a /user/ti/simuboard/utilities - In syntax descriptions, the instruction, command, or directive is in bold typeface and parameters are in an italic typeface. Portions of a syntax that are in bold must be entered as shown; portions of a syntax that are in italics describe the type of information that must be entered. Here is an example of a directive syntax: .asect "section name", address The directive .asect has two parameters, indicated by section name and address. When you use .asect, the first parameter is an actual section name, enclosed in double quotes; the second parameter is an address. - Square brackets ( [ and ] ) identify an optional parameter. If you use an optional parameter, you specify the information within the brackets; you do not enter the brackets themselves. Here is an example of an instruction that has an optional parameter: LALK 16-bit constant [, shift] The LALK instruction has two parameters. The first parameter, 16-bit constant, is required. The second parameter, shift, is optional. As this syntax shows, if you use the optional second parameter, you must precede it with a comma. Square brackets are also used as part of the pathname specification for VMS pathnames; in this case, the brackets are actually part of the pathname (they are not optional). - Braces ( { and } ) indicate a list. The symbol | (read as or) separates items within the list. Here is an example of a list: { * | *+ | *- } This provides three choices: *, *+, or *-. Unless the list is enclosed in square brackets, you must choose one item from the list. - Some directives can have a varying number of parameters. For example, the .byte directive can have up to 100 parameters. The syntax for this directive is: .byte value1 [, ... , valuen ] This syntax shows that .byte has at least one value parameter, but you may supply additional value parameters, separated by commas. iv Information About Cautions / Related Documentation from Texas Instruments Information About Cautions This book contains cautions. This is an example of a caution statement. A caution statement describes a situation that could potentially damage your software or equipment. The information in a caution is provided for your protection. Please read each caution carefully. Related Documentation From Texas Instruments The following books describe the TMS320 floating-point devices and related support tools. To obtain a copy of any of these TI documents, call the Texas Instruments Literature Response Center as indicated in the section If You Need Assistance... on page vi. When ordering, please identify the book by its title and literature number. TMS320C3x General Purpose Applications User's Guide (literature number SPRU194) provides information to assist you in application development for the TMS320C3x generation of digital signal processors (DSPs). It includes example code and hardware connections for various appliances. It also defines the principles involved in many applications and gives the corresponding assembly language code for instructional purposes and for immediate use. TMS320C3x/C4x Assembly Language Tools User's Guide (literature number SPRU035) describes the assembly language tools (assembler, linker, and other tools used to develop assembly language code), assembler directives, macros, common object file format, and symbolic debugging directives for the 'C3x and 'C4x generations of devices. TMS320C3x/C4x Optimizing C Compiler User's Guide (literature number SPRU034) describes the TMS320 floating-point C compiler. This C compiler accepts ANSI standard C source code and produces TMS320 assembly language source code for the 'C3x and 'C4x generations of devices. Read This First v Related Documentation from Texas Instruments / References TMS320C3x C Source Debugger User's Guide (literature number SPRU053) tells you how to invoke the 'C3x emulator, evaluation module, and simulator versions of the C source debugger interface. This book discusses various aspects of the debugger interface, including window management, command entry, code execution, data management, and breakpoints. It also includes a tutorial that introduces basic debugger functionality. TMS320 DSP Development Support Reference Guide (literature number SPRU011) describes the TMS320 family of digital signal processors and the tools that support these devices. Included are code-generation tools (compilers, assemblers, linkers, etc.) and system integration and debug tools (simulators, emulators, evaluation modules, etc.). Also covered are available documentation, seminars, the university program, and factory repair and exchange. TMS320 Third-Party Support Reference Guide (literature number SPRU052) alphabetically lists over 100 third parties that provide various products that serve the family of TMS320 digital signal processors. A myriad of products and applications are offered--software and hardware development tools, speech recognition, image processing, noise cancellation, modems, etc. References The publications in the following reference list contain useful information regarding functions, operations, and applications of digital signal processing (DSP). These books also provide other references to many useful technical papers. The reference list is organized into categories of general DSP, speech, image processing, and digital control theory and is alphabetized by author. - General Digital Signal Processing Antoniou, Andreas, Digital Filters: Analysis and Design. New York, NY: McGraw-Hill Company, Inc., 1979. Bateman, A., and Yates, W., Digital Signal Processing Design. Salt Lake City, Utah: W. H. Freeman and Company, 1990. Brigham, E. Oran, The Fast Fourier Transform. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1974. Burrus, C.S., and Parks, T.W., DFT/FFT and Convolution Algorithms. New York, NY: John Wiley and Sons, Inc., 1984. Chassaing, R., and Horning, D., Digital Signal Processing with the TMS320C25. New York, NY: John Wiley and Sons, Inc., 1990. Digital Signal Processing Applications with the TMS320 Family, Vol. I. Texas Instruments, 1986; Prentice-Hall, Inc., 1987. vi References Digital Signal Processing Applications with the TMS320 Family, Vol. III. Texas Instruments, 1990; Prentice-Hall, Inc., 1990. Gold, Bernard, and Rader, C.M., Digital Processing of Signals. New York, NY: McGraw-Hill Company, Inc., 1969. Hamming, R.W., Digital Filters. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1977. Hutchins, B., and Parks, T., A Digital Signal Processing Laboratory Using the TMS320C25. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1990. IEEE ASSP DSP Committee (Editor), Programs for Digital Signal Processing. New York, NY: IEEE Press, 1979. Jackson, Leland B., Digital Filters and Signal Processing. Hingham, MA: Kluwer Academic Publishers, 1986. Jones, D.L., and Parks, T.W., A Digital Signal Processing Laboratory Using the TMS32010. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1987. Lim, Jae, and Oppenheim, Alan V. (Editors), Advanced Topics in Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1988. Morris, L. Robert, Digital Signal Processing Software. Ottawa, Canada: Carleton University, 1983. Oppenheim, Alan V. (Editor), Applications of Digital Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1978. Oppenheim, Alan V., and Schafer, R.W., Digital Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1975. Oppenheim, Alan V., and Schafer, R.W., Discrete-Time Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1989. Oppenheim, Alan V., and Willsky, A.N., with Young, I.T., Signals and Systems. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1983. Parks, T.W., and Burrus, C.S., Digital Filter Design. New York, NY: John Wiley and Sons, Inc., 1987. Rabiner, Lawrence R., and Gold, Bernard, Theory and Application of Digital Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1975. Treichler, J.R., Johnson, Jr., C.R., and Larimore, M.G., Theory and Design of Adaptive Filters. New York, NY: John Wiley and Sons, Inc., 1987. - Speech Gray, A.H., and Markel, J.D., Linear Prediction of Speech. New York, NY: Springer-Verlag, 1976. Jayant, N.S., and Noll, Peter, Digital Coding of Waveforms. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1984. Papamichalis, Panos, Practical Approaches to Speech Coding. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1987. Read This First vii References Parsons, Thomas., Voice and Speech Processing. New York, NY: McGraw Hill Company, Inc., 1987. Rabiner, Lawrence R., and Schafer, R.W., Digital Processing of Speech Signals. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1978. Shaughnessy, Douglas., Speech Communication. Reading, MA: AddisonWesley, 1987. - Image Processing Andrews, H.C., and Hunt, B.R., Digital Image Restoration. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1977. Gonzales, Rafael C., and Wintz, Paul, Digital Image Processing. Reading, MA: Addison-Wesley Publishing Company, Inc., 1977. Pratt, William K., Digital Image Processing. New York, NY: John Wiley and Sons, 1978. - Multirate DSP Crochiere, R.E., and Rabiner, L.R., Multirate Digital Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1983. Vaidyanathan, P.P., Multirate Systems and Filter Banks. Englewood Cliffs, NJ: Prentice-Hall, Inc. - Digital Control Theory Dote, Y., Servo Motor and Motion Control Using Digital Signal Processors. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1990. Jacquot, R., Modern Digital Control Systems. New York, NY: Marcel Dekker, Inc., 1981. Katz, P., Digital Control Using Microprocessors. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1981. Kuo, B.C., Digital Control Systems. New York, NY: Holt, Reinholt and Winston, Inc., 1980. Moroney, P., Issues in the Implementation of Digital Feedback Compensators. Cambridge, MA: The MIT Press, 1983. Phillips, C., and Nagle, H., Digital Control System Analysis and Design. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1984. - Adaptive Signal Processing Haykin, S., Adaptive Filter Theory. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1991. Widrow, B., and Stearns, S.D. Adaptive Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1985. viii References - Array Signal Processing Haykin, S., Justice, J.H., Owsley, N.L., Yen, J.L., and Kak, A.C. Array Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, Inc., 1985. Hudson, J.E. Adaptive Array Principles. New York, NY: John Wiley and Sons, 1981. Monzingo, R.A., and Miller, J.W. Introduction to Adaptive Arrays. New York, NY: John Wiley and Sons, 1980. Read This First ix If You Need Assistance If You Need Assistance . . . - World-Wide Web Sites TI Online Semiconductor Product Information Center (PIC) DSP Solutions 320 Hotline On-linet Microcontroller Home Page Networking Home Page http://www.ti.com http://www.ti.com/sc/docs/pic/home.htm http://www.ti.com/dsps http://www.ti.com/sc/docs/dsps/support.htm http://www.ti.com/sc/micro http://www.ti.com/sc/docs/network/nbuhomex.htm - North America, South America, Central America Product Information Center (PIC) (972) 644-5580 TI Literature Response Center U.S.A. (800) 477-8924 Software Registration/Upgrades (214) 638-0333 Fax: (214) 638-7742 U.S.A. Factory Repair/Hardware Upgrades (281) 274-2285 U.S. Technical Training Organization (972) 644-5580 Microcontroller Hotline (281) 274-2370 Fax: (281) 274-4203 Email: micro@ti.com Microcontroller Modem BBS (281) 274-3700 8-N-1 DSP Hotline (281) 274-2320 Fax: (281) 274-2324 Email: dsph@ti.com DSP Modem BBS (281) 274-2323 DSP Internet BBS via anonymous ftp to ftp://ftp.ti.com/pub/tms320bbs Networking Hotline Fax: (281) 274-4027 Email: TLANHOT@micro.ti.com - Europe, Middle East, Africa European Product Information Center (EPIC) Hotlines: Multi-Language Support +33 1 30 70 11 69 Deutsch +49 8161 80 33 11 or +33 1 30 70 11 68 English +33 1 30 70 11 65 Francais +33 1 30 70 11 64 Italiano +33 1 30 70 11 67 EPIC Modem BBS +33 1 30 70 11 99 European Factory Repair +33 4 93 22 25 40 Europe Customer Training Helpline Fax: +33 1 30 70 10 32 Email: epic@ti.com Fax: +49 81 61 80 40 10 - Asia-Pacific Literature Response Center +852 2 956 7288 Fax: +852 2 956 2200 Hong Kong DSP Hotline +852 2 956 7268 Fax: +852 2 956 1002 Korea DSP Hotline +82 2 551 2804 Fax: +82 2 551 2828 Korea DSP Modem BBS +82 2 551 2914 Singapore DSP Hotline Fax: +65 390 7179 Taiwan DSP Hotline +886 2 377 1450 Fax: +886 2 377 2718 Taiwan DSP Modem BBS +886 2 376 2592 Taiwan DSP Internet BBS via anonymous ftp to ftp://dsp.ee.tit.edu.tw/pub/TI/ - Japan Product Information Center +0120-81-0026 (in Japan) +03-3457-0972 or (INTL) 813-3457-0972 DSP Hotline +03-3769-8735 or (INTL) 813-3769-8735 DSP BBS via Nifty-Serve Type "Go TIASP" Fax: +0120-81-0036 (in Japan) Fax: +03-3457-1259 or (INTL) 813-3457-1259 Fax: +03-3457-7071 or (INTL) 813-3457-7071 x If You Need Assistance / Trademarks - Documentation When making suggestions or reporting errors in documentation, please include the following information that is on the title page: the full title of the book, the publication date, and the literature number. Mail: Texas Instruments Incorporated Email: comments@books.sc.ti.com Technical Documentation Services, MS 702 P.O. Box 1443 Houston, Texas 77251-1443 Note: When calling a Literature Response Center to order documentation, please specify the literature number of the book. Trademarks ABEL is a trademark of DATA I/O. CodeView, MS, MS-DOS, MS-Windows, and Presentation Manager are registered trademarks of Microsoft Corporation. DEC, Digital DX, Ultrix, VAX, and VMS are trademarks of Digital Equipment Corporation. HPGL is registered trademark of Hewlett Packard Company. Macintosh and MPW are trademarks of Apple Computer Corp. Micro Channel, OS/2, PC-DOS, and PGA are trademarks of International Business Machines Corporation. SPARC, Sun 3, Sun 4, Sun Workstation, SunView, and SunWindows are trademark of SPARC International, Inc., but licensed exclusively to Sun Microsystems, Inc. UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Limited. Read This First xi xii Contents Contents 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 A general description of the TMS320C30, TMS320C31, TMS320C32, and TMS320VC33, their key features, and typical applications. 1.1 TMS320C3x Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.1 TMS320C3x Key Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2 TMS320C30 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.3 TMS320C31/VC33 and TMS320LC31 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.4 TMS320C32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Typical Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 1-3 1-3 1-3 1-4 1-7 1.2 2 Architectural Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Functional block diagram, 'C3x design description, hardware components, device operation, and instruction set summary. 2.1 2.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Central Processing Unit (CPU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 2.2.1 Floating-Point/Integer Multiplier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 2.2.2 Arithmetic Logic Unit (ALU) and Internal Buses . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 2.2.3 Auxiliary Register Arithmetic Units (ARAUs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 CPU Primary Register File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Other Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 Memory Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13 2.5.1 RAM, ROM, and Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13 2.5.2 Memory Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17 Internal Bus Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18 External Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 2.7.1 TMS320C32 16- and 32-Bit Program Memory . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 2.7.2 TMS320C32 8-, 16-, and 32-Bit Data Memory . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21 Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 2.9.1 Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 2.9.2 Serial Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 Direct Memory Access (DMA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24 TMS320C30, TMS320C31/VC33, and TMS320C32 Differences . . . . . . . . . . . . . . . . . 2-26 xiii 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 Contents 3 CPU Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1 Description of the registers in the CPU register file. 3.1 CPU Multiport Register File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 3.1.1 Extended-Precision Registers (R7-R0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 3.1.2 Auxiliary Registers (AR7-AR0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3.1.3 Data-Page Pointer (DP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3.1.4 Index Registers (IR0, IR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3.1.5 Block Size (BK) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3.1.6 System-Stack Pointer (SP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3.1.7 Status (ST) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5 3.1.8 CPU/DMA Interrupt-Enable (IE) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 3.1.9 CPU Interrupt Flag (IF) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11 3.1.10 I/O Flag (IOF) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16 3.1.11 Repeat-Counter (RC) and Block-Repeat (RS, RE) Registers . . . . . . . . . . . . . 3-17 Other Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18 3.2.1 Program-Counter (PC) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18 3.2.2 Instruction Register (IR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18 Reserved Bits and Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19 3.2 3.3 4 Memory and the Instruction Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 Description of memory maps with explanation of instruction cache architecture, algorithm, and control bits. 4.1 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 4.1.1 Memory Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 4.1.2 Peripheral Bus Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Reset/Interrupt/Trap Vector Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14 Instruction Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19 4.3.1 Instruction-Cache Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19 4.3.2 Instruction-Cache Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21 4.3.3 Cache Control Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22 4.2 4.3 5 Data Formats and Floating-Point Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1 Description of signed and unsigned integer and floating-point formats. Discussion of floatingpoint multiplication, addition, subtraction, normalization, rounding, and conversions. 5.1 Integer Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.1 Short-Integer Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.2 Single-Precision Integer Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Unsigned-Integer Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.1 Short Unsigned-Integer Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.2 Single-Precision Unsigned-Integer Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Floating-Point Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.1 Short Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.2 TMS320C32 Short Floating-Point Format for External 16-Bit Data . . . . . . . . . 5-2 5-2 5-2 5-3 5-3 5-3 5-4 5-5 5-6 5.2 5.3 xiv Contents 5.4 5.5 5.6 5.7 5.8 5.9 5.10 5.11 Single-Precision Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7 Extended-Precision Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8 Determining the Decimal Equivalent of a TMS320C3x Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9 5.3.6 Conversion Between Floating-Point Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 Floating-Point Conversion (IEEE Std. 754) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14 5.4.1 Converting IEEE Format to 2s-Complement TMS320C3x Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15 5.4.2 Converting 2s-Complement TMS320C3x Floating-Point Format to IEEE Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21 Floating-Point Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26 Floating-Point Addition and Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-32 Normalization Using the NORM Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-37 Rounding (RND Instruction) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-39 Floating-Point to Integer Conversion (FIX Instruction) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-41 Integer to Floating-Point Conversion (FLOAT Instruction) . . . . . . . . . . . . . . . . . . . . . . . 5-43 Fast Logarithms on a Floating-Point Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-44 5.11.1 Example of Fast Logarithm on a Floating-Point Device . . . . . . . . . . . . . . . . . . 5-45 5.11.2 Points to Consider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47 5.3.3 5.3.4 5.3.5 6 Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1 Operation, encoding, and implementation of addressing modes; format descriptions; system stack management. 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 6.10 Addressing Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 Register Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3 Direct Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 Indirect Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5 Immediate Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18 PC-Relative Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19 Circular Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-21 Bit-Reversed Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-26 Aligning Buffers With the TMS320 Floating-Point DSP Assembly Language Tools . . . . 6-28 System and User Stack Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29 6.10.1 System-Stack Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29 6.10.2 Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-30 6.10.3 Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-31 7 Program Flow Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1 Software control of program flow with repeat modes and branching; interlocked operations; reset and interrupts. 7.1 Repeat Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.1 Repeat-Mode Control Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.2 Repeat-Mode Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.3 RPTB Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Contents 7-2 7-3 7-3 7-4 xv Contents 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 7.1.4 RPTS Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5 7.1.5 Repeat-Mode Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6 7.1.6 RC Register Value After Repeat Mode Completes . . . . . . . . . . . . . . . . . . . . . . . 7-7 7.1.7 Nested Block Repeats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8 Delayed Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9 Calls, Traps, and Returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11 Interlocked Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13 7.4.1 Interrupting Interlocked Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-15 7.4.2 Using Interlocked Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-15 7.4.3 Pipeline Effects of Interlocked Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19 Reset Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26 7.6.1 TMS320C30 and TMS320C31/VC33 Interrupt Vector Table . . . . . . . . . . . . . . 7-26 7.6.2 TMS320C32 Interrupt Vector Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-29 7.6.3 Interrupt Prioritization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-31 7.6.4 CPU Interrupt Control Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-32 7.6.5 Interrupt Flag Register Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-32 7.6.6 Interrupt Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-33 7.6.7 CPU Interrupt Latency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-35 7.6.8 External Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-36 DMA Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-38 7.7.1 DMA Interrupt Control Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-38 7.7.2 DMA Interrupt Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39 7.7.3 CPU/DMA Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-40 7.7.4 TMS320C3x Interrupt Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-41 7.7.5 TMS320C30 Interrupt Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-44 Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47 7.8.1 Initialization of Traps and Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47 7.8.2 Operation of Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47 Power Management Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-49 7.9.1 IDLE2 Power-Down Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-49 7.9.2 LOPOWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-51 8 Pipeline Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1 Discussion of the pipeline of operations on the TMS320C3x 8.1 8.2 Pipeline Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 Pipeline Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 8.2.1 Branch Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 8.2.2 Register Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6 8.2.3 Memory Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8 Resolving Register Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-19 Memory Access for Maximum Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-22 Clocking Memory Accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24 8.5.1 Program Fetches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24 8.5.2 Data Loads and Stores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24 8.3 8.4 8.5 xvi Contents 9 TMS320C30 and TMS320C31/VC33 External-Memory Interface . . . . . . . . . . . . . . . . . . . . . . 9-1 Description of primary and expansion interfaces for the 'C30 and 'C31/VC33; external interface timing diagrams; programmable wait-states and bank switching. 9.1 9.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2 Memory Interface Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 9.2.1 TMS320C30 Memory Interface Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 9.2.2 TMS320C31/VC33 Memory Interface Signals . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 Memory Interface Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7 9.3.1 Primary-Bus Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7 9.3.2 Expansion-Bus Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9 Programmable Wait States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10 Programmable Bank Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12 External Memory Interface Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15 9.6.1 Primary-Bus Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15 9.6.2 Expansion-Bus I/O Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-21 9.6.3 Hold Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-37 9.3 9.4 9.5 9.6 10 TMS320C32 Enhanced External Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1 Description of primary and expansion interfaces for the 'C32; external interface timing diagrams; programmable wait-states and bank switching. TMS320C32 Memory Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2 TMS320C32 Memory Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3 10.2.1 External Memory Interface Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3 10.2.2 Program Memory Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4 10.2.3 Data Memory Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-5 10.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7 10.3.1 External Interface Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7 10.3.2 Using Physical Memory Width and Data-Type Size Fields . . . . . . . . . . . . . 10-13 10.4 Programmable Wait States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-15 10.5 Programmable Bank Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17 10.6 32-Bit-Wide Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20 10.7 16-Bit-Wide Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26 10.8 8-Bit-Wide Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-32 10.9 External Ready Timing Improvement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-38 10.10 Bus Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-39 10.10.1 STRB0 and STRB1 Bus Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-39 10.10.2 IOSTRB Bus Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-42 10.10.3 Inactive Bus States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-51 11 Using the TMS320C31/VC33 and TMS320C32 Boot Loaders . . . . . . . . . . . . . . . . . . . . . . . 11-1 Description of the boot loader operations for the 'C31/VC33 and 'C32. 11.1 TMS320C31/VC33 Boot Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2 11.1.1 TMS320C31/VC33 Boot-Loader Description . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2 11.1.2 TMS320C31/VC33 Boot-Loader Mode Selection . . . . . . . . . . . . . . . . . . . . . . 11-2 Contents xvii 10.1 10.2 Contents 11.2 11.1.3 TMS320C31/VC33 Boot-Loading Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4 11.1.4 TMS320C31/VC33 Boot Data Stream Structure . . . . . . . . . . . . . . . . . . . . . . . 11-7 11.1.5 Interrupt and Trap-Vector Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11 11.1.6 TMS320C31/VC33 Boot-Loader Precautions . . . . . . . . . . . . . . . . . . . . . . . . . 11-13 TMS320C32 Boot Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14 11.2.1 TMS320C32 Boot-Loader Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14 11.2.2 TMS320C32 Boot-Loader Mode Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14 11.2.3 TMS320C32 Boot-Loading Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-15 11.2.4 TMS320C32 Boot Data Stream Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20 11.2.5 Boot-Loader Hardware Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23 11.2.6 TMS320C32 Boot-Loader Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23 12 Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1 Description of the DMA controller, timers, and serial ports. 12.1 Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2 12.1.1 Timer Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3 12.1.2 Timer Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3 12.1.3 Timer Global-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4 12.1.4 Timer-Period and Counter Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-7 12.1.5 Timer Pulse Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-7 12.1.6 Timer Operation Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-10 12.1.7 Using TCLKx as General-Purpose I/O Pins . . . . . . . . . . . . . . . . . . . . . . . . . . 12-12 12.1.8 Timer Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-13 12.1.9 Timer Initialization/Reconfiguration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-13 Serial Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-15 12.2.1 Serial-Port Global-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17 12.2.2 FSX/DX/CLKX Port-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-22 12.2.3 FSR/DR/CLKR Port-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-23 12.2.4 Receive/Transmit Timer-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-25 12.2.5 Receive/Transmit Timer-Counter Register . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-27 12.2.6 Receive/Transmit Timer-Period Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-28 12.2.7 Data-Transmit Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-28 12.2.8 Data-Receive Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-28 12.2.9 Serial-Port Operation Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-29 12.2.10 Serial-Port Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-31 12.2.11 Serial-Port Interrupt Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-34 12.2.12 Serial-Port Functional Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-35 12.2.13 Serial-Port Initialization/Reconfiguration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-41 12.2.14 TMS320C3x Serial-Port Interface Examples . . . . . . . . . . . . . . . . . . . . . . . . . 12-41 DMA Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-48 12.3.1 DMA Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-48 12.3.2 DMA Basic Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-50 12.3.3 DMA Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-51 12.3.4 CPU/DMA Interrupt-Enable Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-59 12.2 12.3 xviii Contents 12.3.5 12.3.6 12.3.7 12.3.8 12.3.9 12.3.10 12.3.11 TMS320C32 DMA Internal Priority Schemes . . . . . . . . . . . . . . . . . . . . . . . . . CPU and DMA Controller Arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DMA and Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DMA Memory Transfer Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DMA Initialization/Reconfiguration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Hints for DMA Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DMA Programming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-62 12-63 12-64 12-67 12-73 12-73 12-74 13 Assembly Language Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1 Functional listing of instructions. Condition codes defined. Alphabetized individual instruction set with examples. 13.1 Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2 13.1.1 Load and Store Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2 13.1.2 2-Operand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-3 13.1.3 3-Operand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4 13.1.4 Program-Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4 13.1.5 Low-Power Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5 13.1.6 Interlocked-Operations Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5 13.1.7 Parallel-Operations Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6 13.1.8 Illegal Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-9 Instruction Set Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-10 Parallel Instruction Set Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-17 Group Addressing Mode Instruction Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-20 13.4.1 General Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-20 13.4.2 3-Operand Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-24 13.4.3 Parallel Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-25 13.4.4 Conditional-Branch Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-27 Condition Codes and Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-28 Individual Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-32 13.6.1 Symbols and Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-32 13.6.2 Optional Assembler Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-34 13.6.3 Individual Instruction Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-37 13.2 13.3 13.4 13.5 13.6 A Instruction Opcodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1 List of the opcode fields for the TMS320C3x instructions. TMS320C31/VC33 Boot Loader Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1 TMS320C32 Boot Loader Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1 C.1 Boot-Loader Source Code Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-2 C.2 Boot-Loader Source Code Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-4 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-1 Contents xix B C D Figures Figures 1-1 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 3-1 3-2 3-3 3-4 3-5 3-6 3-7 3-8 3-9 3-10 3-11 3-12 4-1 4-2 4-3 4-4 4-5 4-6 4-7 4-8 4-9 4-10 4-11 4-12 xx TMS320C3x Devices Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 TMS320C30 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 TMS320C31/VC33 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 TMS320C32 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Central Processing Unit (CPU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 Memory Organization of the TMS320C30 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14 Memory Organization of the TMS320C31/VC33 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 Memory Organization of the TMS320C32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 TMS320C32-Supported Data Types and Sizes and External Memory Widths . . . . . . . . 2-20 Peripheral Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 DMA Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25 Extended-Precision Register Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Extended-Precision Register Integer Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Status Register (TMS320C30 andTMS320C31/VC33) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5 Status Register (TMS320C32 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5 CPU/DMA Interrupt-Enable (IE) Register (TMS320C30 and TMS320C31/VC33) . . . . . . 3-9 CPU/DMA Interrupt-Enable (IE) Register (TMS320C32) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 TMS320C30 CPU Interrupt Flag (IF) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12 TMS320C31/VC33 CPU Interrupt Flag (IF) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12 TMS320C32 CPU Interrupt Flag (IF) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12 Effective Base Address of the Interrupt-Trap Vector Table . . . . . . . . . . . . . . . . . . . . . . . . . 3-14 Interrupt and Trap Vector Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15 I/O Flag (IOF) Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16 TMS320C30 Memory Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4 TMS320C31/VC33 Memory Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6 TMS320C32 Memory Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8 TMS320C30 Peripheral Bus Memory-Mapped Registers . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 TMS320C31/VC33 Peripheral Bus Memory-Mapped Registers . . . . . . . . . . . . . . . . . . . . . 4-11 TMS320C32 Peripheral Bus Memory-Mapped Registers . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13 Reset, Interrupt, and Trap Vector Locations for the TMS320C30 Microprocessor Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15 Reset, Interrupt, and Trap Vector Locations for theTMS320C31/VC33 Microprocessor Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16 Interrupt and Trap Branch Instructions for the TMS320C31/VC33 Microcomputer Mode 4-17 Interrupt and Trap Vector Locations for TMS320C32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18 Address Partitioning for Cache Control Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19 Instruction-Cache Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20 Figures 5-1 5-2 5-3 5-4 5-5 5-6 5-7 5-8 5-9 5-10 5-11 5-12 5-13 5-14 5-15 5-16 5-17 5-18 5-19 5-20 5-21 5-22 5-23 6-1 6-2 6-3 6-4 6-5 6-6 6-7 6-8 6-9 6-10 6-11 7-1 7-2 7-3 7-4 7-5 7-6 7-7 Short-Integer Format and Sign-Extension of Short Integers . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Single-Precision Integer Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Short Unsigned-Integer Format and Zero Fill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 Single-Precision Unsigned-Integer Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 General Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 Short Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5 TMS320C32 Short Floating-Point Format for External 16-Bit Data . . . . . . . . . . . . . . . . . . . 5-6 Single-Precision Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7 Extended-Precision Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8 Converting from Short Floating-Point Format to Single-Precision Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 Converting from Short Floating-Point Format to Extended-Precision Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 Converting from Single-Precision Floating-Point Format to Extended-Precision Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-13 Converting from Extended-Precision Floating-Point Format to Single-Precision Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-13 IEEE Single-Precision Std. 754 Floating-Point Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14 TMS320C3x Single-Precision 2s-Complement Floating-Point Format . . . . . . . . . . . . . . . 5-15 Flowchart for Floating-Point Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28 Flowchart for Floating-Point Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-33 Flowchart for NORM Instruction Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-38 Flowchart for Floating-Point Rounding by the RND Instruction . . . . . . . . . . . . . . . . . . . . . 5-40 Flowchart for Floating-Point to Integer Conversion by FIX Instruction . . . . . . . . . . . . . . . 5-42 Flowchart for Integer to Floating-Point Conversion by FLOAT Instruction . . . . . . . . . . . . 5-43 Tabulated Values for Mantissa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46 Fast Logarithm for FFT Displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-48 Direct Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 Indirect Addressing Operand Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6 Encoding for 24-Bit PC-Relative Addressing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-20 Logical and Physical Representation of Circular Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-21 Logical and Physical Representation of Circular Buffer after Writing Three Values . . . . 6-21 Logical and Physical Representation of Circular Buffer after Writing Eight Values . . . . . 6-22 Circular Buffer Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23 Data Structure for FIR Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-24 System Stack Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29 Implementations of High-to-Low Memory Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-30 Implementations of Low-to-High Memory Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-31 CALL Response Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12 Multiple TMS320C3xs Sharing Global Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17 Zero-Logic Interconnect of TMS320C3x Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18 Effective Base Address of the Interrupt-Trap-Vector Table . . . . . . . . . . . . . . . . . . . . . . . . . 7-29 IF Register Modification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-33 CPU Interrupt Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-34 Interrupt Logic Functional Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-37 Contents xxi Figures 7-8 7-9 7-10 7-11 7-12 7-13 7-14 8-1 8-2 8-3 8-4 8-5 8-6 8-7 9-1 9-2 9-3 9-4 9-5 9-6 9-7 9-8 9-9 9-10 9-11 9-12 9-13 9-14 9-15 9-16 9-17 9-18 9-19 9-20 9-21 9-22 9-23 9-24 9-25 9-26 10-1 10-2 10-3 10-4 xxii DMA Interrupt Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39 Parallel CPU and DMA Interrupt Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-40 Flow of Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47 IDLE2 Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-50 Interrupt Response Timing After IDLE2 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-51 LOPOWER Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-52 MAXSPEED Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-52 TMS320C3x Pipeline Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 Minor Clock Periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24 2-Operand Instruction Word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-25 3-Operand Instruction Word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-25 Multiply or CPU Operation With a Parallel Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-29 Two Parallel Stores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-29 Parallel Multiplies and Adds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30 Memory-Mapped External Interface Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6 Primary-Bus Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7 Expansion-Bus Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9 BNKCMP Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12 Bank-Switching Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14 Read-Read-Write for (M)STRB = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-17 Write-Write-Read for (M)STRB = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-18 Use of Wait States for Read for (M)STRB = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-19 Use of Wait States for Write for (M)STRB = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20 Read and Write for IOSTRB = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-21 Read With One Wait State for IOSTRB = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-22 Write With One Wait State for IOSTRB = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-23 Memory Read and I/O Write for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-24 Memory Read and I/O Read for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-25 Memory Write and I/O Write for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-26 Memory Write and I/O Read for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-27 I/O Write and Memory Write for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-28 I/O Write and Memory Read for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-29 I/O Read and Memory Write for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-30 I/O Read and Memory Read for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-31 I/O Write and I/O Read for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-32 I/O Write and I/O Write for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-33 I/O Read and I/O Read for Expansion Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-34 Inactive Bus States for IOSTRB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-35 Inactive Bus States for STRB and MSTRB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36 HOLD and HOLDA Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-37 Memory Address Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4 Status Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-5 Memory-Mapped External Interface Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7 STRB0 Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8 Figures 10-5 10-6 10-7 10-8 10-9 10-10 10-11 10-12 10-13 10-14 10-15 10-16 10-17 10-18 10-19 10-20 10-21 10-22 10-23 10-24 10-25 10-26 10-27 10-28 10-29 10-30 10-31 10-32 10-33 10-34 10-35 10-36 10-37 10-38 10-39 10-40 10-41 10-42 11-1 11-2 11-3 11-4 STRB1 Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8 IOSTRB Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-9 STRB Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13 BNKCMP Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17 Bank-Switching Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18 TMS320C32 External Memory Interface for 32-Bit SRAMs . . . . . . . . . . . . . . . . . . . . . . . 10-20 Functional Diagram for 8-Bit Data-Type Size and 32-Bit External-Memory . . . . . . . . . . . . . . . . Width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-21 Functional Diagram for 16-Bit Data-Type Size and 32-Bit External-Memory . . . . . . . . . . . . . Width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23 Functional Diagram for 32-Bit Data Size and 32-Bit External-Memory Width . . . . . . . . 10-24 External-Memory Interface for 16-Bit SRAMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26 Functional Diagram for 8-Bit Data-Type Size and 16-Bit External-Memory Width . . . . 10-27 Functional Diagram for 16-Bit Data-Type Size and 16-Bit External-Memory Width . . . . . 10-29 Functional Diagram for 32-Bit Data-Type Size and 16-Bit External-Memory Width . . . . . 10-30 External Memory Interface for 8-Bit SRAMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-32 Functional Diagram for 8-Bit Data-Type Size and 8-Bit External-Memory Width . . . . . . 10-33 Functional Diagram for 16-Bit Data-Type Size and 8-Bit External-Memory Width . . . . 10-34 Functional Diagram for 32-Bit Data-Type Size and 8-Bit External-Memory Width . . . . 10-36 RDY Timing for Memory Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-38 Read-Read-Write Sequence for STRBx Active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-40 Write-Write-Read Sequence for STRBx Active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-40 One Wait-State Read Sequence for STRBx Active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-41 One Wait-State Write Sequence for STRBx Active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-42 Zero Wait-State Read and Write Sequence for IOSTRB Active . . . . . . . . . . . . . . . . . . . . 10-43 One Wait-State Read Sequence for IOSTRB Active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-44 One Wait-State Write Sequence for IOSTRB Active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-44 STRBx Read and IOSTRB Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-45 STRBx Read and IOSTRB Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-45 STRBx Write and IOSTRB Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-46 STRBx Write and IOSTRB Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-46 IOSTRB Write and STRBx Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-47 IOSTRB Write and STRBx Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-48 IOSTRB Read and STRBx Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-48 IOSTRB Read and STRBx Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-49 IOSTRB Write and Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-50 IOSTRB Write and Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-50 IOSTRB Read and Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-51 Inactive Bus States Following IOSTRB Bus Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-51 Inactive Bus States Following STRBx Bus Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-52 TMS320C31/VC33 Boot-Loader Mode-Selection Flowchart . . . . . . . . . . . . . . . . . . . . . . . . 11-3 Boot-Loader Memory-Load Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5 Boot-Loader Serial-Port Load-Mode Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6 TMS320C32 Boot-Loader Mode-Selection Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17 Contents xxiii Figures 11-5 11-6 11-7 11-8 12-1 12-2 12-3 12-4 12-5 12-6 12-7 12-8 12-9 12-10 12-11 12-12 12-13 12-14 12-15 12-16 12-17 12-18 12-19 12-20 12-21 12-22 12-23 12-24 12-25 12-26 12-27 12-28 12-29 12-30 12-31 12-32 12-33 12-34 12-35 12-36 12-37 12-38 12-39 12-40 xxiv Boot-Loader Serial-Port Load Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18 Boot-Loader Memory-Load Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-19 Handshake Data-Transfer Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20 External Memory Interface for Source Data Stream Memory Boot Load . . . . . . . . . . . . 11-23 Timer Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2 Memory-Mapped Timer Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4 Timer Global-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4 Timer Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-8 Timer Configuration with CLKSRC = 1 and FUNC = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-10 Timer Configuration with CLKSRC = 1 and FUNC = 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-11 Timer Configuration with CLKSRC = 0 and FUNC = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-11 Timer Configuration with CLKSRC = 0 and FUNC = 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-12 TCLK as an Input (I/O = 0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-12 TCLK as an Output (I/O = 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-12 Serial Port Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-16 Memory-Mapped Locations for the Serial Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17 Serial-Port Global-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-18 FSX/DX/CLKX Port-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-22 FSR/DR/CLKR Port-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-23 Receive/Transmit Timer-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-25 Receive/Transmit Timer-Counter Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-27 Receive/Transmit Timer-Period Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-28 Transmit Buffer Shift Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-28 Receive Buffer Shift Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-29 Serial-Port Clocking in I/O Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-30 Serial-Port Clocking in Serial-Port Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-31 Data Word Format in Handshake Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-33 Single 0 Sent as an Acknowledge Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-33 Direct Connection Using Handshake Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-34 Fixed Burst Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-36 Fixed Standard Mode With Back-to-Back Frame Sync . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-37 Fixed Continuous Mode Without Frame Sync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-38 Exiting Fixed Continuous Mode Without Frame Sync, FSX Internal . . . . . . . . . . . . . . . . 12-39 Variable Burst Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-39 Variable Standard Mode With Back-to-Back Frame Syncs . . . . . . . . . . . . . . . . . . . . . . . . 12-40 Variable Continuous Mode Without Frame Sync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-41 TMS320C3x Zero-Glue-Logic Interface to TLC320C4x Example . . . . . . . . . . . . . . . . . . 12-45 DMA Basic Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-51 Memory-Mapped Locations for DMA Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-52 TMS320C30 and TMS320C31/VC33 DMA Global-Control Register . . . . . . . . . . . . . . . . 12-53 TMS320C32 DMA0 Global-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-53 TMS320C32 DMA1 Global-Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-53 DMA Controller Address Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-57 Transfer-Counter Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-59 Figures 12-41 12-42 12-43 12-44 12-45 12-46 12-47 12-48 12-49 13-1 13-2 13-3 13-4 13-5 13-6 C-1 TMS320C30 and TMS320C31/VC33 CPU/DMA Interrupt-Enable Register . . . . . . . . . . 12-60 TMS320C32 CPU/DMA Interrupt-Enable Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-60 Mechanism for No DMA Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-65 Mechanism for DMA Source Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-66 Mechanism for DMA Destination Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-66 Mechanism for DMA Source and Destination Synchronization . . . . . . . . . . . . . . . . . . . . 12-67 DMA Timing When Destination is On Chip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-69 DMA Timing When Destination is an STRB, STRB0, STRB1, MSTRB Bus . . . . . . . . . . 12-70 DMA Timing When Destination is an IOSTRB Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-72 Encoding for General Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-21 Encoding for 3-Operand Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-25 Encoding for Parallel Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-25 Encoding for Extended Parallel Addressing Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . 13-26 Encoding for Conditional-Branch Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-27 Status Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-29 Boot-Loader Flow Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-3 Contents xxv Tables Tables 1-1 1-2 2-1 2-2 3-1 3-2 3-3 3-4 3-5 4-1 5-1 5-2 5-3 6-1 6-2 6-3 7-1 7-2 7-3 7-4 7-5 7-6 7-7 7-8 7-9 7-10 8-1 8-2 9-1 9-2 9-3 9-4 9-5 9-6 10-1 xxvi TMS320C30, TMS320C31/VC33, TMS320LC31, and TMS320C32 Comparison . . . . . . 1-5 Typical Applications of the TMS320 Family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 Primary CPU Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Feature Set Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27 CPU Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Status Register Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6 IE Bits and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10 IF Bits and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13 IOF Bits and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16 Combined Effect of the CE and CF Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23 Converting IEEE Format to 2s-Complement Floating-Point Format . . . . . . . . . . . . . . . . . 5-15 Converting 2s-Complement Floating-Point Format to IEEE Format . . . . . . . . . . . . . . . . . 5-21 Squaring Operation of F0 = 1.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-45 CPU Register Address/Assembler Syntax and Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3 Indirect Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7 Index Steps and Bit-Reversed Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27 Repeat-Mode Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2 Interlocked Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13 TMS320C3x Pin Operation at Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21 Reset, Interrupt, and Trap-Vector Locations for the TMS320C30/TMS320C31/VC33 Microprocessor Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-27 Reset, Interrupt, and Trap-Branch Locations for the TMS320C31/VC33 Microcomputer Boot Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-28 Interrupt and Trap-Vector Locations for the TMS320C32 . . . . . . . . . . . . . . . . . . . . . . . . . . 7-30 Reset and Interrupt Vector Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-31 Interrupt Latency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-36 Pipeline Operation with PUSH ST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-42 Pipeline Operation with Load Followed by Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-42 One Program Fetch and One Data Access for Maximum Performance . . . . . . . . . . . . . . 8-22 One Program Fetch and Two Data Accesses for Maximum Performance . . . . . . . . . . . . 8-23 Primary Bus Interface Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-4 Expansion Bus Interface Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5 Primary-Bus Control Register Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8 Expansion-Bus Control Register Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9 Wait-State Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11 BNKCMP and Bank Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12 STRB0, STRB1, and IOSTRB Control Register Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10 Tables 10-2 10-3 10-4 10-5 10-6 10-7 10-8 10-9 10-10 10-11 10-12 10-13 10-14 10-15 10-16 11-1 11-2 11-3 11-4 11-5 11-6 11-7 11-8 12-1 12-2 12-3 12-4 12-5 12-6 12-7 12-8 13-1 13-2 13-3 13-4 13-5 13-6 13-7 13-8 13-9 13-10 13-11 13-12 13-13 13-14 A-1 Data-Access Sequence for a Memory Configuration with Two Banks . . . . . . . . . . . . . . . 10-14 Wait-State Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-16 BNKCMP and Bank Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17 Strobe Byte-Enable for 32-Bit-Wide Memory With 8-Bit Data-Type Size . . . . . . . . . . . . 10-21 Example of 8-Bit Data-Type Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-22 Strobe Byte-Enable for 32-Bit-Wide Memory With 16-Bit Data-Type Size . . . . . . . . . . . 10-22 Example of 16-Bit Data-Type Size and 32-Bit-Wide External Memory . . . . . . . . . . . . . . 10-23 Example of 32-Bit-Wide Memory With 32-Bit Data-Type Size . . . . . . . . . . . . . . . . . . . . . 10-25 Strobe-Byte Enable Behavior for 16-Bit-Wide Memory with 8-Bit Data-Type Size . . . . 10-27 Example of 8-Bit Data-Type Size and 16-Bit-Wide External Memory . . . . . . . . . . . . . . . 10-28 Example of 16-Bit-Wide Memory With 16-Bit Data-Type Size . . . . . . . . . . . . . . . . . . . . . 10-29 Example of 16-Bit-Wide Memory With 32-Bit Data-Type Size . . . . . . . . . . . . . . . . . . . . . 10-31 Example of 8-Bit-Wide Memory With 8-Bit Data-Type Size . . . . . . . . . . . . . . . . . . . . . . . . 10-33 Example of 8-Bit-Wide Memory With 16-Bit Data-Type Size . . . . . . . . . . . . . . . . . . . . . . . 10-35 Example of 32-Bit Data-Type Size and 8-Bit-Wide Memory . . . . . . . . . . . . . . . . . . . . . . . 10-37 Boot-Loader Mode Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3 Source Data Stream Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8 Byte-Wide Configured Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9 16-Bit-Wide Configured Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10 32-Bit-Wide Configured Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10 TMS320C31/VC33 Interrupt and Trap Memory Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12 Boot-Loader Mode Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-15 Source Data Stream Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-21 Timer Global-Control Register Bits Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-5 Serial-Port Global-Control Register Bits Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-18 FSX/DX/CLKX Port-Control Register Bits Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-22 FSR/DR/CLKR Port-Control Register Bits Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-24 Receive/Transmit Timer-Control Register Register Bits Summary . . . . . . . . . . . . . . . . . 12-25 DMA Global-Control Register Bits Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-54 CPU/DMA Interrupt-Enable Register Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-61 TMS320C32 DMA PRI Bits and CPU/DMA Arbitration Rules . . . . . . . . . . . . . . . . . . . . . . 12-64 Load and Store Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2 2-Operand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-3 3-Operand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4 Program-Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5 Low-Power Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5 Interlocked-Operations Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6 Parallel Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6 Instruction Set Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-10 Parallel Instruction Set Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-17 Indirect Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-22 Output Value Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-28 Condition Codes and Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-30 Instruction Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-33 CPU Register Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-36 TMS320C3x Instruction Opcodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2 Contents xxvii Examples Examples 4-1 5-1 5-2 5-3 5-4 5-5 5-6 5-7 5-8 5-9 5-10 5-11 5-12 5-13 5-14 5-15 5-16 5-17 6-1 6-2 6-3 6-4 6-5 6-6 6-7 6-8 6-9 6-10 6-11 6-12 6-13 6-14 6-15 6-16 6-17 6-18 xxviii Pipeline Effects of Modifying the Cache Control Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23 Positive Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10 Negative Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11 Fractional Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11 IEEE-to-TMS320C3x Conversion (Fast Version) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17 IEEE-to-TMS320C3x Conversion (Complete Version) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19 TMS320C3x-to-IEEE Conversion (Fast Version) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22 TMS320C3x-to-IEEE Conversion (Complete Version) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24 Floating-Point Multiply (Both Mantissas = -2.0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29 Floating-Point Multiply (Both Mantissas = 1.5) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30 Floating-Point Multiply (Both Mantissas = 1.0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30 Floating-Point Multiply Between Positive and Negative Numbers . . . . . . . . . . . . . . . . . . . 5-31 Floating-Point Multiply by 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31 Floating-Point Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-34 Floating-Point Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-35 Floating-Point Addition With a 32-Bit Shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-35 Floating-Point Addition/Subtraction With Floating-Point 0 . . . . . . . . . . . . . . . . . . . . . . . . . 5-36 NORM Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-37 Direct Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 Auxiliary Register Indirect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5 Indirect Addressing With Predisplacement Add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9 Indirect Addressing With Predisplacement Subtract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9 Indirect Addressing With Predisplacement Add and Modify . . . . . . . . . . . . . . . . . . . . . . . . 6-10 Indirect Addressing With Predisplacement Subtract and Modify . . . . . . . . . . . . . . . . . . . . 6-10 Indirect Addressing With Postdisplacement Add and Modify . . . . . . . . . . . . . . . . . . . . . . . 6-11 Indirect Addressing With Postdisplacement Subtract and Modify . . . . . . . . . . . . . . . . . . . 6-11 Indirect Addressing With Postdisplacement Add and Circular Modify . . . . . . . . . . . . . . . . 6-12 Indirect Addressing With Postdisplacement Subtract and Circular Modify . . . . . . . . . . . . 6-12 Indirect Addressing With Preindex Add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13 Indirect Addressing With Preindex Subtract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13 Indirect Addressing With Preindex Add and Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-14 Indirect Addressing With Preindex Subtract and Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-14 Indirect Addressing With Postindex Add and Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15 Indirect Addressing With Postindex Subtract and Modify . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15 Indirect Addressing With Postindex Add and Circular Modify . . . . . . . . . . . . . . . . . . . . . . . 6-16 Indirect Addressing With Postindex Subtract and Circular Modify . . . . . . . . . . . . . . . . . . . 6-16 Examples 6-19 6-20 6-21 6-22 6-23 6-24 6-25 6-26 7-1 7-2 7-3 7-4 7-5 7-6 7-7 7-8 7-9 7-10 7-11 7-12 7-13 7-14 7-15 8-1 8-2 8-3 8-4 8-5 8-6 8-7 8-8 8-9 8-10 8-11 8-12 8-13 8-14 8-15 8-16 8-17 8-18 12-1 12-2 Indirect Addressing With Postindex Add and Bit-Reversed Modify . . . . . . . . . . . . . . . . . . 6-17 Short-Immediate Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18 Long-Immediate Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18 PC-Relative Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19 Examples of Formula 2K > R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-22 Circular Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-24 FIR Filter Code Using Circular Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-25 Bit-Reversed Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27 Repeat-Mode Control Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4 RPTB Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4 Incorrectly Placed Standard Branch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6 Incorrectly Placed Delayed Branch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7 Pipeline Conflict in an RPTB Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7 Incorrectly Placed Delayed Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10 Delayed Branch Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10 Busy-Waiting Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16 Multiprocessor Counter Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16 Implementation of V(S) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18 Implementation of P(S) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18 Code to Synchronize Two TMS320C3x Devices at the Software Level . . . . . . . . . . . . . . 7-19 Pipeline Delay of XF Pin Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20 Incorrect Use of Interlocked Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20 Pending Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43 Standard Branch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5 Delayed Branch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6 Write to an AR Followed by an AR for Address Generation . . . . . . . . . . . . . . . . . . . . . . . . . 8-7 A Read of ARs Followed by ARs for Address Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8 Program Wait Until CPU Data Access Completes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10 Program Wait Due to Multicycle Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-11 Multicycle Program Memory Fetches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12 Single Store Followed by Two Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-13 Parallel Store Followed by Single Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14 Interlocked Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15 Busy External Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16 Multicycle Data Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17 Conditional Calls and Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18 Address Generation Update of an AR Followed by an AR for Address Generation . . . . 8-19 Write to an AR Followed by an AR for Address Generation Without a Pipeline Conflict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20 Write to DP Followed by a Direct Memory Read Without a Pipeline Conflict . . . . . . . . . . 8-21 Dummy sr2 Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-27 Operand Swapping Alternative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-28 Timer Output Generation Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-9 Maximum Frequency Timer Clock Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-14 Contents xxix Examples 12-3 12-4 12-5 12-6 12-7 12-8 12-9 12-10 Serial-Port Register Setup #1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Serial-Port Register Setup #1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Serial-Port Register Setup #2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CPU Transfer With Serial Port Transmit Polling Method . . . . . . . . . . . . . . . . . . . . . . . . . . TMS320C3x Zero-Glue-Logic Interface to Burr Brown A/D and D/A . . . . . . . . . . . . . . . . Array Initialization With DMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DMA Transfer With Serial-Port Receive Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DMA Transfer With Serial-Port Transmit Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-42 12-43 12-43 12-44 12-46 12-75 12-76 12-77 xxx Chapter 1 Introduction The TMS320C3x generation of digital signal processors (DSPs) are highperformance CMOS 32-bit floating-point devices in the TMS320 family of single-chip DSPs. The 'C3x generation integrates both system control and math-intensive functions on a single controller. This system integration allows fast, easy data movement and high-speed numeric processing performance. Extensive internal busing and a powerful DSP instruction set provide the devices with the speed and flexibility to execute at up to 60 million floating-point operations per second (MFLOPS). The devices also feature a high degree of on-chip parallelism that allows users to perform up to 11 operations in a single instruction. Topic 1.1 1.2 Page TMS320C3x Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Typical Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 1-1 TMS320C3x Devices 1.1 TMS320C3x Devices The 'C3x family consists of three members: the 'C30, 'C31, 'C32, and 'VC33. The 'C30, 'C31, 'C32, and 'VC33 can perform parallel multiply and arithmetic logic unit (ALU) operations on integer or floating-point data in a single cycle. The processors also possess the following features for high performance and ease of use: Note: VC33 The TMS320VC33 is logically and functionally a superset of the TMS320C31 making nearly all literature and documentation for the TMS320C31 applica- ble. However, the electrical characteristics are different and are covered in detail in the TMS320VC33 data sheet (literature number SPRS087). - General-purpose register file - Program cache - Dedicated auxiliary register arithmetic units (ARAU) - Internal dual-access memories - One direct memory access (DMA) channel (a two-channel DMA on the TMS320C32) supporting concurrent I/O - Short machine-cycle time General-purpose applications are greatly enhanced by the large address space, multiprocessor interface, internally and externally generated wait states, two external interface ports (one on the 'C31 and the 'C32) two timers, two serial ports (one on the 'C31, 'VC33, and the 'C32), and multiple-interrupt structure. The 'C3x supports a wide variety of system applications from host processor to dedicated coprocessor. High-level language is implemented more easily through a register-based architecture, large address space, powerful addressing modes, flexible instruction set, and well-supported floating-point arithmetic. Figure 1-1 shows a block diagram of 'C3x devices. 1-2 TMS320C3x Devices Figure 1-1. TMS320C3x Devices Block Diagram Program cache (64x32) RAM block 0 1Kx32 ('C30 'C31) 256x32 ('C32) RAM block 1 1Kx32 ('C30 'C31) 256x32 ('C32) ROM 4Kx32 ('C30) boot ('C31 'C32) Primary port memory interface Data access 32 bit ('C30 'C31) 8/16/32 bit ('C32) Program access 32 bit ('C30 'C31) 16/32 bit ('C32) CPU Integer and Integer and floating point floating point multiplier multiplier 8 extended precision registers Controller 8 auxiliary registers 2 index registers Address generation 0 Address generation 1 DMA coprocessor DMA channel 0 DMA channel 1 ('C32) Timer 0 Timer 1 Serial port 0 TCLK0 TCLK1 CLKX0 DX0 FSX0 CLKR0 DR0 FSR0 CLKX1 DX1 FSX1 CLKR1 DR1 FSR1 RDY HOLD HOLDA STRB ('C30 'C31) R/W D31 0 A23 0 STRB0_B3 0 ('C32) STRB1_B3 0 ('C32) IOSTRB ('C32) PRGW ('C32) Expansion port ('C30) memory interface IOSTRB XRDY XD31 0 XA12 0 MSTRB RESET INT3 3 IACK XF1 0 H1 H3 MCBL/MP X2/CLKIN VDD VSSSHZE MU6 0 X1 32 bit data access 32 bit program access 12 control registers 2 low power modes ('C31 'C32) Serial port 1 ('C30) 1.1.1 TMS320C3x Key Specifications The key specifications of the 'C3x devices include the following: - Performance up to 60 MFLOPS Highly efficient C language engine Large address space: 16M words 32 bits Fast memory management with on-chip DMA Industry-exclusive 3-V versions available on some devices 1.1.2 TMS320C30 The 'C30 is the first member of the 'C3x generation. It differs from the 'C31/VC33 and 'C32 by offering 4K ROM, 2K RAM, a second serial port, and a second external bus. 1.1.3 TMS320C31 and TMS320LC31 The 'C31 and 'LC31 are the second members of the 'C3x generation. They are low-cost 32-bit floating-point DSPs which have a boot-loader program, 2K RAM, single external port, single serial port, and are available in 3.3-V operation ('LC31). Introduction 1-3 TMS320C3x Devices 1.1.4 TMS320C32 The 'C32 is the newest member of the 'C3x generation. They are enhanced versions of the 'C3x family and the lowest cost floating-point processors on the market today. These enhancements include a variable-width memory interface, two-channel DMA coprocessor with configurable priorities, flexible boot loader, and a relocatable interrupt vector table. 1.1.5 TMS320VC33 The .VC33 is the fourth member of the .C3x generation. This is a low-cost 32-bit floating-point DSPs which has a boot-loader program, 34K RAM, single external port, single serial port, and is fabricated in an ultra-low power (3.3-V/1.8-V) CMOS process. 1-4 Table 1-1. TMS320C30, TMS320C31, TMS320LC31, and TMS320C32 Comparison Memory (words) On-Chip Peripherals Serial Temperature 0 to 85 (commercial) 2 1 2 181 PGA DMA Channels Timers Package Type Cycle Time (ns) RAM 2K 4K 64 16M 32 8K 32 16M 32 8K 32 16M 32 8K 32 16M 32 8K 32 16M 32 1 1 2 2 1 2 2 1 2 181 PGA 208 PQFP 181 PGA 208 PQFP 132 PQFP 2 1 2 181 PGA ROM Cache Parallel 75 Off-Chip Device Name Freq (MHz) 27 33 60 2K 4K 64 'C30 50 2K 4K 64 0 to 85 (commercial) -55 to 125 (military) 0 to 85 (commercial) (5 V) 40 2K 4K 64 40 50 0 to 85 (commercial) 27 75 2K Boot loader 64 0 to 85 (commercial) -55 to 125 (military) 2 132 PQFP 0 to 85 (commercial) -40 to 125 (extended) -55 to 125 (military) 33 60 2K Boot loader 64 16M 32 1 1 'C31 50 2K Boot loader 64 16M 32 1 40 1 2 132 PQFP (5 V) 40 2K Boot loader 64 16M 32 1 1 2 132 PQFP 0 to 85 (commercial) -40 to 125 (extended) -55 to 125 (military) 0 to 85 (commercial) -40 to 125 (extended) 50 60 33 2K Boot loader 64 16M 32 1 1 2 132 PQFP 0 to 85 (commercial) -40 to 125 (extended) 16M 16M 32 32 1 1 1 1 2 2 132 PQFP 132 PQFP 0 to 85 (commercial) 0 to 85 (commercial) 'LC31 50 2K Boot loader 64 33 60 2K Boot loader 64 Introduction (3.3 V) 40 TMS320C3x Devices 1-5 1-6 Memory (words) On-Chip Peripherals Serial Temperature 0 to 85 (commercial) -40 to 125 (extended) 1 2 2 144 PQFP DMA Channels Timers Package Type Off-Chip Table 1-1. TMS320C30, TMS320C31, TMS320LC31, and TMS320C32 Comparison (Continued) TMS320C3x Devices Device Name RAM 512 Boot loader 64 16M 32/16/8 ROM Cache Parallel 50 Freq (MHz) Cycle Time (ns) 40 'C32 40 512 Boot loader 64 16M 32/16/8 1 2 2 144 PQFP 50 (5 V) 33 512 Boot loader 64 16M 32/16/8 1 2 2 144 PQFP 0 to 85 (commercial) -40 to 125 (extended) -55 to 125 (military) 0 to 85 (commercial) 60 Typical Applications 1.2 Typical Applications The TMS320 family's versatility, realtime performance, and multiple functions offer flexible design approaches in a variety of applications, which are shown in Table 1-2. Table 1-2. Typical Applications of the TMS320 Family General-Purpose DSP Digital filtering Convolution Correlation Hilbert transforms Fast Fourier transforms Adaptive filtering Windowing Waveform generation Voice/Speech Voice mail Speech vocoding Speech recognition Speaker verification Speech enhancement Speech synthesis Text-to-speech Neural networks Telecommunications Echo cancellation ADPCM transcoders Digital PBXs Line repeaters Channel multiplexing Modems Adaptive equalizers DTMF encoding/decoding Data encryption Consumer Radar detectors Power tools Digital audio/TV Music synthesizer Toys and games Solid-state answering Machines FAX Cellular telephones Speaker phones Digital speech Interpolation (DSI) X.25 packet switching Video conferencing Spread spectrum Communications Industrial Robotics Numeric control Security access Power line monitors Visual inspection Lathe control CAM Graphics/Imaging 3-D transformations rendering Robot vision Image transmission/compression Pattern recognition Image enhancement Homomorphic processing Workstations Animation/digital map Bar-code scanners Control Disk control Servo control Robot control Laser printer control Engine control Motor control Kalman filtering Instrumentation Spectrum analysis Function generation Pattern matching Seismic processing Transient analysis Digital filtering Phase-locked loops Military Secure communications Radar processing Sonar processing Image processing Navigation Missile guidance Radio frequency modems Sensor fusion Automotive Engine control Vibration analysis Antiskid brakes Anticollision Adaptive ride control Global positioning Navigation Voice commands Digital radio Cellular telephones Medical Hearing aids Patient monitoring Ultrasound equipment Diagnostic tools Prosthetics Fetal monitors MR imaging Introduction Introduction 1-7 1-8 Chapter 2 Architectural Overview This chapter provides an architectural overview of the 'C3x processor. It includes a discussion of the CPU, memory interface, boot loader, peripherals, and direct memory access (DMA) of the 'C3x processor. Topic 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 Page Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Central Processing Unit (CPU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 CPU Primary Register File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Other Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 Memory Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13 Internal Bus Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18 External Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21 Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 2.10 Direct Memory Access (DMA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24 2.11 TMS320C30, TMS320C31/VC33, and TMS320C32 Differences . . . . 2-26 2-1 Overview 2.1 Overview The 'C3x architecture responds to system demands that are based on sophisticated arithmetic algorithms that emphasize both hardware and software solutions. High performance is achieved through the precision and wide dynamic range of the floating-point units, large on-chip memory, a high degree of parallelism, and the DMA controller. Note: VC33 The TMS320VC33 is logically and functionally a superset of the TMS320C31 making nearly all literature and documentation for the TMS320C31 applica- ble. However, the electrical characteristics are different and are covered in detail in the TMS320VC33 data sheet (literature number SPRS087). Figure 2-1 through Figure 2-3 show functional block diagrams of the 'C30, 'C31/VC33, and 'C32 architectures, respectively. 2-2 Overview Figure 2-1. TMS320C30 Block Diagram Cache (64 32) 32 24 24 32 24 32 24 PDATA bus PADDR bus RDY HOLD HOLDA STRB R/W D31-D0 A23-A0 Multiplexer DADDR1 bus DADDR2 bus DMADATA bus DMAADDR bus 32 24 32 24 24 32 24 DMA controller Global-control register Multiplexer Multiplexer DDATA bus Serial port 0 Port-control register R/X timer register Data-transmit register Data-receive register FSX0 DX0 CLKX0 FSR0 DR0 CLKR0 IR PC RESET INT3-0 IACK MC/MP XF(1,0) VDD(3-0) IODVDD(1,0) ADVDD(1,0) PDVDD DDVDD(1,0) MDVDD VSS(3-0) DVSS(3-0) CVSS(1,0) IVSS VBBP SUBS X1 X2/CLKIN H1 H3 EMU6-0 RSV10-0 SHZ CPU1 CPU2 REG1 REG2 REGISTER 1 REGISTER2 CPU1 32 32 Multiplier 40 40 40 32 Extendedprecision registers (R7-R0) DISP0, IR0, IR1 ARAU0 ARAU1 40 40 32-bit barrel shifter ALU 40 40 Source-address register Destinationaddress register Transfercounter register Peripheral Data Bus 40 BK 24 24 32 32 Legend: PDATA bus - program data bus PADDR bus - program address bus DDATA bus - data data bus DADDR1 bus - data address 1 bus DADDR2 bus - data address 2 bus 32 32 24 Auxiliary registers (AR0-AR7) 24 32 Other registers (12) 32 Architectural Overview Serial port 1 Port-control register R/Xtimer register Peripheral Address Bus Controller Data-transmit register Data-receive register Timer0 Global-control register Timer-period register Timer-counter register Timer1 Global-control register Timer-period register Timer-counter register Port control Primary Expansion TCLK1 FSX1 DX1 CLKX1 FSR1 DR1 CLKR1 TCLK0 32 RAM block 0 (1K 32) RAM block 1 (1K 32) ROM block (4K 32) XRDY MSTRB IOSTRB XR/W XD31-XD0 XA12-XA0 2-3 Overview Figure 2-2. TMS320C31 Block Diagram Cache (64 32) RAM block 0 (1K 32) RAM block 1 (1K 32) 32 24 24 32 24 32 24 PDATA bus PADDR bus RDY Multiplexer HOLD HOLDA STRB R/W D31- D0 A23 - A0 DDATA bus DADDR1 bus DADDR2 bus DMADATA bus DMAADDR bus 32 24 32 24 24 32 24 DMA controller Serial port 0 Global-control register Serial-port control register Receive/transmit timer register Data-transmit register Peripheral Address Bus Peripheral Data Bus Data-receive register FSX0 DX0 CLKX0 FSR0 DR0 CLKR0 Multiplexer IR PC RESET INT(3 - 0) IACK MCBL / MP XF(1,0) VDD(19 - 0) VSS(24 - 0) CPU1 CPU2 REG1 REG2 Controller CPU1 REG1 REG2 32 32 40 40 32-bit barrel shifter ALU Source-address register Destinationaddress register Transfercounter register Multiplier SHZ X1 X2 / CLKIN H1 H3 EMU(3 - 0) Multiplexer MUX 40 40 40 32 40 Extendedprecision registers (R7-R0) 40 DISP0, IR0, IR1 Global-control register ARAU0 BK ARAU1 Timer-period register 24 Auxiliary registers (AR0 - AR7) 24 Port Control 32 32 32 Other registers (12) 32 Primary STRBcontrol register Timer-counter register TCLK1 24 Legend: PDATA bus - program data bus PADDR bus - program address bus DDATA bus - data data bus DADDR1 bus - data address 1 bus DADDR2 bus - data address 2 bus 24 32 32 2-4 Boot loader 32 Timer0 Global-control register Timer-period register Timer-counter register Timer1 TCLK0 40 Overview Figure 2-3. TMS320C32 Block Diagram 32 24 32 IR PC 24 RESET INT(3-0) IACK XF(1,0) H1 H3 MCBL / MP CLKIN CVSS(6-0) DVSS(6-0) IVSS(3-9) DVDD(11-3) VDDL(7-0) VSSL(5-0) VSUBS SHZ EMU0-3 PDATA bus PADDR bus DDATA bus DADDR1 bus 24 32 24 32 24 DADDR2 bus DMADATA bus Controller DMAADDR bus Multiplexer DMA controller DMA channel 0 Multiplexer CPU1 CPU2 REG1 REG2 CPU1 REG1 REG2 32 32 40 40 32-bit barrel shifter ALU 40 40 Global-control register Source-address register Destination-address register Transfer-counter rregister DMA channel 1 Global-control register Source-address register Destination register Transfer-counter Peripheral data bus Peripheral address bus Multiplexer Multiplier 40 40 40 32 Extendedprecision registers (R0-R7) DISP0, IR0, IR1 ARAU0 BK 40 ARAU1 24 24 32 32 32 32 24 Auxiliary registers (AR0-AR7) 24 32 Other registers (12) 32 Legend: PDATA bus - program data bus PADDR bus - program address bus DDATA bus - data data bus DADDR1 bus - data address 1 bus DADDR2 bus - data address 2 bus Architectural Overview Boot ROM 32 Program cache (64 32) RAM block 0 (256 32) RAM block 1 (256 32) External memory interface A23 - A0 D31 - D0 R/W RDY HOLD HOLDA PRGW STRB0 STRB0 control reg. STRB1 STRB1 control reg. IOSTRB IOSTRB control reg. STRB0_B3/A-1 STRB0_B2/A-2 STRB0_B1 STRB0_B0 STRB1_B3/A-1 STRB1_B2/A-2 STRB1_B1 STRB1_B0 IOSTRB Serial port Serial-port control register Receive/transmit (R/X) timer register Data-transmit register Data-receive register Timer0 FSX0 DX0 CLKX0 FSR0 DR0 CLKR0 Global-control register Timer-period register Timer-counter register Timer1 TCLK0 Global-control register Timer-period register Timer-counter register TCLK1 2-5 Central Processing Unit (CPU) 2.2 Central Processing Unit (CPU) The 'C3x devices ('C30, 'C31/VC33, and 'C32) have a register-based CPU architecture. The CPU consists of the following components: - Floating-point/integer multiplier Arithmetic logic unit (ALU) 32-bit barrel shifter Internal buses (CPU1/CPU2 and REG1/REG2) Auxiliary register arithmetic units (ARAUs) CPU register file Figure 2-4 shows a diagram of the various CPU components. 2-6 Central Processing Unit (CPU) Figure 2-4. Central Processing Unit (CPU) DADDR1 bus DADDR2 bus DDATA bus Multiplexer CPU1 bus CPU2 bus REG1 bus REG2 bus DADDR2 bus DADDR1 bus REG1 bus REG2 bus CPU1 bus 32 Multiplier 40 40 40 32 Extendedprecision registers (R0-R7) Disp, IR0, IR1 ARAU0 BK ARAU1 40 40 32 40 40 32-bit barrel shifter ALU 40 24 24 32 32 32 32 Disp = an 8-bit integer displacement carried in a program-control instruction 24 Auxiliary registers (AR0-AR7) 24 32 Other registers (12) 32 Architectural Overview 2-7 Central Processing Unit (CPU) 2.2.1 Floating-Point/Integer Multiplier The multiplier performs single-cycle multiplications on 24-bit integer and 32-bit floating-point values. The 'C3x implementation of floating-point arithmetic allows for floating-point or fixed-point operations at speeds up to 33-ns per instruction cycle. To gain even higher throughput, you can use parallel instructions to perform a multiply and an ALU operation in a single cycle. When the multiplier performs floating-point multiplication, the inputs are 32-bit floating-point numbers, and the result is a 40-bit floating-point number. When the multiplier performs integer multiplication, the input data is 24 bits and yields a 32-bit result. See Chapter 5, Data Formats and Floating-Point Operation, for detailed information. 2.2.2 Arithmetic Logic Unit (ALU) and Internal Buses The ALU performs single-cycle operations on 32-bit integer, 32-bit logical, and 40-bit floating-point data, including single-cycle integer and floatingpoint conversions. Results of the ALU are always maintained in 32-bit integer or 40-bit floating-point formats. The barrel shifter is used to shift up to 32 bits left or right in a single cycle. See Chapter 5, Data Formats and Floating-Point Operation, for detailed information. Four internal buses, CPU1, CPU2, REG1, and REG2 carry two operands from memory and two operands from the register file, allowing parallel multiplies and adds/subtracts on four integer or floating-point operands in a single cycle. 2.2.3 Auxiliary Register Arithmetic Units (ARAUs) Two auxiliary register arithmetic units (ARAU0 and ARAU1) can generate two addresses in a single cycle. The ARAUs operate in parallel with the multiplier and ALU. They support addressing with displacements, index registers (IR0 and IR1), and circular and bit-reversed addressing. See Chapter 6, Addressing Modes, for more information. 2-8 CPU Primary Register File 2.3 CPU Primary Register File The 'C3x provides 28 registers in a multiport register file that is tightly coupled to the CPU. Table 2-1 lists the register names and functions. All of the primary registers can be operated upon by the multiplier and ALU and can be used as general-purpose registers. The registers also have some special functions. For example, the eight extended-precision registers are especially suited for maintaining extended-precision floating-point results. The eight auxiliary registers support a variety of indirect addressing modes and can be used as general-purpose 32-bit integer and logical registers. The remaining registers provide such system functions as addressing, stack management, processor status, interrupts, and block repeat. See Chapter 3, CPU Registers, for more information. Table 2-1. Primary CPU Registers Register Name R0 R1 R2 R3 R4 R5 R6 R7 AR0 AR1 AR2 AR3 AR4 AR5 AR6 AR7 DP IR0 Assigned Function Extended-precision register 0 Extended-precision register 1 Extended-precision register 2 Extended-precision register 3 Extended-precision register 4 Extended-precision register 5 Extended-precision register 6 Extended-precision register 7 Auxiliary register 0 Auxiliary register 1 Auxiliary register 2 Auxiliary register 3 Auxiliary register 4 Auxiliary register 5 Auxiliary register 6 Auxiliary register 7 Data-page pointer Index register 0 Section 3.1.1 3.1.1 3.1.1 3.1.1 3.1.1 3.1.1 3.1.1 3.1.1 3.1.2 3.1.2 3.1.2 3.1.2 3.1.2 3.1.2 3.1.2 3.1.2 3.1.3 3.1.4 Page 3-3 3-3 3-3 3-3 3-3 3-3 3-3 3-3 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-4 Architectural Overview 2-9 CPU Primary Register File Table 2-1. Primary CPU Registers (Continued) Register Name IR1 BK SP ST IE Assigned Function Index register 1 Block-size register System-stack pointer Status register CPU/DMA interrupt-enable register CPU interrupt flag I/O flag Repeat start-address Repeat end-address Repeat counter Section 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 Page 3-4 3-4 3-4 3-5 3-9 IF IOF RS RE RC 3.1.9 3.1.10 3.1.11 3.1.11 3.1.11 3-11 3-16 3-17 3-17 3-17 The extended-precision registers (R7-R0) can store and support operations on 32-bit integers and 40-bit floating-point numbers. Any instruction that assumes the operands are floating-point numbers uses bits 39-0. If the operands are either signed or unsigned integers, only bits 31-0 are used; bits 39-32 remain unchanged. This is true for all shift operations. See Chapter 5, Data Formats and Floating-Point Operation, for extended-precision register formats for floatingpoint and integer numbers. The 32-bit auxiliary registers (AR7-AR0) are accessed by the CPU and modified by the two ARAUs. The primary function of the auxiliary registers is the generation of 24-bit addresses. They also can be used as loop counters or as 32-bit general-purpose registers that are modified by the multiplier and ALU. See Chapter 6, Addressing Modes, for detailed information and examples of the use of auxiliary registers in addressing. The data-page pointer (DP) is a 32-bit register. The eight least significant bits (LSBs) of the data-page pointer are used by the direct addressing mode as a pointer to the page of data being addressed. Data pages are 64K words long, with a total of 256 pages. The 32-bit index registers (IR0, IR1) contain the value used by the ARAU to compute an indexed address. See Chapter 6, Addressing Modes, for examples of the use of index registers in addressing. 2-10 CPU Primary Register File The ARAU uses the 32-bit block size register (BK) in circular addressing to specify the data block size. The system-stack pointer (SP) is a 32-bit register that contains the address of the top of the system stack. The SP always points to the last element pushed onto the stack. A push performs a preincrement; a pop performs a postdecrement of the system-stack pointer. The SP is manipulated by interrupts, traps, calls, returns, and the PUSH and POP instructions. See Section 6.10, System and User Stack Management, on page 6-29, for more information. The status register (ST) contains global information relating to the state of the CPU. Operations usually set the condition flags of the status register according to whether the result is 0, negative, etc. These include register load and store operations as well as arithmetic and logical functions. When the status register is loaded, however, a bit-for-bit replacement is performed with the contents of the source operand, regardless of the state of any bits in the source operand. Following a load, the contents of the status register are identical to the contents of the source operand. This allows the status register to be easily saved and restored. See Table 3-2 on page 3-6 for a list and definitions of the status register bits. The CPU/DMA interrupt-enable register (IE) is a 32-bit register. The CPU interrupt-enable bits are in locations 10-0. The DMA interrupt-enable bits are in locations 26-16. A 1 in a CPU/DMA interrupt-enable register bit enables the corresponding interrupt. A 0 disables the corresponding interrupt. See Section 3.1.8 on page 3-9 for more information. The CPU interrupt flag register (IF) is also a 32-bit register. A 1 in a CPU interrupt flag register bit indicates that the corresponding interrupt is set. A 0 indicates that the corresponding interrupt is not set. See Section 3.1.9 on page 3-11 for more information. The I/O flag register (IOF) controls the function of the dedicated external pins, XF0 and XF1. These pins may be configured for input or output and may also be read from and written to. See Section 3.1.10 on page 3-16 for more information. The repeat-counter (RC) is a 32-bit register that specifies the number of times to repeat a block of code when performing a block repeat. When the processor is operating in the repeat mode, the 32-bit repeat start-address register (RS) contains the starting address of the block of program memory to repeat, and the 32-bit repeat end-address register (RE) contains the ending address of the block to repeat. Architectural Overview 2-11 Other Registers 2.4 Other Registers The program-counter (PC) is a 32-bit register containing the address of the next instruction to fetch. Although the PC is not part of the CPU register file, it is a register that can be modified by instructions that modify the program flow. The instruction register (IR) is a 32-bit register that holds the instruction opcode during the decode phase of the instruction. This register is used by the instruction decode control circuitry and is not accessible to the CPU. 2-12 Memory Organization 2.5 Memory Organization The total memory space of the 'C3x is 16M (million) 32-bit words. Program, data, and I/O space are contained within this 16M-word address space, allowing the storage of tables, coefficients, program code, or data in either RAM or ROM. In this way, memory usage is maximized and memory space allocated as desired. 2.5.1 RAM, ROM, and Cache Figure 2-5 shows how the memory is organized on the 'C30. RAM blocks 0 and 1 are each 1K 32 bits. The ROM block, available only on the 'C30, is 4K 32 bits. Each RAM and ROM block is capable of supporting two CPU accesses in a single cycle. Figure 2-6 shows how the memory is organized on the 'C31/VC33. RAM blocks 0 and 1 are each 1K 32 bits and support two accesses in a single cycle. The VC33 has two additional 16K RAM blocks bringing the total on-chip memory to 34K words (see the TMS320VC33 Data Sheet, literature number SPRS087). A boot loader allows the loading of program and data at reset from 8-, 16-, 32-bit-wide memories or serial port. Figure 2-7 shows how the memory is organized on the 'C32. RAM blocks 0 and 1 are each 256 32 bits and support two accesses in a single cycle. A boot loader allows the loading of program and data at reset from 1-, 2-, 4-, 8-, 16-, and 32-bit-wide memories or serial port. The 'C32 enhanced external memory interface provides the flexibility to address 8-, 16-, or 32-bit data independently of the external memory width. The external memory width can be 8-, 16-, or 32-bits wide. The 'C3x's separate program, data, and DMA buses allow for parallel program fetches, data reads and writes, and DMA operations. For example, the CPU can access two data values in one RAM block and perform an external program fetch in parallel with the DMA controller loading another RAM block, all within a single cycle. Architectural Overview 2-13 Memory Organization Figure 2-5. Memory Organization of the TMS320C30 Cache (64 32) RAM block 0 (1K 32) RAM block 1 (1K 32) 32 24 24 32 24 32 PDATA bus PADDR bus RDY HOLD HOLDA STRB R/W D31-D0 A23-A0 Multiplexer DADDR1 bus DADDR2 bus DMADATA bus DMAADDR bus 32 24 Program counter/ instruction register Multiplexer DDATA bus 32 24 24 32 24 CPU DMA controller 2-14 Peripheral bus ROM block (4K 32) 24 32 XRDY MSTRB IOSTRB XR/W XD31-XD0 XA12-XA0 Memory Organization Figure 2-6. Memory Organization of the TMS320C31/VC33 Cache (64 32) RAM block 0 (1K 32) RAM block 1 (1K 32) 32 24 24 32 24 32 PDATA bus PADDR bus RDY HOLD HOLDA STRB R/W D31-D0 A23-A0 Multiplexer DADDR1 bus DADDR2 bus DMADATA bus DMAADDR bus 32 24 Program counter/ instruction register Multiplexer 32 24 24 32 24 CPU DMA controller Peripheral bus DDATA bus Boot ROM 24 32 Architectural Overview 2-15 Memory Organization Figure 2-7. Memory Organization of the TMS320C32 Cache (64 32) RAM block 0 (256 32) RAM block 1 (256 32) Boot ROM 32 A23 -A0 D31 -D0 R/W HOLD HOLDA PRGW STRB0_B3/A-1 STRB0_B2/A-2 STRB0_B1 STRB0_B0 STRB1_B3/A-1 STRB1_B2/A-2 STRB1_B1 STRB1_B0 IOSTRB 24 24 32 24 32 24 32 PDATA bus PADDR bus Multiplexer Multiplexer 32 24 24 32 24 CPU DMA controller Peripheral bus DDATA bus DADDR1 bus DADDR2 bus DMADATA bus DMAADDR bus 32 24 Program counter/ instruction register Enhanced external memory interface A 64 32-bit instruction cache is provided to store often-repeated sections of code, which greatly reduces the number of off-chip accesses. This allows for code to be stored off chip in slower, lower-cost memories. The external buses are also freed for use by the DMA, external memory fetches, or other devices in the system. See Chapter 4, Memory and the Instruction Cache, for more information. 2-16 Memory Organization 2.5.2 Memory Addressing Modes The 'C3x supports a base set of general-purpose instructions as well as arithmeticintensive instructions that are particularly suited for digital signal processing and other numeric-intensive applications. See Chapter 6, Addressing Modes, for more information. Four groups of addressing modes are provided on the 'C3x. Each group uses two or more of several different addressing types. The following list shows the addressing modes with their addressing types. - General instruction addressing modes: J J J J Register. The operand is a CPU register. Short immediate. The operand is a 16-bit (short) or 24-bit (long) immediate value. Direct. The operand is the contents of a 24-bit address formed by concatenating the 8 bits of data-page pointer and a 16-bit operand. Indirect. An auxiliary register indicates the address of the operand. - 3-operand instruction addressing modes: J J Register. Same as for general addressing mode. Indirect. Same as for general addressing mode. - Parallel instruction addressing modes: J J Register. The operand is an extended-precision register. Indirect. Same as for general addressing mode. - Branch instruction addressing modes: J J Register. Same as for general addressing mode. PC-relative. A signed 16-bit displacement or a 24-bit displacement is added to the PC. Architectural Overview 2-17 Internal Bus Operation 2.6 Internal Bus Operation Much of the 'C3x's high performance is due to internal busing and parallelism. Separate buses allow for parallel program fetches, data accesses, and DMA accesses: - Program buses: PADDR and PDATA - Data buses: DADDR1, DADDR2, and DDATA - DMA buses: DMAADDR and DMADATA These buses connect all of the physical spaces (on-chip memory, off-chip memory, and on-chip peripherals) supported by the 'C3x. Figure 2-5, Figure 2-6, and Figure 2-7 show these internal buses and their connections to on-chip and off-chip memory blocks. The program counter (PC) is connected to the 24-bit program address bus (PADDR). The instruction register (IR) is connected to the 32-bit program data bus (PDATA). These buses can fetch a single instruction word every machine cycle. The 24-bit data address buses (DADDR1 and DADDR2) and the 32-bit data data bus (DDATA) support two data-memory accesses every machine cycle. The DDATA bus carries data to the CPU over the CPU1 and CPU2 buses. The CPU1 and CPU2 buses can carry two data-memory operands to the multiplier, ALU, and register file every machine cycle. Also internal to the CPU are register buses REG1 and REG2, which can carry two data values from the register file to the multiplier and ALU every machine cycle. Figure 2-4 shows the buses internal to the CPU section of the processor. The DMA controller is supported with a 24-bit address bus (DMAADDR) and a 32-bit data bus (DMADATA). These buses allow the DMA to perform memory accesses in parallel with the memory accesses occurring from the data and program buses. 2-18 External Memory Interface 2.7 External Memory Interface The 'C30 provides two external interfaces: the primary bus and the expansion bus. The 'C31/VC33 provides one external interface: the primary bus. The 'C32 provides one enhanced external interface with three independent multi-function strobes. These buses consist of a 32-bit data bus and a set of control signals. The primary and enhanced memory buses have a 24-bit address bus, whereas the expansion bus has a 13-bit address bus. These buses address external program/ data memory or I/O space. The buses also have external RDY signals for waitstate generation. You can insert additional wait states under software control. Chapter 9, External Memory Interface, covers external bus operation. The 'C3x family was designed for 32-bit instructions and 32-bit data operations. This architecture has many advantages, including a high degree of parallelism and provisions for a C compiler. However, the 'C30 and 'C31/VC33 require a 32-bit-wide external memory even when the data requires only 8- or 16-bit-wide memories. The 'C32 enhanced external memory interface overcomes this limitation by providing the flexibility to address 8-, 16-, or 32-bit data independently of the external memory width. In this way, the chip count and the size of external memory is reduced. The number of memory chips can be further reduced by the 'C32's ability to allow code execution from 16- or 32-bit-wide memories. The 'C32 memory interface also reduces the total amount of RAM by allowing the physical data memory to be 8, 16, or 32 bits wide. Internally, the 'C32 has a 32-bit architecture. So you can treat the 'C32 as a 32-bit device regardless of the physical external memory width. The external memory interface handles the conversion between external memory width and 'C32 internal 32-bit architecture. 2.7.1 TMS320C32 16- and 32-Bit Program Memory The 'C32 executes code from either 16- or 32-bit-wide memories. When connected to 32-bit memories, `C32 program execution is identical to that of the 'C31/VC33. When connected to 16-bit zero wait-state memory, the 'C32 takes two instruction cycles to fetch a single 32-bit instruction. During the first cycle, the 'C32 fetches the lower 16 bits. During the second cycle, the 'C32 fetches the upper 16 bits and concatenates them with the previously fetched lower 16 bits. This process occurs entirely within the memory interface and is transparent to you. An external pin, PRGW, dictates the external program memory width. Architectural Overview 2-19 External Memory Interface 2.7.2 TMS320C32 8-, 16-, and 32-Bit Data Memory The 'C32 external memory interface can load and store 8-, 16-, or 32-bit quantities into external memory and convert them into an internally-equivalent 32-bit representation. The external memory interface accomplishes this without changing the CPU instruction set. Figure 2-8 shows the supported external memory widths, data types and sizes for zero wait-state memory and the associated cycle count. Figure 2-8. TMS320C32-Supported Data Types and Sizes and External Memory Widths 2-20 Memory Width 16 1-cycle read 1-cycle read 8 32 Data Size 8 1-cycle read 1-cycle read 1-cycle read 1-cycle read Type 16 32 2-cycle read 4-cycle read 2-cycle read To access 8-, 16-, or 32-bit data quantities (types) from 8-, 16-, or 32-bit-wide memory, the memory interface uses either strobe STRB0 or STRB1, depending on the address location within the memory map. Each strobe consists of four pins for byte enables and/or additional addresses. For a 32-bit memory interface, all four pins are used as strobe byte-enable pins. These strobe byte-enable pins select one or more bytes of the external memory. For a 16-bit memory interface, the 'C32 uses one of these pins as an additional address pin, while using two pins as strobe byte-enable pins. For an 8-bit memory interface, the 'C32 uses two of these pins as additional address pins while using one pin as strobe pin. The 'C32 manipulates the behavior of these pins according to the contents of the bus control registers (one control register per strobe). By setting a few bit fields in this register, you indicate the data-type size and external memory width. Interrupts 2.8 Interrupts The 'C3x supports four external interrupts (INT3-INT0), a number of internal interrupts, and a nonmaskable external RESET signal. These can be used to interrupt either the DMA or the CPU. When the CPU responds to the interrupt, the IACK pin can be used to signal an external interrupt acknowledge. Section 7.5, Reset Operation, on page 7-21 covers RESET and interrupt processing. The 'C30 and 'C31 external interrupts are level-triggered. To reduce external logic and simplify the interface, the 'C32 external interrupts are edge- and levelor level-only triggered. The triggering is user-selectable through a bit in the status register. The VC33 external interrupts are either edge or level-trig- gered depending upon the state of the external EDGEMODE pin. See Section 3.1.7, Status Register (ST), for more information. Two external I/O flags, XF0 and XF1, can be configured as input or output pins under software control. These pins are also used by the interlocked operations of the 'C3x. The interlocked-operations instruction group supports multiprocessor communication. See Section 7.4, Interlocked Operations, on page 7-13 for examples. Architectural Overview 2-21 Peripherals 2.9 Peripherals All 'C3x peripherals are controlled through memory-mapped registers on a dedicated peripheral bus. This peripheral bus is composed of a 32-bit data bus and a 24-bit address bus. This peripheral bus permits straightforward communication to the peripherals. The 'C3x peripherals include two timers and two serial ports (only one serial port and one DMA coprocessor are available on the 'C31/VC33 and one serial port and two DMA coprocessor channels on the 'C32). Figure 2-9 shows these peripherals with their associated buses and signals. See Chapter 12, Peripherals, for more information. Figure 2-9. Peripheral Modules Serial port 0 Port-control register Memory space R/X timer register Data-transmit register Data-receive register FSX0 DX0 CLKX0 FSR0 DR0 CLKR0 Peripheral address bus Peripheral data bus Available on 'C30 2-22 Serial port 1 Port-control register R/X timer register Data-transmit register Data-receive register Timer0 Global-control register Timer-period register Timer-counter register Timer1 Global-control register Timer-period register Timer-counter register FSX1 DX1 CLKX1 FSR1 DR1 CLKR1 TCLK0 TCLK1 Peripherals 2.9.1 Timers The two timer modules are general-purpose 32-bit timer/event counters with two signaling modes and internal or external clocking. They can signal internally to the 'C3x or externally to the outside world at specified intervals or they can count external events. Each timer has an I/O pin that can be used as an input clock to the timer, as an output signal driven by the timer, or as a general-purpose I/O pin. See Chapter 12, Peripherals, for more information about timers. 2.9.2 Serial Ports The bidirectional serial ports (two on 'C30, one each on the 'C31/VC33 and 'C32) are totally independent. They are identical to a complementary set of control registers that control each port. Each serial port can be configured to transfer 8, 16, 24, or 32 bits of data per word. The clock for each serial port can originate either internally or externally. An internally generated divide-down clock is provided. The pins are configurable as general-purpose I/O pins. The serial ports can also be configured as timers. A special handshake mode allows 'C3x devices to communicate over their serial ports with guaranteed synchronization. Architectural Overview 2-23 Direct Memory Access (DMA) 2.10 Direct Memory Access (DMA) The on-chip DMA controller can read from or write to any location in the memory map without interfering with the CPU operation. The 'C3x can interface to slow, external memories and peripherals without reducing throughput to the CPU. The DMA controller contains its own address generators, source and destination registers, and transfer counter. Dedicated DMA address and data buses minimize conflicts between the CPU and the DMA controller. A DMA operation consists of a block or single-word transfer to or from memory. See Section 12.3, DMA Controller, on page 12-48 for more information. Figure 2-10 shows the DMA controller and its associated buses. The 'C30 and 'C31/VC33 DMA coprocessors have one channel, while the 'C32 DMA coprocessor has two channels. Each channel of the 'C32 DMA coprocessor is equivalent to the 'C30/31 DMA with the addition of user-configurable priorities. Because the DMA and CPU have distinct buses on the 'C3x devices, they can operate independently of each other. However, when the CPU and DMA access the same on-chip or external resources, the bandwidth can be exceeded and priorities must be established. The 'C30 and 'C31/VC33 assign highest priority to the CPU. The 'C32 DMA coprocessor provides more flexibility by allowing you to choose one of the following priorities: - CPU: - DMA: For all resource conflicts, the CPU has priority over the DMA. For all resource conflicts, the DMA has priority over the CPU. - Rotating: When the CPU and DMA have a resource conflict during con- secutive instruction cycles, the CPU is granted priority. On the following cycle, the DMA is granted priority. Alternate access continues as long as the CPU and DMA requests conflict in consecutive instruction cycles. The DMA/CPU priority is configured by the DMA PRI bit fields of the corresponding DMA global-control register. See Section 12.3, DMA Controller, on page 12-48 for a complete description. 2-24 Direct Memory Access (DMA) Figure 2-10. DMA Controller DMADATA bus DMAADDR bus Peripheral data bus Peripheral address bus DMA controller Global-control register Source-address register Destination-address register Transfer-counter register Architectural Overview 2-25 TMS320C30, TMS320C31/VC33, and TMS320C32 Differences 2.11 TMS320C30, TMS320C31/VC33, and TMS320C32 Differences Table 2-2 shows the major differences between the 'C32, 'C31/VC33, and the 'C30 devices. 2-26 TMS320C30, TMS320C31/VC33, and TMS320C32 Differences Table 2-2. Feature Set Comparison Feature External bus 'C30 Two buses: - 'C31/VC33 One bus: 32-bit data 24-bit address STRB active 0h-7FFFFFh and 80A000h-FFFFFFh 'C32 One bus: - Primary bus: 32-bit data 24-bit address STRB active for 0h-7FFFFFh and 80A000h-FFFFFFh Expansion bus: 32-bit data 13-bit address MSTRB active for 800000h-801FFFh IOSTRB active for 804000h-805FFFh 32-bit data 24-bit address STRB0 active for 0h-7FFFFFh and 880000h-8FFFFFh; 8-, 16-, 32-bit data in 8-, 16-, 32-bit-wide memory STRB1 active for 900000h-FFFFFFh; 8-, 16-, 32-bit data in 8-, 16-, 32- bit-wide memory IOSTRB active for 810000h-82FFFFh - - - ROM Boot loader On-chip RAM 4k No 2k address: 809800h-809FFFh 1 channel CPU greater priority than DMA 2 2 Level-triggered No Yes 2k address: 809800h-809FFFh 1 channel CPU greater priority than DMA 1 2 Level-triggered No Yes 512 address: 87FE00h-87FFFFh 2 channels Configurable priorities 1 2 Level-triggered or combination of edge- and level-triggered Relocatable DMA Serial ports Timers Interrupts Interrupt vector table Fixed 0-3Fh Microprocessor: 0-3Fh fixed Boot loader: 809C1h-809FFFh fixed 132 PQFP 5 V and 3.3 V 0 to 85C (commercial) 40 to 125C (extended) -55 125C (military) Package Voltage Temperature 208 PQFP 181 PGA 5V 0 to 85C (commercial) 40 to 125C (extended) -55 125C (military) 144 PQFP 5V 0 to 85C (commercial) 40 to 125C (extended) -55 125C (military) Architectural Overview 2-27 2-28 Chapter 3 CPU Registers The central processing unit (CPU) register file contains 28 registers that can be operated on by the multiplier and arithmetic logic unit (ALU). Included in the register file are the auxiliary registers, extended-precision registers, and index registers. Three registers in the 'C32 CPU register file have been modified to support new features (2-channel DMAs, program execution from 16-bit memory width, etc.) The registers modified in the 'C32 are: the status (ST) register, interrupt-enable (IE) register, and interrupt flag (IF) register. Topic 3.1 3.2 3.3 Page CPU Multiport Register File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Other Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18 Reserved Bits and Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19 3-1 CPU Multiport Register File 3.1 CPU Multiport Register File The 'C3x provides 28 registers in a multiport register file that is tightly coupled to the CPU. The program counter (PC) is not included in the 28 registers. All of these registers can be operated on by the multiplier and the ALU and can be used as general-purpose 32-bit registers. Table 3-1 lists the registers' names and assigned functions of the 'C3x. Table 3-1. CPU Registers Register Symbol R0 R1 R2 R3 R4 R5 R6 R7 AR0 AR1 AR2 AR3 AR4 AR5 AR6 AR7 DP IR0 IR1 BK SP ST IE IF IOF RS RE RC Register Machine Value (hex) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B Assigned Function Name Extended-precision register 0 Extended-precision register 1 Extended-precision register 2 Extended-precision register 3 Extended-precision register 4 Extended-precision register 5 Extended-precision register 6 Extended-precision register 7 Auxiliary register 0 Auxiliary register 1 Auxiliary register 2 Auxiliary register 3 Auxiliary register 4 Auxiliary register 5 Auxiliary register 6 Auxiliary register 7 Data-page pointer Index register 0 Index register 1 Block-size register System-stack pointer Status register CPU/DMA interrupt-enable CPU interrupt flags I/O flags Repeat start-address Repeat end-address Repeat counter Section 3.1.1 3.1.1 3.1.1 3.1.1 3.1.1 3.1.1 3.1.1 3.1.1 3.1.2 3.1.2 3.1.2 3.1.2 3.1.2 3.1.2 3.1.2 3.1.2 3.1.3 3.1.4 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.1.10 3.1.11 3.1.11 3.1.11 Page 3-3 3-3 3-3 3-3 3-3 3-3 3-3 3-3 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-4 3-5 3-9 3-11 3-16 3-17 3-17 3-17 3-2 CPU Multiport Register File The registers also have some special functions for which they are particularly appropriate. For example, the eight extended-precision registers are especially suited for maintaining extended-precision floating-point results. The eight auxiliary registers support a variety of indirect addressing modes and can be used as general-purpose 32-bit integer and logical registers. The remaining registers provide system functions, such as addressing, stack management, processor status, interrupts, and block repeat. See Chapter 6, Addressing Modes, for more information. 3.1.1 Extended-Precision Registers (R7-R0) The eight extended-precision registers (R7-R0) can store and support operations on 32-bit integer and 40-bit floating-point numbers. These registers consist of two separate and distinct regions: - Bits 39-32: dedicated to storage of the exponent (e) of the floating-point number. - Bits 31-0: store the mantissa of the floating-point number: J J Bit 31: sign bit (s) Bits 30-0: the fraction (f) Any instruction that assumes the operands are floating-point numbers uses bits 39-0. Figure 3-1 illustrates the storage of 40-bit floating-point numbers in the extended-precision registers. Figure 3-1. Extended-Precision Register Floating-Point Format 39 Exponent 32 31 Sign 30 Fraction 0 Mantissa For integer operations, bits 31-0 of the extended-precision registers contain the integer (signed or unsigned). Any instruction that assumes the operands are either signed or unsigned integers uses only bits 31-0. Bits 39-32 remain unchanged. This is true for all shift operations. The storage of 32-bit integers in the extended-precision registers is shown in Figure 3-2. Figure 3-2. Extended-Precision Register Integer Format 39 Unchanged 32 31 Signed or unsigned integer 0 CPU Registers 3-3 CPU Multiport Register File 3.1.2 Auxiliary Registers (AR7-AR0) The CPU can access the eight 32-bit auxiliary registers (AR7-AR0), and the two auxiliary register arithmetic units (ARAUs) can modify them. The primary function of the auxiliary registers is the generation of 24-bit addresses. However, they can also operate as loop counters in indirect addressing or as 32-bit generalpurpose registers that can be modified by the multiplier and ALU. See Chapter 6, Addressing Modes, for more information. 3.1.3 Data-Page Pointer (DP) The data-page pointer (DP) is a 32-bit register that is loaded using the load data page (LDP) instruction (see Chapter 13, Assembly Language Instructions). The eight LSBs of the data-page pointer are used by the direct addressing mode as a pointer to the page of data being addressed (see Section 6.3, Direct Addressing, on page 6-4). Data pages are 64K-words long, with a total of 256 pages. Bits 31-8 are reserved; you must always keep these set to 0 (cleared). 3.1.4 Index Registers (IR0, IR1) The 32-bit index registers (IR0 and IR1) are used by the ARAU for indexing the address. See Chapter 6, Addressing Modes, for more information. 3.1.5 Block Size (BK) Register The 32-bit block size register (BK) is used by the ARAU in circular addressing to specify the data block size. See Section 6.7, Circular Addressing, on page 6-21 for more information. 3.1.6 System-Stack Pointer (SP) The system-stack pointer (SP) is a 32-bit register that contains the address of the top of the system stack. The SP always points to the last element pushed onto the stack. The SP is manipulated by interrupts, traps, calls, returns, and the PUSH, PUSHF, POP, and POPF instructions. Stack pushes and pops perform preincrements and postdecrements on all 32 bits of the SP. However, only the 24 LSBs are used as an address. See Section 6.10, System and User Stack Management, on page 6-29 for more information. 3-4 CPU Multiport Register File 3.1.7 Status (ST) Register The status (ST) register contains global information about the state of the CPU. Operations usually set the condition flags of the status register according to whether the result is 0, negative, etc. This includes register load and store operations as well as arithmetic and logical functions. However, when the status register is loaded, the contents of the source operand replace the ST's contents bit for bit, regardless of the state of any bits in the source operand. Following an ST load, the contents of the status register are identical to the contents of the source operand. This allows the status register to be saved easily and restored. At system reset, a 0 is written to this register. Figure 3-3 shows the format of the status register for the 'C30 and 'C31/VC33 devices. Figure 3-4 shows the format of the status register for the 'C32 device. Table 3-2 describes the status register bits, their names, and their functions. Figure 3-3. Status Register (TMS320C30 andTMS320C31/VC33) 31 - 16 xx 15 xx 14 xx 13 GIE R/W Notes: 12 CC R/W 11 CE R/W 10 CF R/W 9 xx 8 RM R/W 7 OVM R/W 6 LUF R/W 5 LV R/W 4 UF R/W 3 N R/W 2 Z 1 V 0 C R/W R/W R/W 1) xx = reserved bit, read as 0 2) R = read, W = write Figure 3-4. Status Register (TMS320C32 Only) 31 - 16 xx 15 PRGW status R Notes: 14 INT config R/W 13 GIE R/W 12 CC R/W 11 CE R/W 10 CF R/W 9 xx 8 RM R/W 7 OVM R/W 6 LUF R/W 5 LV R/W 4 UF R/W 3 N R/W 2 Z 1 V 0 C R/W R/W R/W 1) xx = reserved bit, read as 0 2) R = read, W = write CPU Registers 3-5 CPU Multiport Register File Table 3-2. Status Register Bits Bit Name C V Z N UF Reset Value 0 0 0 0 0 Name Carry flag Overflow flag Zero flag Negative flag Floating-point underflow flag Latched overflow flag Latched floating-point underflow flag Overflow mode flag Description Carry condition flag Overflow condition flag Zero condition flag Negative condition flag Floating-point underflow condition flag LV LUF 0 0 Latched overflow condition flag Latched floating-point underflow condition flag OVM 0 Overflow mode flag The overflow mode flag affects only integer operations. If OVM = 0, the overflow mode is turned off and integer results that overflow are treated in no special way. If OVM = 1, integer results overflowing in the positive direction are set to the most positive, 2s-complement number (7FFF FFFFh), and integer results overflowing in the negative direction are set to the most negative 32-bit, 2s-complement number (8000 0000h). RM 0 Repeat mode flag Repeat mode flag If RM = 1, the PC is modified in either the repeat-block or repeat-single mode. CE 0 Cache enable CE enables or disables the instruction cache. Set CE = 1 to enable the cache, allowing the cache to be used according to the least recently used (LRU) stack manipulation. Set CE = 0 to disable the cache, preventing cache updates or modifications (no cache fetches can be made). Cache clearing (CC = 1) is allowed when CE = 0. Note: If a load of the status register occurs simultaneously with a CPU interrupt pulse trying to reset GIE, GIE is reset. 3-6 CPU Multiport Register File Table 3-2. Status Register Bits (Continued) Bit Name CF Reset Value 0 Name Cache freeze Description Enables or disables the instruction cache Set CF = 1 to freeze the cache (cache is not updated), including LRU stack manipulation. If the cache is enabled (CE = 1), fetches from the cache are allowed, but modification of the cache contents is not allowed. Cache clearing (CC = 1) is allowed. At reset, this bit is cleared to 0, but it is set to 1 after reset. When CF = 0, the cache is automatically updated by instruction fetches from external memory. Also, when CF = 0, cache clearing (CC = 1) is allowed. The following table summarizes the CE and CF bits: CE 0 0 1 1 CF 0 1 0 1 Effect Cache not enabled Cache not enabled Cache enabled and not frozen Cache enabled but frozen (cache read only) CC 0 Cache clear CC = 1 invalidates all entries in the cache. This bit is always cleared after it is written to, and is always read as 0. At reset, 0 is written to this bit. If GIE = 1, the CPU responds to an enabled interrupt. If GIE = 0, the CPU does not respond to an enabled interrupt. GIE 0 Global interrupt-enable INT config 0 Interrupt configuration (`C32 only) Sets the external interrupt signals INT3 - INT0 for levelor edge-triggered interrupts. INT Config 0 Effect All the external interrupts (INT3 - INT0) are configured as level-triggered interrupts. Multiple interrupts may be triggered when the signal is active for a long period of time. All the external interrupts (INT3 - INT0) are configured as edge-triggered interrupts. Edge and duration are required for all interrupts to be recognized. 1 Note: If a load of the status register occurs simultaneously with a CPU interrupt pulse trying to reset GIE, GIE is reset. CPU Registers 3-7 CPU Multiport Register File Table 3-2. Status Register Bits (Continued) Bit Name PRGW Reset Value Dependent on PRGW pin level Name Program width status (`C32 only) Description Indicates the status of the external input PRGW pin. When the signal of the PRGW pin is high, the PRGW status bit is set to 1, indicating a 16-bit memory width. The `C32 performs two fetches to retrieve a single 32-bit instruction word. The PRGW bit is a read-only bit, and can have the following values: PRG 0 1 Note: Effect Instruction fetches use one 32-bit external program memory read. Instruction fetches use two 16-bit external program memory reads. If a load of the status register occurs simultaneously with a CPU interrupt pulse trying to reset GIE, GIE is reset. 3-8 CPU Multiport Register File 3.1.8 CPU/DMA Interrupt-Enable (IE) Register The CPU/DMA interrupt-enable (IE) register of the 'C30, 'C31/VC33, and 'C32 are 32-bit registers (see Figure 3-5 and Figure 3-6). The CPU interrupt-enable bits are in locations 10-0 for 'C30 and 'C31/VC33 devices, and 11-0 for 'C32 devices. The direct memory access (DMA) interrupt-enable bits are in locations 26-16 for `C30 and `C31/VC33 devices, and 31-16 for 'C32 devices. A 1 in a CPU/DMA IE bit enables the corresponding interrupt. A 0 disables the corresponding interrupt. At reset, 0 is written to this register. Table 3-3 describes the interrupt-enable register bits, their names, and their functions. Figure 3-5. CPU/DMA Interrupt-Enable (IE) Register (TMS320C30 and TMS320C31/VC33) 31 xx 30 xx 29 xx 28 xx 27 xx 26 EDINT (DMA) R/W 25 ETINT1 (DMA) R/W 24 ETINT0 (DMA) R/W 23 ERINT1 (DMA) R/W 22 EXINT1 (DMA) R/W 21 ERINT0 (DMA) R/W 20 EXINT0 (DMA) R/W 19 EINT3 (DMA) R/W 18 EINT2 (DMA) R/W 17 EINT1 (DMA) R/W 16 EINT0 (DMA) R/W 15 xx 14 xx 13 xx 12 xx 11 xx 10 EDINT (CPU) R/W 9 ETINT1 (CPU) R/W 8 ETINT0 (CPU) R/W 7 ERINT1 (CPU) R/W 6 EXINT1 (CPU) R/W 5 ERINT0 (CPU) R/W 4 EXINT0 (CPU) R/W 3 EINT3 (CPU) R/W 2 EINT2 (CPU) R/W 1 EINT1 (CPU) R/W 0 EINT0 (CPU) R/W Notes: 1) xx = reserved bit, read as 0 2) R = read, W = write Figure 3-6. CPU/DMA Interrupt-Enable (IE) Register (TMS320C32) 31 EINT3 (DMA1) R/W 30 EINT2 (DMA1) R/W 29 28 27 EDINT0 (DMA1) R/W 26 EDINT1 (DMA0) R/W 25 ETINT1 (DMA0) R/W 24 ETINT0 (DMA0) R/W 23 ETINT1 (DMA1) R/W 22 ETINT0 (DMA1) R/W 21 ERINT0 (DMA1) R/W 20 EXINT0 (DMA0) R/W 19 18 17 16 EINT1 EINT0 (DMA1) (DMA1) R/W R/W EINT0 EINT3 EINT2 EINT1 (DMA0) (DMA0) (DMA0) (DMA0) R/W R/W R/W R/W 15 xx 14 xx 13 xx 12 xx 11 EDINT1 (CPU) R/W 10 EDINT0 (CPU) R/W 9 ETINT1 (CPU) R/W 8 ETINT0 (CPU) R/W 7 xx 6 xx R/W 5 ERINT0 (CPU) R/W 4 EXINT0 (CPU) R/W 3 EINT3 (CPU) R/W 2 EINT2 (CPU) R/W 1 EINT1 (CPU) R/W 0 EINT0 (CPU) R/W Notes: 1) xx = reserved bit, read as 0 2) R = read, W = write CPU Registers 3-9 CPU Multiport Register File Table 3-3. IE Bits and Functions Abbreviation EINT0 (CPU) EINT1 (CPU) EINT2 (CPU) EINT3 (CPU) EXINT0 (CPU) ERINT0 (CPU) EXINT1 (CPU) ERINT1 (CPU) ETINT0 (CPU) ETINT1 (CPU) EDINT (CPU) EDINT0 (CPU) EDINT1 (CPU) EINT0 (DMA) EINT1 (DMA) EINT2 (DMA) EINT3 (DMA) EINT0 (DMA0) EINT1 (DMA0) EINT2 (DMA0) EINT3 (DMA0) EXINT0 (DMA) ERINT0 (DMA) EXINT1 (DMA) Reset Value Description 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 CPU external interrupt 0 enable CPU external interrupt 1 enable CPU external interrupt 2 enable CPU external interrupt 3 enable CPU serial port 0 transmit interrupt enable CPU serial port 0 receive interrupt enable CPU serial port 1 transmit interrupt enable ('C30 only) CPU serial port 1 receive interrupt enable ('C30 only) CPU timer0 interrupt enable CPU timer1 interrupt enable CPU DMA controller interrupt enable ('C30 and 'C31/VC33 only) CPU DMA0 controller interrupt enable ('C32 only) CPU DMA1 controller interrupt enable ('C32 only) DMA external interrupt 0 enable ('C30 and 'C31/VC33 only) DMA external interrupt 1 enable ('C30 and 'C31/VC33 only) DMA external interrupt 2 enable ('C30 and 'C31/VC33 only) DMA external interrupt 3 enable ('C30 and 'C31/VC33 only) DMA0 external interrupt 0 enable ('C32 only) DMA0 external interrupt 1 enable ('C32 only) DMA0 external interrupt 2 enable ('C32 only) DMA0 external interrupt 3 enable ('C32 only) DMA serial port 0 transmit interrupt enable ('C30 and 'C31/VC33 only) DMA serial port 0 receive interrupt enable ('C30 and 'C31/VC33 only) DMA serial port 1 transmit interrupt enable ('C30 only) 3-10 CPU Multiport Register File Table 3-3. IE Bits and Functions(Continued) Abbreviation ERINT1 (DMA) EXINT0 (DMA0) ERINT0 (DMA1) ETINT0 (DMA) ETINT1 (DMA) ETINT0 (DMA0) ETINT1 (DMA0) ETINT0 (DMA1) ETINT1 (DMA1) EDINT (DMA) EDINT1 (DMA0) EDINT0 (DMA1) EINT0 (DMA1) EINT1 (DMA1) EINT2 (DMA1) EINT3 (DMA1) Reset Value Description 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 DMA serial port 1 receive interrupt enable ('C30 only) DMA0 serial port 1 transmit interrupt enable ('C32 only) DMA1 serial port 1 receive interrupt enable ('C32 only) DMA timer0 interrupt enable ('C30 and 'C31/VC33) DMA timer1 interrupt enable ('C30 and 'C31/VC33 only) DMA0 timer1 interrupt enable ('C32 only) DMA0 timer1 interrupt enable ('C32 only) DMA1 timer0 interrupt enable ('C32 only) DMA1 timer1 interrupt enable ('C32 only) DMA controller interrupt enable ('C30 and 'C31/VC33 only) DMA0-DMA1 controller interrupt enable ('C32 only) DMA1-DMA0 controller interrupt enable ('C32 only) DMA1 external interrupt 0 enable ('C32 only) DMA1 external interrupt 1 enable ('C32 only) DMA1 external interrupt 2 enable ('C32 only) DMA1 external interrupt 2 enable ('C32 only) 3.1.9 CPU Interrupt Flag (IF) Register Figure 3-7, Figure 3-8, and Figure 3-9 show the 32-bit CPU interrupt flag registers (IF) for the `C30, `C31/VC33, and `C32 devices, respectively. A 1 in a CPU IF register bit indicates that the corresponding interrupt is set. The IF bits are set to 1 when an interrupt occurs. They may also be set to 1 through software to cause an interrupt. A 0 indicates that the corresponding interrupt is not set. If a 0 is written to an IF register bit, the corresponding interrupt is cleared. At reset, 0 is written to this register. Table 3-4 describes the interrupt flag register bits, their names, and their functions. CPU Registers 3-11 CPU Multiport Register File Figure 3-7. TMS320C30 CPU Interrupt Flag (IF) Register 31-16 xx 15-12 yy 11 yy R/W Notes: 10 DINT R/W 9 TINT1 R/W 8 7 6 5 4 XINT0 R/W 3 INT3 R/W 2 INT2 R/W 1 INT1 R/W 0 INT0 R/W TINT0 RINT1 XINT1 RINT0 R/W R/W R/W R/W 1) xx = reserved bit, read as 0 2) yy = reserved bit, set to 0 at reset; can store value 3) R = read, W = write Figure 3-8. TMS320C31/VC33 CPU Interrupt Flag (IF) Register 31-16 xx 15-12 yy 11 yy 10 DINT R/W Notes: 9 TINT1 R/W 8 TINT0 R/W 7 xx R/W 6 xx R/W 5 RINT0 R/W 4 XINT0 R/W 3 INT3 R/W 2 INT2 R/W 1 INT1 R/W 0 INT0 R/W 1) xx = reserved bit, read as 0 2) yy = reserved bit, set to 0 at reset 3) R = read, W = write Figure 3-9. TMS320C32 CPU Interrupt Flag (IF) Register 31-16 ITTP 15-12 xx 11 DINT1 R/W Notes: 10 DINT0 R/W 9 TINT1 R/W 8 TINT0 R/W 7 xx R/W 6 xx R/W 5 RINT0 R/W 4 XINT0 R/W 3 INT3 R/W 2 INT2 R/W 1 INT1 R/W 0 INT0 R/W 1) xx = reserved bit, read as 0 2) R = read, W = write 3-12 CPU Multiport Register File Table 3-4. IF Bits and Functions Bit Name INT0 INT1 INT2 INT3 XINT0 RINT0 XINT1 RINT1 TINT0 TINT1 DINT DINT0 DINT1 ITTP Reset Value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Function External interrupt 0 flag External interrupt 1 flag External interrupt 2 flag External interrupt 3 flag Serial port 0 transmit flag Serial port 0 receive flag Serial port 1 transmit flag (`C30 only) Serial port 1 receive interrupt flag (`C30 only) Timer 0 interrupt flag Timer 1 interrupt flag DMA channel interrupt flag (`C30 and `C31/VC33 only) DMA0 channel interrupt flag (`C32 only) DMA1 channel interrupt flag (`C32 only) Interrupt-trap table pointer (see Section 3.1.9.1) Allows the relocation of interrupt and trap vector tables (`C32 only) Note: If a load of the interrupt flag (IF) register occurs simultaneously with a set of a flag by an interrupt pulse, the loading of the flag has higher priority and overwrites the value of the interrupt flag register. CPU Registers 3-13 CPU Multiport Register File 3.1.9.1 Interrupt-Trap Table Pointer (ITTP) Similar to the rest of the `C3x device family, the 'C32's reset vector location remains at address 0. However, the interrupt and trap vectors are relocatable. This is achieved by the interrupt-trap table pointer (ITTP) bit field in the CPU interrupt flag register, shown in Figure 3-9. The ITTP bit field dictates the starting location (base) of the interrupt-trap vector table. This base address is formed by left shifting by eight bits the value of the ITTP bit field. This shifted value is called the effective base address and is referenced as EA[ITTP], as shown in Figure 3-10. Therefore, the location of an interrupt or trap vector is given by the addition of the effective base address formed by the ITTP bit field (EA[ITTP]) and the offset of the interrupt or trap vector in the interrupttrap vector table, as shown in Figure 3-11. For example, if the ITTP contains the value 100h, the serial port transmit interrupt vector is located at 10005h. Note that the vectors stored in the interrupt-trap vector table are the addresses of the start of the respective interrupt and trap routines. Furthermore, the interrupt-trap vector table must lie on a 256-word boundary, since the eight LSBs of the effective base address of the interrupt-trap vector table are 0. See Section 7.6, Interrupts, on page 7-26 for more information on interrupt vector tables. Figure 3-10. Effective Base Address of the Interrupt-Trap Vector Table 23 EA[ITTP] = Bits 31 -16 of the CPU interrupt flag register 8 7 00000000 0 3-14 CPU Multiport Register File Figure 3-11.Interrupt and Trap Vector Locations EA (ITTP) + 00h EA (ITTP) + 01h EA (ITTP) + 02h EA (ITTP) + 03h EA (ITTP) + 04h EA (ITTP) + 05h EA (ITTP) + 06h EA (ITTP) + 07h EA (ITTP) + 08h EA (ITTP) + 09h EA (ITTP) + 0Ah EA (ITTP) + 0Bh EA (ITTP) + 0Ch EA (ITTP) + 0Dh Reserved EA (ITTP) + 1Fh EA (ITTP) + 20h TRAP0 . . . . EA (ITTP) + 3Bh EA (ITTP) + 3Ch EA (ITTP) + 3Dh EA (ITTP) + 3Eh EA (ITTP) + 3Fh TRAP27 TRAP28 (reserved) TRAP29 (reserved) TRAP30 (reserved) TRAP31 (reserved) Reserved INT0 INT1 INT2 INT3 XINT0 RINT0 Reserved Reserved TINT0 TINT1 DINT0 DINT1 CPU Registers 3-15 CPU Multiport Register File 3.1.10 I/O Flag (IOF) Register The I/O flag (IOF) register is shown in Figure 3-12 and controls the function of the dedicated external pins, XF0 and XF1. These pins can be configured for input or output. The pins can also be read from and written to. At reset, 0 is written to this register. Table 3-5 describes the I/O flags register bits, their names, and their functions. Figure 3-12. I/O Flag (IOF) Register 31-16 xx 15-12 xx 11-8 xx 7 INXF1 R Notes: 1) xx = reserved bit, read as 0 2) R = read, W = write 6 5 4 xx 3 INXF0 R 2 OUTXF0 R/W 1 I/OXF0 R/W 0 xx OUTXF1 I/OXF1 R/W R/W Table 3-5. IOF Bits and Functions Bit Name I/OXF0 Reset Value 0 Function If 0, XF0 is configured a general-purpose input pin. If 1, XF0 is configured a general-purpose output pin. OUTXF0 INXF0 I/OXF1 0 0 0 Data output on XF0. Data input on XF0. A write has no effect. If 0, XF1 is configured a general-purpose input pin. If 1, XF1 is configured a general-purpose output pin. OUTXF1 INXF1 0 0 Data output on XF1. Data input on XF1. A write has no effect. 3-16 CPU Multiport Register File 3.1.11 Repeat-Counter (RC) and Block-Repeat (RS, RE) Registers The repeat-counter (RC) register is a 32-bit register that specifies the number of times a block of code is to be repeated when a block repeat is performed. If RC contains the number n, the loop is executed n + 1 times. The 32-bit repeat start-address (RS) register contains the starting address of the program-memory block to be repeated when the CPU is operating in the repeat mode. The 32-bit repeat end-address (RE) register contains the ending address of the program-memory block to be repeated when the CPU is operating in the repeat mode. Note: RE < RS If RE< RS and the block mode is enabled, the code between RE and RS is bypassed when the program counter encounters the repeat end (RE) address. CPU Registers 3-17 Other Registers 3.2 Other Registers 3.2.1 Program-Counter (PC) Register The program counter (PC) is a 32-bit register containing the address of the next instruction fetch. While the program-counter register is not part of the CPU register file, it can be modified by instructions that modify the program flow. 3.2.2 Instruction Register (IR) The instruction register (IR) is a 32-bit register that holds the instruction opcode during the decode phase of the instruction. This register is used by the instruction decode control circuitry and is not accessible to the CPU. 3-18 Reserved Bits and Compatibility 3.3 Reserved Bits and Compatibility To retain compatibility with future members of the 'C3x family of microprocessors, reserved bits that are read as 0 must be written as 0. You must not modify the current value of a reserved bit that has an undefined value. In other cases, you should maintain the reserved bits as specified. CPU Registers 3-19 3-20 Chapter 4 Memory and the Instruction Cache The 'C3x provides a total memory space of 16M (million) 32-bit words that contain program, data, and I/O space. Two RAM blocks of 1K 32 bits each (available on the 'C30 and 'C31) or two RAM blocks of 256 32 bits (available on the 'C32) and a ROM block of 4K 32 bits (available only on the 'C30) or boot loader (available on the 'C31 and the 'C32) permit two CPU accesses in a single cycle. The VC33 contains four RAM blocks totaling 34K words plus an internal bootloader identical to the C31 bootloader. A 64 32-bit instruction cache stores often-repeated sections of code, greatly reducing the number of off-chip accesses and allowing code to be stored off-chip in slower, lower-cost memories. Note: VC33 The TMS320VC33 is logically and functionally a superset of the TMS320C31 making nearly all literature and documentation for the TMS320C31 applica- ble. However, the electrical characteristics are different and are covered in detail in the TMS320VC33 data sheet (literature number SPRS087). Topic 4.1 4.2 4.3 Page Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 Reset/Interrupt/Trap Vector Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14 Instruction Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19 4-1 Memory 4.1 Memory The 'C3x accesses a total memory space of 16M (million) 32-bit words of program, data, and I/O space and allows tables, coefficients, program code, or data to be stored in either RAM or ROM. In this way, you can maximize memory usage and allocate memory space as desired. RAM blocks 0 and 1 are each 1K 32 bits on the 'C30 and 'C31/VC33. The ROM block is 4K 32 bits on the 'C30. The 'C31/VC33 and 'C32 have a boot ROM. By manipulating one external pin (MC/MP or MCBL/MP), you can configure the first 1000h words of memory to address the on-chip ROM or external RAM. Each on-chip RAM and ROM block can support two CPU accesses in a single cycle. The separate program buses, data buses, and DMA buses allow for parallel program fetches, data reads/writes, and DMA operations, which are covered in Chapter 11, Peripherals. 4.1.1 Memory Maps The following sections describe the memory maps for the 'C30, 'C31/VC33, and 'C32. 4.1.1.1 TMS320C30 Memory Map The memory map depends on whether the processor is running in microprocessor mode (MC/MP = 0) or microcomputer mode (MC/MP = 1). The memory maps for these modes are similar (see Figure 4-1 on page 4-4). Locations 800000h-801FFFh are mapped to the expansion bus. When this region is accessed, MSTRB is active. Locations 802000h-803FFFh are reserved. Locations 804000h-805FFFh are mapped to the expansion bus. When this region is accessed, IOSTRB is active. Locations 806000h- 807FFFh are reserved. All of the memory-mapped peripheral bus registers are in locations 808000h-8097FFh. In both modes, RAM block 0 is located at addresses 809800h-809BFFh, and RAM block 1 is located at addresses 809C00h-809FFFh. Locations 80A000h-0FFFFFFh are accessed over the external memory port (STRB active). - Microprocessor Mode In microprocessor mode, the 4K on-chip ROM is not mapped into the 'C3x memory map. Locations 0h-03Fh consist of interrupt vector, trap vector, and reserved locations, all of which are accessed over the external memory port (STRB active) (see Figure 4-1 on page 4-4). Locations 040h-7FFFFFh are also accessed over the external memory port. 4-2 Memory - Microcomputer Mode In microcomputer mode, the 4K on-chip ROM is mapped into locations 0h-0FFFh. There are 192 locations (0h-0BFh) within this block for interrupt vectors, trap vectors, and a reserved space ('C30). Locations 1000h- 7FFFFFh are accessed over the external memory port (STRB active). Section 4.1.2, Peripheral Bus Memory Map, on page 4-9 describes the peripheral memory maps in greater detail and Section 4.2, Reset/Interrupt/Trap Vector Map, on page 4-14 provides the vector locations for reset, interrupts, and traps. Be careful! Access to a reserved area produces unpredictable results. Memory and the Instruction Cache 4-3 Memory Figure 4-1. TMS320C30 Memory Maps 0h Reset, interrupt, trap vectors, and reserved locations (64) (external STRB active) 0h Reset, interrupt, trap vectors, and reserved locations (192) 0BFh 0C0h External STRB active (8.192M words) 7FFFFFh 800000h 0FFFh 1000h ROM (Internal) External STRB active (8.188M words) Expansion bus MSTRB active (8K words) Reserved (8K words) 803FFFh 804000h Expansion bus IOSTRB active (8K words) Reserved (8K words) 807FFFh 808000h Peripheral bus memory-mapped registers (6K words internal) 8097FFh 809800h RAM block 0 (1K words internal) 809BFFh 809C00h RAM block 1 (1K words internal) 809FFFh 80A000h External STRB active (7.96M words) Microprocessor mode 809FFFh 80A000h 809BFFh 809C00h 8097FFh 809800h RAM block 0 (1K words internal) RAM block 1 (1K words internal) Peripheral bus memory-mapped registers (Internal) (6K words internal) 03Fh 040h 801FFFh 802000h Expansion bus MSTRB active (8K words) Reserved (8K words) 7FFFFFh 800000h 801FFFh 802000h 803FFFh 804000h 805FFFh 806000h Expansion bus IOSTRB active (8K words) Reserved (8K words) 805FFFh 806000h 807FFFh 808000h FFFFFFh FFFFFFh External STRB active (7.96M words) Microcomputer mode 4-4 Memory 4.1.1.2 TMS320C31/VC33 Memory Map The memory map depends on whether the processor is running in microprocessor mode (MCBL/MP = 0) or microcomputer mode (MCBL/MP = 1). The memory maps for these modes are similar (see Figure 4-2 on page 4-6). Locations 800000h-807FFFh are reserved. All of the memory-mapped peripheral bus registers are in locations 808000h-8097FFh. In both modes, RAM block 0 is located at addresses 809800h-809BFFh, and RAM block 1 is located at addresses 809C00h-809FFFh. Locations 80A000h-0FFFFFFh are accessed over the external memory port (STRB active). - Microprocessor Mode In microprocessor mode, the boot loader is not mapped into the 'C3x memory map. Locations 0h-03Fh consist of interrupt vector, trap vector, and reserved locations, all of which are accessed over the external memory port (STRB active) (see Figure 4-2 on page 4-6). Locations 040h-7FFFFFh are also accessed over the external memory port. - Microcomputer Mode In microcomputer mode, the boot loader ROM is mapped into locations 0h-0FFFh. The last 63 words (809FC1h to 809FFFh) of internal RAM Block 1 are used for interrupt and trap branches (see Figure 4-2 on page 4-6). Locations 1000h-7FFFFFh are accessed over the external memory port (STRB active). Section 4.1.2, Peripheral Bus Memory Map, on page 4-9 describes the peripheral memory maps in greater detail and Section 4.2, Reset/Interrupt/ Trap Vector Map, on page 4-14 provides the vector locations for reset, interrupts, and traps. Be careful! Access to a reserved area produces unpredictable results. Memory and the Instruction Cache 4-5 Memory Figure 4-2. TMS320C31/VC33 Memory Maps 0h Reset, interrupt, trap vectors, and reserved locations (64) (external STRB active) 0h Reserved for bootloader operations 03Fh 040h External STRB active (8.192M words) 0FFFh 1000h Boot 1 External STRB active (8.188M words) 400000h 7FFFFFh 800000h Reserved (32K words) 807FFFh 808000h Peripheral bus memory-mapped registers (6K words internal) RAM block 0 (1K words internal) 809BFFh 809C00h 809BFFh 809C00h 807FFFh 808000h 7FFFFFh 800000h Boot 2 Reserved (32K words) Peripheral bus memory-mapped registers (6K words internal) RAM block 0 (1K words internal) RAM block 1 (1K - 63 words internal) 8097FFh 809800h 8097FFh 809800h RAM block 1 (1K words internal) 809FFFh 80A000h External STRB active (7.96M words) FFFFFFh Microprocessor mode 809FC0h 809FC1h 809FFFh 80A000h FFF000h FFFFFFh User program interrupt and trap branches (63 words internal) External STRB active (7.96M words) Boot 3 Microcomputer/boot-loader mode See Section 3.1.3, Data-Page Pointer (DP), on page 3-4 for more information. 4-6 Memory 4.1.1.3 TMS320C32 Memory Map The memory map depends on whether the processor is running in microprocessor mode (MCBL/MP = 0) or microcomputer mode (MCBL/MP = 1). The memory maps for these modes are similar (see Figure 4-3 on page 4-8). Locations 800000h-807FFFh, 809800h-80FFFh, and 830000H-87FDFFh are reserved. Locations 810000h-82FFFFh are mapped to the external bus with IOSTRB active. All of the memory-mapped peripheral bus registers are in locations 808000h-8097FFh. In both modes, RAM block 0 is located at addresses 87FE00h-87FEFFh, and RAM block 1 is located at addresses 87FF00h- 87FFFFh. Locations 900000h-FFFFFFh are mapped to the external bus with STRB1 active. Unlike the fixed interrupt-trap vector table location of the 'C30 and 'C31/VC33 devices, the 'C32 has a user-relocatable interrupt-trap vector table. The interrupt-trap vector table must start on a 256-word boundary. The starting location is programmed through the interrupt-trap table pointer (ITTP) bit field in the CPU interrupt flag (IF) register. See Section 3.1.9.1, Interrupt-Trap Table Pointer (ITTP), on page 3-14. - Microprocessor Mode In microprocessor mode, the boot loader is not mapped into the 'C3x memory map. Locations 0h-7FFFFFFh are accessed over the external memory port (STRB0 active) with location 0h containing the reset vector. - Microcomputer Mode In microcomputer mode, the on-chip boot loader ROM is mapped into locations 0h-0FFFh. Locations 1000h-7FFFFFh are accessed over the external memory port (STRB0 active). The 'C32 boot loader has additional modes over the 'C31/VC33 boot loader to handle the data types, sizes, and memory widths supported by the external memory interface. The memory boot load supports data transfer with and without handshaking. The handshake mode allows synchronous program transfer by using two pins as data-acknowledge and data-ready signals. See Section 4.1.2, Peripheral Bus Memory Map, on page 4-9 and Section 4.2, Reset/Interrupt/Trap Vector Map, on page 4-14 for more information. Be careful! Access to a reserved area produces unpredictable results. Memory and the Instruction Cache 4-7 Memory Figure 4-3. TMS320C32 Memory Maps 0h Reset-vector location 0FFFh 1000h External memory STRB0 active (8.192M words) 7FFFFFh 800000h Reserved (32K words) 807FFFh 808000h 8097FFh 809800h Peripheral bus memory-mapped registers (6K words internal) Reserved (26K words) 80FFFFh 810000h 80FFFFh 810000h 810001h 807FFFh 808000h 8097FFh 809800h 1001h External memory STRB0 active (8.188M words) 7FFFFFh 800000h Reserved (32K words) Peripheral bus memory-mapped registers (6K words internal) Reserved (26K words) Boot 2 0h Reserved for boot-loader operations Boot 1 External memory IOSTRB active (128K) (128K words) External memory IOSTRB active (128K) (128K words) 82FFFFh 830000h 87FDFFh 87FE00h 87FEFFh 87FF00h 87FFFFh 880000h Reserved (319.5K words) RAM block 0 (256 words internal) RAM block 1 (256 words internal) External memory STRB0 active (512K words) External memory STRB1 active (7.168M words) 82FFFFh 830000h 87FDFFh 87FE00h 87FEFFh 87FF00h 87FFFFh 880000h Reserved (319.5K words) RAM block 0 (256 words internal) RAM block 1 (256 words internal) External memory STRB0 active (512K words) Boot 3 External memory STRB1 active (7.168M words) 8FFFFFh 900000h 8FFFFFh 900000h 900001h FFFFFFh FFFFFFh Microprocessor mode Microcomputer/boot-loadermode 4-8 Memory 4.1.2 Peripheral Bus Memory Map The following sections describe the peripherial bus memory maps for the 'C30, 'C31/VC33, and 'C32. 4.1.2.1 TMS320C30 Peripheral Bus Memory Map The 'C30 memory-mapped peripheral registers are located starting at address 808000h. Figure 4-4 on page 4-10 shows the peripheral bus memory map. The shaded blocks are reserved. Memory and the Instruction Cache 4-9 Memory Figure 4-4. TMS320C30 Peripheral Bus Memory-Mapped Registers 808000h 808004h 808006h 808008h 808020h 808024h 808028h 808030h 808034h 808038h 808040h 808042h 808043h 808044h 808045h 808046h 808048h 80804Ch 808050h 808052h 808053h 808054h 808055h 808056h 808058h 80805Ch 808060h 808064h DMA global control DMA source address DMA destination address DMA transfer counter Timer 0 global control Timer 0 counter Timer 0 period Timer 1 global control Timer 1 counter Timer 1 period register Serial port 0 global control FSX/DX/CLKX serial port 0 control FSR/DR/CLKR serial port 0 control Serial port 0 R/X timer control Serial port 0 R/X timer counter Serial port 0 R/X timer period Serial port 0 data transmit Serial port 0 data receive Serial port 1 global control FSX/DX/CLKX serial port 1 control FSR/DR/CLKR serial port 1 control Serial port 1 R/X timer control Serial port 1 R/X timer counter Serial port 1 R/X timer period Serial port 1 data transmit Serial port 1 data receive Expansion-buscontrol Primary-bus control 4-10 Memory 4.1.2.2 TMS320C31/VC33 Peripheral Bus Memory Map The 'C31/VC33 memory-mapped peripheral registers are located starting at address 808000h. Figure 4-5 shows the peripheral bus memory map. The shaded blocks are reserved. Figure 4-5. TMS320C31/VC33 Peripheral Bus Memory-Mapped Registers 808000h 808004h 808006h 808008h 808020h 808024h 808028h 808030h 808034h 808038h 808040h 808042h 808043h 808044h 808045h 808046h 808048h 80804Ch 808064h DMA global control DMA source address DMA destination address DMA transfer counter Timer 0 global control Timer 0 counter Timer 0 period Timer 1 global control Timer 1 counter Timer 1 period register Serial port global control FSX/DX/CLKX serial port control FSR/DR/CLKR serial port control Serial port R/X timer control Serial port R/X timer counter Serial port R/X timer period Serial port data transmit Serial port data receive Primary-bus control Memory and the Instruction Cache 4-11 Memory 4.1.2.3 TMS320C32 Peripheral Bus Memory Map The 'C32's memory-mapped peripheral and external-bus control registers are located starting at address 808000h, as shown in Figure 4-6 on page 4-13. The shaded blocks are reserved. 4-12 Memory Figure 4-6. TMS320C32 Peripheral Bus Memory-Mapped Registers 808000h 808004h 808006h 808008h 808010h 808014h 808016h 808018h 808020h 808024h 808028h 808030h 808034h 808038h 808040h 808042h 808043h 808044h 808045h 808046h 808048h 80804Ch 808060h 808064h 808068h 8097FFh DMA 0 global control DMA 0 source address DMA 0 destination address DMA 0 transfer counter DMA 1 global control DMA 1 source address DMA 1 destination address DMA 1 transfer counter Timer 0 global control Timer 0 counter Timer 0 period Timer 1 global control Timer 1 counter Timer 1 period register Serial port global control FSX/DX/CLKX serial port control FSR/DR/CLKR serial port control Serial port R/X timer control Serial port R/X timer counter Serial port R/X timer period Serial port data transmit Serial port data receive IOSTRB bus control STRB0 bus control STRB1 bus control Memory and the Instruction Cache 4-13 Reset/Interrupt/Trap Vector Map 4.2 Reset/Interrupt/Trap Vector Map The addresses for the reset, interrupt, and trap vectors are 00h-3Fh, as shown in Figure 4-7 and Figure 4-8. The reset vector contains the address of the reset routine. - 'C30 and 'C31/VC33 Microprocessor and Microcomputer Modes In the microprocessor mode of the 'C30 and 'C31/VC33 and the microcomputer mode of the 'C30, the reset interrupt and trap vectors stored in locations 0h-3Fh are the addresses of the starts of the respective reset, interrupt, and trap routines. For example, at reset, the content of memory location 00h (reset vector) is loaded into the PC, and execution begins from that address (see Figure 4-8 on page 4-16). - 'C31/VC33 Microcomputer/Boot-Loader Mode In the microcomputer/boot-loader mode of the 'C31/VC33, the interrupt and trap vectors stored in locations 809FC1h-809FFFh are branch instructions to the start of the respective interrupt and trap routines (see Figure 4-9 on page 4-17). - 'C32 Microprocessor and Microcomputer/Boot-Loader Mode The 'C32 has a user-relocatable interrupt-trap vector table. The interrupttrap vector table must start on a 256-word boundary. The starting location is programmed through the interrupt-trap table pointer (ITTP) bit field in the CPU interrupt flag (IF) register. See Section 3.1.9.1, Interrupt-Trap Table Pointer (ITTP), on page 3-14. The reset vector is stored at location 0h in microprocessor mode. 4-14 Reset/Interrupt/Trap Vector Map Figure 4-7. Reset, Interrupt, and Trap Vector Locations for the TMS320C30 Microprocessor Mode 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch Reserved 1Fh 20h TRAP 0 D D D 3Bh 3Ch 3Dh 3Eh 3Fh TRAP 27 TRAP 28 (reserved) TRAP 29 (reserved) TRAP 30 (reserved) TRAP 31 (reserved) RESET INT0 INT1 INT2 INT3 XINT0 RINT0 XINT1 RINT1 TINT0 TINT1 DINT Note: Traps 28-31 Traps 28-31 are reserved; do not use them. Memory and the Instruction Cache 4-15 Reset/Interrupt/Trap Vector Map Figure 4-8. Reset, Interrupt, and Trap Vector Locations for theTMS320C31/VC33 Microprocessor Mode 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch 1Fh 20h RESET INT0 INT1 INT2 INT3 XINT0 RINT0 XINT1 (Reserved) RINT1 (Reserved) TINT0 TINT1 DINT Reserved TRAP 0 3Bh 3Ch 3Dh 3Eh 3Fh TRAP 27 TRAP 28 (reserved) TRAP 29 (reserved) TRAP 30 (reserved) TRAP 31 (reserved) Note: Traps 28-31 Traps 28-31 are reserved; do not use them. 4-16 Reset/Interrupt/Trap Vector Map Figure 4-9. Interrupt and Trap Branch Instructions for the TMS320C31/VC33 Microcomputer Mode 809FC1h 809FC2h 809FC3h 809FC4h 809FC5h 809FC6h 809FC7h 809FC8h 809FC9h 809FCAh 809FCBh 809FCCh 809FDFh 809FE0h 809FE1h INT0 INT1 INT2 INT3 XINT0 RINT0 XINT1 (reserved) RINT1 (reserved) TINT0 TINT1 DINT Reserved TRAP 0 TRAP 1 809FFBh 809FFCh 809FFDh 809FFEh 809FFFh TRAP 27 TRAP 28 (reserved) TRAP 29 (reserved) TRAP 30 (reserved) TRAP 31 (reserved) Note: Traps 28-31 Traps 28-31 are reserved; do not use them. Unlike the 'C31/VC33's microprocessor mode, the 'C31/VC33 microcomputer/boot loader mode uses a dual-vectoring scheme to service interrupts and trap requests. In this dual vectoring scheme, a branch instruction rather than a vector address is used. Memory and the Instruction Cache 4-17 Reset/Interrupt/Trap Vector Map Figure 4-10. Interrupt and Trap Vector Locations for TMS320C32 EA (ITTP) + 00h EA (ITTP) + 01h EA (ITTP) + 02h EA (ITTP) + 03h EA (ITTP) + 04h EA (ITTP) + 05h EA (ITTP) + 06h EA (ITTP) + 07h EA (ITTP) + 08h EA (ITTP) + 09h EA (ITTP) + 0Ah EA (ITTP) + 0Bh EA (ITTP) + 0Ch EA (ITTP) + 0Dh Reserved EA (ITTP) + 1Fh EA (ITTP) + 20h TRAP0 . . . . EA (ITTP) + 3Bh EA (ITTP) + 3Ch EA (ITTP) + 3Dh EA (ITTP) + 3Eh EA (ITTP) + 3Fh TRAP27 TRAP28 (reserved) TRAP29 (reserved) TRAP30 (reserved) TRAP31 (reserved) Reserved INT0 INT1 INT2 INT3 XINT0 RINT0 Reserved Reserved TINT0 TINT1 DINT0 DINT1 Note: Traps 28-31 Traps 28-31 are reserved; do not use them. 4-18 Instruction Cache 4.3 Instruction Cache A 64 32-bit instruction cache speeds instruction fetches and lowers system cost by caching program fetches from external memory. The instruction cache allows the use of slow, external memories while still achieving single-cycle access performances. This reduces the number of off-chip accesses necessary and allows code to be stored off-chip in slower, lower-cost memories. The cache also frees external buses from program fetches so that they can be used by the DMA or other system elements. The cache can operate automatically, with no user intervention. Subsection 4.3.2 describes a form of the least recently used (LRU) cache update algorithm. 4.3.1 Instruction-Cache Architecture The instruction cache (see Figure 4-12) contains 64 32-bit words of RAM; it is divided into two 32-word segments. A 19-bit segment start address (SSA) register is associated with each segment. For each word in the cache, there is a corresponding single bit-present (P) flag. When the CPU requests an instruction word from external memory, the cache algorithm checks to determine if the word is already contained in the instruction cache. Figure 4-11 shows how the cache-control algorithm partitions an instruction address. The algorithm uses the19 most significant bits (MSBs) of the instruction address to select the segment; the five least significant bits (LSBs) define the address of the instruction word within the pertinent segment. The algorithm compares the 19 MSBs of the instruction address with the two SSA registers. If there is a match, the algorithm checks the relevant P flag. The P flag indicates if a word within a particular segment is already present in cache memory: - P = 1: the word is already present in cache memory - P = 0: the location cache is invalid Figure 4-11.Address Partitioning for Cache Control Algorithm 23 Segment start address (SSA) 5 4 Instruction word address within segment 0 If there is no match, one of the segments must be replaced by the new data. The segment replaced in this circumstance is determined by the LRU algorithm. The LRU stack (see Figure 4-12) is maintained for this purpose. Memory and the Instruction Cache 4-19 Instruction Cache Figure 4-12. Instruction-Cache Architecture Segment start address registers P flags Segment words LRU Stack MRU segment number SSA register 0 19 0 1 Segment word 0 Segment word 1 LRU segment number Segment 0 30 31 Segment word 30 Segment word 31 32 SSA register 1 0 1 Segment word 0 Segment word 1 Segment 1 30 31 Segment word 30 Segment word 31 The LRU stack determines which of the two segments qualifies as the least recently used after each access to the cache. Each time a segment is accessed, its segment number is removed from the LRU stack and pushed onto the top of the LRU stack. Therefore, the number at the top of the stack is the most recently used (MRU) segment number, and the number at the bottom of the stack is the least recently used segment number. At reset, the LRU stack is initialized with 0 at the top and 1 at the bottom. All P flags in the instruction cache are cleared. When a replacement is necessary, the LRU segment is selected for replacement. Also, the 32 P flags for the segment to be replaced are set to 0, and the segment's SSA register is replaced with the 19 MSBs of the instruction address. 4-20 Instruction Cache 4.3.2 Instruction-Cache Algorithm When the 'C3x requests an instruction word from external memory, one of two possible actions occurs: a cache hit or a cache miss. - Cache Hit. The cache contains the requested instruction, and the following actions occur: J J The instruction word is read from the cache. The number of the segment containing the word is removed from the LRU stack and pushed to the top of the LRU stack (if it is not already at the top), thus moving the other segment number to the bottom of the stack. - Cache Miss. The cache does not contain the instruction. There are two types of cache misses: J Subsegment miss. The segment address register matches the instruction address, but the relevant P flag is not set. The following actions occur in parallel: H H The instruction word is read from memory and copied into the cache. The number of the segment containing the word is removed from the LRU stack and pushed to the top of the LRU stack (if it is not already at the top), thus moving the other segment number to the bottom of the stack. The relevant P flag is set. H J Segment miss. Neither of the segment addresses matches the instruction address. The following actions occur in parallel: H H H The LRU segment is selected for replacement. The P flags for all 32 words are cleared. The SSA register for the selected segment is loaded with the 19 MSBs of the address of the requested instruction word. The instruction word is fetched and copied into the cache. It goes into the appropriate word of the LRU segment. The P flag for that word is set to 1. The number of the segment containing the instruction word is removed from the LRU stack and pushed to the top of the LRU stack, thus moving the other segment number to the bottom of the stack. Memory and the Instruction Cache 4-21 H Instruction Cache Only instructions may be fetched from the program cache. All reads and writes of data in memory bypass the cache. Program fetches from internal memory do not modify the cache and do not generate cache hits or misses. The program cache is a single-access memory block. Dummy program fetches (for example, those following a branch) are treated by the cache as valid program fetches and can generate cache misses and cache updates. Notes: Using Self-Modifying Code Be careful when using self-modifying code. If an instruction resides in the cache and the corresponding location in primary memory is modified, the copy of the instruction in the cache is not modified. You can use the cache more efficiently by aligning program code on 32-word address boundaries. Do this with the .align directive when coding assembly language. 4.3.3 Cache Control Bits Three cache control bits are located in the CPU status register: - Cache Clear Bit (CC). Set CC = 1 to invalidate all entries in the cache. This bit is always cleared after it is written to; it is always read as a 0. At reset, the cache is cleared, and 0 is written to this bit. - Cache Enable Bit (CE). Set CE = 1 to enable the cache, allowing the cache to be used according to the LRU cache algorithm. Set CE = 0 to disable the cache; this prevents cache update modifications (thus, no cache fetches can be made). At reset, 0 is written to this bit. Cache clearing (CC = 1) is allowed when CE = 0. - Cache Freeze Bit (CF). Set CF = 1 to freeze both the cache and LRU stack manipulation. If the cache is enabled (CE = 1) and the cache is frozen (CF = 1), fetches from the cache are allowed, but modification of cache contents is not allowed. Cache clearing (CC = 1) is allowed when CF = 1 or CF = 0. At reset, this CF bit is cleared to 0. Table 4-1 shows the combined effect of the CE and CF. 4-22 Instruction Cache Table 4-1. Combined Effect of the CE and CF Bits CE 0 0 1 1 CF 0 1 0 1 Effect Cache not enabled Cache not enabled Cache enabled and not frozen Cache enabled and frozen When the CE or CF bits of the CPU status register are modified, the following four instructions may or may not be fetched from the cache or external memory (see Example 4-1). When the CC bit of the CPU status register is modified, the following five instructions may or may not be fetched from the cache before the cache is cleared (see Example 4-1). Example 4-1. Pipeline Effects of Modifying the Cache Control Bits Pipeline Operation Cycle n n+1 n+2 n+3 Instructions may be fetched before cache cleared. Fetch LDI 1000h, ST LDI 1h, R1 LDI 2h, R2 LDI 3h, R3 LDI 4h, R4 LDI 5h, R5 Decode Read Execute Instructions may be fetched before cache is enabled or frozen. LDI 1000h, ST LDI 1h, R1 LDI 2h, R2 LDI 3h, R3 LDI 4h, R4 LDI 5h, R5 LDI 1000h, ST LDI 1h, R1 LDI 2h, R2 LDI 3h, R3 LDI 4h, R4 LDI 5h, R5 Cache cleared LDI 1000h, ST LDI 1h, R1 LDI 2h, R2 LDI 3h, R3 LDI 4h, R4 LDI 5h, R5 n+4 n+5 n+6 n+7 n+8 Memory and the Instruction Cache 4-23 4-24 Chapter 5 Data Formats and Floating Point Operation In the 'C3x architecture, data is organized into three fundamental types: integer, unsigned integer, and floating-point. The terms integer and signed integer are equivalent. The 'C3x supports short and single-precision formats for signed and unsigned integers. It also supports short, single-precision, and extendedprecision formats for floating-point data. Floating-point operations make fast, trouble-free, accurate, and precise computations. Specifically, the 'C3x implementation of floating-point arithmetic facilitates floating-point operations at integer speeds, while preventing problems with overflow, operand alignment, and other burdensome tasks that are common in integer operations. This chapter discusses data formats and floating-point operations supported in the 'C3x. Topic 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 Page Integer Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Unsigned-Integer Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 Floating-Point Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 Floating-Point Conversion (IEEE Std. 754) . . . . . . . . . . . . . . . . . . . . . 5-14 Floating-Point Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26 Floating-Point Addition and Subtraction . . . . . . . . . . . . . . . . . . . . . . . 5-32 Normalization Using the NORM Instruction . . . . . . . . . . . . . . . . . . . . . 5-37 Rounding (RND Instruction) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-39 Floating-Point to Integer Conversion (FIX Instruction) . . . . . . . . . . . 5-41 5.10 Integer to Floating-Point Conversion (FLOAT Instruction) . . . . . . . 5-43 5.11 Fast Logarithms on a Floating-Point Device . . . . . . . . . . . . . . . . . . . . 5-44 5-1 Integer Formats 5.1 Integer Formats The 'C3x supports two integer formats: a 16-bit short-integer format and a 32-bit single-precision integer format. Note: When extended-precision registers are used as integer operands, only bits 31-0 are used; bits 39-32 remain unchanged. 5.1.1 Short-Integer Format The short-integer format is a 16-bit 2s-complement integer format for immediateinteger operands. For those instructions that assume integer operands, this format is sign-extended to 32 bits (see Figure 5-1). The range of an integer si, represented in the short-integer format, is -215 si 215 - 1. In Figure 5-1, s = signed bit. Figure 5-1. Short-Integer Format and Sign-Extension of Short Integers 15 s Short-integer format 31 16 15 s 0 0 s s s s s s s s s s s s s s s s Sign-extension of a short integer 5.1.2 Single-Precision Integer Format In the single-precision integer format, the integer is represented in 2s-complement notation. The range of an integer sp, represented in the single-precision integer format, is -231 sp 231 - 1. Figure 5-2 shows the single-precision integer format. Figure 5-2. Single-Precision Integer Format 31 s 0 5-2 Unsigned-Integer Formats 5.2 Unsigned-Integer Formats The 'C3x supports two unsigned-integer formats: a 16-bit short format and a 32-bit single-precision format. Note: In extended-precision registers, the unsigned-integer operands use only bits 31-0; bits 39-32 remain unchanged. 5.2.1 Short Unsigned-Integer Format Figure 5-3 shows the16-bit, short, unsigned-integer format for immediate unsigned-integer operands. For those instructions which assume unsignedinteger operands, this format is zero filled to 32 bits. The range of a short unsigned integer is 0 si 216. Figure 5-3. Short Unsigned-Integer Format and Zero Fill 15 0 Short unsigned-integer format 31 16 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Zero fill of a short unsigned integer 5.2.2 Single-Precision Unsigned-Integer Format In the single-precision unsigned-integer format, the number is represented as a 32-bit value, as shown in Figure 5-4. The range of a single-precision unsigned integer is 0 sp 232. Figure 5-4. Single-Precision Unsigned-Integer Format 31 0 Data Formats and Floating-Point Operation 5-3 Floating-Point Formats 5.3 Floating-Point Formats The 'C3x supports four floating-point formats: - A short floating-point format for immediate floating-point operands, consisting of a 4-bit exponent, a sign bit, and an 11-bit fraction - ('C32 only) A short floating-point format for use with 16-bit floating-point data types, consisting of a 2s-complement, 8-bit exponent field, a sign bit, and a 7-bit fraction - A single-precision floating-point format by an 8-bit exponent field, a sign bit, and a 23-bit fraction - An extended-precision floating-point format consisting of an 8-bit exponent field, a sign bit, and a 31-bit fraction. All 'C3x floating-point formats consist of three fields: an exponent field (e), a single-bit sign field (s), and a fraction field (f). The sign field and fraction field may be considered as one unit and referred to as the mantissa field (man). Figure 5-5. General Floating-Point Format Exponent Sign Fraction Mantissa The general equation for calculating the value in a floating-point number is: x + ss.f 2 2e In the equation, s is the value of the sign bit, s is the inverse of the value of the sign bit, f is the binary value of the fraction field, and e is the decimal equivalent of the exponent field. The mantissa represents a normalized 2s-complement number. In a normalized representation, a most significant nonsign bit is implied, thus providing an additional bit of precision. The implied sign bit is used as follows: - If s = 0, then the leading two bits of the mantissa are 01. - If s = 1, then the leading two bits of the mantissa are 10. If the sign bit, s, is equal to 0, the mantissa becomes 01.f2, where f is the binary representation of the fraction field. If s is 1, the mantissa becomes 10.f2, where f is the binary representation of the fraction field. For example, if f = 000000000012 and s = 0, the value of the mantissa (man) is 01.000000000012. If s = 1 for the same value of f, the value of man is 10.000000000012. 5-4 Floating-Point Formats The exponent field is a 2s-complement number that determines the factor of 2 by which the number is multiplied. Essentially, the exponent field shifts the binary point in the mantissa. If the exponent is positive, then the binary point is shifted to the right. If the exponent is negative, then the binary point is shifted to the left. For example, if man = 01.000000000012 and the e = 1110, then the binary point is shifted 11 places to the right, producing the number: 01000000000012, which is equal to 2049 decimal. 5.3.1 Short Floating-Point Format In the short floating-point format, floating-point numbers are represented by a 2s-complement, 4-bit exponent field (e) and a 2s-complement, 12-bit mantissa field (man) with an implied most significant nonsign bit (see Figure 5-6). Figure 5-6. Short Floating-Point Format 15 Exponent 12 11 10 Sign Fraction Mantissa 0 Operations are performed with an implied binary point between bits 11 and 10. When the implied most significant nonsign bit is made explicit, it is located to the immediate left of the binary point. The floating-point 2s-complement number x in the short floating-point format is given by the following: x = 01.f 2e x = 10.f 2e x = 0 if s = 0 if s = 1 if e = -8 You must use the following reserved values to represent 0 in the short floatingpoint format: e = -8 s = 0 f = 0 Data Formats and Floating-Point Operation 5-5 Floating-Point Formats The following examples illustrate the range and precision of the short floatingpoint format: Most positive: Least positive: Least negative: Most negative: x = (2 - 2 -11) 27 = 2.5594 102 x = 1 2 -7 = 7.8125 10-3 x = (-1-2 -11) 2 -7 = -7.8163 10-3 x = -2 27 = -2.5600 102 5.3.2 TMS320C32 Short Floating-Point Format for External 16-Bit Data To facilitate the handling of 16-bit floating-point data types, the `C32 uses a new short floating-point format for external 16-bit data types. Note that the following short floating-point format is used only in external 16-bit floating-point data access. This format is different than the 16-bit immediate short floating-point data format used in the `C32's instruction set. In the short floating-point format for external 16-bit data-type size, floating-point numbers are represented by a 2s-complement, 8-bit exponent field (e), a sign bit (s), and an 8-bit mantissa field (man) with an implied most significant nonsign bit. Figure 5-7. TMS320C32 Short Floating-Point Format for External 16-Bit Data 15 Exponent 8 Sign 76 Fraction Mantissa 0 Operations are performed with an implied binary point between bits 7 and 6. When the implied most significant nonsign bit is made explicit, it is located to the immediate left of the binary point. The floating-point 2s-complement number x in the short floating-point format is given by: x = 01.f 2e x = 10.f 2e x = 0 if s = 0 if s = 1 if e = -128 You must use the following reserved values to represent 0 in the `C32 short floating-point format for external 16-bit data: e = -128 s = 0 f = 0 5-6 Floating-Point Formats The following examples illustrate the range and precision of the `C32 short floating-point format for external 16-bit data: Most positive: Least positive Least negative: Most negative: x = (2-2-8) 2127 = 3.3961775 1038 -127 = 5.8774717541 x=1 2 10-39 -8) -127 = -5.9004306 x = (-1-2 2 10-39 x = (-2 2127) = -3.4028236 1038 Note that the floating-point instructions (such as LDF, MPYF, ADDF) and the integer instructions (such as LDI, MPYI, ADDI) produce different results when accessing the same memory location. The integer load instructions store the value in the LSBs of the `C32's registers. A bit field in the strobe control register controls sign extension or zero fill of the MSBs of the integer value. On the other hand, the floating-point load instructions store the value in the MSBs of the `C32's registers. For example: If AR1 = 4000h, R1 = 00 0000 0000h, the value stored at memory location 4000h is 0180h, and STRB0 is configured for a physical memory size and data type size of 16 bits. The result of: ADDI *AR1,R1 is R1 = 00 0000 0180h, while The result of: ADDF *AR1,R1 is R1 = 01 C0000000h (= - 3.0), since - 4.0 + 1.0 = - 3.0 5.3.3 Single-Precision Floating-Point Format In the single-precision format, the floating-point number is represented by an 8-bit exponent field (e ) and a 2s-complement 24-bit mantissa field (man) with an implied most significant nonsign bit (see Figure 5-8). Figure 5-8. Single-Precision Floating-Point Format 31 Exponent 24 23 Sign 22 Fraction Mantissa 0 Operations are performed with an implied binary point between bits 23 and 22. When the implied most significant nonsign bit is made explicit, it is located to the immediate left of the binary point. The floating-point number x is given by the following: x = 01.f 2e x = 10.f 2e x = 0 if s = 0 if s = 1 if e = -128 Data Formats and Floating-Point Operation 5-7 Floating-Point Formats You must use the following reserved values to represent 0 in the single-precision floating-point format: e = - 128 s = 0 f = 0 The following examples illustrate the range and precision of the single-precision floating-point format: Most positive: Least positive: Least negative: Most negative: x = (2 - 2 -23) 2127 = 3.4028234 1038 x = 1 2 -127 = 5.8774717 10-39 x = (-1-2 -23) 2 -127 = - 5.8774724 10-39 x = -2 2127 = - 3.4028236 1038 5.3.4 Extended-Precision Floating-Point Format In the extended-precision format, the floating-point number is represented by an 8-bit exponent field (e ) and a 32-bit mantissa field (man) with an implied most significant nonsign bit (see Figure 5-9). Figure 5-9. Extended-Precision Floating-Point Format 39 Exponent 32 31 30 Sign Fraction Mantissa 0 Operations are performed with an implied binary point between bits 31 and 30. When the implied most significant nonsign bit is made explicit, it is located to the immediate left of the binary point. The floating-point number x is given by the following: x = 01.f 2e x = 10.f 2e x = 0 if s = 0 if s = 1 if e = -128 You must use the following reserved values to represent 0 in the extendedprecision floating-point format: e = -128 s = 0 f = 0 5-8 Floating-Point Formats The following examples illustrate the range and precision of the extendedprecision floating-point format: Most positive: Least positive: Least negative: Most negative: x = (2 - 2 -23) 2127 = 3.4028234 1038 x = 1 2 -127 = 5.8774717541 1038 x = (-1-2 -31) 2 -127 = - 5.8774717569 10-39 x = -2 2127 = - 3.4028236691 1038 5.3.5 Determining the Decimal Equivalent of a TMS320C3x Floating-Point Format To convert a `C3x floating-point number to its decimal equivalent, follow these steps: Step 1: Convert the exponent field to its decimal representation. The exponent field is a 2s-complement number. To convert a 2scomplement number, look at the MSB. If it is 0, then convert the binary number to a decimal number. If the MSB is 1, then complement the binary number, add 1 to the result, and then convert this binary number to a decimal number. Step 2: Convert the mantissa field to its decimal representation. The mantissa field is represented as a sign-mantissa number with an implied 1 and an implied binary point between the sign bit and the fraction field. If the sign bit is cleared (s = 0), form the mantissa by writing 01, and appending the bits in the fraction field after the binary point. For example, if f = 101000000002, then man = 01.101000000002: s 0 1 0 1 0 0 Fraction 0 0 0 0 0 0 Rewrite the mantissa as: Mantissa 0 1 . 1 0 1 0 0 0 0 0 0 0 0 If the sign bit is set (s = 1), form the mantissa by writing 10 and appending the bits in the fraction field after the binary point. For example, if f = 101000000002, then man = 10.101000000002. s 1 1 0 1 0 0 Fraction 0 0 0 0 0 0 Data Formats and Floating-Point Operation 5-9 Floating-Point Formats Rewrite the mantissa as: Mantissa 1 0 . 1 0 1 0 0 0 0 0 0 0 0 Step 3: Shift the decimal point of the mantissa according to the value of the exponent. If the exponent is positive, shift the binary point to the right by the value of the exponent. If the exponent is negative, shift the binary point to the left. For example, if e = 210 and the man = 01.110000000002, then the shifted mantissa becomes 0111.0000000002, which is equivalent to 7 in decimal. If, on the other hand, e = -210 and man = 01.100000000002, then the shifted mantissa becomes 0.01100000000002, which is equivalent to 3/8 in decimal. The following examples illustrate how you can obtain the equivalent floating-point value of a number in `C3x floating-point format. Each of the examples uses the single-precision floating-point format. Example 5-1. Positive Number 0 2 4 0 0 0 0 0 0000 0010 0100 0000 0000 0000 0000 0000 Exponent = Sign = Fraction = Value = 0000 00102 = 2 0 .100002 01.12 22 = 01102. = 6 Fraction Implied Sign Hex value Binary value 5-10 Floating-Point Formats Example 5-2. Negative Number 0 1 C 0 0 0 0 0 0000 0001 1100 0000 0000 0000 0000 0000 Exponent = Sign = Fraction = Value = 0000 00012 = 1 1 .100002 10.12 21 = 1012. = -3 Fraction Implied Sign Hex value Binary value Example 5-3. Fractional Number F B 4 0 0 0 0 0 1111 1011 0100 0000 0000 0000 0000 0000 Exponent = Sign = Fraction = Value = 1111 10112 = -5 0 .100002 2-5 2-6 Hex value Binary value 01.12 2-5 = .0000112 = 3/64 Fraction Implied Sign Data Formats and Floating-Point Operation 5-11 Floating-Point Formats 5.3.6 Conversion Between Floating-Point Formats Floating-point operations assume several different formats for inputs and outputs. These formats often require conversion from one floating-point format to another (for example, short floating-point format to extended-precision floatingpoint format). Format conversions occur automatically in hardware, with no overhead, as a part of the floating-point operations. Examples of the four conversions are shown in Figure 5-10 through Figure 5-13. When a floating-point format 0 is converted to a greater-precision format, it is always converted to a valid representation of 0 in that format. In Figure 5-10 through Figure 5-13, s = sign bit of the exponent, y = short mantissa, and x = short exponent. Figure 5-10. Converting from Short Floating-Point Format to Single-Precision Floating-Point Format 15 s x x x 12 11 y 10 y 0 y Short floating-point format 31 27 24 23 y 22 y 12 y 11 0 0 0 s s s s s x x x Single-precision floating-point format In this format, the exponent field is sign extended, and the 12 LSBs of the mantissa field are filled with 0s. Figure 5-11. Converting from Short Floating-Point Format to Extended-Precision Floating-Point Format 15 s x x 12 x 11 y 10 y 0 y Short floating-point format 39 35 32 31 y 30 y 20 19 y 0 0 0 s s s s s x x x Extended-precision floating-point format The exponent field in this format is sign extended, and the 20 LSBs of the mantissa field are filled with 0s. 5-12 Floating-Point Formats Figure 5-12. Converting from Single-Precision Floating-Point Format to Extended-Precision Floating-Point Format 31 x 24 23 22 x y y 0 y Single-precision floating-point format 39 x 32 31 30 x y y 8 y Extended-precision floating-point format 7 0 0 0 The 8 LSBs of the mantissa field are filled with 0s. Figure 5-13. Converting from Extended-Precision Floating-Point Format to Single-Precision Floating-Point Format 39 x 32 31 30 x y y 8 y Extended-precision floating-point format 31 x 24 23 22 x y y 0 y 7 z 0 z Single-precision floating-point format The 8 LSBs of the mantissa field are truncated. Data Formats and Floating-Point Operation 5-13 Floating-Point Conversion (IEEE Std. 754) 5.4 Floating-Point Conversion (IEEE Std. 754) The `C3x floating-point format is not compatible with the IEEE standard 754 format. The IEEE floating-point format uses sign-magnitude notation for the mantissa, and the exponent is biased by 127. In a 32-bit word representing a floating-point number, the first bit is the sign bit. The next eight bits correspond to the exponent, which is expressed in an offset-by-127 format (the actual exponent is e -127). The next 23 bits represent the absolute value of the mantissa with the most significant 1 implied. The binary point follows this most significant 1. In other words, the mantissa actually has 24 bits (see Figure 5-14). There are several special cases, summarized below. These are the values of the represented numbers in the IEEE floating-point format: x = (-1)s x 2e-127 x (01.f) if 0 < e < 255 Figure 5-14. IEEE Single-Precision Std. 754 Floating-Point Format 31 s 30 e 23 22 f mantissa 0 The following five cases define the value v of a number expressed in the IEEE format: 1) 2) 3) 4) 5) where: s = sign bit e = the exponent field f = the fraction field NaN = not a number For the above five representations, e is treated as an unsigned integer. Case 1 generates NaN (not an number) and is primarily used for software signaling. Case 4 represents a denormalized number. Case 5 represents positive and negative 0. 5-14 If If If If If e = 255 e = 255 e=0 e=0 and f 0, and f = 0, and f 0, and f = 0, then then then then then v = NaN v = (-1)s infinite v = (-1)s 2 e -127(1.f ) v = (-1)s 2-126(0.f ) v = (-1)s 0 0 < e < 255, Floating-Point Conversion (IEEE Std. 754) Figure 5-15. TMS320C3x Single-Precision 2s-Complement Floating-Point Format 31 e 24 23 s 22 f 0 Note: Same format as for the 'C4x In comparison, Figure 5-15 shows the the `C3x 2s-complement floating-point format. In this format, two cases can be used to define value v of a number: 1) 2) where: s = sign bit e = the exponent field f = the fraction field For this representation, e is treated as a 2s-complement integer. The fraction and sign bit form a normalized 2s-complement mantissa. Note: Differentiating Symbols for IEEE and TMS320C3x Formats To differentiate between the symbols that define these two formats, all IEEE fields are subscripted with an IEEE (for example, eIEEE, sIEEE, and so forth). Similarly, all 2s-complement fields are subscripted with 2 (that is, e2, s2, f2). If If e = -128 e -128 then v = 0 then v = ss.f2 2 e 5.4.1 Converting IEEE Format to 2s-Complement TMS320C3x Floating-Point Format The most common conversion is the IEEE-to-2s-complement format. This conversion is done according to rules in Table 5-1. Table 5-1. Converting IEEE Format to 2s-Complement Floating-Point Format If these values are present Description max neg 1 max pos 1 Case 1 2 3 4 5 zero 6 eIEEE 255 255 0 < eIEEE < 255 0 < eIEEE < 255 0 < eIEEE <255 0 sIEEE 1 0 0 1 1 any fIEEE any any e2 7Fh 7Fh eIEEE -7Fh eIEEE -7Fh eIEEE -80h 80h Then these values equal s2 1 0 0 1 1 0 f2 00 0000h 7F FFFFh fIEEE f IEEE + 1 0 00 0000h fIEEE 0 0 any f IEEE = 1s complement of fIEEE Data Formats and Floating-Point Operation 5-15 Floating-Point Conversion (IEEE Std. 754) Case 1 maps the IEEE positive NaNs and positive infinity to the single-precision 2s-complement most positive number. Overflow is also signaled to allow you to check for these special cases. Case 2 maps the IEEE negative NaNs and negative infinity to the singleprecision 2s-complement most negative number. Overflow is also signaled to allow you to check for these special cases. Case 3 maps the IEEE positive normalized numbers to the identical value in the 2s-complement positive number. Case 4 maps the IEEE negative normalized numbers with a nonzero fraction to the identical value in the 2s-complement negative number. Case 5 maps the IEEE negative normalized numbers with a 0 fraction to the identical value in the 2s-complement negative number. Case 6 maps the IEEE positive and negative denormalized numbers and positive and negative 0s to a 2s-complement 0. Based on these definitions of the formats, two versions of the conversion routines were developed. One version handles the complete definition of the formats. The other ignores some of the special cases (typically the ones that are rarely used), but it has the benefit of executing faster than the complete conversion. For this discussion, the two versions are referred to as the complete version and the fast version, respectively. 5-16 Floating-Point Conversion (IEEE Std. 754) 5.4.1.1 IEEE-to-TMS320C3x Floating-Point Format Conversion Example 5-4 shows the fast conversion from IEEE to 'C3x floating-point format. It properly handles the general case when 0 < e < 255, and also handles 0s (that is, e = 0 and f = 0). The other special cases (denormalized, infinity, and NaN) are not treated and, if present, will give erroneous results. The fast version of the IEEE-to 'C3x conversion routine was originally developed by Keith Henry of Apollo Computer, Inc. The other routines were based on this initial input. Example 5-4. IEEE-to-TMS320C3x Conversion (Fast Version) * * * * * * * * * * * * * * * * * * * * * * * * * * * * TITLE IEEE TO TMS320C3x CONVERSION (FAST VERSION) SUBROUTINE FMIEEE FUNCTION: CONVERSION BETWEEN THE IEEE FORMAT AND THE TMS320C3x FLOATING-POINT FORMAT. THE NUMBER TO BE CONVERTED IS IN THE LOWER 32 BITS OF R0. THE RESULT IS STORED IN THE UPPER 32 BITS OF R0. UPON ENTERING THE ROUTINE, AR1 POINTS TO THE FOLLOWING TABLE: (0) 0xFF800000 <-- AR1 (1) 0xFF000000 (2) 0x7F000000 (3) 0x80000000 (4) 0x81000000 ARGUMENT ARGUMENT ASSIGNMENTS: | FUNCTION -----------+------------------------------------- R0 AR1 | | NUMBER TO BE CONVERTED POINTER TO TABLE WITH CONSTANTS REGISTERS USED AS INPUT: R0, AR1 REGISTERS MODIFIED: R0, R1 REGISTER CONTAINING RESULT: R0 Data Formats and Floating-Point Operation 5-17 Floating-Point Conversion (IEEE Std. 754) Example 5-4.IEEE-to-TMS320C3x Conversion (Fast Version) (Continued) * * * * * * * FMIEEE AND3 BND ADDI LDIZ SUBI PUSH POPF RETS * NEG PUSH POPF NEGF RETS R0,*AR1,R1 NEG R0,R1 *+AR1(1),R1 *+AR1(2),R1 R1 R0 ; ; ; ; ; ; Replace fraction with 0 Test sign Shift sign and exponent inserting 0 If all 0, generate C30 0 Unbias exponent NOTE: SINCE THE STACK POINTER SP IS USED, MAKE SURE TO INITIALIZE IT IN THE CALLING PROGRAM. CYCLES: 12 (WORST CASE) WORDS: 12 .global FMIEEE ; Load this as a flt. pt. number R1 R0 R0,R0 ; Load this as a flt. pt. number ; Negate if orig. sign is negative Example 5-5 shows the complete conversion between IEEE and 'C3x formats. In addition to the general case and the 0s, it handles the special cases as follows: - If NaN (e = 255, f < > 0), the number is returned intact. - If infinity (e = 255, f = 0), the output is saturated to the most positive or nega- tive number, respectively. - If denormalized (e = 0, f< >0), two cases are considered. If the MSB of f is 1, the number is converted to 'C3x format. Otherwise an underflow occurs, and the number is set to 0. 5-18 Floating-Point Conversion (IEEE Std. 754) Example 5-5. IEEE-to-TMS320C3x Conversion (Complete Version) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * TITLE IEEE TO TMS320C3x CONVERSION (COMPLETE VERSION) SUBROUTINE FMIEEE1 FUNCTION: CONVERSION BETWEEN THE IEEE FORMAT AND THE TMS320C3x FLOATING-POINT FORMAT. THE NUMBER TO BE CONVERTED IS IN THE LOWER 32 BITS OF R0. THE RESULT IS STORED IN THE UPPER 32 BITS OF R0. UPON ENTERING THE ROUTINE, AR1 POINTS TO THE FOLLOWING TABLE: (0) 0xFF800000 <-- AR1 (1) 0xFF000000 (2) 0x7F000000 (3) 0x80000000 (4) 0x81000000 (5) 0x7F800000 (6) 0x00400000 (7) 0x007FFFFF (8) 0x7F7FFFFF ARGUMENT ASSIGNMENTS: ARGUMENT | FUNCTION -----------+------------------------------------- R0 | NUMBER TO BE CONVERTED AR1 | POINTER TO TABLE WITH CONSTANTS REGISTERS USED AS INPUT: R0, AR1 REGISTERS MODIFIED: R0, R1 REGISTER CONTAINING RESULT: R0 NOTE: SINCE THE STACK POINTER SP IS USED, MAKE SURE TO INITIALIZE IT IN THE CALLING PROGRAM. CYCLES: 23 (WORST CASE) WORDS: 34 .global FMIEEE1 * FMIEEE1 LDI R0,R1 AND *+AR1(5),R1 BZ UNNORM * XOR *+AR1(5),R1 BNZ NORMAL ; ; ; If e = 0, number is either 0 or denormalized If e < 255, use regular routine Data Formats and Floating-Point Operation 5-19 Floating-Point Conversion (IEEE Std. 754) Example 5-5.IEEE-to-TMS320C3x Conversion (Complete Version) (Continued) * HANDLE NaN AND INFINITY TSTB *+AR1(7),R0 RETSNZ LDI R0,R0 LDFGT LDFN RETS * *+AR1(8),R0 *+AR1(5),R0 ; ; ; ; ; Return if NaN If positive, infinity = most positive number If negative, infinity = most negative number RETS HANDLE 0s AND UNNORMALIZED NUMBERS TSTB LDFZ RETSZ XOR BND LSH SUBI PUSH POPF RETS POPF NEGF RETS *+AR1(6),R0 *+AR1(3),R0 *+AR1(6),R0 NEG1 1,R0 *+AR1(2),R0 R0 R0 R0 R0,R0 ; ; ; ; ; ; ; ; Is the MSB of f equal to 1? If not, force the number to 0 and return If MSB of f = 1, make it 0 Eliminate sign bit & line up mantissa Make e = -127 Put number in floating point format UNNORM NEG1 ; If negative, negate R0 * HANDLE THE REGULAR CASES * NORMAL AND3 R0,*AR1,R1 BND NEG ADDI R0,R1 SUBI *+AR1(2),R1 PUSH R1 POPF R0 RETS ; ; ; ; ; Replace fraction with 0 Test sign Shift sign and exponent inserting 0 Unbias exponent Load this as a flt. pt. number NEG POPF NEGF RETS R0 R0,R0 ; ; Load this as a flt. pt. number Negate if original sign negative 5-20 Floating-Point Conversion (IEEE Std. 754) 5.4.2 Converting 2s-Complement TMS320C3x Floating-Point Format to IEEE Format This conversion is performed according to the following table: Table 5-2. Converting 2s-Complement Floating-Point Format to IEEE Format If these values are present Case 1 2 3 4 5 6 Then these values equal f2 eIEEE 00h 00h sIEEE 0 0 0 0 1 1 fIEEE 00 0000h 00 0000h f2 f 2 +1 00 0000h 00 0000h e2 -128 -127 -126 e2 127 -126 e2 127 -126 e2 127 127 s2 0 1 1 1 0 0 0 e2 +7Fh e2 +7Fh e2 +80h FFh f2 = 2s-complement of f2 . Case 1 maps a 2s-complement 0 to a positive IEEE 0. Case 2 maps the 2s-complement numbers that are too small to be represented as normalized IEEE numbers to a positive IEEE 0. Case 3 maps the positive 2s-complement numbers that are not covered by case 2 into the identically valued IEEE number. Case 4 maps the negative 2s-complement numbers with a nonzero fraction that are not covered in case 2 into the identically valued IEEE number. Case 5 maps all the negative 2s-complement numbers with a 0 fraction, except for the most negative 2s-complement number and those that are not covered in case 2, into the identically valued IEEE number. Case 6 maps the most negative 2s-complement number to the IEEE negative infinity. Data Formats and Floating-Point Operation 5-21 Floating-Point Conversion (IEEE Std. 754) 5.4.2.1 TMS320C3x-to-IEEE Floating-Point Format Conversion The vast majority of the numbers represented by the 'C3x floating-point format are covered by the general IEEE format and the representation of 0s. The only special case is e = -127 in the 'C3x format; this corresponds to a denormalized number in IEEE format. It is ignored in the fast version, while it is treated properly in the complete version. Example 5-6 shows the fast version, and Example 5-7 shows the complete version of the 'C3x-to-IEEE conversion. Example 5-6. TMS320C3x-to-IEEE Conversion (Fast Version) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * TITLE TMS320C3x TO IEEE CONVERSION (FAST VERSION) SUBROUTINE TOIEEE FUNCTION: CONVERSION BETWEEN THE TMS320C3x FORMAT AND THE IEEE FLOATING-POINT FORMAT. THE NUMBER TO BE CONVERTED IS IN THE UPPER 32 BITS OF R0. THE RESULT WILL BE IN THE LOWER 32 BITS OF R0. UPON ENTERING THE ROUTINE, AR1 POINTS TO THE FOLLOWING TABLE: (0) 0xFF800000 <-- AR1 (1) 0xFF000000 (2) 0x7F000000 (3) 0x80000000 (4) 0x81000000 ARGUMENT ARGUMENT ASSIGNMENTS: | FUNCTION ----------+------------------------------------- R0 AR1 | | NUMBER TO BE CONVERTED POINTER TO TABLE WITH CONSTANTS REGISTERS USED AS INPUT: R0, AR1 REGISTERS MODIFIED: R0 REGISTER CONTAINING RESULT: R0 NOTE: SINCE THE STACK POINTER `SP' IS USED, MAKE SURE TO INITIALIZE IT IN THE CALLING PROGRAM. 5-22 Floating-Point Conversion (IEEE Std. 754) Example 5-6.TMS320C3x-to-IEEE Conversion (Fast Version) (Continued) * * CYCLES: 14 (WORST CASE) .global * TOIEEE LDF LDFZ BND ABSF LSH PUSHF POP ADDI LSH RETS POP ADDI LSH ADDI RETS TOIEEE R0,R0 *+AR1(4),R0 NEG R0 1,R0 R0 R0 *+AR1(2),R0 -1,R0 ; ; ; ; ; ; ; ; Determine the sign of the number If 0, load appropriate number Branch to NEG if negative (delayed) Take the absolute value of the number Eliminate the sign bit in R0 Place number in lower 32 bits of R0 Add exponent bias (127) Add the positive sign WORDS: 15 NEG R0 *+AR1(2),R0 -1,R0 *+AR1(3),R0 ; ; ; ; ; Place number in lower 32 bits of R0 Add exponent bias (127) Make space for the sign Add the negative sign Data Formats and Floating-Point Operation 5-23 Floating-Point Conversion (IEEE Std. 754) Example 5-7. TMS320C3x-to-IEEE Conversion (Complete Version) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * TITLE TMS320C3x TO IEEE CONVERSION (COMPLETE VERSION) SUBROUTINE TOIEEE1 FUNCTION: CONVERSION BETWEEN THE TMS320C3x FORMAT AND THE IEEE FLOATING-POINT FORMAT. THE NUMBER TO BE CONVERTED IS IN THE UPPER 32 BITS OF R0. THE RESULT WILL BE IN THE LOWER 32 BITS OF R0. UPON ENTERING THE ROUTINE, AR1 POINTS TO THE FOLLOWING TABLE: (0) 0xFF800000 <-- AR1 (1) 0xFF000000 (2) 0x7F000000 (3) 0x80000000 (4) 0x81000000 (5) 0x7F800000 (6) 0x00400000 (7) 0x007FFFFF (8) 0x7F7FFFFF ARGUMENT ASSIGNMENTS: ARGUMENT | FUNCTION ----------+------------------------------------- R0 | NUMBER TO BE CONVERTED AR1 | POINTER TO TABLE WITH CONSTANTS REGISTERS USED AS INPUT: R0, AR1 REGISTERS MODIFIED: R0 REGISTER CONTAINING RESULT: R0 NOTE: SINCE THE STACK POINTER 'SP' IS USED, MAKE SURE TO INITIALIZE IT IN THE CALLING PROGRAM. CYCLES: 31 (WORST CASE) .global TOIEEE1 WORDS: 25 5-24 Floating-Point Conversion (IEEE Std. 754) Example 5-7.TMS320C3x-to-IEEE Conversion (Complete Version) (Continued) * TOIEEE1 LDF LDFZ BND ABSF LSH PUSHF POP ADDI LSH R0,R0 *+AR1(4),R0 NEG R0 1,R0 R0 R0 *+AR1(2),R0 -1,R0 *+AR1(5),R0 ; ; ; ; ; ; ; ; ; ; Determine the sign of the number If 0, load appropriate number Branch to NEG if negative (delayed) Take the absolute value of the number Eliminate the sign bit in R0 Place number in lower 32 bits of R0 Add exponent bias (127) Add the positive sign If e > 0, return If e = 0 & f = 0, return CONT TSTB RETSNZ TSTB RETSZ PUSH POPF LSH PUSHF POP ADDI RETS POP BRD ADDI LSH ADDI RETS *+AR1(7),R0 ; R0 R0 -1,R0 R0 R0 *+AR1(6),R0 R0 CONT *+ARI(2),R0 -1,R0 *+AR1(3),R0 ; Shift f right by one bit ; ; ; ; ; Add 1 to the MSB of f Place number in lower 32 bits of R0 Add exponent bias (127) Make space for the sign Add the negative sign NEG Data Formats and Floating-Point Operation 5-25 Floating-Point Multiplication 5.5 Floating-Point Multiplication A floating-point number can be written in floating-point format as in the following formula, where (man) is the mantissa and (exp) is the exponent: = (man) 2(exp) The product of and b is c, defined as: c = b = (man) b(man) 2((exp) + b (exp)) thus: c(man) = (man) b(man) c(exp) = (exp) + b(exp) During floating-point multiplication, source operands are in the single-precision floating-point format. If the source operands are in short floating-point format, they are converted to single-precision floating-point format. If the source operands are in extended-precision floating-point format, they are truncated to single-precision format. These conversions occur automatically in hardware with no overhead. All results of floating-point multiplications are in the extendedprecision format. These multiplications occur in a single cycle. Figure 5-16 is a flowchart that shows the steps involved in floating-point multiplication. Each step is labelled with a number in parenthesis. - In step 1, the 24-bit source operand mantissas are multiplied, producing a 50-bit result c(man). (Input and output data are always represented as normalized numbers.) - In step 2, the exponents, (exp) and b(exp), are added, yielding c(exp). - Step 3 checks for whether c(man) in extended-precision format is equal to 0. If c(man) is 0, step 7 sets c(exp) to -128, thus yielding the representation for 0. - Steps 4 and 5 normalize the result. - If a right shift of 1 is necessary, then in step 8, c(man) is right-shifted one bit, thus adding 1 to c(exp). - If a right shift of 2 is necessary, then in step 9, c(man) is right-shifted two bits, thus adding 2 to c(exp). Step 6 occurs when the result is normalized. - In step 10, c(man) is set in the extended-precision floating-point format. - Steps 11 through 16 check for special cases of c(exp). 5-26 Floating-Point Multiplication - If c(exp) has overflowed (step 11) in the positive direction, then step 14 sets c(exp) to the most positive extended-precision format value. If c(exp) has overflowed in the negative direction, then step 14 sets c(exp) to the most negative extended-precision format value. - If c(exp) has underflowed (step 12), then step 15 sets c to 0; that is, c(man) = 0 and c(exp) = -128. Data Formats and Floating-Point Operation 5-27 Floating-Point Multiplication Figure 5-16. Flowchart for Floating-Point Multiplication (man) b(man) (1) Multiply mantissas c(man) = (man) x b(man) (50-bit result) Add exponents c(exp) = (exp) + b(exp) (exp) b(exp) (2) Test for special cases of c(man) (3) c(man) = 0 (4) Right shift 1 to normalize (8) c(man) > > 1 and c(exp) = c(exp) + 1 (5) Right shift 2 to normalize (9) c(man) > > 2 and c(exp) = c(exp) + 2 (6) No shift to normalize (7) c(exp) =- 128 Dispose of extra bits Put c(man) in extended precision floating-point format (10) Test for special cases of c(exp) (11) c(exp) overflow (14) If c(man) > 0, set c(exp) to most positive value If c(man) < 0, set c(exp) to most negative value (12) c(exp) underflow (13) c(exp) in range c(exp) = -128 c(man) = 0 (15) Set c to final result c=xb (16) 5-28 Floating-Point Multiplication Example 5-8 through Example 5-12 illustrate how floating-point multiplication is performed on the 'C3x. For these examples, the implied most significant nonsign bit is made explicit. Example 5-8. Floating-Point Multiply (Both Mantissas = -2.0) Let: = -2.0 2(exp) = 10.00000000000000000000000 2(exp) b = -2.0 2 b(exp) = 10.00000000000000000000000 2 b(exp) Where: and b are both represented in binary form according to the normalized single-precision floating-point format. Then: 10.00000000000000000000000 2(exp) 10.00000000000000000000000 2 b(exp) 0100.000000000000000000000000000000000000000000000 2 ((exp) + b(exp)) To place this number in the proper normalized format, it is necessary to shift the mantissa two places to the right and add 2 to the exponent. This yields: 10.00000000000000000000000 2(exp) 10.00000000000000000000000 2 b(exp) 0100.0000000000000000000000000000000000000000000000 2 ((exp) + b(exp)) In floating-point multiplication, the exponent of the result may overflow. This can occur when the exponents are initially added or when the exponent is modified during normalization. Data Formats and Floating-Point Operation 5-29 Floating-Point Multiplication Example 5-9. Floating-Point Multiply (Both Mantissas = 1.5) Let: = 1.5 2(exp) = 01.0000000000000000000000 2(exp) b = 1.5 2 b(exp) = 01.0000000000000000000000 2 b(exp) Where: a and b are both represented in binary form according to the single-precision floating-point format. Then: 10.00000000000000000000000 2(exp) x 10.00000000000000000000000 2 b(exp) 01.0000000000000000000000000000000000000000000000 2 ((exp) + b(exp) + 2) To place this number in the proper normalized format, it is necessary to shift the mantissa one place to the right and add 1 to the exponent. This yields: 01.0000000000000000000000 2(exp) 01.0000000000000000000000 2 b(exp) 01. 00100000000000000000000000000000000000000000000 2 ((exp) + b(exp) + 1) Example 5-10. Floating-Point Multiply (Both Mantissas = 1.0) Let: = 1.0 2(exp) = 01.00000000000000000000000 2(exp) b = 1.0 2 b(exp) = 01.00000000000000000000000 2 b(exp) Where: a and b are both represented in binary form according to the single-precision floating-point format. Then: 01.00000000000000000000000 2(exp) 01.00000000000000000000000 2 b(exp) 0001.0000000000000000000000000000000000000000000000 y 2 (a(exp) + b(exp)) This number is in the proper normalized format. Therefore, no shift of the mantissa or modification of the exponent is necessary. The previous examples show cases where the product of two normalized numbers can be normalized with a shift of 0, 1, or 2. The floating-point format of the `C3x makes this possible. 5-30 Floating-Point Multiplication Example 5-11. Floating-Point Multiply Between Positive and Negative Numbers Let: = 1.0 x 2(exp) = 01.00000000000000000000000 x 2(exp) b = -2.0 x 2 b(exp) = 10.00000000000000000000000 x 2 b(exp) Then: 01.00000000000000000000000 2(exp) x 10.00000000000000000000000 2 b(exp) 1110.0000000000000000000000000000000000000000000000 2 ((exp) + b(exp)) The result is: c = -2.0 x 2((exp) + b(exp)) Example 5-12. Floating-Point Multiply by 0 All multiplications by a floating-point 0 yield a result of 0 (f = 0, s = 0, and exp = -128). Data Formats and Floating-Point Operation 5-31 Floating-Point Addition and Subtraction 5.6 Floating-Point Addition and Subtraction In floating-point addition and subtraction, two floating-point numbers and b can be defined as: = (man) 2 (exp) b = b(man) 2 b(exp) The sum (or difference) of and b can be defined as: c = b = ((man) (b(man) 2 -((exp) - b(exp))) 2 (exp), if (exp) b(exp) = ((man) 2 -(b(exp) -(exp))) b(man)) 2 b(exp), if (exp) < b(exp) Figure 5-17 shows the flowchart for floating-point addition. Because this flowchart assumes signed data, it is also appropriate for floating-point subtraction. In this figure, it is assumed that (exp) b(exp). - In step 1, the source exponents, (exp) and b(exp), are compared, and c(exp) is set equal to the largest of the two source exponents. - In step 2, d is set to the difference of the two exponents. - In step 3, the mantissa with the smallest exponent, in this case (man), is right-shifted d bits to align the mantissas. - In step 4, after the mantissas have been aligned, they are added. - In steps 5 through 7, a check for a special case of c(man). If c(man) is 0 (step 5), then c(exp) is set to its most negative value (step 8) to yield the correct representation of 0. If c(man) has overflowed c (step 6), then in step 9 c(man) is right-shifted one bit and 1 is added to c(exp). In step 10, the result is normalized. - Steps 11 through 13 check for special cases of c(exp). If c(exp) has over- flowed (step 11) in the positive direction, then step 14 sets c(exp) to the most positive extended-precision format value. If c(exp) has overflowed (step 11) in the negative direction, then step 14 sets c(exp) to the most negative extended-precision format value. If c(exp) has underflowed (step 12), then step 15 sets c to 0; that is, c(man) = 0 and c(exp) = -128. If no overflow or underflow occurred, then c is not modified. 5-32 Floating-Point Addition and Subtraction Figure 5-17. Flowchart for Floating-Point Addition (man) b(man) (exp) b(exp) (1) Compare exponents If (exp) < = b(exp) c(exp) = b(exp) else c(exp) = (exp) (Assume for simplicity that (exp) < = b(exp)) (2) Subtract exponents d = b(exp) - (exp) (3) Align mantissas (man) = (man) > > d Discard LSBs to keep (man) in extendedprecision floatingpoint format (4) Add mantissas c (man) = (man) + b(man) Test for special cases of c(man) (6) Overflow of c(man) (9) c(man) = c(man) > > 1 c(exp) = c(exp) + 1 Discard LSBs to keep in extended-precision floating-point format (5) c(man) = 0 (7) k = # of leading non-significant sign bits (8) c(exp) = -128 Test for special cases of c(exp) (11) c(exp) overflow If c(man) > 0, set c to most positive value If c(man) < 0, set c to most negative value (12) c(exp) underflow set c to 0 c(exp) = -128 c(man) = 0 (10) c(man) < < k c(exp) = c(exp) - k (13) c(exp) in range (14) (15) (16) Set c to final result c=+b Data Formats and Floating-Point Operation 5-33 Floating-Point Addition and Subtraction The following examples describe the floating-point addition and subtraction operations. It is assumed that the data is in the extended-precision floatingpoint format. Example 5-13. Floating-Point Addition In the case of two normalized numbers to be summed, let = 1.5 = 01.1000000000000000000000000000000 20 b = 0.5 = 01.0000000000000000000000000000000 2 -1 It is necessary to shift b to the right by 1 so that and b have the same exponent. This yields: b = 0.5 = 00.1000000000000000000000000000000 20 Then: 01.10000000000000000000000000000000 2 +00.10000000000000000000000000000000 20 010.00000000000000000000000000000000 20 As in the case of multiplication, it is necessary to shift the binary point one place to the left and add 1 to the exponent. This yields: 01.1000000000000000000000000000000 20 00.1000000000000000000000000000000 20 01.0000000000000000000000000000000 21 5-34 Floating-Point Addition and Subtraction Example 5-14. Floating-Point Subtraction A subtraction is performed in this example. Let: = 01.0000000000000000000000000000001 20 b = 01.0000000000000000000000000000000 20 The operation performed is -b. The mantissas are already aligned because the two numbers have the same exponent. The result is a large cancellation of the upper bits, as shown below. 01.0000000000000000000000000000001 20 -01.0000000000000000000000000000000 20 00.0000000000000000000000000000001 20 The result must be normalized. In this case, a left shift of 31 is required. The exponent of the result is modified accordingly. The result is: 01.0000000000000000000000000000001 20 - 01.0000000000000000000000000000000 20 01.0000000000000000000000000000000 2 -31 Example 5-15. Floating-Point Addition With a 32-Bit Shift This example illustrates a situation where a full 32-bit shift is necessary to normalize the result. Let: = 01.1111111111111111111111111111111 2127 b = 10.0000000000000000000000000000000 2127 The operation to be performed is + b. 01.1111111111111111111111111111111 2127 + 10.0000000000000000000000000000000 2127 11.1111111111111111111111111111111 2127 Normalizing the result requires a left shift of 32 and a subtraction of 32 from the exponent. The result is: 01.1111111111111111111111111111111 2127 + 10.0000000000000000000000000000000 2127 11.1111111111111111111111111111111 2127 Data Formats and Floating-Point Operation 5-35 Floating-Point Addition and Subtraction Example 5-16. Floating-Point Addition/Subtraction With Floating-Point 0 When floating-point addition and subtraction are performed with a floatingpoint 0, the following identities are satisfied: 0 = ( 0) 0 0 = 0 0 - = - ( 0) 5-36 Normalization Using the NORM Instruction 5.7 Normalization Using the NORM Instruction The NORM instruction normalizes an extended-precision floating-point number that is assumed to be unnormalized (see Example 5-17). Since the number is assumed to be unnormalized, no implied most significant nonsign bit is assumed. The NORM instruction: 1) Locates the most significant nonsign bit of the floating-point number 2) Left shifts to normalize the number 3) Adjusts the exponent Example 5-17. NORM Instruction Assume that an extended-precision register contains the value: man = 00000000000000000001000000000001, exp = 0 When the normalization is performed on a number assumed to be unnormalized, the binary point is assumed to be: man = 0.0000000000000000001000000000001, exp = 0 This number is then sign-extended one bit so that the mantissa contains 33 bits: man = 00.0000000000000000001000000000001, exp = 0 The intermediate result after the most significant nonsign bit is located and the shift performed is: man = 01.0000000000010000000000000000000, exp = -19 The final 32-bit value output after removing the redundant bit is: man = 00000000000010000000000000000000, exp = -19 The NORM instruction is useful for counting the number of leading 0s or leading 1s in a 32-bit field. If the exponent is initially 0, the absolute value of the final value of the exponent is the number of leading 1s or 0s. This instruction is also useful for manipulating unnormalized floating-point numbers. Given the extended-precision floating-point value a to be normalized, the normalization, norm ( ), is performed as shown in Figure 5-18. Data Formats and Floating-Point Operation 5-37 Normalization Using the NORM Instruction Figure 5-18. Flowchart for NORM Instruction Operation Test for special cases of c (man) (1) ( man) = 0 (2) Leading nonsignificant sign bits k = # of leading nonsignificant sign bits (3) c(exp) = -128 (4) Sign-extended (man) 1 bit c (man) = (man) < < k c (exp) = (exp) - k Remove most significant nonsign bit (5) Test for special cases of c (exp) (6) c (exp) underflow (7) c (exp) in range (8) c (exp) = -128 No change to c (man) (9) Set c to final result c = norm() 5-38 Rounding (RND Instruction) 5.8 Rounding (RND Instruction) The RND instruction rounds a number from the extended-precision floatingpoint format to the single-precision floating-point format. Rounding is similar to floating-point addition. Given the number a to be rounded, the following operation is performed first. c = (man) 2(exp) + (1 2(exp) -24) Next, a conversion from extended-precision floating-point to single-precision floating-point format is performed. Given the extended-precision floating-point value, the rounding, rnd( ), is performed as shown in Figure 5-19. Note: RND, src, dst--where (src) = 0--does not set the 0 conditions flag (bit 2 in the status register). Instead, it sets the underflow condition flag (bit 4 in the status register). When required, check for the underflow condition instead of the 0 condition. Data Formats and Floating-Point Operation 5-39 Rounding (RND Instruction) Figure 5-19. Flowchart for Floating-Point Rounding by the RND Instruction 12 (exp) - 24 Add (man) and 1/2 of LSB c ( man) = ( man) + 2- 24 Test for special cases of c(man) c (man) = 0 Overflow of c (man) No special case c (exp) = -128 c (man) = c (man) < < 1 c (exp) = (exp) + 1 Test for special cases of c (exp) c (exp) overflow c (exp) in range If c (man) > 0, set c to most positive single-precision value If c (man) < 0, set c to most negative single-precision value Set eight LSBs of c(man) to 0 c = rnd() 5-40 Floating-Point to Integer Conversion (FIX Instruction) 5.9 Floating-Point to Integer Conversion (FIX Instruction) Using the FIX instruction, you can convert an extended-precision floatingpoint number to a single-precision integer in a single cycle. The floating-point to integer conversion of the value x is referred to here as fix(x). The conversion does not overflow if a, the number to be converted, is in the range: -231 231 - 1 First, you must be certain that (exp) 30 If these bounds are not met, an overflow occurs. If an overflow occurs in the positive direction, the output is the most positive integer. If an overflow occurs in the negative direction, the output is the most negative integer. If (exp) is within the valid range, then (man), with implied bit included, is sign-extended and right-shifted (rs) by the amount rs = 31 - (exp) This right shift (rs) shifts out those bits corresponding to the fractional part of the mantissa. For example: If 0 < 1, then fix(x) = 0 If -1 < 0, then fix(x) = -1 Figure 5-20 shows the flowchart for the floating-point-to-integer conversion. Data Formats and Floating-Point Operation 5-41 Floating-Point to Integer Conversion (FIX Instruction) Figure 5-20. Flowchart for Floating-Point to Integer Conversion by FIX Instruction Test for special cases of (exp) (exp) > 30 (exp) in range rs = 31 - (exp) Overflow If (man) > 0, c = most positive integer If (man) < 0, c = most negative integer Shift c = (man) > > rs Set c to final result c = fix() 5-42 Integer to Floating-Point Conversion (FLOAT Instruction) 5.10 Integer to Floating-Point Conversion (FLOAT Instruction) Integer to floating-point conversion, using the FLOAT instruction, allows single-precision integers to be converted to extended-precision floating-point numbers. The flowchart for this conversion is shown in Figure 5-21. Figure 5-21. Flowchart for Integer to Floating-Point Conversion by FLOAT Instruction c (man) = c (exp) = 30 Test for special cases of c (man) c (man) = 0 Leading nonsignificant sign bits k = # leading nonsignificant sign bits c (exp) = -128 c (man) = c (man) < < k c (exp) = 30 - k Remove most significant nonsign bit Set c to final result c = float () Data Formats and Floating-Point Operation 5-43 Fast Logarithms on a Floating-Point Device 5.11 Fast Logarithms on a Floating-Point Device The following TMS320C30/C40 function calculates the log base two of a number in about half the time of conventional algorithms. Furthermore, the method can easily be scaled for faster execution if less accuracy is desired. The method is efficient because the algorithm uses the floating-point multipliers' exponent/normalization hardware in a unique way. The following is a proof of the algorithm. The value of a floating point number X is given by: X = 2^EXP_old * mant_old Since the bit fields used to store the exponent and mantissa are actually integer, the exponent is already in log2 (log base 2) form. In fact, the exponent is nothing more than a normalizing shift value. By converting both sides of the first equation to a logarithm, the logarithm of the value becomes the sum of the exponent and mantissa in log form: log2(X) = EXP_old + log2(mant_old) (Log base two) Since EXP is in the exponent register, no calculation is needed and the value can be used directly as an integer. To extract the value of the exponent, PUSH, POP, and masking operations are used. The remaining mantissa conversion is done by first forcing the exponent bits to zero using an LDE 1.0 instruction. This causes the exponent term 2^EXP to equal 1.0, leaving 1.0 <= Value < 2.0. Then, by using the following identity, the logarithm of the mantissa can be extracted from the final results exponent. If the value (mant_old) is repeatedly squared, the sequence becomes: X_new = mant_old^N where: 1.0 X_new < 2^N N = 1,2,4,8,16... Since the hardware multiplier restructures the new value (X_new) during each squaring operation, X_new is represented by a new exponent (EXP_new) and mantissa (mant_new): X_new = 2^EXP_New * mant_new By then applying familiar logarithm rules, we find that EXP_new holds the logarithm of Old_mant. This is best shown by setting the previous two equations equal to each other and taking the logarithm of both sides: mant_old^N = 2^EXP_new * mant_new N=1,2,4,8,16... 5-44 Fast Logarithms on a Floating-Point Device N * log2(mant_old) = EXP_new + log2(mant_new) log2(mant_old) = EXP_new/N + log2(mant_new)/N This last equation shows that the logarithm of mant_old is indeed related to EXP_new. And as shown earlier, EXP_new can be separated from the new mantissa and used as the logarithm of the original mantissa. We also need to consider the divisor N, which is defined to be the series 1, 2, 4, 8, 16... , and EXP_new is an integer. The division by N becomes a shift for each squaring operation. What remains is to concatenate the bits of EXP_new to EXP_old and then repeat the process until the desired accuracy is achieved. 5.11.1 Example of Fast Logarithm on a Floating-Point Device Consider a mantissa value of 1.5 and an exponent value of 0 (giving an exponent multiplier 2^0, or 1.0). The TMS320C30/C40 extended register bit pattern for the algorithm sequence is shown below. Table 5-3. Squaring Operation of F0 = 1.5 Squaring Operation of F0 = 1.5 Exp 00000000 00000001 00000010 00000100 00100100 00010010 00100101 01001010 XXXXXXXX Exp S 0 0 0 0 0 0 0 0 S S Mantissa 1000000000000000000000000000000 0010000000000000000000000000000 0100010000000000000000000000000 1001101000010000000000000000000 0100100001101011101000001000000 1010010101010011111101110011111 0101101010110110101000010101001 1101010110010010001010101100011 MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM Mantissa X X^2 X^4 X^8 X^16 X^32 X^64 X^128 =1.5 =2.25 =5.0625 =25.628906 =656.84083 =431.43988-E3 =186.14037-E9 =34.648238-E21 Exp=0 Exp=1 Exp=2 Exp=4 Exp=9 Exp=18 Exp=37 Exp=74 Hand-calculated value of log2(1.5) log2(1.5) = 0.58496250 = 1001010 111000000 xxxxxxx- first 7 bits (exponent) mmm- quick 3 bits (mantissa) If you compare the hand-calculated value and the binary representation of log2(1.5), you find that the sequence of bits in the exponent (seven bits worth) Data Formats and Floating-Point Operation 5-45 Fast Logarithms on a Floating-Point Device are equivalent to the seven MSBs of the logarithm. If the exponent could hold all the bits needed for full accuracy, then it would be possible to continue the operation for all 24 bits of the mantissa. Since there are only eight bits in the exponent and the MSBs are used for negative values, only seven iterations are possible before the exponent must be off-loaded and reinitialized to zero. By concatenating EXP_new to the previous exponent, longer strings of bits can be built for greater accuracy. The process is then repeated until the desired accuracy is achieved. Also remember that the original numbers exponent, which represents the whole number part of the result, becomes the eight MSBs of the final result. Another technique is to look at the three MSBs of the mantissa and apply a roundup from the fourth bit. Those same MSBs can be used as a quick extension of the exponent (logarithm). To visualize this, consider the following tabulated values and graph. 1.0 Mant 1.000 1.250 1.500 1.7500 1.999 log2(Mant) 0.000 0.322 0.585 0.807 0.999 Fraction 0.585 0.5 0.0 1.0 1.5 Mantissa 2.0 Figure 5-22. Tabulated Values for Mantissa Note: The fractional part is the same at the endpoints. In the middle, only a slight bowing exists which can either be ignored or optionally rounded for better accuracy. The maximum actually occurs at a mantissa value of 1 ln(2.0) or 1.442695. The value of log2(mant) at that point is 0.52876637, giving a maximum error of 0.086071. 5-46 Fast Logarithms on a Floating-Point Device When finished, the bits representing the finished logarithm are in a fixed-point notation and need to be scaled. This is done by using the FLOAT instruction followed by a multiplication by a constant scaling factor. If the final result needs to be in any other base, the scaling factor is simply adjusted for that base. 5.11.2 Points to Consider The round-off accuracy of the first three squaring operations affect the final result if >21 mantissa bits are desired. A RND instruction placed after the first three MPYF R0,R0 instructions remedy this, but adds to the cycle count. When the input value approaches 1.0, the result is driven close to zero and accuracy suffers. In this case, an input range comparison and a branch to a McLauren series expansion is used as a solution with minimal degradation in speed. This is because the power series converges quickly for input values close to 1.0. If you only need to calculate a visual quality logarithm, such as in spectrum analysis, the logarithm can often be calculated in one cycle. In this case the mantissa is substituted directly into the fractional bits of the logarithm giving a maximum error of 0.086 (about 3.5 bits). The one cycle arises from the need to remove the 2's compliment sign bit in the 'C3x's mantissa. Data Formats and Floating-Point Operation 5-47 Fast Logarithms on a Floating-Point Device Figure 5-23. Fast Logarithm for FFT Displays **************************************************************** * * FAST Logarithm for FFT displays * * >>>> NEED ONLY ADD ONE INSTRUCTION IN MANY CASES <<<< * ****************************************************************** || MPYF MYPF ADDF ASH || REAL,REAL,R0 IMAG,IMAG,R1 R1,R0 -1,R0 ; ; calculate the magnitude ; Note: sign bit is zero ; ; <-One instruction logarithm! STR R0,OUT ; scaled externally in DAC || || ; ********************************************************************** * _log_E.asm DEVICE: TMS320C30 * ********************************************************************** .global_log_E _log_E:POP AR1 ; return address -> AR1 POPF R0 ; X -> R0 LDF R0,R1 ; use R1 to accumulate answer LDI 2,RC ; repeat 3x RPTB loop ; ASH 7,R1 ; LDE 1.0,R0 ; EXP = 0 MPYF R0,R0 ; mant^2 MPYF R0,R0 ; mant^4 MPYF R0,R0 ; mant^8 MPYF R0,R0 ; mant^16 MPYF R0,R0 ; mant^32 MPYF R0,R0 ; mant^64 MPYF R0,R0 ; mant^128 PUSHF R1 ; PUSH EXP and Mantissa (sign is now data!) POP R0 ; POP as ianteger (EXP+FRACTION) BD AR1 ; FLOAT R0 ; convert EXP+FRACTION to float MPYF @CONST,R0 ; scale the result by 2^-24 and change base ADDI 1,SP ; restore stack pointer .data CONST_ADR: .word CONST CONST .long 0e7317219h ;;Base e hand calc w/1 lsb round .end 5-48 Chapter 6 Addressing Modes The 'C3x supports five groups of powerful addressing modes. Six types of addressing that allow data access from memory, registers, and the instruction word can be used within the groups. This chapter describes the operation, encoding, and implementation of the addressing modes. It also discusses the management of system stacks, queues, and dequeues in memory. Topic 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 Page Addressing Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 Register Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3 Direct Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 Indirect Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5 Immediate Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18 PC-Relative Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19 Circular Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-21 Bit-Reversed Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-26 Aligning Buffers With the TMS320 Floating-Point DSP Assembly Language Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-28 6.10 System and User Stack Management . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29 6-1 Addressing Types 6.1 Addressing Types You can access data from memory, registers, and the instruction word by using five types of addressing: - Register addressing . A CPU register contains the operand. - Direct addressing . The data address is formed by concatenating the eight least significant bits (LSBs) of the data-page (DP) register and the 16 LSBs of the instruction. - Indirect addressing . An auxiliary register contains the address of the operand. - Immediate addressing. The operand is a 16-bit or 24-bit immediate value. - PC-relative addressing. A 16-bit or 24-bit displacement to the program counter (PC). Two specialized modes are available for use in filters, FFTs, and DSP algorithms: - Circular addressing . An auxiliary register is incremented/decremented with regards to a circular buffer boundary. - Bit-reverse address ing. An auxiliary register is transferred to its bit- reversed representation that contains the address of the operand. 6-2 Register Addressing 6.2 Register Addressing In register addressing, a CPU register contains the operand, as shown in this example: ABSF R1 ; R1 = |R1| The syntax for the CPU registers, the assembler syntax, and the assigned function for those registers are listed in Table 6-1. Table 6-1. CPU Register Address/Assembler Syntax and Function Register Name R0 R1 R2 R3 R4 R5 R6 R7 AR0 AR1 AR2 AR3 AR4 AR5 AR6 AR7 DP IR0 IR1 BK SP ST IE IF IOF RS RE RC Machine Address 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch 0Dh 0Eh 0FH 10h 11h 12h 13h 14h 15h 16h 17h 18h 19h 1Ah 1Bh Assigned Function Extended-precision register 0 Extended-precision register 1 Extended-precision register 2 Extended-precision register 3 Extended-precision register 4 Extended-precision register 5 Extended-precision register 6 Extended-precision register 7 Auxiliary register 0 Auxiliary register 1 Auxiliary register 2 Auxiliary register 3 Auxiliary register 4 Auxiliary register 5 Auxiliary register 6 Auxiliary register 7 Data-page pointer Index register 0 Index register 1 Block-size register Active stack pointer Status register CPU/DMA interrupt-enable CPU interrupt flags I/O flags Repeat start address Repeat end address Repeat counter Addressing Modes 6-3 Direct Addressing 6.3 Direct Addressing In direct addressing, the data address is formed by the concatenation of the eight LSBs of the data-page pointer (DP) with the 16 LSBs of the instruction word (expr). This results in 256 pages (64K words per page), allowing you to access a large address space without requiring a change of the page pointer. The syntax and operation for direct addressing are: Syntax: Operation: @expr address = DP concatenated with expr Figure 6-1 shows the formation of the data address. Example 6-1 is an instruction example with data before and after instruction execution. Figure 6-1. Direct Addressing 31 Instruction word 31 DP x (Datapage pointer) x...x 31 0 0...0 8 x 24 0 23 address 7 page 0 16 15 expr 0 0 31 operand 0 Example 6-1. Direct Addressing ADDI @0BCDEh,R7 Before Instruction R7 DP Data memory 8ABCDEh 1234 5678 8ABCDEh 1234 5678 00 0000 0000 After Instruction R7 DP 00 1234 5678 8A 8A 6-4 Indirect Addressing 6.4 Indirect Addressing Indirect addressing specifies the address of an operand in memory through the contents of an auxiliary register, optional displacements, and index registers as shown in Example 6-2. Only the 24 LSBs of the auxiliary registers and index registers are used in indirect addressing. The auxiliary register arithmetic units (ARAUs) perform the unsigned arithmetic on these lower 24 bits. The upper eight bits are unmodified. Example 6-2. Auxiliary Register Indirect An auxiliary register (ARn) contains the address of the operand to be fetched. Operation: Assembler Syntax: Modification Field: 31 ARn x 31 Operand operand address = ARn *ARn 11000 24 x 23 Address 0 0 The flexibility of indirect addressing is possible because the ARAUs on the 'C3x modify auxiliary registers in parallel with operations within the main CPU. Indirect addressing is specified by a 5-bit field in the instruction word, referred to as the mod field (shown in Table 6-2). A displacement is either an explicit unsigned 8-bit integer contained in the instruction word or an implicit displacement of 1. Two index registers, IR0 and IR1, can also be used in indirect addressing, enabling the use of 24-bit indirect displacement. In some cases, an addressing scheme using circular or bit-reversed addressing is optional. Generating addresses in circular addressing is discussed in Section 6.7 on page 6-21; bit-reversed addressing is discussed in Section 6.8 on page 6-26. Table 6-2 lists the various kinds of indirect addressing, along with the value of the modification (mod) field, assembler syntax, operation, and function for each. The succeeding 17 examples show the operation for each kind of indirect addressing. Figure 6-3 on page 6-20 shows the format in the instruction encoding. Addressing Modes 6-5 Indirect Addressing Figure 6-2. Indirect Addressing Operand Encoding MSB mod 5 bits ARn 3 bits disp 0, 5, or 8 bits LSB Note: Auxiliary Register The auxiliary register (ARn) is encoded in the instruction word according to its binary representation n (for example, AR3 is encoded as 112), not its register machine address (shown in Table 6-1). 6-6 Indirect Addressing Table 6-2. Indirect Addressing (a) Indirect addressing with displacement Mod Field 00000 00001 00010 00011 00100 00101 00110 00111 Syntax *+ARn(disp) *-ARn(disp) *++ARn(disp) *--ARn(disp) *ARn++(disp) *ARn --(disp) *ARn++(disp)% *ARn--(disp)% Operation addr = ARn + disp addr = ARn - disp addr = ARn + disp ARn = ARn + disp addr = ARn - disp ARn = ARn - disp addr = ARn ARn = ARn + disp addr = ARn ARn = ARn - disp addr = ARn ARn = circ(ARn + disp) addr = ARn ARn = circ(ARn - disp) Description With predisplacement add With predisplacement subtract With predisplacement add and modify With predisplacement subtract and modify With postdisplacement add and modify With postdisplacement subtract and modify With postdisplacement add and circular modify With postdisplacement subtract and circular modify (b) Indirect addressing with index register IR0 Mod Field 01000 01001 01010 01011 01100 01101 01110 01111 Legend: Syntax *+ARn(IR0) *-ARn(IR0) *++ARn(IR0) * --ARn(IR0) *ARn++(IR0) *ARn --(IR0) *ARn++(IR0)% *ARn --(IR0)% addr ARn circ( ) disp Operation addr = ARn + IR0 addr = ARn - IR0 addr = ARn + IR0 ARn = ARn + IR0 addr = ARn - IR0 ARn = ARn - IR0 addr = ARn ARn = ARn + IR0 addr= ARn ARn = ARn - IR0 addr = ARn ARn = circ(ARn + IR0) addr = ARn ARn = circ(ARn - IR0) Description With preindex (IR0) add With preindex (IR0) subtract With preindex (IR0) add and modify With preindex (IR0) subtract and modify With postindex (IR0) add and modify With postindex (IR0) subtract and modify With postindex (IR0) add and circular modify With postindex (IR0) subtract and circular modify ++ -- % IRn add and modify subtract and modify where circular addressing is performed index register IR0 or IR1 memory address auxiliary registers AR0-AR7 address in circular addressing displacement Addressing Modes 6-7 Indirect Addressing Table 6-2. Indirect Addressing (Continued) (c) Indirect addressing with index register IR1 Mod Field 10000 10001 10010 Syntax *+ ARn(IR1) * -ARn(IR1) * ++ ARn(IR1) Operation addr = ARn + IR1 addr = ARn - IR1 addr = ARn + IR1 ARn = ARn + IR1 addr = ARn - IR1 ARn = ARn - IR1 addr = ARn ARn = ARn + IR1 addr = ARn ARn = ARn - IR1 addr = ARn ARn = circ(ARn + IR1) addr = ARn ARn = circ(ARn - IR1) Description With preindex (IR1) add With preindex (IR1) subtract With preindex (IR1) add and modify 10011 * --ARn(IR1) With preindex (IR1) subtract and modify 10100 * ARn ++ (IR1) With postindex (IR1) add and modify 10101 *ARn --(IR1) With postindex (IR1) subtract and modify 10110 * ARn ++ (IR1)% With postindex (IR1) add and circular modify 10111 * ARn --(IR1)% With postindex (IR1) subtract and circular modify (d) Indirect addressing (special cases) Mod Field 11000 11001 Syntax *ARn *ARn ++ (IR0)B Operation addr = ARn addr = ARn ARn = B(ARn + IR0) Legend: addr ARn B B() memory address auxiliary registers AR0-AR7 where bit-reversed addressing is performed bit-reversed address circ( ) ++ -- % IRn Description Indirect With postindex (IR0) add and bit-reversed modify address in circular addressing add and modify by 1 subtract and modify by 1 where circular addressing is performed index register IR0 or IR1 Example 6-3 through Example 6-19 show the operation for each type of indirect addressing. 6-8 Indirect Addressing Example 6-3. Indirect Addressing With Predisplacement Add The address of the operand to fetch is the sum of an auxiliary register (ARn) and the displacement (disp). The displacement is either an 8-bit unsigned integer contained in the instruction word or an implied value of 1. Operation: Assembler Syntax: Modification Field: 31 ARn 31 disp 0 0...0 31 Operand x operand address = ARn + disp *+ARn(disp) 00000 24 23 x Address 0 8 0 7 Integer 0 (+) 0 Example 6-4. Indirect Addressing With Predisplacement Subtract The address of the operand to fetch is the contents of an auxiliary register (ARn) minus the displacement (disp). The displacement is either an 8-bit unsigned integer contained in the instruction word or an implied value of 1. Operation: Assembler Syntax: Modification Field: 31 ARn 31 disp 0 0...0 31 Operand x operand address = ARn - disp *-ARn(disp) 00001 24 23 x 8 0 7 Integer Address 0 (-) 0 0 Addressing Modes 6-9 Indirect Addressing Example 6-5. Indirect Addressing With Predisplacement Add and Modify The address of the operand to fetch is the sum of an auxiliary register (ARn) and the displacement (disp). The displacement is either an 8-bit unsigned integer contained in the instruction word or an implied value of 1. After the data is fetched, the auxiliary register is updated with the address generated. Operation: Assembler Syntax: Modification Field: 31 ARn 31 disp 0 0...0 31 Operand x operand address = ARn + disp ARn = ARn + disp *++ARn (disp) 00010 24 23 x 8 0 7 Integer Address 0 (+) 0 0 Example 6-6. Indirect Addressing With Predisplacement Subtract and Modify The address of the operand to fetch is the contents of an auxiliary register (ARn) minus the displacement (disp). The displacement is either an 8-bit unsigned integer contained in the instruction word or an implied value of 1. After the data is fetched, the auxiliary register is updated with the address generated. Operation: Assembler Syntax: Modification Field: 31 ARn 31 disp 0 0...0 31 Operand x operand address = ARn - disp ARn = ARn - disp *--ARn(disp) 00011 24 23 x 8 0 7 Integer Address 0 (-) 0 0 6-10 Indirect Addressing Example 6-7. Indirect Addressing With Postdisplacement Add and Modify The address of the operand to fetch is the contents of an auxiliary register (ARn). After the operand is fetched, the displacement (disp) is added to the auxiliary register. The displacement is either an 8-bit unsigned integer contained in the instruction word or an implied value of 1. Operation: Assembler Syntax: Modification Field: 31 ARn 31 disp 0 0...0 31 Operand x operand address = ARn ARn = ARn + disp *ARn ++ (disp) 00100 24 23 x 8 0 7 Integer Address 0 (+) 0 0 Example 6-8. Indirect Addressing With Postdisplacement Subtract and Modify The address of the operand to fetch is the contents of an auxiliary register (ARn). After the operand is fetched, the displacement (disp) is subtracted from the auxiliary register. The displacement is either an 8-bit unsigned integer contained in the instruction word or an implied value of 1. Operation: Assembler Syntax: Modification Field: 31 ARn x operand address = ARn ARn = ARn - disp *ARn --(disp) 00101 24 23 x Address 0 31 disp 0 0...0 31 8 0 7 0 (-) 0 Integer Operand Addressing Modes 6-11 Indirect Addressing Example 6-9. Indirect Addressing With Postdisplacement Add and Circular Modify The address of the operand to fetch is the contents of an auxiliary register (ARn). After the operand is fetched, the displacement (disp) is added to the contents of the auxiliary register using circular addressing. This result is used to update the auxiliary register. The displacement is either an 8-bit unsigned integer contained in the instruction word or an implied value of 1. Operation: Assembler Syntax: Modification Field: 31 ARn 31 disp 0 0...0 31 Operand x operand address = ARn ARn = circ(ARn + disp) *ARn ++ (disp)% 00110 24 23 x 8 0 7 Address 0 0 (%) (+) 0 Integer Example 6-10. Indirect Addressing With Postdisplacement Subtract and Circular Modify The address of the operand to fetch is the contents of an auxiliary register (ARn). After the operand is fetched, the displacement (disp) is subtracted from the contents of the auxiliary register using circular addressing. This result is used to update the auxiliary register. The displacement is either an 8-bit unsigned integer contained in the instruction word or an implied value of 1. Operation: Assembler Syntax: Modification Field: 31 ARn 31 disp 0 0...0 31 Operand x operand address = ARn ARn = circ(AR n - disp) *ARn --(disp)% 00111 24 x 8 0 7 23 Address 0 (%) (-) 0 0 Integer 6-12 Indirect Addressing Example 6-11. Indirect Addressing With Preindex Add The address of the operand to fetch is the sum of an auxiliary register (ARn) and an index register (IR0 or IR1). Operation: Assembler Syntax: Modification Field: operand address = ARn + IRm *+ARn(IRm) 01000 10000 31 ARn x if m = 0 if m = 1 24 23 x Address 0 31 IRm x 24 23 x 31 Operand Index 0 (+) 0 Example 6-12. Indirect Addressing With Preindex Subtract The address of the operand to fetch is the difference of an auxiliary register (ARn) and an index register (IR0 or IR1). Operation: Assembler Syntax: Modification Field: operand address = ARn - IRm *-ARn(IRm) 01001 10001 31 ARn x if m = 0 if m = 1 24 23 x Address 0 31 IRm x 24 23 x 31 Operand Index 0 (-) 0 Addressing Modes 6-13 Indirect Addressing Example 6-13. Indirect Addressing With Preindex Add and Modify The address of the operand to fetch is the sum of an auxiliary register (ARn) and an index register (IR0 or IR1). After the data is fetched, the auxiliary register is updated with the generated address. Operation: Assembler Syntax: Modification Field: operand address = ARn + IRm ARn = ARn + IRm *++ARn(IRm) 01010 10010 31 ARn 31 IRm x 24 23 x 31 Operand Index x if m = 0 if m = 1 24 23 x Address 0 (+) 0 0 Example 6-14. Indirect Addressing With Preindex Subtract and Modify The address of the operand to fetch is the difference between an auxiliary register (ARn) and an index register (IR0 or IR1). The resulting address becomes the new contents of the auxiliary register. Operation: Assembler Syntax: Modification Field: operand address = ARn - IRm ARn = ARn - IRm *--ARn(IRm) 01011 10011 31 ARn x if m = 0 if m = 1 24 23 x Address 0 Index (-) 0 Operand 0 31 IRm x 24 23 x 31 6-14 Indirect Addressing Example 6-15. Indirect Addressing With Postindex Add and Modify The address of the operand to fetch is the contents of an auxiliary register (ARn). After the operand is fetched, the index register (IR0 or IR1) is added to the auxiliary register. Operation: Assembler Syntax: Modification Field: operand address = ARn ARn = ARn + IRm *ARn ++ (IRm) 01100 10100 31 ARn 31 IRm x 24 23 x 31 Operand Index x if m = 0 if m = 1 24 23 x Address 0 (+) 0 0 Example 6-16. Indirect Addressing With Postindex Subtract and Modify The address of the operand to fetch is the contents of an auxiliary register (ARn). After the operand is fetched, the index register (IR0 or IR1) is subtracted from the auxiliary register. Operation: Assembler Syntax: Modification Field: operand address = ARn ARn = ARn - IRm *ARn --(IRm) 01101 10101 31 ARn 31 IRm x 24 23 x 31 Operand Index x if m = 0 if m = 1 24 23 x Address 0 (-) 0 0 Addressing Modes 6-15 Indirect Addressing Example 6-17. Indirect Addressing With Postindex Add and Circular Modify The address of the operand to fetch is the contents of an auxiliary register (ARn). After the operand is fetched, the index register (IR0 or IR1) is added to the auxiliary register. This value is evaluated using circular addressing and replaces the contents of the auxiliary register. Operation: Assembler Syntax: Modification Field: operand address = ARn ARn = circ(ARn + IRm) *ARn ++ (IRm)% 01110 10110 31 ARn 31 IRm x 24 23 x 31 Operand Index x if m = 0 if m = 1 24 23 x Address 0 (%) (+) 0 0 Example 6-18. Indirect Addressing With Postindex Subtract and Circular Modify The address of the operand to fetch is the contents of an auxiliary register (ARn). After the operand is fetched, the index register (IR0 or IR1) is subtracted from the auxiliary register. This result is evaluated using circular addressing and replaces the contents of the auxiliary register. Operation: Assembler Syntax: Modification Field: operand address = ARn ARn = circ(ARn - IRm) *ARn -- (IRm)% 01111 10111 31 ARn x 24 23 x 31 Operand Index if m = 0 if m = 1 24 23 x Address 0 (%) (-) 0 0 31 IRm x 6-16 Indirect Addressing Example 6-19. Indirect Addressing With Postindex Add and Bit-Reversed Modify The address of the operand to fetch is the contents of an auxiliary register (ARn). After the operand is fetched, the index register (IR0) is added to the auxiliary register. This addition is performed with a reverse-carry propagation and can be used to yield a bit-reversed (B) address. This value replaces the contents of the auxiliary register. Operation: operand address = ARn ARn = B(ARn + IR0) *ARn++(IR0)B 11001 31 ARn 31 IRm x 24 23 x 31 Operand Index x 24 23 x Address 0 (B) (+) 0 0 Assembler Syntax: Modification Field: Addressing Modes 6-17 Immediate Addressing 6.5 Immediate Addressing In immediate addressing, the operand is a 16-bit (short) or 24-bit (long) immediate value contained in the 16 or 24 LSBs of the instruction word (expr). Depending on the data types assumed for the instruction, the short-immediate operand can be a 2s-complement integer, an unsigned integer, or a floating-point number. This is the syntax for this mode: Syntax: expr Example 6-20 illustrates an instruction example with data before and after the instruction is executed. Example 6-20. Short-Immediate Addressing SUBI 1,R0 Before Instruction R0 00 0000 0000 After Instruction R0 00 FFFF FFFF In long-immediate addressing, the operand is a 24-bit unsigned immediate value contained in the 24 LSBs of the instruction word (expr). This is the syntax for this mode: Syntax: expr Example 6-21 illustrates an instruction example with data from before and after the instruction is executed. Example 6-21. Long-Immediate Addressing BR 8000h Before Instruction PC 0000 PC After Instruction 8000 6-18 PC-Relative Addressing 6.6 PC-Relative Addressing Program counter (PC)-relative addressing is used for branching. It adds the contents of the 16 or 24 LSBs of the instruction word to the PC register. The assembler takes the src (a label or address) specified by the user and generates a displacement. If the branch is a standard branch, this displacement is equal to [label - (instruction address +1)]. If the branch is a delayed branch, this displacement is equal to [label - (instruction address+3)]. The displacement is stored as a 16-bit or 24-bit signed integer in the LSBs of the instruction word. The displacement is added to the PC during the pipeline decode phase. Notice that because the PC is incremented by 1 in the fetch phase, the displacement is added to this incremented PC value. Syntax: expr (src) Example 6-22 illustrates an example with data from before and after the instruction is executed. Example 6-22. PC-Relative Addressing BU NEWPC ; pc=1001h, NEWPC label = 1005h, displacement = 3 Before Instruction decode phase: PC 1002 After Instruction execution phase: PC 1005 The 24-bit addressing mode encodes the program-control instructions (for example, BR, BRD, CALL, RPTB, and RPTBD). Depending on the instruction, the new PC value is derived by adding a 24-bit signed value in the instruction word with the present PC value. Bit 24 determines the type of branch (D = 0 for a standard branch or D = 1 for a delayed branch). Some of the instructions are encoded in Figure 6-3. Addressing Modes 6-19 PC-Relative Addressing Figure 6-3. Encoding for 24-Bit PC-Relative Addressing Mode (a) BR, BRD: unconditional branches (standard and delayed) 31 0 25 24 23 1 1 0 0 0 0 0 Displacement 0 (b) CALL: unconditional subroutine call 31 0 24 23 1 1 0 0 0 1 0 Displacement 0 (c) RPTB: repeat block 31 0 25 24 23 1 1 0 0 1 0 0 Displacement 0 6-20 Circular Addressing 6.7 Circular Addressing Many DSP algorithms, such as convolution and correlation, require a circular buffer in memory. In convolution and correlation, the circular buffer acts as a sliding window that contains the most recent data to process. As new data is brought in, the new data overwrites the oldest data by increasing the pointer to the data through the buffer in counter-clockwise fashion. When the pointer accesses the end of the buffer, the device sets the pointer to the beginning of the buffer. For example, Figure 6-4a shows a circular buffer that holds six values. Figure 6-4b shows how this buffer is implemented in the 'C3x memory space. Figure 6-5 shows this buffer after writing three values. Figure 6-6 shows this buffer after writing eight values. Figure 6-4. Logical and Physical Representation of Circular Buffer a) Logical representation Start End b) Physical representation Start End Figure 6-5. Logical and Physical Representation of Circular Buffer after Writing Three Values a) Logical representation Start value0 value1 value2 End End b) Physical representation Start value0 value1 value2 Addressing Modes 6-21 Circular Addressing Figure 6-6. Logical and Physical Representation of Circular Buffer after Writing Eight Values a) Logical representation Start value6 value7 value2 End value5 value4 value3 End b) Physical representation Start value6 value7 value2 value3 value4 value5 To implement a circular buffer in the 'C3x, the following criteria must be satisfied (more than one circular buffer can be implemented on the 'C3x as long as the size of the buffers are identical): - Specify the size of the circular buffer (R) by storing the length of the buffer in the block-size register (BK). The size of the buffer must be less than or equal to 64K (16 bits). - Align the start of the buffer to a K-bit boundary (that is, the K LSBs of the starting address of the circular buffer must be 0) by satisfying the following formula: 2K > R where: R = length of circular buffer K = number of 0s in the LSBs of the circular buffer starting address Example 6-23. Examples of Formula 2 K > R Length of Buffer 31 32 1024 BK Register Value 31 32 1024 Starting Address of Buffer XXXXXXXXXXXXXXXXXXX000002 XXXXXXXXXXXXXXXXXX0000002 XXXXXXXXXXXXX000000000002 6-22 Circular Addressing In circular addressing, index refers to the K LSBs (from the K-bit boundary criteria) of the auxiliary register selected, and step is the quantity being added to or subtracted from the auxiliary register. Follow these two rules when you use circular addressing: - The step used must be less than or equal to the block size. The step size is treated as an unsigned integer. If an index register (IR) is used as a step increment or decrement, it is also treated as an unsigned integer. - The first time the circular queue is addressed, the auxiliary register must be pointing to an element in the circular queue. The algorithm for circular addressing is as follows: If 0 index + step < BK: Else if index + step BK: Else if index + step < 0: index = index + step. index = index + step - BK. index = index + step + BK. Figure 6-7 shows how the circular buffer is implemented and illustrates the relationship of the quantities generated and the elements in the circular buffer. Figure 6-7. Circular Buffer Implementation Address 31 Effective base (EB) H...H MSBs of ARn K K-1 0...0 0 Data Top of circular buffer Element 0 Element 1 31 Auxiliary register (ARn) H...H K K-1 L...L LSBs of ARn 0 Element (K LSBs of ARn) MSBs of ARn 31 H...H K K-1 LSBs BK 0 Last element Last element + 1 MSBs of ARn Example 6-24 shows circular addressing operation. Assuming that all ARs are four bits, let AR0 = 0000 and BK = 0110 (block size of 6). Example 6-24 shows a sequence of modifications and the resulting value of AR0. Example 6-24 also shows how the pointer steps through the circular queue with a variety of step sizes (both incrementing and decrementing). Addressing Modes 6-23 Circular Addressing Example 6-24. Circular Addressing *AR0 ++ (5)% *AR0 ++ (2)% *AR0 - -(3)% *AR0++(6)% *AR0 - -% *AR0 Value 0 2nd ; ; ; ; ; ; AR0 AR0 AR0 AR0 AR0 AR0 = = = = = = 0 5 1 4 4 3 (0 value) (1st value) (2nd value) (3rd value) (4th value) (5th value) Data Element 0 Element 1 Element 2 Address 0 1 2 3 4 5 6 5th 4th, 3rd 1st Element 3 Element 4 Element 5 (last element) Last element + 1 Circular addressing is especially useful for the implementation of FIR filters. Figure 6-8 shows one possible data structure for FIR filters. Note that the initial value of AR0 points to h(N -1), and the initial value of AR1 points to x(0). Circular addressing is used in the 'C3x code for the FIR filter shown in Example 6-25. Figure 6-8. Data Structure for FIR Filters Impulse response AR0 Input samples x(N -1) x(N -2) h(N -1) h(N -2) . . . h(2) h(1) h(0) . . . x(2) x(1) x(0) AR1 6-24 Circular Addressing Example 6-25. FIR Filter Code Using Circular Addressing * H Impulse Response .sect "Impulse_Resp" .float 1.0 .float 0.99 .float 0.95 . . . .float 0.1 Input Buffer .usect "Input_Buf",128 * X .data HADDR .word H XADDR .word X N .word 128 * * Initialization LDP LDI LDI LDI * TOP HADDR @N,BK @HADDR,AR0 @XADDR,AR1 ; ; ; ; ; Load block size. Load pointer to impulse re- sponse. Load pointer to bottom of input sample buffer. LDF STF LDF LDF IN,R3 R3,*AR1++% 0,R0 0,R2 ;Read input sample. ;Store with other samples, ;and point to top of buffer. ;Initialize R0. ;Initialize R2. * * * Filter RPTS MPYF3 ADDF3 ADDF STF B N -1 ;Repeat next instruction. *AR0++%,*AR1++%,R0 R0,R2,R2 ;Multiply and accumulate. R0,R2 ;Last product accumulated. R2,Y TOP ;Save result. ;Repeat. || * Addressing Modes 6-25 Bit-Reversed Addressing 6.8 Bit-Reversed Addressing The 'C3x can implement fast Fourier transforms (FFT) with bit-reversed addressing. Whenever data in increasing sequence order is transformed by an FFT, the resulting data is presented in bit-reversed order. To recover this data in the correct order, certain memory locations must be swapped. By using the bit-reversed addressing mode, swapping data is unnecessary. The data is accessed by the CPU in bit-reversed order rather than sequentially. For correct bit-reversed access, the base address of bit-reversed access, the base address must be located on a boundary given by the size of the FFT table. Similar to circular addressing, the base address of bit-reversed addressing must follow this criteria. - Base address must be aligned to a K-bit boundary (that is, the K LSBs of the starting address of the buffer/table must be 0) as follows: 2K > R where: R = length of table/buffer K = number of 0s in the LSBs of the buffer/table starting address - Size of the buffer/table must be less than or equal to 64K (16 bits) The CPU bit-reversed operation can be illustrated by assuming an FFT table of size 2n. When real and imaginary data are stored in separate arrays, the n LSBs of the base address must be 0, and IR0 must be equal to 2n-1 (half of the FFT size). When real and imaginary data are stored in consecutive memory locations (Real0, Imaginary0, Real1, Imaginary1, Real2, Imaginary2, etc.), the n+1 LSBs of the base address must be 0, and IR0 must be equal to 2n (FFT size). For CPU bit-reversed addressing, one auxiliary register points to the physical location of data. Adding IR0 (in bit-reversed addressing) to this auxiliary register performs a reverse-carry propagation. IR0 is treated as an unsigned integer. To illustrate bit-reversed addressing, assume 8-bit auxiliary registers. Let AR2 contain the value 0110 0000 (96). This is the base address of the data in memory assuming a 16-entry table. Let IR0 contain the value 0000 1000 (8). Example 6-26 shows a sequence of modifications of AR2 and the resulting values of AR2. 6-26 Bit-Reversed Addressing Example 6-26. Bit-Reversed Addressing *AR2++(IR0)B *AR2++(IR0)B *AR2++(IR0)B *AR2++(IR0)B *AR2++(IR0)B *AR2++(IR0)B *AR2++(IR0)B *AR2 ; ; ; ; ; ; ; ; AR2= AR2= AR2= AR2= AR2= AR2= AR2= AR2= 0110 0110 0110 0110 0110 0110 0110 0110 0000 1000 0100 1100 0010 1010 0110 1110 (0th (1st (2nd (3rd (4th (5th (6th (7th value) value) value) value) value) value) value) value) Table 6-3 shows the relationship of the index steps and the four LSBs of AR2. You can find the four LSBs by reversing the bit pattern of the steps. Table 6-3. Index Steps and Bit-Reversed Addressing Step 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Bit Pattern 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Bit-Reversed Pattern 0000 1000 0100 1100 0010 1010 0110 1110 0001 1001 0101 1101 0011 1011 0111 1111 Bit-Reversed Step 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 Addressing Modes 6-27 Aligning Buffers With the TMS320 Floating-Point DSP Assembly Language Tools Aligning 6.9 Aligning Buffers With the TMS320 Floating-Point DSP Assembly Language Tools To align buffers to a K-bit boundary, you can use the .sect or .usect assembly directives to define a section in conjunction with the align memory allocation parameter of the sections directive of the linker command file. For the FIR filter of Example 6-25 with a length of 32, the linker command file is: MEMORY { RAM origin = 0h, length = 1000h } SECTIONS { .text: > RAM Impulse_Resp ALIGN(64): > RAM Input_Buf ALIGN(64): > RAM } 6-28 System and User Stack Management 6.10 System and User Stack Management The 'C3x provides a dedicated system-stack pointer (SP) for building stacks in memory. The auxiliary registers can also be used to build a variety of more general linear lists. This section discusses the implementation of the following types of linear lists: - Stack The stack is a linear list for which all insertions and deletions are made at one end of the list. - Queue The queue is a linear list for which all insertions are made at one end of the list and all deletions are made at the other end. - Dequeue The dequeue is a double-ended queue linear list for which insertions and deletions are made at either end of the list. 6.10.1 System-Stack Pointer The system-stack pointer (SP) is a 32-bit register that contains the address of the top of the system stack. The system stack fills from low-memory address to high-memory address (see Figure 6-9). The SP always points to the last element pushed onto the stack. A push performs a preincrement, and a pop performs a postdecrement of the system-stack pointer. The program counter is pushed onto the system stack on subroutine calls, traps, and interrupts. It is popped from the system stack on returns. The system stack can be pushed and popped using the PUSH, POP, PUSHF, and POPF instructions. Figure 6-9. System Stack Configuration Low memory Bottom of stack . . . SP Top of stack (Free) High memory Addressing Modes 6-29 System and User Stack Management 6.10.2 Stacks Stacks can be built from low to high memory or high to low memory. Two cases for each type of stack are shown. Stacks can be built using the preincrement/ decrement and postincrement/decrement modes of modifying the auxiliary registers (AR). Stack growth from high-to-low memory can be implemented in two ways: CASE 1: Stores to memory using *- -ARn to push data onto the stack and reads from memory using *ARn ++ to pop data off the stack. CASE 2: Stores to memory using *ARn - -to push data onto the stack and reads from memory using * ++ ARn to pop data off the stack. Figure 6-10 illustrates these two cases. The only difference is that in case 1, the AR always points to the top of the stack, and in case 2, the AR always points to the next free location on the stack. Figure 6-10. Implementations of High-to-Low Memory Stacks Case 1 Low memory (Free) ARn ARn Case 2 Low memory (Free) Top of stack Top of stack Bottom of stack High memory Bottom of stack High memory Stack growth from low-to-high memory can be implemented in two ways: CASE 3: Stores to memory using *++ ARn to push data onto the stack and reads from memory using *ARn - -to pop data off the stack. CASE 4: Stores to memory using *ARn ++ to push data onto the stack and reads from memory using *- -ARn to pop data off the stack. Figure 6-11 shows these two cases. In case 3, the AR always points to the top of the stack. In case 4, the AR always points to the next free location on the stack. 6-30 System and User Stack Management Figure 6-11.Implementations of Low-to-High Memory Stacks Case 3 Low memory Bottom of stack . . . ARn Case 4 Low memory Bottom of stack . . . Top of stack ARn Top of stack (Free) High memory (Free) High memory 6.10.3 Queues A queue is like a FIFO. The implementation of queues is based on the manipulation of auxiliary registers. Two auxiliary registers are used: one to mark the front of the queue from which data is popped (or dequeued) and the other to mark the rear of the queue where data is pushed. With proper management of the auxiliary registers, the queue can also be circular. (A queue is circular when the rear pointer is allowed to point to the beginning of the queue memory after it has pointed to the end of the queue memory.) Addressing Modes 6-31 6-32 Chapter 7 Program Flow Control The TMS320C3x provides a complete set of constructs that facilitate software and hardware control of the program flow. Software control includes repeats, branches, calls, traps, and returns. Hardware control includes reset operation, interrupts, and power management. You can select the constructs best suited for your particular application. Topic 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 Page Repeat Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2 Delayed Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9 Calls, Traps, and Returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11 Interlocked Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13 Reset Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26 DMA Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-38 Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47 Power Management Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-49 7-1 Repeat Modes 7.1 Repeat Modes The repeat modes of the 'C3x can implement zero-overhead looping. For many algorithms, most execution time is spent in an inner kernel of code. Using the repeat modes allows these time-critical sections of code to be executed in the shortest possible time. The 'C3x provides two instructions to support zero-overhead looping: - RPTB (repeat a block of code). RPTB repeats execution of a block of code a specified number of times. - RPTS (repeat a single instruction). RPTS fetches a single instruction once and then repeats its execution a number of times. Since the instruction is fetched only once, bus traffic is minimized. RPTB and RPTS are 4-cycle instructions. These four cycles of overhead occur during the initial execution of the loop. All subsequent executions of the loop have no overhead (0 cycle). Three registers (RS, RE, and RC) control the updating of the program-counter (PC) when it is modified in a repeat mode. Table 7-1 describes these registers. Table 7-1. Repeat-Mode Registers Register RS Function Repeat start-address register. Holds the address of the first instruction of the block of code to be repeated. RE RC Correct operation of the repeat modes requires that all of the above registers must be initialized correctly. RPTB and RPTS perform this initialization in slightly different ways. 7-2 Repeat end-address register. Holds the address of the last instruction of the block of code to be repeated. REwRS (see subsection 7.1.2). Repeat-counter register. Contains 1 less than the number of times the block remains to be repeated. For example, to execute a block n times, load n - 1 into RC. Repeat Modes 7.1.1 Repeat-Mode Control Bits Two bits are important to the operation of RPTB and RPTS: - RM bit. The repeat-mode (RM) flag bit in the status register specifies whether the processor is running in the repeat mode. J J RM = 0: Fetches are not made in repeat mode. RM = 1: Fetches are made in repeat mode. - S bit. The S bit is internal to the processor and cannot be programmed, but this bit is necessary to fully describe the operation of RPTB and RPTS. J If RM = 1 and S = 0, RPTB is executing. Program fetches occur from memory. J If RM = 1 and S = 1, RPTS is executing. After the first fetch from memory, program fetches occur from the instruction register. 7.1.2 Repeat-Mode Operation Information in the repeat-mode registers and associated control bits controls the modification of the PC during repeat-mode fetches. The repeat modes compare the contents of the RE register (repeat-end-address register) with the PC after the execution of each instruction. If they match and the repeat counter (RC) is nonnegative, the RC is decremented; the PC is loaded with the repeatstart-address, and the processing continues. The fetches and appropriate status bits are modified as necessary. Note that the RC is never modified when the RM flag is 0. The repeat counter should be loaded with a value 1 less than the number of times to execute the block; for example, an RC value of 4 executes the block five times. The detailed algorithm for the update of the PC is shown in Example 7-1. Note: Maximum Number of Repeats 1) The maximum number of repeats occurs when RC = 8000 0000h. This results in 8000 0001h repetitions. The minimum number of repeats occurs when RC = 0. This results in one repetition. 2) RE must be greater than or equal to RS (RE RS). Otherwise, the code does not repeat even though the RM bit remains set to 1. 3) By writing a 0 into the repeat counter or writing 0 into the RM bit of the status register, you can stop the repeating of the loop before completion. Program Flow Control 7-3 Repeat Modes Example 7-1. Repeat-Mode Control Algorithm if RM == 1 if S == 1 if first time through fetch instruction from memory else fetch instruction from IR RC - 1 RC if RC < 0 0 ST(RM) 0 S PC + 1 PC else if S == 0 fetch instruction from memory if PC == RE RC - 1 RC if RC 0 RS PC else if RC < 0 0 ST(RM) 0 S PC + 1 PC ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; If in repeat mode (RPTB or RPTS) If RPTS If this is the first fetch Fetch instruction from memory If not the first fetch Fetch instruction from IR Decrement RC If RC is negative Repeat single mode completed Turn off repeat-mode bit Clear S Increment PC If RPTB Fetch instruction from memory If this is the end of the block Decrement RC If RC is not negative Set PC to start of block If RC is negative Turn off repeat mode bits Clear S Increment PC 7.1.3 RPTB Instruction The RPTB instruction repeats a block of code a specified number of times. The number of times to repeat the block is the RC (repeat count) register value plus 1. Because the execution of RPTB does not load the RC, you must load this register yourself. The RC register must be loaded before the RPTB instruction is executed. A typical setup of the block repeat operation is shown in Example 7-2. Example 7-2. RPTB Operation LDI 15,RC RPTB ENDLOOP STLOOP . . . ENDLOOP ; ; ; ; Load repeat counter with 15 Execute the block of code from STLOOP to ENDLOOP 16 times 7-4 Repeat Modes All block repeats initiated by RPTB can be interrupted. When RPTB src (source) instruction executes, it performs the following sequence: 1) Load the start address of the block into repeat-start-address register (RS). This is the next address following the instruction: RS z PC (program-counter) of RPTB + 1 2) Load the end address of the block into repeat-end-address register (RE). - In PC-relative mode, the end address is the 24-bit src operand plus RS: RE z src + PC of RPTB + 1 - In register mode, the end address is the contents of the src register: RE z src register 3) Set the status register to indicate the repeat-mode operation. RM z 1 4) Indicate repeat-mode operation by clearing the S bit. Sz0 Note: You can stop the loop from repeating before its completion by writing a 0 to the repeat counter or writing a 0 to the RM bit of the status register. 7.1.4 RPTS Instruction An RPTS src instruction repeats the instruction following the RPTS (src + 1) times. Repeats of a single instruction initiated by RPTS are not interruptible, because the RPTS fetches the instruction word only once and then keeps it in the instruction register for reuse. An interrupt in this situation would cause the instruction word to be lost. Refetching the instruction word from the instruction register reduces memory accesses and, in effect, acts as a one-word program cache. If you need a single instruction that is repeatable and interruptible, you can use the RPTB instruction. When RPTS src is executed, the following sequence of operations occurs: 1) 2) 3) 4) 5) PC + 1 RS PC + 1 RE 1 RM status register bit 1 S bit src RC (repeat count register) Program Flow Control 7-5 Repeat Modes The RPTS instruction loads all registers and mode bits necessary for the operation of the single-instruction repeat mode. Step 1 loads the start address of the block into RS. Step 2 loads the end address into the RE (end address of the block). Since this is a repeat of a single instruction, the start address and the end address are the same. Step 3 sets the status register to indicate the repeat mode of operation. Step 4 indicates that this is the repeat single-instruction mode of operation. Step 5 loads src into RC. 7.1.5 Repeat-Mode Restrictions Because the block-repeat modes modify the program counter, no other instruction can modify the program counter at the same time. Two rules apply: Rule 1: The last instruction in the block (or the only instruction in a block of size 1) cannot be a Bcond, BR, DBcond, CALL, CALLcond, TRAPcond, RETIcond, RETScond, IDLE, RPTB, or RPTS. Example 7-3 shows an incorrectly placed standard branch. Rule 2: None of the last four instructions from the bottom of the block (or the only instruction in a block of size 1) can be a BcondD, BRD, or DBcondD. Example 7-4 shows an incorrectly placed delayed branch. If either of these rules is violated, the PC is undefined. Example 7-3. Incorrectly Placed Standard Branch LDI RPTB STLOOP . . . ENDLOOP 15,RC ENDLOOP ; ; ; ; Load repeat counter with 15 Execute the block of code from STLOOP to ENDLOOP 16 times BR OOPS ; This branch violates rule 1 7-6 Repeat Modes Example 7-4. Incorrectly Placed Delayed Branch LDI RPTB STLOOP . . . BRD ADDF MPYF SUBF 15,RC ENDLOOP ; ; ; ; Load repeat counter with 15 Execute block of code from STLOOP to ENDLOOP 16 times OOPS ; This branch violates rule 2 ENDLOOP 7.1.6 RC Register Value After Repeat Mode Completes For the RPTB instruction, the RC register normally decrements to 0000 0000h unless the block size is 1; in which case, it decrements to FFFF FFFFh. However, if the RPTB instruction using a block size of 1 has a pipeline conflict in the instruction being executed, the RC register decrements to 0000 0000h. Example 7-5 illustrates a pipeline conflict. See Chapter 8 for pipeline information. RPTS normally decrements the RC register to FFFF FFFFh. However, if the RPTS has a pipeline conflict on the last cycle, the RC register decrements to 0000 0000h. Note: Number of Repetitions In any case, the number of repetitions is always RC + 1. Example 7-5. Pipeline Conflict in an RPTB Instruction EDC .word 40000000h LDP EDC LDI @EDC,AR0 LDI 15,RC RPTB ENDLOOP LDI *AR0,R0 ; The program is located in 4000000Fh ; ; ; ; ; ; ; Load repeat counter with 15 Execute block of code The *AR0 read conflicts with the instruction fetching Then RC decrements to 0 If cache is enabled, RC decrements to FFFF FFFFh ENDLOOP Program Flow Control 7-7 Repeat Modes 7.1.7 Nested Block Repeats Block repeats (RPTB) can be nested. Since the registers RS, RE, RC, and ST control the repeat-mode status, these registers must be saved and restored in order to nest block repeats. For example, if you write an interrupt service routine that requires the use of RPTB, it is possible that the interrupt associated with the routine may occur during another block repeat. The interrupt service routine can check the RM bit to determine whether the block repeat mode is active. If this RM is set, the interrupt routine must save ST, RS, RE, and RC, in that order. The interrupt routine can then perform a block repeat. Before returning to the interrupted routine, the interrupt routine must restore RC, RE, RS, and ST, in that order. If the RM bit is not set, you do not need to save and restore these registers. Note: Saving/Restoring Registers in Correct Order The order in which the registers are saved/restored is important to guarantee correct operation. The ST register must be restored last, after the RC, RE, and RS registers. ST must be restored after restoring RC, because the RM bit cannot be set to 1 if the RC register is 0 or -1. For this reason, if you execute a POP ST instruction (with ST (RM bit) = 1) while RC = 0, the POP instruction recovers all the ST register bits but not the RM bit that stays at 0 (repeat mode disabled). Also, RS and RE must be correctly set before you activate the repeat mode. The RPTS instruction can be used in a block repeat loop if the proper registers are saved. Because the program counter is modified at the end of the loop according to the contents of registers RS, RE, and RC, no operation should attempt to modify the repeat counter or the program-counter to a different value at the end of the loop. It takes four cycles in the pipeline to save and restore these registers. Hence, sometimes, it may be more economical to implement a nested loop by the more traditional method of using a register as a counter and then using a delayed branch or a decrement and branch-delayed instructions, rather than using nested repeat blocks. Often implementing the outer loop as a counter and the inner loop as RPTB instruction produces the fastest execution. 7-8 Delayed Branches 7.2 Delayed Branches The 'C3x offers three main types of branching: standard, delayed, and conditional delayed. Standard branches empty the pipeline before performing the branch, ensuring correct management of the program counter and resulting in a 'C3x branch taking four cycles. Included in this class are repeats, calls, returns, and traps. Delayed branches on the 'C3x do not empty the pipeline, but rather execute the next three instructions before the program counter is modified by the branch. This results in a branch that requires only a single cycle, making the speed of the delayed branch very close to that of the optimal block repeat modes of the 'C3x. However, unlike block-repeat modes, delayed branches may be used in situations other than looping. Every delayed branch has a standard branch counterpart that is used when a delayed branch cannot be used. The delayed branches of the 'C3x are Bcond D, BRD, and DBcond D. Conditional delayed branches use the conditions that exist at the end of the instruction immediately preceding the delayed branch. They do not depend on the instructions following the delayed branch. The condition flags are set by a previous instruction only when the destination register is one of the extendedprecision registers (R0-R7) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Delayed branches guarantee that the next three instructions will execute, regardless of other pipeline conflicts. When a delayed branch is fetched, it remains pending until the three subsequent instructions are executed. The following instructions cannot be used in the three instructions after a delayed branch (see Example 7-6): Bcond BcondD BR BRD CALL CALLcond DBcond DBcondD IDLE IDLE2 RETIcond RETScond RPTB RPTS TRAPcond Delayed branches disable interrupts until the completion of the three instructions that follow the delayed branch regardless of whether the branch is or is not performed. Note: Incorrect Use of Delayed Branches If delayed branches are used incorrectly, the PC is undefined. Program Flow Control 7-9 Delayed Branches Example 7-6. Incorrectly Placed Delayed Branches B1: BD NOP NOP B NOP NOP NOP . . . L1 B2: L2 ; This branch is incorrectly placed. For faster execution, it might still be advantageous to use a delayed branch followed by NOP instructions by trading increased program size for faster speed. This is shown in Example 7-7 where a NOP takes the place of the third unused instruction after the delayed branch. Example 7-7. Delayed Branch Execution * TITLE DELAYED BRANCH EXECUTION . . . . LDF* +AR1(5),R2 ; Load contents of memory to R2 BGED SKIP ; If loaded number >=0, branch ; (delayed) LDFN R2,R1 ; If loaded number <0, load it to R1 SUBF 3.0,R1 ; Subtract 3 from R1 NOP ; Dummy operation to complete delayed ; branch MPYF 1.5,R1 ; Continue here if loaded number <0 . . . SKIP LDF R1,R3 ; Continue here if loaded number >=0 7-10 Calls, Traps, and Returns 7.3 Calls, Traps, and Returns Calls and traps provide a means of executing a subroutine or function while providing a return to the calling routine. The CALL, CALLcond, and TRAPcond instructions store the value of the PC on the stack before changing the PC's contents. The RETScond or RETIcond instructions use the value on the stack to return execution from traps and calls. CALL is a 4-cycle instruction, while CALLcond and TRAPcond are 5-cycle instruction. - The CALL instruction places the next PC value on the stack and places the src (source) operand into the PC. The src is a 24-bit immediate value. Figure 7-1 shows CALL response timing. - The CALLcond instruction is similar to the CALL instruction except for two differences: J J It executes only if a specific condition is true (the 20 conditions-- including unconditional--are listed in Table 13-12 on page 13-30). The src is either a PC-relative displacement or is in register-addressing mode. The condition flags are set by a previous instruction only when the destination register is one of the extended-precision registers (R0-R7) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. - The TRAPcond instruction also executes only if a specific condition is true (same conditions as for the CALLcond instruction). When executing, the following actions occur: 1) Interrupts are disabled with 0 written to bit GIE of the ST. 2) The next PC value is stored on the stack. 3) The specified vector is retrieved from the trap-vector table and is loaded into the PC. The vector address corresponds to the trap number in the instruction. Using the RETIcond to return reenables interrupts by setting the bit field of the status register. - RETScond returns execution from any of the above three instructions by popping the top of the stack to the PC. For RETScond to execute, the specified condition must be true. The conditions are the same as for the CALLcond instruction. Program Flow Control 7-11 Calls, Traps, and Returns - RETIcond returns from traps or calls like the RETScond, with the addition that RETIcond also sets the GIE bit of the status register, which enables all interrupts whose enabling bit is set to 1. The conditions for RETIcond are the same as for the CALLcond instruction. Functionally, calls and traps accomplish the same task -- a subfunction is called and executed, and control is then returned to the calling function. Traps offer two advantages over calls: - Interrupts are automatically disabled when a trap is executed. This allows critical code to execute without risk of being interrupted. Traps are generally terminated with a RETIcond instruction to reenable interrupts. - You can use traps to indirectly call functions. This is particularly benefi- cial when a kernel of code contains the basic subfunctions to be used by applications. In this case, you can modify the functions in the kernel and relocate them without recompiling each application. Figure 7-1. CALL Response Timing Fetch CALL Decode CALL Read CALL Execute CALL (store PC on stack) Fetch first subroutine instruction H3 H1 ADDR Data Vector address PC First instruction address Inst 1 7-12 Interlocked Operations 7.4 Interlocked Operations One of the most common parallel processing configurations is the sharing of global memory by multiple processors. For multiple processors to access this global memory and share data in a coherent manner, some sort of arbitration or handshaking is necessary. This requirement for arbitration is the purpose of the 'C3x interlocked operations. The 'C3x provides a flexible means of multiprocessor support with five instructions, referred to as interlocked operations. Through the use of external signals, these instructions provide powerful synchronization mechanisms. They also guarantee the integrity of the communication and result in a high-speed operation. The interlocked-operation instruction group is listed in Table 7-2. Table 7-2. Interlocked Operations Mnemonic LDFI LDII SIGI STFI STII Description Load floating-point value into a register, interlocked Load integer into a register, interlocked Signal, interlocked Store floating-point value to memory, interlocked Store integer to memory, interlocked Operation Signal interlocked src dst Signal interlocked src dst Signal interlocked Clear interlock Clear interlock src dst Clear interlock src dst The interlocked operations use the two external flag pins, XF0 and XF1. XF0 must be configured as an output pin; XF1 is an input pin. When configured in this manner: - XF0 signals an interlock operation request - XF1 acts as an acknowledge signal for the requested interlocked operation. In this mode, XF0 and XF1 are treated as active-low signals. The external timing for the interlocked loads and stores is the same as for standard loads and stores. The interlocked loads and stores may be extended like standard accesses by using the appropriate ready signal (RDYint or XRDYint). (RDYint and XRDYint are a combination of external ready input and software wait states. see Chapter 9, External Memory Interface, for more information on ready generation.) Program Flow Control 7-13 Interlocked Operations The LDFI and LDII instructions perform the following actions: 1) Simultaneously set XF0 to 0 and begin a read cycle. The timing of XF0 is similar to that of the address bus during a read cycle. 2) Execute an LDF or LDI instruction and extend the read cycle until XF1 is set to 0 and a ready (RDYint or XRDYint) is signaled. The read cycle completes one H1/H3 cycle after the XF1 signal is detected. 3) Leave XF0 set to 0 and end the read cycle. Note: Timing Diagrams for LDFI and LDII The timing diagrams for LDFI and LDII shown on the data sheets depict a 0 wait state read cycle. Since the read cycle is extended for one H1/H3 cycle after XF1 signal is detected, the data sheets show the XF1 signal sampled one H1/H3 cycle before setting the XF0 signal low. For the sequence of steps described here, the read cycle finishes one H1/H3 cycle after the XF1 signal is detected. The read/write operation is identical to any other read/write cycle except for the special use of XF0 and XF1. The src operand for LDFI and LDII is always a direct or indirect memory address. XF0 is set to 0 only if the src is located off chip; that is, STRB, STRB0, STRB1, MSTRB, or IOSTRB is active, or the src is one of the on-chip peripherals. If on-chip memory is accessed, then XF0 is not asserted, and the operation executes as an LDF or LDI from internal memory. The STFI and STII instructions perform the following operations: 1) Simultaneously set XF0 to 1 and begin a write cycle. The timing of XF0 is similar to that of the address bus during a write cycle. 2) Execute an STF or STI instruction and extend the write cycle until a ready (RDYint or XRDYint) is signaled. As in the case for LDFI and LDII, the dst of STFI and STII affects XF0. If dst is located off chip (STRB, STRB0, STRB1, MSTRB, or IOSTRB is active) or the dst is one of the on-chip peripherals, XF0 is set to 1. If on-chip memory is accessed, then XF0 is not asserted and the operation executes as an STF or STI to internal memory. The SIGI instruction functions as follows: 1) Sets XF0 to 0 2) Idles until one H1/H3 cycle after XF1 is set to 0 3) Sets XF0 to 1 and ends the operation 7-14 Interlocked Operations Note: Timing Diagrams for SIGI The timing diagrams for SIGI shown in the data sheets depict a zero wait state condition. Since the device idles until one cycle after XF1 is signaled, the data sheets show the XF1 signal sampled one H1/H3 cycle before setting the XF0 signal low. For the sequence of steps described here, the device idles past one H1/H3 cycle after the XF1 signal is detected. 7.4.1 Interrupting Interlocked Operations While the LDFI, LDII, and SIGI instructions are waiting for XF1 to be set to 0, you can interrupt them. LDFI and LDII require a ready signal (RDYint or XRDYint) in order to be interrupted. Because interrupts are taken on bus-cycle boundaries (see Section 7.6 on page 7-26), an interrupt may be taken any time after a valid ready. If the interrupted LDFI or LDII consists of a multicycle load, the load stops and an unknown value might be loaded into the register. Interrupting an LDFI, LDII, or SIGI instruction allows you to implement protection mechanisms against deadlock conditions by interrupting an interlocked load that has taken too long. Upon return from the interrupt, the next instruction is executed. The STFI and STII instructions are not interruptible. Since the STFI and STII instructions complete when ready is signaled, the delay until an interrupt can occur is the same as for any other instruction. 7.4.2 Using Interlocked Operations Note: Incorrect Use of Interlock Instructions Do not place an STFI or STII back-to-back with an LDFI, LDII, or SIGI instruction as follows: STFI LDFI R1,*AR1 ; *AR1, R2 ; Incorrect use of interlock instructions See Section 7.4.3, Pipeline Effects of Interlocked Instructions, on page 7-19. Interlocked operations can be used to implement a busy-waiting loop, to manipulate a multiprocessor counter, to implement a simple semaphore mechanism, or to perform synchronization between two 'C3x devices. The following examples illustrate the usefulness of the interlocked operations instructions. Program Flow Control 7-15 Interlocked Operations Example 7-8 shows the implementation of a busy-waiting loop. If location LOCK is the interlock for a critical section of code, and a nonzero means the lock is busy, the algorithm for a busy-waiting loop can be used as shown. Example 7-8. Busy-Waiting Loop LDI LDII STII BNZ 1,R0 @LOCK,R1 R0,@LOCK L1 ; ; ; ; ; ; Put 1 into R0 Interlocked operation begun Contents of LOCK R1 Put R0 (= 1) into LOCK, XF0 = 1 Interlocked operation ended Keep trying until LOCK = 0 L1: Example 7-9 shows how a location COUNT may contain a count of the number of times a particular operation must be performed. This operation may be performed by any processor in the system. If the count is 0, the processor waits until it is nonzero before beginning processing. The example also shows the algorithm for modifying COUNT correctly. Example 7-9. Multiprocessor Counter Manipulation CT: OR LDII BZ CT SUBI STII 4,IOF @COUNT,R1 ; ; ; ; ; ; ; ; XF0 = 1 Interlocked operation ended Interlocked operation begun Contents of COUNT R1 If COUNT = 0, keep trying Decrement R1 (= COUNT) Update COUNT, XF0 = 1 Interlocked operation ended 1,R1 R1,@COUNT Figure 7-2 illustrates multiple 'C3x devices sharing global memory and using the interlocked instructions as in Example 7-10, Example 7-11, and Example 7-12. 7-16 Interlocked Operations Figure 7-2. Multiple TMS320C3xs Sharing Global Memory Global memory ADDR Arbitration logic Lock, count, or S XF0 XF1 (X)A (X)D CTRL (X)A (X)D CTRL XF0 XF1 'C3x #1 CTRL DATA 'C3x #2 Local memory Local memory Sometimes it may be necessary for several processors to access some shared data or other common resources. The portion of code that must access the shared data is called a critical section. To ease the programming of critical sections, semaphores may be used. Semaphores are variables that can take only nonnegative integer values. Two primitive, indivisible operations are defined on semaphores (with S being a semaphore): V(S): P(S): S + 1 S P: if (S == 0), go to P else S - 1 S Indivisibility of V(S) and P(S) means that when these processes access and modify the semaphore S; they are the only processes doing so. To enter a critical section, a P operation is performed on a common semaphore, say S (S is initialized to 1). The first processor performing P(S) will be able to enter its critical section. All other processors are blocked because S has become 0. After leaving its critical section, the processor performs a V(S), thus allowing another processor to execute P(S) successfully. Program Flow Control 7-17 Interlocked Operations The 'C3x code for V(S) is shown in Example 7-10; code for P(S) is shown in Example 7-11. Compare the code in Example 7-11 to the code in Example 7-9, which does not use semaphores. Example 7-10. Implementation of V(S) V: LDII ADDI STII @S,R0 1,R0 R0,@S ; ; ; ; Interlocked read of S begins (XFO = 0) Contents of S R0 Increment R0 (= S) Update S, end interlock (XF0 = 0) Example 7-11. Implementation of P(S) P: OR NOP 4,IOF ; ; ; ; @S,R0 ; ; P ; 1,R0 ; R0,@S ; End interlock (XF0 = 1) Avoid potential pipeline conflicts when executing out of cache, on-chip memory or zero wait-state memory Interlocked read of S begins Contents of S R0 If S = 0, go to P and try again Decrement R0 (= S) Update S, end interlock (XF0 = 1) LDII BZ SUBI STII The SIGI operation can synchronize, at an instruction level, multiple 'C3xs. Consider two processors connected as shown in Figure 7-3. The code for the two processors is shown in Example 7-12. Figure 7-3. Zero-Logic Interconnect of TMS320C3x Devices 'C3x #1 XF0 XF1 XF1 XF0 'C3x #2 Processor #1 runs until it executes the SIGI. It then waits until processor #2 executes a SIGI. At this point, the two processors are synchronized and continue execution. 7-18 Interlocked Operations Example 7-12. Code to Synchronize Two TMS320C3x Devices at the Software Level Time O Code for 'C3x #1 Code for 'C3x #2 SIGI (WAIT) Synchronization occurs SIGI N 7.4.3 Pipeline Effects of Interlocked Instructions Before performing an interlocked instruction, the XF0 pin must be configured as an output pin and the XF1 pin must be configured as an input pin through the IOF register (see subsection 3.1.10, I/O Flag Register (IOF), on page 3-16). After the XF0 and XF1 pins are configured, no interlocked instruction can occur in the following two instructions. Program Flow Control 7-19 Interlocked Operations Example 7-13. Pipeline Delay of XF Pin Configuration Pipeline Operation PC n n+1 n+2 n+3 XF1 sampled Fetch LDI 2h, IOF NOP NOP LDII *AR1, R1 Decode Read Execute XF0 set as an output pin and XF1 set as an input pin LDI 2h, IOF NOP NOP LDII *AR1, R1 LDI 2h, IOF NOP NOP LDII *AR1, R1 LDI 2h, IOF NOP NOP LDII *AR1, R1 XF0 driven low and XF1 sampled n+4 n+5 n+6 STFI and STII instructions drive the XF0 pin high during its execution phase. LDFI, LDII, and SIGI instructions sample the XF1 pin during its decode phase while driving the XF0 pin low during its read phase. Therefore, do not use an LDFI, LDII, or SIGI instruction immediately after an STFI or STII instruction (see Example 7-14). Example 7-14. Incorrect Use of Interlocked Instructions Pipeline Operation PC n n+1 XF1 pin sampled Fetch STFI R1, *AR1 LDFI *AR1, R2 Decode Read Execute STFI R1, *AR1 LDFI *AR1, R2 STFI R1, *AR1 LDFI *AR1, R2 XF0 pin driven high n+2 n+3 n+4 STFI R1, *AR1 LDFI *AR1, R2 XF0 pin driven low 7-20 Reset Operation 7.5 Reset Operation The 'C3x supports a nonmaskable external reset signal (RESET), which is used to perform system reset. This section discusses the reset operation. At start-up, the state of the 'C3x processor is undefined. You can use the RESET signal to place the processor in a known state. This signal must be asserted low for ten or more H1 clock cycles to guarantee a system reset. H1 is an output clock signal generated by the 'C3x. (Check the datasheet for your device for the specific signal descriptions and electrical characteristics.) Reset affects the other pins on the device in either a synchronous or asynchronous manner. The synchronous reset is gated by the 'C3x's internal clocks. The asynchronous reset directly affects the pins and is faster than the synchronous reset. Table 7-3 shows the state of the 'C3x's pins after RESET = 0. Each pin is described according to whether the pin is reset synchronously or asynchronously. Table 7-3. TMS320C3x Pin Operation at Reset Device Signal Operation at Reset Primary Bus Interface Signals D31 -D0 A23 -A0 R/W IOSTRB STRB0_B3/A-1 STRB0_B2/A-2 STRB0_B1 STRB0_B0 STRB1_B3/A-1 STRB1_B2/A-2 STRB1_B1 STRB1_B0 STRB RDY HOLD Synchronous reset; placed in high-impedance state Synchronous reset; placed in high-impedance state Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Synchronous reset; deasserted by going to a high level Reset has no effect Reset has no effect n n n n n n n n n n n n n n n n n n n n n n n n n n n `C30 `C31/ VC33 `C32 Program Flow Control 7-21 Reset Operation Table 7-3. TMS320C3x Pin Operation at Reset (Continued) Device Signal HOLDA PRGW Operation at Reset Reset has no effect Reset has no effect Expansion Bus Interface XD31 -XD0 XA12 -XA0 XR/W MSTRB XRDY Synchronous reset; placed in high-impedance state Synchronous reset; placed in high-impedance state Synchronous reset; placed in high-impedance state Synchronous reset; deasserted by going to a high level Reset has no effect Control Signals RESET INT3 -INT0 IACK MC/MP or MCBL/MP SHZ XF1-XF0 Reset input pin Reset has no effect Synchronous reset; deasserted by going to a high level Reset has no effect Reset has no effect Asynchronous reset; placed in high-impedance state Serial Port 0 Signals CLKX0 DX0 FSX0 CLKR0 DR0 FSR0 Asynchronous reset; placed in high-impedance state Asynchronous reset; placed in high-impedance state Asynchronous reset; placed in high-impedance state Asynchronous reset; placed in high-impedance state Asynchronous reset; placed in high-impedance state Asynchronous reset; placed in high-impedance state Serial Port 1 Signals CLKX1 DX1 FSX1 Asynchronous reset; placed in high-impedance state Asynchronous reset; placed in high-impedance state Asynchronous reset; placed in high-impedance state n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n `C30 n `C31/ VC33 n `C32 n n 7-22 Reset Operation Table 7-3. TMS320C3x Pin Operation at Reset (Continued) Device Signal CLKR1 DR1 FSR1 Operation at Reset Asynchronous reset; placed in high-impedance state Asynchronous reset; placed in high-impedance state Asynchronous reset; placed in high-impedance state Timer0 Signal TCLK0 Asynchronous reset; placed in high-impedance state Timer1 Signal TCLK1 Asynchronous reset; placed in high-impedance state Supply and Oscillator Signals VDD IODVDD ADVDD PDVDD DDVDD MDVDD VSS DVSS CVSS IVSS VBBP VSUBS X1 X2/CLKIN H1 H3 Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Reset has no effect Synchronous reset; will go to its initial state when RESET makes a 1 to 0 transition Synchronous reset; will go to its initial state when RESET makes a 1 to 0 transition n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n `C30 n n n `C31/ VC33 `C32 Program Flow Control 7-23 Reset Operation Table 7-3. TMS320C3x Pin Operation at Reset (Continued) Device Signal Operation at Reset Emulation, Test, and Reserved EMU0 EMU1 EMU2 EMU3 EMU4 EMU5 EMU6 RSV0 RSV1 RSV2 RSV3 RSV4 RSV5 RSV6 RSV7 RSV8 RSV9 RSV10 Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined Undefined n n n n n n n n n n n n n n n n n n n n n n n n n n `C30 `C31/ VC33 `C32 7-24 Reset Operation At system reset, the following additional operations are performed: - The peripherals are reset. This is a synchronous operation. Peripheral reset is described in Chapter 12, Peripherals. - The external bus control registers are reset. The reset values of the control registers are described in Chapter 9, 'C30 and 'C31/VC33 ExternalMemory Interface. - The following CPU registers are loaded with 0: J ST (CPU status register), except in the 'C32, the PRGW status bit field is loaded with the status of the PRGW pin J IE (CPU/DMA interrupt-enable flags) J IF (CPU interrupt flags) J IOF (I/O flags) - The reset vector is read from memory location 0h. On the 'C32, this is a 32-bit data read. Once read, this value is loaded into the PC. This vector contains the start address of the system reset routine. - At this point, code location is dictated by the PC. Multiple 'C3x devices, driven by the same system clock, may be reset and synchronized. When the 1 to 0 transition of RESET occurs, the processor is placed on a well-defined internal phase, and all of the 'C3x devices come up on the same internal phase and all internal memory locations. Unless otherwise specified, all registers are undefined after reset. Program Flow Control 7-25 Interrupts 7.6 Interrupts The 'C3x supports multiple internal and external interrupts, which can be used for a variety of applications. Internal interrupts are generated by the DMA controller, timers, and serial ports. Four external maskable interrupt pins include INT0 - INT3. Interrupts are automatically prioritized allowing interrupts to occur simultaneously and serviced in a predefined order. This section discusses the operation of these interrupts. Additional information regarding internal interrupts can be found in Section 12.3.7, DMA and Interrupts, on page 12-65; Section 12.1.8, Timer Interrupts on page 12-13; and Section 12.2.11, Serial-Port Interrupt Sources, on page 12-34. 7.6.1 TMS320C30 and TMS320C31/VC33 Interrupt Vector Table Table 7-4 and Table 7-5 contain the interrupt vectors. In the microprocessor mode of the 'C30 and the 'C31/VC33 (Table 7-4) and the microcomputer mode of the 'C31/VC33 (Table 7-5), the interrupt vectors contain the addresses of interrupt service routines that should start executing when an interrupt occurs. On the other hand, in the microcomputer/boot-loader mode of the 'C31/VC33, the interrupt vector contains a branch instruction to the start of the interrupt service routine. 7-26 Interrupts Table 7-4. Reset, Interrupt, and Trap-Vector Locations for the TMS320C30/ TMS320C31/VC33 Microprocessor Mode Address 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch 1Fh 20h Name RESET INT0 INT1 INT2 INT3 XINT0 RINT0 XINT1 RINT1 TINT0 TINT1 DINT Reserved Reserved TRAP 0 3Bh 3Ch 3Dh 3Eh 3Fh TRAP 27 TRAP 28 (reserved) TRAP 29 (reserved) TRAP 30 (reserved) TRAP 31 (reserved) Internal interrupt generated by TRAP 27 instruction Internal interrupt generated by TRAP 0 instruction Function External reset signal input External interrupt on the INT0 pin External interrupt on the INT1 pin External interrupt on the INT2 pin External interrupt on the INT3 pin Internal interrupt generated when serial port 0 transmit buffer is empty Internal interrupt generated when serial port 0 transmit buffer is full Internal interrupt generated when serial port 1 transmit buffer is empty Internal interrupt generated when serial port 1 transmit buffer is full Internal interrupt generated by timer0 Internal interrupt generated by timer1 Internal interrupt generated by DMA controller Reserved on 'C31/VC33 Program Flow Control 7-27 Interrupts Table 7-5. Reset, Interrupt, and Trap-Branch Locations for the TMS320C31/VC33 Microcomputer Boot Mode Address 809FC1 809FC2 809FC3 809FC4 809FC5 809FC6 Name INT0 INT1 INT2 INT3 XINT0 RINT0 Function External reset signal input External interrupt on the INT0 pin External interrupt on the INT1 pin External interrupt on the INT2 pin External interrupt on the INT3 pin Internal interrupt generated when serial port 0 transmit buffer is empty 809FC7 809FC8 809FC9 XINT1 (Reserved) RINT1 (Reserved) TINT0 Internal interrupt generated by timer0 Internal interrupt generated by timer1 Internal interrupt generated by DMA controller 809FCA TINT1 809FCB DINT 809FCC-809FDF 809FE0 Reserved TRAP0 Internal interrupt generated by TRAP 0 instruction Internal interrupt generated by TRAP 1 instruction 809FE1 809FFB TRAP1 TRAP27 Internal interrupt generated by TRAP 27 instruction 809FFC-809FFF Reserved 7-28 Interrupts 7.6.2 TMS320C32 Interrupt Vector Table Similarly to the rest of the 'C3x device family, the 'C32's reset vector location remains at address 0. On the other hand, the interrupt and trap vectors are relocatable. This is achieved by a new bit field in the CPU interrupt flag register called the interrupt-trap table pointer (ITTP), shown in Figure 3-11 on page 3-15. The ITTP bit field dictates the starting location (base) of the interrupttrap-vector table. This base address is formed by left-shifting the value of the ITTP bit field by eight bits. This shifted value is called the effective base address and is referenced as EA[ITTP], as shown in Figure 7-4. Therefore, the location of an interrupt or trap vector is given by the addition of the effective base address formed by the ITTP bit field (EA[ITTP]) and the offset of the interrupt or trap vector in the interrupt-trap-vector table, as shown in Table 7-6. For example, if the ITTP contains the value 100h, the serial-port transmit interrupt vector will be located at 10005h. Note that the vectors stored in the interrupt-trap-vector table are the addresses of the start of the respective interrupt and trap routines. Furthermore, the interrupt-trap-vector table must lie on a 256-word boundary, since the eight LSBs of the effective base address of the interrupt-trap-vector table are 0. Figure 7-4. Effective Base Address of the Interrupt-Trap-Vector Table 23 EA[ITTP] = Bits 31 -16 of the CPU interrupt flag register 8 7 00000000 0 Program Flow Control 7-29 Interrupts Table 7-6. Interrupt and Trap-Vector Locations for the TMS320C32 Address EA[ITTP] + 00h EA[ITTP] + 01h EA[ITTP] + 02h EA[ITTP] + 03h EA[ITTP] + 04h EA[ITTP] + 05h EA[ITTP] + 06h EA[ITTP] + 07h EA[ITTP] + 08h EA[ITTP] + 09h EA[ITTP] + 0Ah EA[ITTP] + 0Bh EA[ITTP] + 0Ch EA[ITTP] + 0Dh EA[ITTP] + 1Fh EA[ITTP] + 20h Name Reserved INT0 INT1 INT2 INT3 XINT0 RINT0 Reserved Reserved TINT0 TINT1 DINT0 DINT1 Reserved Reserved TRAP 0 EA[ITTP] + 3Bh EA[ITTP] + 3Ch EA[ITTP] + 3Dh EA[ITTP] + 3Eh EA[ITTP] + 3Fh TRAP 27 TRAP 28 (reserved) TRAP 29 (reserved) TRAP 30 (reserved) TRAP 31 (reserved) Internal interrupt generated by TRAP 27 instruction Internal interrupt generated by TRAP 0 instruction Internal interrupt generated by timer0 Internal interrupt generated by timer1 Internal interrupt generated by DMA channel 0 Internal interrupt generated by DMA channel 1 External interrupt on the INT0 pin External interrupt on the INT1 pin External interrupt on the INT2 pin External interrupt on the INT3 pin Internal interrupt generated when serial port 0 transmit buffer is empty Internal interrupt generated when serial port 0 transmit buffer is full Function 7-30 Interrupts 7.6.3 Interrupt Prioritization When two interrupts occur in the same clock cycle or when two previously received interrupts are waiting to be serviced, one interrupt is serviced before the other. The CPU handles this prioritization by servicing the interrupt with the least priority. The priority of interrupts is handled by the CPU according to the interrupt vector table. Priority is set according to position in the table--those with displacements closest to the base address of the table are higher in priority. Table 7-7 shows the priorities assigned to the reset and interrupt vectors. Table 7-7. Reset and Interrupt Vector Priorities Reset or Interrupt RESET INT0 INT1 INT2 INT3 XINT0 RINT0 XINT1 RINT1 TINT0 TINT1 DINT/ DINT0 DINT1 Vector Location 0h 1h 2h 3h 4h 5h 6h 7h 8h 9h 0Ah 0Bh 0Ch Priority 0 1 2 3 4 5 6 7 8 9 10 11 12 Function External reset signal input on the RESET pin External interrupt on the INT0 pin External interrupt on the INT1 pin External interrupt on the INT2 pin External interrupt on the INT3 pin Internal interrupt generated when serial-port 0 transmit buffer is empty Internal interrupt generated when serial-port 0 receive buffer is full Internal interrupt generated when serial-port 1 transmit buffer is empty Internal interrupt generated when serial-port 1 receive buffer is full Internal interrupt generated by timer0 Internal interrupt generated by timer1 Internal interrupt generated by DMA channel 0 Internal interrupt generated by DMA channel 1 Reserved on 'C31/VC33 and 'C32 Present on 'C32 only Program Flow Control 7-31 Interrupts 7.6.4 CPU Interrupt Control Bits Three CPU registers contain bits that control interrupt operation: - Status (ST) register The CPU global interrupt-enable bit (GIE) located in the CPU status register (ST) controls all maskable CPU interrupts. When this bit is set to 1, the CPU responds to an enabled interrupt. When this bit is cleared to 0, all CPU interrupts are disabled. see Section 3.1.7 on page 3-5 for more information. - CPU/DMA interrupt-enable (IE) register This register individually enables/disables CPU, DMA external, serial port, and timer interrupts. See Section 3.1.8 on page 3-9 for more information. - CPU interrupt flag (IF) register This register contains interrupt flag bits that indicate the corresponding interrupt is set. See Section 3.1.9 on page 3-11 for more information. 7.6.5 Interrupt Flag Register Behavior When an external interrupt occurs, the corresponding bit of the IF register is set to 1. When the CPU or DMA controller processes this interrupt, the corresponding interrupt flag bit is cleared by the internal interrupt acknowledge signal. However, for level-triggered interrupts, if INTn is still low when the interrupt acknowledge signal occurs, the interrupt flag bit is cleared for only one cycle and then set again, because INTn is still low. Depending on when the IF register is read, it is also possible that this bit may be 0 even though INTn is 0. When the 'C3x is reset, 0 is written to the interrupt flag register, clearing all pending interrupts. The interrupt flag register bits can be read from and written to under software control. Writing a 1 to an IF register bit sets the associated interrupt flag to 1. Similarly, writing a 0 resets the corresponding interrupt flag to 0. In this way, all interrupts may be triggered and/or cleared through software. Since the interrupt flags may be read, the interrupt pins may be polled in software when an interrupt-driven interface is not required. Internal interrupts operate in a similar manner. In the IF register, the bit corresponding to an internal interrupt can be read from and written to through software. Writing a 1 sets the interrupt latch; writing a 0 clears it. All internal interrupts are one H1/H3 cycle in length. If any previous bit value of the IF register needs to be preserved, a modification to IF register should be performed with logic operations (AND, OR, etc.) directly to IF. 7-32 Interrupts Figure 7-5. IF Register Modification Correct LDI @MASK, R0 AND R0, IF Incorrect LDI IF, R1 AND @MASK, R1 LDI R1, IF Note: IF Register Load Priority If a load of the IF register occurs simultaneously with a set or reset of a flag by an interrupt pulse, the loading of the flag has higher priority and overwrites the IF register value. 7.6.6 Interrupt Processing The 'C3x allows the CPU and DMA coprocessor to respond to and process interrupts in parallel. Figure 7-6 on page 7-34 shows interrupt processing flow; for the exact sequence, see Table 7-8 on page 7-36. For a CPU interrupt to occur, at least two conditions must be met: - All interrupts must be enabled globally by setting the GIE bit to 0 in the status register. - The interrupt must be enabled by setting the corresponding bit in the IF register. In the CPU interrupt processing cycle (left side of Figure 7-6), the corresponding interrupt flag in the IF register is cleared, and interrupts are globally disabled (GIE = 0). The CPU completes all fetched instructions. The current PC is pushed to the top of the stack. The interrupt vector is then fetched and loaded into the PC, and the CPU starts executing the first instruction in the interrupt service routine (ISR). Program Flow Control 7-33 Interrupts Figure 7-6. CPU Interrupt Processing No Is an enabled interrupt set ? Yes If enabled, interrupt is a CPU interrupt If enabled, interrupt is a DMA interrupt Disable interrupts GIE 0 Clear interrupt flag Clear interrupt flag DMA proceeds according to SYNC bits PC *(++SP) DMA continues Complete all fetched instructions PC interrupt vector CPU starts executing ISR routine Note: CPU and DMA Interrupts CPU interrupts are acknowledged (responded to by the CPU) on instruction fetch boundaries only. If instruction fetches are halted because of pipeline conflicts or execution of RPTS loops, CPU interrupts are not acknowledged until the next instruction fetch. 7-34 Interrupts If you wish to make the interrupt service routine interruptible, you can set the GIE bit to 1 after entering the ISR. The interrupt acknowledge (IACK) instruction can be used to signal externally that an interrupt has been serviced. If external memory is specified in the operand, IACK drives the IACK pin and performs a dummy read. The read is performed from the address specified by the IACK instruction operand. IACK is typically placed in the early portion of an ISR. However, depending on your application, it may be better to place it at the end of the ISR or not at all. Note the following: - Interrupts are disabled during an RPTS and during a delayed branch (until the three instructions following a delayed branch are completed). Interrupts are held until after the branch. - When an interrupt occurs, instructions currently in the decode and read phases continue regular execution, unlike an instruction in the fetch phase: J If the interrupt occurs in the first cycle of the fetch of an instruction, the fetched instruction is discarded (not executed), and the address of that instruction is pushed to the top of the system stack. If the interrupt occurs after first cycle of the fetch (in the case of a multicycle fetch due to wait states), that instruction is executed, and the address of the next instruction to be fetched is pushed to the top of the system stack. J 7.6.7 CPU Interrupt Latency CPU interrupt latency, defined as the time from the acknowledgement of the interrupt to the execution of the first ISR instruction, is at least eight cycles. This is explained in Table 7-8 on page 7-36, where the interrupt is treated as an instruction. It assumed that all of the instructions are single-cycle instructions. Program Flow Control 7-35 Interrupts Table 7-8. Interrupt Latency Cycle 1 Description Recognize interrupt in single-cycle fetched (prog a + 1) instruction Clear GIE bit. Clear interrupt flag Read the interrupt vector table Store return address to stack Pipeline begins to fill with ISR instruction Pipeline continues to fill with ISR instruction Pipeline continues to fill with ISR instruction Execute first instruction of interrupt service routine Fetch prog a + 1 Decode prog a Read prog a-1 Execute prog a-2 2 3 4 5 6 7 8 -- -- -- isr1 isr2 isr3 isr4 interrupt -- -- -- isr1 isr2 isr3 prog a interrupt -- -- -- isr1 isr2 prog a-1 prog a interrupt -- -- -- isr1 7.6.8 External Interrupts The four external maskable interrupt pins INT0-INT3 are enabled at the IF register (Section 3.1.9, CPU Interrupt Flag (IF) Register, on page 3-11) and are synchronized internally. They are sampled on the falling edge of H1 and passed through a series of H1/H3 latches internally. These latches require the interrupt signal to be held low for at least one H1/H3 clock cycle to be recognized by the `C3x. Once synchronized, the interrupt input sets the corresponding interrupt flag register (IF) bit if the interrupt is active. Figure 7-7 shows a functional diagram of the logic used to implement external interrupt inputs. 7-36 Interrupts Figure 7-7. Interrupt Logic Functional Diagram Internal interrupt set signal EINTn(CPU) Interrupt flag (n) INTn DQ CLK D Q CLK D Q CLK Set Q RESET Internal interrupt clear/acknowledge signal EINTn(DMA) GIE(CPU) Internal interrupt processor To control section H1 H3 H1 These interrupts are prioritized by the selection of one over the other if both come on the same clock cycle (INT0 the highest, INT1 next, etc.). When an interrupt is taken, the status register ST(GIE) bit is reset to 0, disabling any other incoming interrupt. This prevents any other interrupt (INT0 - INT3) from assuming program control until the ST(GIE) bit is set back to 1. On a return from an interrupt routine, the RETI and RETIcond instructions set the ST(GIE) bit to 1. On the `C30 and `C31/VC33, external interrupts are level triggered. On the `C32, external interrupts are edge or level triggered, depending on the INT config bit field of the status register. For an edge-triggered interrupt to be detected by the 'C32 the external pin must transition from 1 to 0. And then, it needs to be held low for at least one H1/H3 cycle (but it could be held low longer). For a level-triggered interrupt to be detected by the 'C3x, the external pin must be held low for between one and two cycles (1 vlow-pulse width v2). If the interrupt is held low for more than two cycles, more than one interrupt might be recognized. There is no need to provide an edge in this case. Program Flow Control 7-37 DMA Interrupts 7.7 DMA Interrupts Interrupts can also trigger DMA read and write operations. This is called DMA synchronization. The DMA interrupt processing cycle is similar to that of the CPU. After the pertinent interrupt flag is cleared, the DMA coprocessor proceeds according to the status of the SYNC bits in the DMA coprocessor global-control register. If the interrupt in the CPU/DMA interrupt-enable (IE) register is enabled, the interrupt controller automatically latches the interrupt and saves it for future DMA use. The interrupt controller latches the interrupt, clears the flag in the IF register, and informs the data that an interrupt has occurred. The DMA then proceeds with the transfer according to the previously configured CPU/DMA priority. Even if the DMA has not been started, the interrupt latch occurs, and the flag is cleared, except when the start bits in the DMA control register have the reset value 002 in START bits. DMA reset clears the interrupt internal latch. 7.7.1 DMA Interrupt Control Bits Two registers contain bits used to control DMA interrupt operation: - CPU/DMA interrupt-enable register (IE). All DMA interrupts are controlled by the most significant 16 bits in the IE register and by the SYNC bits of the DMA channel control registers (see Section 12.3.3, DMA Registers, on page 12-51). The DMA interrupts are not dependent upon ST(GIE) and are local to the DMA. - The DMA channel control register. Each DMA coprocessor channel uses a channel control register to determine its mode of operation. This register is shown in Section 12.3.3. The IE is broken into several subfields that determine which interrupts can be used to control the synchronization for each DMA channel. For example, the bits in each of these fields allow you to select whether a DMA channel is synchronized to a port, a timer, or an external interrupt pin. Note that the 'C32 has two DMA channels while the 'C30 and 'C31/VC33 have a single DMA channel. See Section 3.1.8, CPU/DMA Interrupt-Enable Register (IE), on page 3-9, for a description of the IE. 7-38 DMA Interrupts 7.7.2 DMA Interrupt Processing Figure 7-8 shows the general flow of interrupt processing by the DMA coprocessor. Figure 7-8. DMA Interrupt Processing No Is an enabled interrupt set ? Yes If enabled in the IE register, the interrupt Is a DMA interrupt Clear interrupt flag DMA proceeds according to DMA control register SYNC bits DMA continues For more information about DMA interrupts, see Section 12.3.7, DMA Interrupts on page 12-65. Program Flow Control 7-39 DMA Interrupts 7.7.3 CPU/DMA Interaction If the DMA is not using interrupts for synchronization of transfers, it is not affected by the processing of the CPU interrupts. Detected interrupts are responded to by the CPU and DMA on instruction fetch boundaries only. Since instruction fetches are halted due to pipeline conflicts or when executing instructions in an RPTS loop, interrupts are not responded to until instruction fetching continues. It is therefore possible to interrupt the CPU and DMA simultaneously with the same or different interrupts and, in effect, synchronize their activities. For example, it may be necessary to cause a high-priority DMA transfer that avoids bus conflicts with the CPU (that is, a transfer that makes the DMA higher priority than the CPU). This may be accomplished by using an interrupt that causes the CPU to trap to an interrupt routine that contains an IDLE instruction. Then, if the same interrupt is used to synchronize DMA transfers, the DMA transfer counter can be used to generate an interrupt and thus return control to the CPU following the DMA transfer. Since the DMA and CPU share the same set of interrupt flags, the DMA may clear an interrupt flag before the CPU can respond to it. For example, if the CPU interrupts are disabled, the DMA can respond to interrupts and thus clear the associated interrupt flags. Figure 7-9 shows the sequence of events in the interrupt processing for both the CPU and DMA controllers. Figure 7-9. Parallel CPU and DMA Interrupt Processing Interrupt CPU DMA coprocessor No Does GIE=1 and is the interrupt enabled in the IE register? No Is the interrupt enabled in the IE register? Yes Process the CPU interrupt as shown in Figure 7-6. Yes Process the DMA interrupt as shown in Figure 7-8. 7-40 DMA Interrupts 7.7.4 TMS320C3x Interrupt Considerations Give careful consideration to 'C3x interrupts, especially if you make modifications to the status register when the global interrupt-enable (GIE) bit is set. This can result in the GIE bit being erroneously set or reset as described in the following paragraphs. The GIE bit field of the status register is set to 0 (reset) by an interrupt. If a load of the status register occurs simultaneously with a CPU interrupt pulse trying to reset GIE, GIE will be reset. Also, resetting GIE by an interrupt or TRAP instruction can cause a processing error if any code, following within two cycles of the interrupt recognition, attempts to read or modify the status register. For example, if the status register is being pushed onto the stack, it will be stored incorrectly if an interrupt was acknowledged two cycles before the store instruction. When an interrupt signal is recognized, the 'C3x continues executing the instructions already in the read and decode phases in the pipeline. However, because the interrupt is acknowledged, the GIE bit is reset to 0, and the store instruction already in the pipeline will store the wrong status register value. For example, if the program is like this: ... NOP interrupt recognized -->LDI MPYI PUSH ... POP ... @V_ADDR,AR1 *AR1, R0 ST ST the PUSH ST instruction will save the ST contents in memory, which includes GIE = 0. Since the device is expected to have GIE = 1, the POP ST instruction will put the wrong status register value into the ST (see Table 7-9). Program Flow Control 7-41 DMA Interrupts Table 7-9. Pipeline Operation with PUSH ST Cycle 1 2 3 4 5 6 7 8 Read location V_ADDR Load AR1; recognize interrupt Clear GIE bit; clear interrupt flag; read SP Read interrupt vector table; save ST in stack Store return address on stack Description Fetch NOP LDI MPYI PUSH - NOP LDI MPYI PUSH Interrupt NOP LDI MPYI PUSH Interrupt NOP LDI MPYI PUSH Interrupt Decode Read Execute The following example shows setting the GIE bit by a load instruction that is immediately followed by an interrupt: ... ; GIE = 1 LDI 02000h, ST ; GIE = 0 interrupt recognized -->MPYI *AR1, R0 ; ADD *AR0, R1 In this example, the load of the status register or interrupt-flag register overwrites the reset of the GIE bit by the interrupt (see Table 7-10). Table 7-10. Pipeline Operation with Load Followed by Interrupt Cycle 1 2 3 4 5 6 Interrupt recognized Interrupt resets GIE bit, clears interrupt flag, reads SP GIE set by load instruction; interrupt vector table read and ST saved on stack Store return address on stack Fetch first instruction of ISR with GIE = 1 ISR Description Fetch LDI - LDI interrupt LDI interrupt LDI interrupt Decode Read Execute A similar situation may occur if the GIE bit = 1 and an instruction executes that is intended to modify the other status bits and leave the GIE bit set. In the above example, this erroneous setting would occur if the interrupt were recognized two cycles before the POP ST instruction. In that case, the interrupt would clear the GIE bit, but the execution of the POP instruction would set the GIE bit. Since the interrupt has been recognized, the interrupt service routine will be entered with interrupts enabled, rather than disabled as expected. 7-42 DMA Interrupts One solution is to use an instruction that is uninterruptible such as RPTS as follows to set the GIE: RPTS AND 0 2000h, ST ; Set GIE=1 Use the following to reset the GIE: RPTS AND 0 0DFFFh, ST ; Set GIE=0 Another alternative incorporates the following code fragment, which protects against modifying or saving the status register by disabling interrupts through the interrupt-enable register: PUSH LDI NOP NOP AND POP IE 0, IE ; Save IE register Added instructions to ; Clear IE register avoid pipeline problems 2 NOPs or useful instructions ; ; 0DFFFh, ST ; Set GIE = 0 Instruction that reads or IE ; writes to ST register. ; Added instruction ; to avoid pipeline ; problems. In summary, the next three instructions immediately following an instruction that clears the GIE bit might be interrupted. Also, the next three instructions immediately following an instruction that sets the GIE bit might not be interrupted even if there is a pending interrupt (see Example 7-15). Similarly, the next three instructions immediately following an instruction that clears an interrupt-enable mask might be interrupted. Furthermore, the next three instructions immediately following an instruction that sets an interrupt flag might be executed before the interrupt occurs. Example 7-15. Pending Interrupt LDI LDI LDI MPYI ADDI 0h, ST ; set GIE = 0 1h, R1 2h, R2 *AR1, R0 ; interrupts still enabled *AR1,R1 ; interrupts disabled here Program Flow Control 7-43 DMA Interrupts 7.7.5 TMS320C30 Interrupt Considerations The 'C30 silicon revisions earlier than 4.0 have two unique exceptions to the interrupt operation. This does not apply to 'C30 silicon revision 4.0 or greater, any 'C31/VC33 silicon, or any 'C32 silicon. On 'C30 silicon revisions earlier than 4.0: - The status register global interrupt-enable (GIE) bit may be erroneously reset to 0 (disabled setting) if all of the following conditions are true: J J J A conditional trap instruction (TRAPcond) has been fetched The condition for the trap is false. A pipeline conflict has occurred, resulting in a delay in the decode or read phase of the instruction. During the decode phase of a conditional trap, interrupts are temporarily disabled to ensure that the trap executes before a subsequent interrupt. If a pipeline conflict occurs and causes a delay in execution of the conditional trap, the interrupt disabled condition may become the last known condition of the GIE bit. If the trap condition is false, interrupts are permanently disabled until the GIE bit is intentionally set. The condition is not present when the trap condition is true, because normal operation of the instruction causes the GIE to be reset, and standard coding practice sets the GIE to 1 before the trap routine is exited. Several instruction sequences that cause pipeline conflicts have been found: J J LDI TRAPcond LDI NOP TRAPcond STI TRAPcond STI LDI ||LDI TRAPcond mem,SP n mem,SP n SP,mem n Rx,*ARy *ARx,Ry *ARz,Rw n J J Other similar conditions may also cause a delay in the execution. The following solution is recommended to avoid or rectify the problem: 7-44 DMA Interrupts Insert two NOP instructions immediately before the TRAPcond instruction. One NOP is insufficient in some cases, as illustrated in the second bulleted item, above. This eliminates the opportunity for any pipeline conflicts in the immediately preceding instructions and enables the conditional trap instruction to execute without delays. - Asynchronous accesses to the interrupt flag register (IF) can cause the 'C30 silicon revision prior to 4.0 to fail to recognize and service an interrupt. This may occur when an interrupt is generated and is ready to be latched into the IF register on the same cycle that the IF is being written to by the CPU. Note that logic operations (AND, OR, XOR) may write to the IF register. The logic of 'C30 silicon revision earlier than 4.0 currently gives the CPU write priority; consequently, the asserted interrupt might be lost. This is true if the asserted interrupt was generated internally (for example, a direct memory access (DMA) interrupt). This situation arises as a result of a decision to poll certain interrupts or a desire to clear pending interrupts due to a long pulse width. In the case of a long pulse width, the interrupt may be generated after the CPU responds to the interrupt and attempts to automatically clear it by the interrupt vector process. The recommended solution is to avoid using the interrupt polling technique, and to design the external interrupt inputs to have pulse widths between 1 and 2 instruction cycles. The alternative to strict polling is to periodically enable and disable the interrupts that would be polled, allowing the normal interrupt vectoring to take place; this automatically clears the interrupt flag without affecting other interrupts. If you must clear a pending interrupt, you should use a memory location to indicate that the interrupt is invalid. The interrupt service routine can read that location, clear it (if the pending interrupt is invalid), and return immediately. The following code fragments show how to handle a dummy interrupt due to a long interrupt pulse: Program Flow Control 7-45 DMA Interrupts ISR_n: PUSH PUSH PUSH LDI LDI BNN STI POP POP POP RETI ST DP R0 0, DP @DUMMY_INT, R0 ISR_n_START DP, @DUMMY_INT R0 DP ST ; ; ; ; ; ; ; ; ; ; ; Save registers Clear Data-page Pointer If DUMMY_INT is 0 or positive, go to ISR_n_START Set DUMMY_INT = 0 Housekeeping, return from interrupt ISR_n_START: . . . LDI AND BNZ LDI LDI STI ISR_n_END: POP POP POP RETI INT_Fn, R0 IF, R0 ISR_n_END 0, DP 0FFFFh, R0 R0, @DUMMY_INT R0 DP ST ; ; ; ; ; ; ; ; Normal interrupt service routine Code goes here If ones in IF reg match INT_Fn, exit ISR Otherwise clear DP and set DUMMY_INT negative & exit ; ; Exit ISR ; ; 7-46 Traps 7.8 Traps A trap is the equivalent of a software-triggered interrupt. In the 'C3x, traps and interrupts are treated identically, except in the way in which they are triggered. 7.8.1 Initialization of Traps and Interrupts Traps and interrupts are triggered differently in the 'C3x: - Traps are always triggered by a software mechanism, by the TRAPcond (conditional trap) instructions. - Interrupts are always triggered by hardware events (for example, by exter- nal interrupts, DMA interrupts, or serial-port interrupts). The GIE bit in the ST register and the mask bits in the IE do not apply to traps. 7.8.2 Operation of Traps Figure 7-10 shows the general flow of traps which is similar to interrupts. Figure 7-10. Flow of Traps Trap executed (TRAPcond) (1) 0 GIE (2) Trap or interrupt service routine Return executed (RETIcond) (3) 1 GIE Program Flow Control 7-47 Traps The RETIcond instruction manipulates the status flags as shown in block (3) in Figure 7-10. RETIcond provides a return from a trap or interrupt. The 'C3x supports 32 different traps. When a TRAPcond n instruction is executed, the 'C3x jumps to the address stored in the memory location pointed to by the corresponding trap-vector table pointer. The location of the trap-vector table is shown in Table 7-4 on page 7-27 ('C30/'C31/VC33 microprocessor mode), Table 7-5 ('C31/VC33 microcomputer boot mode) on page 7-28, and Table 7-6 on page 7-30 for the 'C32. 7-48 Power Management Modes 7.9 Power Management Modes The following 'C3x devices have been enhanced by the addition of two powerdown modes: IDLE2 and LOPOWER: - 'C30 silicon version 7.0 or greater 'LC31 'C31 silicon revision 5.0 or greater 'C32 'VC33 7.9.1 IDLE2 Power-Down Mode The H1 instruction clock is held high until one of the four external interrupts is asserted. In IDLE2 mode, the 'C3x devices supporting these modes behave as follows: - No instructions are executed. - The CPU, peripherals, and internal memory retain their previous states. - The external bus output pins are idle: J J J J The address lines remain in their previous states. The data lines are in the high-impedance state. The output control signals are in their inactive state. If a multicycle read or write does not preceed the IDLE2 opcode, that access will be forzen onto the bus until IDLE2 is exited. This can be advantageous for low power applications since the bus is frozen in an active state. That is, the device pins are not floating, and therefore do not require pullup or pulldowns. - When the device is in the functional (nonemulation) mode, the clocks stop with H1 high and H3 low (see Figure 7-11). - The devices remain in IDLE2 until one of the four external interrupts (INT3-INT0) is asserted for at least one H1 cycle. When one of the four interrupts is asserted, the clocks start after a delay of one H1 cycle. When the clocks restart, they may be in the opposite phase (that is, H1 may be high if H3 was high before the clocks were stopped; H3 may be low if H1 was previously low). The H1 and H3 clocks remain 180 degrees out of phase with each other (see Figure 7-12). - During IDLE2 operations, the CPU recognizes one of the four external interrupts if it is asserted for more than one H1 cycle. To avoid generating Program Flow Control 7-49 Power Management Modes multiple false interrupts in level-triggered mode, the interrupt must be asserted for fewer than three H1 cycles. - The interrupt service routine (ISR) must have been set up before placing the device in IDLE2 mode, because the instruction following the IDLE2 instruction is not executed until the RETI (return from interrupt) instruction is executed. - When the device is in emulation mode, the H1 and H3 clocks continue to run normally and the CPU operates as if an IDLE instruction was executed. The clocks continue to run for correct operation of the emulator. Delayed Branch For correct device operation, the three instructions following a delayed branch should not include either IDLE or IDLE2 instructions. Figure 7-11.IDLE2 Timing CLKIN Idle 2 execution H3 H1 ADDR Data 7-50 Power Management Modes Figure 7-12. Interrupt Response Timing After IDLE2 Operation Clocks driven Interrupt vector read Fetch first instruction of service routing CLKIN H3 H1 INT3 to INT0 INT3 to INT0 Flag ADDR Data Vector address 1st address 7.9.2 LOPOWER In the LOPOWER (low-power) mode, the CPU continues to execute instructions, and the DMA can continue to perform transfers, but at a reduced clock rate of CLKIN frequency divided by 16. A 'C31/VC33 with a CLKIN frequency of 32 MHz performs identically to a 2 MHz 'C31/VC33 with an instruction cycle time of 1,000 ns. During the read phase of the . . . LOPOWER instruction (Figure 7-13) MAXSPEED instruction (Figure 7-14) The 'C31/VC33 and 'C32 . . . Slow to 1/16 of full-speed operation. Resume full-speed operation. Program Flow Control 7-51 Power Management Modes Figure 7-13. LOPOWER Timing CLKIN LOPOWER read H3 H1 32 CLKIN Figure 7-14. MAXSPEED Timing CLKIN MAXSPEED read H3 H1 32 CLKIN 7-52 Chapter 8 Pipeline Operation Two characteristics of the'C3x that contribute to its high performance are: - Pipelining - Concurrent I/O and CPU operation The following four functional units control 'C3x operation: - Fetch Decode Read Execute Pipelining is the overlapping or parallel operations of the fetch, decode, read, and execute levels of a basic instruction. The DMA controller decreases pipeline interference and enhances the CPU's computational throughput by performing input/output operations. Topic 8.1 8.2 8.3 8.4 8.5 Page Pipeline Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 Pipeline Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 Resolving Register Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-19 Memory Access for Maximum Performance . . . . . . . . . . . . . . . . . . . . 8-22 Clocking Memory Accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24 Pipeline Operation 8-1 Pipeline Structure 8.1 Pipeline Structure The following list describes the four major units of the `C3x pipeline structure and their functions: Fetch unit (F) Decode unit (D) Fetches the instruction words from memory and updates the program counter (PC). Decodes the instruction word and performs address generation. Also, the decode unit controls modification of the ARn registers in the indirect addressing mode and of the stack pointer when PUSH to/POP from the stack occurs. If required, reads the operands from memory. If required, reads the operands from the register file, performs the necessary operation, and writes results to the register file. If required, results of previous operations are written to memory. Read unit (R) Execute unit (E) All instruction executions perform these four basic functions: fetch, decode, read, and execute. Figure 8-1 illustrates these four levels of the pipeline structure. The levels are indexed according to instruction and execution cycle. In the figure, perfect overlap in the pipeline, where all four units operate in parallel, occurs at cycle (m). Levels about to be executed are at m +1, and those just previously executed are at m-1. The `C3x pipeline controller supports a high-speed processing rate of one execution per cycle. It also manages pipeline conflicts so that they are transparent to you. You do not need to take any special precautions to ensure correct operation. Figure 8-1. TMS320C3x Pipeline Structure CYCLE m-3 m-2 m-1 m m+1 m+2 m+3 Note: Fetch W X Y Z -- -- -- Decode -- W X Y Z -- -- Read -- -- W X Y Z -- Execute -- -- -- W X Y Z Perfect overlap W, X, Y, Z = Instruction representations 8-2 Pipeline Structure For `C30 and `C31/VC33, priorities from highest to lowest have been assigned to each of the functional units of the pipeline and to the DMA controller as follows: - Execute (highest) Read Decode Fetch DMA (lowest) Despite the DMA controller's low priority, you can minimize or even eliminate conflicts with the CPU through suitable data structuring because the DMA controller has its own data and address buses. In the `C32, the DMA has configurable priorities. Therefore, priorities from highest to lowest have been assigned to each of the functioned units of the pipeline and to the DMA controller as follows: - DMA (if configured with highest priority) Execute Read Decode Fetch DMA (if configured with lowest priority) A pipeline conflict occurs when an instruction is being processed, and is ready to pass to the next higher pipeline level while that level is not ready to accept a new input. In this case, the lower priority unit waits until the higher priority unit completes executing the current function. Pipeline Operation 8-3 Pipeline Conflicts 8.2 Pipeline Conflicts Pipeline conflicts in the 'C3x can be grouped into the following categories: Branch conflicts Register conflicts Branch conflicts involve most of those instructions or operations that read and/or modify the PC. Register conflicts involve delays that can occur when reading from, or writing to, registers that are used for address generation. Memory conflicts occur when the internal units of the 'C3x compete for memory resources. Memory conflicts Each of these three types, including examples, is discussed in the following subsections. In these examples, when data is refetched or an operation is repeated, the symbol representing the stage of the pipeline is appended with a number. For example, if a fetch is performed again, the instruction mnemonic is repeated. When an access is detained for multiple cycles because the unit is not ready, the symbol RDY indicates that a unit is not ready and RDY indicates that a unit is ready. If the particular unit does not perform a function, the nop label is placed in that stage of the pipeline. 8.2.1 Branch Conflicts The first class of pipeline conflicts occurs with standard (nondelayed) branches, that is, BR, Bcond, DBcond, CALL, IDLE, RPTB, RPTS, RETIcond, RETScond, interrupts, and reset. Conflicts arise with these instructions and operations because, during their execution, the pipeline is used only for the completion of the operation; other information fetched into the pipeline is discarded or refetched, or the pipeline is inactive. This is referred to as flushing the pipeline. Flushing the pipeline is necessary in these cases to ensure that portions of succeeding instructions do not inadvertently get partially executed. TRAP cond and CALLcond are classified differently from the other types of branches and are considered later. Example 8-1 shows the code and pipeline operation for a standard branch. Note: Dummy Fetch In this example, one dummy fetch (an MPYF instruction) is performed before the branch is decoded. After the branch address is available, a new fetch (an OR instruction) is performed. 8-4 Pipeline Conflicts Example 8-1. Standard Branch BR MPYF ADD SUBF AND . . . THREE OR STI . . . THREE ; ; ; ; ; Unconditional branch Not executed Not executed Not executed Not executed ; Fetched after BR is taken Pipeline Operation PC n n+1 n+1 n+1 3 Fetch BR MPYF (nop) (nop) OR STI Decode -- BR (nop) (nop) (nop) OR Read -- -- BR (nop) (nop) (nop) Execute -- -- -- 3 BR (nop) (nop) PC Fetch held for new PC value Note: Both RPTS and RPTB flush the pipeline, allowing the RS, RE, and RC registers to be loaded at the proper time. If these registers are loaded without the use of RPTS or RPTB, no flushing of the pipeline occurs. Thus, RS, RE, and RC can be used as general-purpose 32-bit registers without pipeline conflicts. When RPTB is nested because of nested interrupts, it may be necessary to load and store these registers directly while using the repeat modes. Since up to four instructions can be fetched before entering the repeat mode, you should follow loads by a branch to flush the pipeline. If the RC is changing when an instruction is loading it, the direct load takes priority over the modification made by the repeat mode logic. Delayed branches are implemented to ensure the fetching of the next three instructions. The delayed branches include BRD, BcondD, and DBcondD. Example 8-2 shows the code and pipeline operation for a delayed branch. Pipeline Operation 8-5 Pipeline Conflicts Example 8-2. Delayed Branch BRD MPYF ADD SUBF AND . . . THREE MPYF . . . THREE ; ; ; ; ; Unconditional delayed branch Executed Executed Executed Not executed ; Fetched after SUBF is fetched Pipeline Operation PC n n+1 n+2 n+3 3 Fetch BRD MPYF ADDF SUBF MPYF Decode -- BRD MPYF ADDF SUBF Read -- -- BRD MPYF ADDF Execute -- -- -- BRD MPYF No execute delay 3 PC 8.2.2 Register Conflicts Register conflicts involve reading or writing registers used for addressing. These conflicts occur when the pertinent register is not ready to be used. Some conditions under which you can avoid register conflicts are discussed in Section 8.3 on page 8-19. The registers comprise the following three functional groups: Group 1 Group 2 Group 3 This group includes auxiliary registers (AR0-AR7), index registers (IR0, IR1), and block-size register (BK). This group includes the data-page pointer (DP). This group includes the system-stack pointer (SP). If an instruction writes to one of these three groups, the decode unit cannot use any register within that particular group until the write is complete, that is, until the instruction execution is completed. In Example 8-3, an auxiliary register 8-6 Pipeline Conflicts is loaded, and a different auxiliary register is used on the next instruction. Since the decode stage needs the result of the write to the auxiliary register, the decode of this second instruction is delayed two cycles. Every time the decode is delayed, a refetch of the program word is performed; the ADDF is fetched three times. Since these are actual refetches, they can cause not only conflicts with the DMA controller but also cache hits and misses. A post-/preincrement/decrement of an AR register in an instruction is not considered a write to a register. A write is in the form of an LDF, LDI, LDII, or DB instruction. Example 8-3. Write to an AR Followed by an AR for Address Generation LDI 7,AR2 MPYF *AR2,R0 ADDF FLOAT ; 7 AR2 ; Decode delayed 2 cycles NEXT Pipeline Operation PC n n+1 n+2 n+2 n+2 n+3 Fetch LDI MPYF ADDF ADDF ADDF FLOAT Decode -- LDI MPYF MPYF MPYF ADDF Read -- -- LDI (nop) (nop) MPYF Execute -- -- -- LDI 7,AR2 (nop) (nop) Decode/address generation held until AR write is completed ARs written The case for reads of these groups is similar to the cases for writes. If an instruction must read a member of one of these groups, the use of that particular group by the decode for the following instruction is delayed until the read is complete. The registers are read at the start of the execute cycle and require only a one-cycle delay of the following decode. For four registers (IR0, IR1, BK, or DP), there is no delay. For all other registers, including the SP, the delay occurs. Note that an address generation through the use of an AR register (*ARn, *++ARn, *-ARn, etc.) in an instruction is not considered a read. Pipeline Operation 8-7 Pipeline Conflicts In Example 8-4, two auxiliary registers are added together, with the result going to an extended-precision register. The next instruction uses a different auxiliary register as an address register. Example 8-4. A Read of ARs Followed by ARs for Address Generation NEXT ADDI AR0,AR1,R1 MPYF *++AR2,R0 ADDF FLOAT ; AR0+AR1 R1 ; Decode delayed one cycle Pipeline Operation PC n n+1 n+2 n+2 n+3 Fetch ADDI MPYF ADDF ADDF FLOAT Decode -- ADDI MPYF MYPF ADDF Read -- -- ADDI (nop) MPYF Execute -- -- -- ARs read ADDI AR0,AR1,R0 (nop) Decode/address generation held until AR is read Note: Loop counter auxiliary registers for the decrement and branch (DBR) instructions are regarded in the same way as they are for addressing. The operation shown in Example 8-3 and Example 8-4 also can occur for this instruction. 8.2.3 Memory Conflicts Memory conflicts can occur when the memory bandwidth of a physical memory space is exceeded. For example, RAM blocks 0 and 1 and the ROM block can support only two accesses per cycle. The external interface can support only one access per cycle. Section 8.4, Memory Access for Maximum Performance, on page 8-22 contains some conditions under which you can avoid memory conflicts. 8-8 Pipeline Conflicts Memory pipeline conflicts consist of the following four types: Program wait A program fetch is prevented from beginning. Program fetch Incomplete A program fetch has begun but is not yet complete. Execute only Hold everything An instruction sequence requires three CPU data accesses in a single cycle. A primary or expansion bus operation must complete before another one can proceed. These four types of memory conflicts are illustrated in examples and discussed in the paragraphs that follow. 8.2.3.1 Program Wait Two conditions can prevent the program fetch from beginning: - The start of a CPU data access when: J J Two CPU data accesses are made to an internal RAM or ROM block, and a program fetch from the same block is necessary. One of the external ports is starting a CPU data access, and a program fetch from the same port is necessary. - A multicycle CPU data access or DMA data access over the external bus is needed. Example 8-5 illustrates a program wait until a CPU data access completes. In this case, *AR0 and *AR1 are both pointing to data in RAM block 0, and the MPYF instruction will be fetched from RAM block 0. This results in the conflict shown in Example 8-5. Because more than two accesses can be made to RAM block 0 in a single cycle, the program fetch cannot begin and must wait until the CPU data accesses are complete. Pipeline Operation 8-9 Pipeline Conflicts Example 8-5. Program Wait Until CPU Data Access Completes ADDF3 *AR0,*AR1,R0 FIX MPYF ADDF3 NEGB Pipeline Operation PC n n+1 n+2 n+2 n+3 n+4 Fetch ADDF3 FIX (wait) MPYF ADDF3 NEGB Decode -- ADDF3 FIX (nop) MPYF ADDF3 Read -- -- ADDF3 FIX (nop) MPYF Execute -- -- -- ADDF3 FIX (nop) Data accessed Fetch held until data access completes Example 8-6 shows a program wait due to a multicycle data-data access or a multicycle DMA access. The ADDF, MPYF, and SUBF are fetched from some portion in memory other than the external port the DMA requires. The DMA begins a multicycle access. The program fetch corresponding to the CALL is made to the same external port that the DMA is using. Either of two cases may produce this situation: - One of the following two memory boundaries is crossed: J J From internal memory to external memory From one external port to another - Code that has been cached is executed, and the instruction prior to the ADDF is one of the following (conditional or unconditional): J J A delayed branch instruction A delayed decrement and branch instruction Even though the DMA has the lowest priority on 'C30 and 'C31/VC33 or when configured as such in the 'C32, multicycle access cannot be aborted. The program fetch must wait until the DMA access completes. 8-10 Pipeline Conflicts Example 8-6. Program Wait Due to Multicycle Access ADDF MPY SUBF CALL ; ; ; ; code code code code in in in in internal internal internal external memory memory memory memory Pipeline Operation PC n n+1 n+2 n+3 n+3 n+4 Fetch ADDF MPYF SUBF (wait) CALL -- Decode -- ADDF MPYF SUBF (nop) CALL Read -- -- ADDF MPYF SUBF (nop) Execute -- -- -- ADDF MPYF SUBF 2-cycle DMA access 8.2.3.2 Program Fetch Incomplete A program fetch incomplete occurs when an instruction fetch takes more than one cycle to complete because of wait states. In Example 8-7, the MPYF and ADDF are fetched from memory that supports single-cycle accesses. The SUBF is fetched from memory requiring one wait state. One example that demonstrates this conflict is a fetch across a bank boundary on the primary port. See Section 9.5 on page 9-12. Pipeline Operation 8-11 Pipeline Conflicts Example 8-7. Multicycle Program Memory Fetches Pipeline Operation PC n n+1 n+2 RDY n+2 RDY n+3 Note: Fetch MPYF ADDF SUBF SUBF ADDI PC = program counter Decode -- MPYF ADDF (nop) SUBF Read -- -- MPYF ADDF (nop) Execute -- -- -- MPYF ADDF 1 wait state required 8.2.3.3 Execute Only The execute-only type of memory pipeline conflict occurs when performing an interlocked load or when a sequence of instructions requires three CPU data accesses in a single cycle. There are two cases in which this occurs: - An instruction performs a store and is followed by an instruction that performs two memory reads. - An instruction performs two stores and is followed by an instruction that performs at least one memory read. - An interlocked load (LDII or LDFI) instruction is performed, and XF1 = 1. The first case is shown in Example 8-8. Since this sequence requires three data memory accesses and only two are available, only the execute phase of the pipeline is allowed to proceed. The dual reads required by the LDF || LDF are delayed one cycle. In this case, a refetch of the next instruction can occur. 8-12 Pipeline Conflicts Example 8-8. Single Store Followed by Two Reads STFR LDF LDF 0,*AR1 *AR2,R1 *AR3,R2 ; R0 *AR1 ; *AR2 R1 in parallel with ; *AR3 R2 Pipeline Operation PC n n+1 n+2 n+3 n+4 Fetch STF LDF LDF W X X Decode -- STF LDF LDF W W Read -- -- STF LDF LDF LDF LDF Execute -- -- -- STF (nop) Write must complete before the two reads can complete 2 reads performed n+4 Note: Y X W LDF LDF W, X, Y = Instruction representations Pipeline Operation 8-13 Pipeline Conflicts Example 8-9 shows a parallel store followed by a single load or read. Since two parallel stores are required, the next CPU data-memory read must wait one cycle before beginning. One program-memory refetch can occur. Example 8-9. Parallel Store Followed by Single Read STF STF ADDF IACK ASH R0,*AR0 R2,*AR1 @SUM,R1 ; ; ; R0 *AR0 in parallel with R2 *AR1 R1 + @SUM R1 Pipeline Operation PC n n+1 n+2 n+3 n+4 n+4 Fetch STF STF ADDF IACK ASH ASH -- Decode -- STF STF ADDF IACK IACK ASH Read -- -- STF STF ADDF ADDF IACK Execute -- -- -- STF STF (nop) ADDF Writes performed Read must wait until the writes are completed The final case involves an interlocked load (LDII or LDFI) instruction and XF1 = 1. Since the interlocked loads use the XF1 pin as an acknowledge that the read can complete, the loads might need to extend the read cycle, as shown in Example 8-10. A program refetch can occur. 8-14 Pipeline Conflicts Example 8-10. Interlocked Load NOT LDII 2 ADDI CMPI R1,R0 300h,AR *AR2,R2 R0,R2 Pipeline Operation PC n n+1 n+2 n+3 n+3 n+4 XF1 1 1 1 1 1 0 Fetch NOT LDII ADDI CMPI -- -- Decode -- NOT LDII ADDI CMPI CMPI Read -- -- NOT LDII ADDI ADDI Execute -- -- -- NOT LDII LDII XF1 = 0, read operation is complete XF1 = 1, read must wait 8.2.3.4 Hold Everything Three situations result in hold-everything memory pipeline conflicts: - A CPU data load or store cannot be performed because an external port is busy. - An external load takes more than one cycle. - Conditional calls and traps, which take one more cycle than conditional branches, are processed. The first type of hold-everything conflict occurs when one of the external ports is busy because an access has started, but is not complete. In Example 8-11, the first store is a 2-cycle store. The CPU writes the data to an external port. The port control then takes two cycles to complete the data-data write. The LDF is a read over the same external port. Since the store is not complete, the CPU continues to attempt LDF until the port is available. Pipeline Operation 8-15 Pipeline Conflicts Example 8-11. Busy External Port STF LDF R0,@DMA1 @DMA2,R0 Pipeline Operation PC n n+1 n+2 n+2 n+2 n+3 n+4 Note: Fetch Decode Read Execute STF LDF W W W X Y -- STF LDF LDF LDF W X -- -- STF (nop) (nop) LDF W -- -- -- STF 2-cycle external bus write access (nop) (nop) LDF W, X, Y = Instruction representations The second type of hold-everything conflict involves multicycle data reads. The read has begun and continues until completed. In Example 8-12, the LDF is performed from an external memory that requires several cycles to access. 8-16 Pipeline Conflicts Example 8-12. Multicycle Data Reads LDF @DMA,R0 Pipeline Operation PC n n+1 n+2 n+3 n+3 Note: Fetch Decode Read Execute LDF I J K(dummy) K2 -- LDF I I J -- -- LDF LDF I -- -- -- -- LDF 2-cycle external bus read access I, J, K = Instruction representations The final type of hold-everything conflict deals with conditional calls (CALLcond) and traps (TRAPcond), which are different from other branch instructions. Whereas other branch instructions are conditional loads, the conditional calls and traps are conditional stores, which take one more cycle to complete than conditional branches (see Example 8-13). The added cycle pushes the return address after the call condition is evaluated. Pipeline Operation 8-17 Pipeline Conflicts Example 8-13. Conditional Calls and Traps Pipeline Operation PC n n+1 n+1 n+1 n+1 n+2/CALLaddr Note: Fetch CALLcond I (nop) (nop) (nop) I Decode -- CALLcond (nop) (nop) (nop) (nop) Read -- -- CALLcond (nop) (nop) (nop) Execute -- -- -- CALLcond CALLcond (nop) PC store cycle I = Instruction representation 8-18 Resolving Register Conflicts 8.3 Resolving Register Conflicts If the auxiliary registers (AR7-AR0), the index registers (IR1-IR0), data-page pointer (DP), or stack pointer (SP) are accessed for any reason other than address generation, pipeline conflicts associated with the next memory access can occur. The pipeline conflicts and delays are presented in Section 8.2 on page 8-4. Example 8-14, Example 8-15, and Example 8-16 demonstrate some common uses of these registers that do not produce a conflict or ways that you can avoid the conflict. Example 8-14. Address Generation Update of an AR Followed by an AR for Address Generation LDF MPYF ADDF FIX MPYF ADDF 7.0,R0 ; 7.0 R0 *++AR0(IR1),R0 *AR2,R0 Pipeline Operation PC n n+1 n+2 n+3 n+4 n+5 Note: Fetch LDF MYPF ADDF FIX MPYF ADDF Decode -- LDF MYPF ADDF FIX MYPF Read -- -- LDF MYPF ADDF FIX Execute -- -- -- LDF MYPF ADDF ARs read W, X, Y, Z = Instruction representations Pipeline Operation 8-19 Resolving Register Conflicts Example 8-15. Write to an AR Followed by an AR for Address Generation Without a Pipeline Conflict LDI MPYF ADDF MPYF SUBF STF @TABLE,AR2 @VALUE,R1 R2,R1 *AR2++,R1 Pipeline Operation PC n n+1 n+2 n+3 n+4 n+5 Fetch LDI MYPF ADDF MYPF SUBF STF Decode -- LDI MYPF ADDF MYPF SUBF Read -- -- LDI MYPF ADDF MYPF AR2 read Execute -- -- -- AR2 written LDI MYPF ADDF 8-20 Resolving Register Conflicts Example 8-16. Write to DP Followed by a Direct Memory Read Without a Pipeline Conflict LDP POP LDF LDI PUSHF PUSH TABLE_ADDR R0 *-AR3(2),R1 @TABLE_ADDR,AR0 R6 R4 Pipeline Operation PC n n+1 n+2 n+3 n+4 n+5 Fetch LDP POP LDF LDI PUSHF PUSH Decode -- LDP POP LDF LDI PUSHF Read -- -- LDP POP LDF LDI Execute -- -- -- LDP POP LDF DP read DP written Pipeline Operation 8-21 Memory Access for Maximum Performance 8.4 Memory Access for Maximum Performance If program fetches and data accesses are performed so that the resources being used cannot provide the necessary bandwidth, the pipeline is stalled until the data accesses are complete. Certain configurations of program fetch and data accesses yield conditions under which the 'C3x can achieve maximum throughput. Table 8-1 shows how many accesses can be performed from the different memory spaces when it is necessary to do a program fetch and a single data access and still achieve maximum performance (one cycle). Four cases achieve 1-cycle maximization. Table 8-1. One Program Fetch and One Data Access for Maximum Performance Primary Bus Accesses 1 1 -- -- Expansion Bus or Peripheral Accesses -- 1 -- 1 Case No. 1 2 3 4 Accesses From Dual Access Internal Memory 1 -- 2 from any combination of internal memory 1 The expansion bus is available only on the 'C30. Table 8-2 shows how many accesses can be performed from the different memory spaces when it is necessary to do a program fetch and two data accesses and still achieve maximum performance (one cycle). Six conditions achieve this maximization. 8-22 Memory Access for Maximum Performance Table 8-2. One Program Fetch and Two Data Accesses for Maximum Performance Primary Bus Accesses 1 1 program 1 data 1 data -- -- -- 1 program 1 DMA Accesses From Dual-Access Internal Memory 2 from any combination of internal memory 1 data 1 data 1 program, 1 data 2 from same internal memory block and 1 from a different internal memory block 3 from different internal memory blocks 2 from any combination of internal memory 2 data 2 data Expansion Or Peripheral Bus Accesses -- 1 data 1 program 1 DMA -- -- 1 1 DMA 1 program Case No. 1 2 3 4 5 6 7 8 9 The expansion bus is available only on the 'C30. Pipeline Operation 8-23 Clocking Memory Accesses 8.5 Clocking Memory Accesses This section discusses the role of internal clock phases (H1 and H3) and how the 'C3x handles multiple-memory accesses. The previous section discusses the interaction between sequences of instructions; this section discusses the flow of data on an individual instruction basis. Each major clock period of 33.3 ns is composed of two minor clock periods of 16.67 ns, labeled H3 and H1. The active clock period for H3 and H1 is the time when that signal is high. See Figure 8-2. Figure 8-2. Minor Clock Periods Major clock period H1 H1 minor clock period H3 H3 minor clock period The precise operation of memory reads and writes can be defined according to these minor clock periods. The types of memory operations that can occur are program fetches, data loads and stores, and DMA accesses. 8.5.1 Program Fetches Internal program fetches are always performed during H3 unless a single data store must occur at the same time due to another instruction in the pipeline. In that case, the program fetch occurs during H1 and the data store occurs during H3. External program fetches always start at the beginning of H3 with the address being presented on the external bus. At the end of H1, the fetches are completed with the latching of the instruction word. 8.5.2 Data Loads and Stores Four types of instructions perform loads, memory reads, and stores: - 2-operand instructions 3-operand instructions Multiplier/ALU operation with store instructions Parallel multiply and add instructions 8-24 Clocking Memory Accesses See Chapter 6, Addressing Modes, for more information. As discussed in Chapter 7, the number of bus cycles for external memory accesses differs in some cases from the number of CPU execution cycles. For external reads, the number of bus cycles and CPU execution cycles is identical. For external writes, there are always at least two bus cycles, but unless there is a port-access conflict, there is only one CPU execution cycle. In the following examples, any difference in the number of bus cycles and CPU cycles is noted. 8.5.2.1 2-Operand Instruction Memory Accesses All instructions whose bits 31-29 are 000 or 010 (see Figure 8-3) are 2-operand instructions. In the case of a data read, bits 15-0 represent the src operand. Internal data reads are always performed during H1. External data reads always start at the beginning of H3 with the address presented on the external bus; they complete with the latching of the data word at the end of H1. In the case of a data store, bits 15-0 represent the dst operand. Internal data stores are performed during H3. External data stores always start at the beginning of H3 with the address and data being presented on the external bus. Figure 8-3. 2-Operand Instruction Word 31 0 X 0 24 23 Operation G dst(src) 16 15 8 7 src(dst) 0 8.5.2.2 3-Operand Instruction Memory Reads All instructions whose bits 31-29 are 001 (see Figure 8-4) are 3-operand instructions. The source operands, src1 and src2, come from either registers or memory. When one or more of the source operands are from memory, these instructions are always memory reads. Figure 8-4. 3-Operand Instruction Word 31 0 0 1 24 23 Operation T dst 16 15 src1 8 7 src2 0 If only one of the source operands is from memory (either src1 or src2) and is located in internal memory, the data is read during H1. If the single memory source operand is in external memory, the read starts at the beginning of H3, with the address presented on the external bus, and completes with the latching of the data word at the end of H1. Pipeline Operation 8-25 Clocking Memory Accesses If both source operands are to be fetched from memory, then memory reads can occur in several ways: - If both operands are located in internal memory, the src1 read is performed during H3 and the src2 read during H1, completing two memory reads in a single cycle. - If src1 is in internal memory and src2 is in external memory, the src2 access begins at the start of H3 and latches at the end of H1. At the same time, the src1 access to internal memory is performed during H3. Again, two memory reads are completed in a single cycle. - If src1 is in external memory and src2 is in internal memory, two cycles are necessary to complete the two reads. In the first cycle, both operands are addressed. Since src1 takes an entire cycle to be read and latched from external memory, the internal operation on src2 cannot be completed until the second cycle. Ordering the operands so that src1 is located internally is necessary to achieve single-cycle execution. - If src1 and src2 are both from external memory, two cycles are required to complete the two reads. In the first cycle, the src1 access is performed and loaded on the next H3; in the second cycle, the src2 access is performed and loaded on that cycle's H1. If src2 is in external memory and src1 is in on-chip or external memory and is immediately preceded by a single store instruction to external memory, a dummy src2 read can occur between the execution of the store instruction and the src2 read, regardless of which memory space is accessed (STRB, MSTRB, or IOSTRB). The dummy read can cause an externally interfaced FIFO address pointer to be incremented prematurely, thereby causing the loss of FIFO data. Example 8-17 illustrates how the dummy read can occur. Example 8-18 offers an alternative code segment that suppresses the dummy read. In the alternative code segment, the dummy read is eliminated by swapping the order of the source operands. 8-26 Clocking Memory Accesses Example 8-17. Dummy sr2 Read STI ADDI3 R0,*AR6 *AR1,*AR3,R0 ; AR6 points to MSTRB space ; AR3 points to on-chip RAM (src1) ; AR1 points to MSTRB space (src2) H1 H3 Pipeline Operation PC n n+1 n+2 n+3 n+4 n+5 n+6 n+7 n+8 Fetch STI ADDI3 STI ADDI3 STI -- -- ADDI3 -- ADDI3 STI -- -- -- -- ADDI3 actual read of src2 and src1 2-cycle dummy load of src2 R0, *AR6 until the store is complete Decode Read Execute Two cycles are required for the MSTRB store. Two additional cycles are required for the dummy MSTRB read of *AR3 (because a read follows a write). One cycle is required for an actual MSTRB read of *AR3. Pipeline Operation 8-27 Clocking Memory Accesses Example 8-18. Operand Swapping Alternative Switch the operands of the 3-operand instruction so that the internal read is performed first. STI ADDI3 R0,*AR6 *AR3,*AR1,R0 ; AR6 points to MSTRB space ; AR3 points to on-chip RAM (src2) ; AR1 points to MSTRB space (src1) H1 H3 Pipeline Operation PC n n+1 n+2 n+3 n+4 n+5 n+6 n+7 n+8 Fetch STI ADDI3 STI ADDI3 STI -- -- ADDI3 -- -- STI 2-cycle store -- -- 2-cycle read of src1 and src2 -- ADDI3 ADDI3 The read of src2 cannot start until the store is complete Decode Read Execute 8-28 Clocking Memory Accesses 8.5.2.3 Operations with Parallel Stores The next class of instructions includes every instruction that has a store in parallel with another instruction. Bits 31 and 30 for these instructions are equal to 1 1. The instruction word format for operations that perform a multiply or ALU operation in parallel with a store is shown in Figure 8-5. If the store operation to dst2 is external or internal, it is performed during H3. Two bus cycles are required for external stores, but only one CPU cycle is necessary to complete the write. If the memory read operation is external, it starts at the beginning of H3 and latches at the end of H1. If the memory read operation is internal, it is performed during H1. Note that memory reads are performed by the CPU during the read (R) phase of the pipeline, and stores are performed during the execute (E) phase. Figure 8-5. Multiply or CPU Operation With a Parallel Store 31 1 1 Operation 24 23 P d1 d2 src1 16 15 src2 src3 8 7 src4 0 The instruction word format for instructions that have parallel stores to memory is shown in Figure 8-6. If both destination operands, dst1 and dst2, are located in internal memory, dst1 is stored during H3 and dst2 during H1, thus completing two memory stores in a single cycle. Figure 8-6. Two Parallel Stores 31 1 1 ST||ST 24 23 src2 0 0 0 16 15 src1 dst1 8 7 dst2 0 - If dst1 is in external memory and dst2 is in internal memory, the dst1 store begins at the start of H3. The dst2 store to internal memory is performed during H1. Two bus cycles are required for the external store, but only one CPU cycle is necessary to complete the write. Again, two memory stores are completed in a single cycle. - If dst1 is in internal memory and dst2 is in external memory, an additional bus cycle is necessary to complete the dst2 store. Only one CPU cycle is necessary to complete the write, but the port access requires three bus cycles. In the first cycle, the internal dst1 store is performed during H3, and dst2 is written to the port during H1. During the next cycle, the dst2 store is performed on the external bus, beginning in H3, and executes as normal through the following cycle. Pipeline Operation 8-29 Clocking Memory Accesses - If dst1 and dst2 are both written to external memory, a single CPU cycle is still all that is necessary to complete the stores. In this case, four bus cycles are required. 1) In the first cycle, both dst1 and dst2 are written to the port, and the external-bus access for dst1 begins. a) The store for dst1 is completed on the second cycle. b) The store for dst2 begins on the third external-bus cycle. c) The store for dst2 is completed on the fourth external-bus cycle. 8.5.2.4 Parallel Multiplies and Adds Memory addressing for parallel multiplies and adds is similar to that for 3-operand instructions. The parallel multiplies and adds include all instructions with bits 31-30 = 10 (see Figure 8-7). Figure 8-7. Parallel Multiplies and Adds 31 1 0 Operation 24 23 P d1 d2 src1 16 15 src2 src3 8 7 src4 0 For these operations, src3 and src4 are both located in memory. If both operands are located in internal memory, src3 is performed during H3, and src4 is performed during H1, thus completing two memory reads in a single cycle. - If src3 is in internal memory and src4 is in external memory, the src4 access begins at the start of H3 and latches at the end of H1. At the same time, the src3 access to internal memory is performed during H3. Again, two memory reads are completed in a single cycle. - If src3 is in external memory and src4 is in internal memory, two cycles are necessary to complete the two reads. In the first cycle, the internal src4 access is performed. During the H3 of the next cycle, the src3 access is performed. - If src3 and src4 are both from external memory, two cycles are necessary to complete the two reads. In the first cycle, the src3 access is performed; in the second cycle, the src4 access is performed. 8-30 Chapter 9 TMS320C30 and TMS320C31/VC33 External Memory Interface This chapter describes the 'C30 and 'C31/VC33 external-memory interface. See Chapter 10, Enhanced External-Memory Interface, for detailed information on the 'C32 external bus operation. Memories and external peripheral devices are accessible through two external interfaces on the 'C30: - Primary bus - Expansion bus On the 'C31/VC33, one bus, the primary bus, is available to access external memories and peripheral devices. You can control wait-state generation, permitting access to slower memories and peripherals, by manipulating memorymapped control registers associated with the interfaces and by using an external input signal. Note: VC33 The TMS320VC33 is logically and functionally a superset of the TMS320C31 making nearly all literature and documentation for the TMS320C31 applica- ble. However, the electrical characteristics are different and are covered in detail in the TMS320VC33 data sheet (literature number SPRS087). Topic 9.1 9.2 9.3 9.4 9.5 9.6 Page Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2 Memory Interface Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 Memory Interface Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7 Programmable Wait States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10 Programmable Bank Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12 External Memory Interface Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15 9-1 Overview 9.1 Overview The 'C30 provides two external interfaces: the primary bus and the expansion bus. The TMS320C31/VC33 provides one external interface: the primary bus. The primary bus consists of a 32-bit data bus, a 24-bit address bus, and a set of control signals. The expansion bus consists of a 32-bit data bus, a 13-bit address bus, and a set of control signals. Each interface has the following features: - Separate configurations controlled by memory-mapped external interface control registers - Hold request and acknowledge signal for putting the external memory inter- face signals in high impedance mode and preventing the processor from accessing the external bus - Selectable wait state that can be controlled through software, hardware, or combination of software and hardware - Unified memory space for data, program, and I/O access 9-2 Memory Interface Signals 9.2 Memory Interface Signals This section describes the differences between the 'C30 and 'C31/VC33 memory interface signals. 9.2.1 TMS320C30 Memory Interface Signals The TMS320C30 has two sets of control signals as follows: - Primary bus control signals: STRB, R/W, HOLD, HOLDA, RDY Table 9-1 lists and describes the signals. - Expansion bus control signals: MSTRB, IOSTRB, XR/W, XRDY Table 9-2 lists and describes the expansion bus control signals. Access is determined by an active strobe signal (STRB, MSTRB, or IOSTRB). When a primary bus access is performed, STRB is low. The expansion bus of the 'C30 supports two types of accesses: - Memory access signaled by MSTRB low. The timing for an MSTRB access is the same as that of the STRB access on the primary bus. - External peripheral device access is signaled by IOSTRB low. Each of the buses (primary and expansion) has an associated control register. These registers are memory-mapped as shown in Figure 9-1. 9.2.2 TMS320C31/VC33 Memory Interface Signals The TMS320C31/VC33 has one set of control signals: - Primary bus control signals: STRB, R/W, HOLD, HOLDA, RDY STRB is low when an external bus access is performed. The primary bus control register controls its behavior (see Section 9.3). TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-3 Memory Interface Signals Table 9-1. Primary Bus Interface Signals Signal STRB R/W Type O/Z O/Z Description Primary interface access strobe Specifies memory read (active high) or write (active low) mode Hold external memory interface Hold acknowledge for external memory interface Indicates external primary interface is ready to be accessed Primary address bus. When the primary bus address lines are not in high-impedance state due to HOLD signal, they keep in the last external primary bus access. Primary data bus. These signals go to highimpedance between write accesses. Value After Reset 1 1 NA 1 NA Idle Status 1 1 HOLD HOLDA RDY I O/Z I Ignored 1 Ignored A (23-0) O/Z HI Address of last external bus access D (31-0) I/O/Z HIZ HIZ I Input O Output Z High impedance NA means not affected. 9-4 Memory Interface Signals Table 9-2. Expansion Bus Interface Signals Signal MSTRB IOSTRB XR/W Type O/Z O/Z O/Z Description Expansion bus memory access strobe Expansion bus peripheral-access strobe Specifies memory (active high) or write (active low) mode Indicates external expansion interface is ready to be accessed Expansion address bus. When the expansion bus address lines are not in high-impedance state due to HOLD signal, they keep the last external expansion bus access. Expansion data bus. These signals go to highimpedance between write accesses. Value After Reset 1 1 1 NA Idle Status 1 1 1 XRDY I Ignored XA (12-0) O HI Address of last external expansion bus access XD (31-0) I/O/Z HIZ HIZ I Input O Output Z High impedance NA means not affected. TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-5 Memory Interface Signals Figure 9-1. Memory-Mapped External Interface Control Registers Peripheral Address 808060h 808061h 808062h 808063h 808064h 808065h 808066h 808067h 808068h 808069h 80806Ah 80806Bh 80806Ch 80806Dh 80806Fh Expansion-bus control ('C30 only) Reserved Reserved Reserved Primary-bus control ('C30, 'C31/VC33) Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved 9-6 Memory Interface Control Registers 9.3 Memory Interface Control Registers Two memory interface control registers, the primary-bus control register and the expansion-bus control register, are described in this section. 9.3.1 Primary-Bus Control Register The primary bus control register is a 32-bit register that contains the control bits for the primary bus (see Figure 9-2). Table 9-3 describes the register bits with the bit names and functions. Figure 9-2. Primary-Bus Control Register 31-16 xx 15-13 xx 12 11 10 BNKCMP R/W Notes: 1) xx = reserved bit, read as 0 2) R = read, W = write 9 8 7 6 WTCNT R/W 5 4 3 2 HIZ R/W 1 NOHOLD R/W 0 HOLDST R SWW R/W Note: After changing the bit fields of the primary-bus control register, up to three instructions are fetched before the primary bus is reconfigured because the configuration change is performed in the execute stage of the pipeline. TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-7 Memory Interface Control Registers Table 9-3. Primary-Bus Control Register Bits Abbreviation HOLDST Reset Value 0 Name Hold status bit Description This bit signals whether the port is being held (HOLDST = 1) or is not being held (HOLDST = 0). This status bit is valid whether the port has been held through hardware or software. NOHOLD allows or disallows the port to be held by an external HOLD signal. When NOHOLD = 1, the 'C3x takes over the external bus and controls it, regardless of serviced or pending requests by external devices. No hold acknowledge (HOLDA) is asserted when a HOLD signal is received. It is asserted if an internal hold is generated (HIZ = 1). When set (HIZ = 1), the port is put in hold mode. This is equivalent to the external HOLD signal. By forcing a high-impedance condition, the 'C3x can relinquish the external-memory port through software. HOLDA goes low when the port is placed in the highimpedance state. In conjunction with WTCNT, this 2-bit field defines the mode of wait-state generation. (See Table 9-5.) This three-bit field specifies the number of cycles to use when in software wait mode for the generation of internal wait states. The range is 0 (WTCNT = 0 0 0) to 7 (WTCNT=1 1 1) H1/H3 cycles. (See Section 9.4.) This 5-bit field specifies the number of MSBs of the address to be used to define the bank size. (See Table 9-6.) NOHOLD 0 Port hold signal HIZ 0 Internal hold SWW 11 Software wait mode WTCNT 111 Software wait mode BNKCMP 10000 Bank compare 9-8 Memory Interface Control Registers 9.3.2 Expansion-Bus Control Register The expansion-bus control register is a 32-bit register that contains control bits for the expansion bus (see Figure 9-3 and Table 9-4). Figure 9-3. Expansion-Bus Control Register 31-16 xx 15-12 xx 11-8 xx 7 6 WTCNT R/W 5 4 3 SWW R/W 2 xx 1 xx 0 xx Notes: 1) xx = reserved bit, read as 0 2) R = read, W = write Table 9-4. Expansion-Bus Control Register Bits Abbreviation SWW Reset Value 11 Name Software wait mode Description In conjunction with the WTCNT, 2-bit field defines the mode of wait-state generation. (See Table 9-5.) This 3-bit field specifies the number of cycles to use when in software wait mode for the generation of internal wait state. The range is 0 (WTCNT = 0 0 0) to 7 (WTCNT = 1) H1/H3 cycles. (See Section 9.4.) WTCNT 111 Software wait mode Note: After changing the bit fields of the expansion-bus control register, up to three instructions are fetched before the expansion bus is reconfigured because the configuration change is performed in the execute stage of the pipeline. TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-9 Programmable Wait States 9.4 Programmable Wait States The 'C3x has its own internal software-configurable ready-generation capability for each strobe. This software wait-state generator is controlled by configuring two bit fields in the primary or expansion bus interface control registers. Use the WTCNT field to specify the number of software wait-states to generate and use the SWW field to select one of the following four modes of wait-state generation: - External RDY wait states are generated solely by the external RDY line ignoring software wait states. - WTCNT-generated RDYwtcnt wait states are generated solely by the soft- ware wait-state generator ignoring external RDY signals. - Logical-AND of RDY and RDYwtcnt wait states are generated with a logical AND of internal and external ready signals. Both signals must occur. - Logical-OR of RDY and RDYwtcnt wait states are generated with a logical OR of internal and external ready signals. Either signal can generate the ready signal. The four modes are used to generate the internal ready signal, RDYint, that controls accesses. As long as RDYint = 1, the current external access is delayed. When RDYint = 0, the current access completes. Since the use of programmable wait states for both external interfaces is identical, only the primary bus interface is described in the following paragraphs. RDYwtcnt is an internally-generated ready signal. When an external access is begun, the value in WTCNT is loaded into a counter. WTCNT can be any value from 0 through 7. The counter is decremented every H1/H3 clock cycle until it becomes 0. Once the counter is set to 0, it remains set to 0 until the next access. While the counter is nonzero, RDYwtcnt = 1. While the counter is 0, RDYwtcnt = 0. Table 9-5 shows the truth table for each value of SWW and the different combinations of RDY, RDYwtcnt, and RDYint. Note: At reset, the 'C3x is programmed with seven wait states for each external memory access. These wait states are inserted to ensure the system can function with slow memories. To maximize system performance when accessing external memories, you need to decrease the number of wait states. After changing the wait states, up to three instructions are fetched before the change in the wait state occurs. 9-10 Programmable Wait States Table 9-5. Wait-State Generation Inputs SWW Bit Field 00 /RDYext 0 1 01 x x 10 0 0 1 1 11 0 0 1 1 /RDYwtcnt x x 0 1 0 1 0 1 0 1 0 1 Output /RDYint 0 1 0 1 0 0 0 1 0 1 1 1 Wait until both external RDY is signaled and wait state generator counts down to 0 (logical AND) Wait until internal wait state generator counts down to 0 Wait until first signal: external RDY or the internal wait state generator (logical OR) Functional Description Wait until external RDY is signaled TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-11 Programmable Bank Switching 9.5 Programmable Bank Switching Programmable bank switching allows you to switch between external memory banks without having to insert wait states externally due to memories that require several cycles to turn off. Bank switching is implemented on the primary bus only. The size of a bank is determined by the number of bits specified by the BNKCMP field of the primary bus control register. For example, if BNKCMP = 16, the 16 MSBs of the address are used to define a bank (see Figure 9-4). Since addresses are 24 bits, the bank size is specified by the eight LSBs, yielding a bank size of 256 words. If BNKCMP 16, only the 16 MSBs are compared. Bank sizes from 28 = 256 to 224 = 16M are allowed. Table 9-6 summarizes the relationship between BNKCMP, the address bits used to define a bank, and the resulting bank size. Figure 9-4. BNKCMP Example 24-bit address 23 8 7 0 Number of bits to compare Defines bank size Table 9-6. BNKCMP and Bank Size BNKCMP 00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001-11111 MSBs Defining a Bank None 23 23-22 23-21 23-20 23-19 23-18 23-17 23-16 23-15 23-14 23-13 23-12 23-11 23-10 23-9 23-8 Reserved Bank Size (32-Bit Words) 224 = 16M 223 = 8M 222 = 4M 221 = 2M 220 = 1M 219 = 512K 218 = 256K 217 = 128K 216 = 64K 215 = 32K 214 = 16K 213 = 8K 212 = 4K 211 = 2K 210 = 1K 29 = 512 28 = 256 Undefined 9-12 Programmable Bank Switching The 'C3x has an internal register that contains the MSBs (as defined by the BNKCMP field) of the last address used for a read or write over the primary interface. At reset, the register bits are set to 0. If the MSBs of the address being used for the current primary interface read do not match those contained in this internal register, a read cycle is not asserted for one H1/H3 clock cycle. During this extra clock cycle, the address bus switches over to the new address, but STRB is inactive (high). The contents of the internal register are replaced with the MSBs being used for the current read of the current address. If the MSBs of the address being used for the current read match the bits in the register, a normal read cycle takes place. If repeated reads are performed from the same memory bank, no extra cycles are inserted. When a read is performed from a different memory bank, an extra cycle is inserted. This feature can be disabled by setting BNKCMP to 0. The insertion of the extra cycle occurs only when a read is performed. The changing of the MSBs in the internal register occurs for all reads and writes over the primary interface. Figure 9-5 shows the addition of an inactive cycle when switches between banks of memory occur. TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-13 Programmable Bank Switching Figure 9-5. Bank-Switching Example H3 H1 STRB R/W A D Read Read Read RDY Extra cycle Note: After changing BNKCMP, up to three instructions are fetched before the change in the bank size occurs. 9-14 External Memory Interface Timing 9.6 External Memory Interface Timing This section discusses functional timing of operations on the primary bus and the expansion bus, the two independent parallel buses or the 'C3x devices. The parallel buses implement three mutually exclusive address spaces distinguished through the use of three separate control signals: STRB, MSTRB, and IOSTRB. The STRB signal controls accesses on the primary bus, and the MSTRB and IOSTRB signals control accesses on the expansion bus. Since the two buses are independent, you can make two accesses in parallel. With the exception of bank switching and the external HOLD function (discussed later in this section), timing of primary bus cycles and MSTRB expansion bus cycles are identical and are discussed collectively. The abbreviation (M)STRB is used in references that pertain equally to STRB and MSTRB. Similarly, (X)R/W, (X)A, (X)D, and (X)RDY are used to symbolize the equivalent primary and expansion bus signals. The IOSTRB expansion bus cycles are timed differently and are discussed independently. 9.6.1 Primary-Bus Cycles All bus cycles comprise integral numbers of H1 clock cycles. One H1 cycle is defined to be from one falling edge of H1 to the next falling edge of H1. For full-speed (zero wait-state) accesses, writes require two H1 cycles and reads require one cycle; however, if the read follows a write, the read requires two cycles.This applies to both the primary bus and the MSTRB expansion bus access. Note: Posted Write The data written to external memory by CPU or DMA is "latched" into the bus logic, allowing the CPU to continue with internal operation. Consequently, writes to external memory effectively require only one cycle if no accesses to that interface are in progress. However, if the next DMA or CPU access is to the same external bus, the DMA or CPU waits and the write is considered a 2-cycle operation. This is normally referred to as posted-write. The following discussions pertain to zero wait-state accesses unless otherwise specified. TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-15 External Memory Interface Timing The (M)STRB signal is low for the active portion of both reads and writes. The active portion lasts one H1 cycle. Additionally, before and after the active portion ((M)STRB low) of writes only, there is a transition cycle of H1. This transition cycle consists of the following sequence: 1) (M)STRB is high. 2) If required, (X)R/W changes state on H1 rising. 3) If required, address changes on H1 rising if the previous H1 cycle was the active portion of a write. If the previous H1 cycle was a read, address changes on the next H1 falling. Figure 9-6 illustrates a read-read-write sequence for (M)STRB active and no wait states. The data is read as late in the cycle as possible to allow maximum access time from address valid. Although external writes require two cycles, internally (from the perspective of the CPU and DMA) they require only one cycle if no accesses to that interface are in progress. In the typical timing for all external interfaces, the (X)R/W strobe does not change until (M)STRB or IOSTRB goes inactive. 9-16 External Memory Interface Timing Figure 9-6. Read-Read-Write for (M)STRB = 0 H3 H1 (M)STRB (X)R/W (X)A (X)D Read Read Write data (X)RDY Note: (x) RDY is sampled low on rising edge of H1. Data is read next falling edge of H1. Note: Back-to-Back Read Operations (M)STRB remains low during back-to-back read operations. TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-17 External Memory Interface Timing Figure 9-7 illustrates a write-write-read sequence for (M)STRB active and no wait states. The address and data written are held valid approximately one-half cycle after (M)STRB changes. Figure 9-7. Write-Write-Read for (M)STRB = 0 H3 H1 (M)STRB (X)R/W (X)A (X)D Write data Write data Read (X)RDY 9-18 External Memory Interface Timing Figure 9-8 illustrates a read cycle with one wait state. Since (X)RDY = 1, the read cycle is extended. (M)STRB, (X)R/W, and (X)A are also extended one cycle. The next time (X)RDY is sampled, it is 0. Figure 9-8. Use of Wait States for Read for (M)STRB = 0 H3 H1 (M)STRB XR/W (X)A (X)D Read Write data (X)RDY Extra cycle TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-19 External Memory Interface Timing Figure 9-9 illustrates a write cycle with one wait state. Since initially (X)RDY = 1, the write cycle is extended. (M)STRB, (X)R/W, and (X)A are extended one cycle. The next time (X)RDY is sampled, it is 0. Figure 9-9. Use of Wait States for Write for (M)STRB = 0 H3 H1 (M)STRB (X)R/W (X)A (X)D Write data Write data (X)RDY Extra cycle 9-20 External Memory Interface Timing 9.6.2 Expansion-Bus I/O Cycles In contrast to primary bus and MSTRB cycles, IOSTRB reads and writes are both two cycles in duration (with no wait states) and exhibit the same timing. During these cycles, address always changes on the falling edge of H1, and IOSTRB is low from the rising edge of the first H1 cycle to the rising edge of the second H1 cycle. The IOSTRB signal always goes inactive (high) between cycles, and XR/W is high for reads and low for writes. Figure 9-10 illustrates read and write cycles when IOSTRB is active and there are no wait states. For IOSTRB accesses, reads and writes require a minimum of two cycles. Some off-chip peripherals might change their status bits when read or written to. Therefore, it is important to maintain valid addresses when communicating with these peripherals. For reads and writes when IOSTRB is active, IOSTRB is completely framed by the address. Figure 9-10. Read and Write for IOSTRB = 0 H3 H1 IOSTRB XR/W XA XD Read Write data XRDY TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-21 External Memory Interface Timing Figure 9-11 illustrates a read with one wait state when IOSTRB is active, and Figure 9-12 illustrates a write with one wait state when IOSTRB is active. For each wait state added, IOSTRB, XR/W, and XA are extended one clock cycle. Writes hold the data on the bus one additional cycle. The sampling of XRDY is repeated each cycle. Figure 9-11.Read With One Wait State for IOSTRB = 0 H3 H1 IOSTRB XR/W XA XD Read XRDY Extra cycle 9-22 External Memory Interface Timing Figure 9-12. Write With One Wait State for IOSTRB = 0 H3 H1 IOSTRB XR/W XA XD Write data XRDY Extra cycle TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-23 External Memory Interface Timing Figure 9-13 through Figure 9-23 illustrate the various transitions between memory reads and writes, and I/O writes over the expansion bus. Figure 9-13. Memory Read and I/O Write for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA Memory address I/O address XD Read I/O write XRDY 9-24 External Memory Interface Timing Figure 9-14. Memory Read and I/O Read for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA Memory address I/O address XD Read I/O read XRDY TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-25 External Memory Interface Timing Figure 9-15. Memory Write and I/O Write for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA Memory address I/O address XD Memory write I/O write XRDY 9-26 External Memory Interface Timing Figure 9-16. Memory Write and I/O Read for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA Memory address I/O address XD Memory write I/O read XRDY TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-27 External Memory Interface Timing Figure 9-17. I/O Write and Memory Write for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA I/O address Memory address XD I/O write Memory write XRDY 9-28 External Memory Interface Timing Figure 9-18. I/O Write and Memory Read for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA I/O address Memory address XD I/O write Read XRDY TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-29 External Memory Interface Timing Figure 9-19. I/O Read and Memory Write for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA I/O address Memory address XD I/O read Memory write XRDY 9-30 External Memory Interface Timing Figure 9-20. I/O Read and Memory Read for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA I/O address Memory address XD I/O read Read XRDY TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-31 External Memory Interface Timing Figure 9-21. I/O Write and I/O Read for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA I/O address I/O address XD I/O write I/O read XRDY 9-32 External Memory Interface Timing Figure 9-22. I/O Write and I/O Write for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA I/O address I/O address XD I/O write I/O write XRDY TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-33 External Memory Interface Timing Figure 9-23. I/O Read and I/O Read for Expansion Bus H3 H1 MSTRB IOSTRB XR/W XA I/O address I/O address XD I/O read I/O read XRDY 9-34 External Memory Interface Timing Figure 9-24 and Figure 9-25 illustrate the signal states when a bus is inactive (after an IOSTRB or (M)STRB access, respectively). The strobes (STRB, MSTRB and IOSTRB) and (X)R/W) go to 1. The address is driven with last external bus access, and the ready signal (XRDY or RDY) is ignored. Figure 9-24. Inactive Bus States for IOSTRB H3 H1 IOSTRB XR/W XA XD Write data XRDY XRDY ignored Bus inactive TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-35 External Memory Interface Timing Figure 9-25. Inactive Bus States for STRB and MSTRB H3 H1 (M)STRB (X)R/W (X)A (X)D Write data (X)RDY (X)RDY ignored Bus inactive 9-36 External Memory Interface Timing 9.6.3 Hold Cycles Figure 9-26 illustrates the timing for HOLD and HOLDA. HOLD is an external asynchronous input. There is a minimum of one cycle delay from the time when the processor recognizes HOLD = 0 until HOLDA = 0. When HOLDA = 0, the address, data buses, and associated strobes are placed in a high-impedance state. All accesses occurring over an interface are completed before a hold is acknowledged. Figure 9-26. HOLD and HOLDA Timing H3 H1 HOLD HOLDA STRB R/W A D Write data Bus inactive TMS320C30 and TMS320C31/VC33 External-Memory Interface 9-37 9-38 Chapter 10 TMS320C32 Enhanced External Memory Interface The 'C32 external memory interface provides greater flexibility by improving the 'C3x core with several new features. This chapter describes these features and enhancements in detail. Topic Page 10.1 TMS320C32 Memory Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2 10.2 TMS320C32 Memory Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3 10.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7 10.4 Programmable Wait States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-15 10.5 Programmable Bank Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17 10.6 32-Bit Wide Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20 10.7 16-Bit Wide Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26 10.8 8-Bit Wide Memory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-32 10.9 External Ready Timing Improvement . . . . . . . . . . . . . . . . . . . . . . . . . 10-38 10.10 Bus Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-39 10-1 TMS320C32 Memory Features 10.1 TMS320C32 Memory Features The 'C32 external memory interface includes the following features: - One external pin, PRGW, configures the external-program-memory width to 16 or 32 bits. - Two sets of memory strobes (STRB0 and STRB1) and one IOSTRB allow zero glue-logic interface to two banks of memory and one bank of external peripherals. - Separate bus control registers for each strobe-control wait-state genera- tion, external memory width, and data-type size. - Each memory STRB handles 8-, 16- or 32-bit external data accesses (reads and writes) to 8-, 16-, or 32-bit-wide memory. - Multiprocessor support through the HOLD and HOLDA signals, is valid for all the STRBs. 10-2 TMS320C32 Memory Overview 10.2 TMS320C32 Memory Overview The following sections describe examples, control register setups, and restrictions necessary to fully understand the operation and functionality of the external memory interface. 10.2.1 External Memory Interface Overview The 'C32 memory interface accesses external memory through one 24-bit address and one 32-bit data bus that is shared by three mutually-exclusive strobes (STRB0, STRB1, and IOSTRB). Depending on the address accessed, the 'C32 activates one of these strobes according to the memory map shown in Figure 4-3 on page 4-8. STRB0 and STRB1 can access 8-, 16-, or 32-bit data from 8-, 16-, or 32-bit wide memory. This is accomplished by four signals in each strobe: STRBx_B3/A-1, STRBx_B2/A-2, STRBxB1, and STRBx_B0. These signals serve as byte-enable pins to access one byte, half word, or a full word from the external memory. The first two signals also serve as additional address pins to perform two or four consecutive accesses in 8-bit or 16-bit-wide external memory. The 'C32 controls the behavior of these pins through the data size and memory width bit fields in the corresponding strobe control register, as follows: - Memory width (default value dependent on PRGW pin level) J 8-bit-wide memory H H H STRBx_B3/A-1 and STRBx_B2/A-2 as address pins STRBx_B0 as byte-enable/chip-select signal STRBx_B1 unused J 16-bit-wide memory H H H STRBx_B3/A-1 as address pin STRBx_B1 and STRBx_B0 as byte-enable signal STRBx_B2 unused J 32-bit-wide memory H STRBx_B3, STRBx_B2, STRBx_B1, and STRBx_B0 as byteenable signals - Data size J J J 8-bit data, physical address = logical address shift right by 2 16-bit data, physical address = logical address shift right by 1 32-bit data, physical address = logical address TMS320C32 Enhanced External Memory Interface 10-3 TMS320C32 Memory Overview IOSTRB can access 32-bit data from 32-bit wide memory. It does not have the flexibility of STRB0 and STRB1 since it is composed of a single signal: IOSTRB. IOSTRB bus cycles are different from those of STRB0 and STRB1 and are discussed in Section 10.10. This timing difference accomodates slower I/O peripherals. The 'C32 memory interface parallel bus implements three mutually-exclusive address spaces distinguished via three separate control signals as shown in Figure 10-1. STRB0 and STRB1 support 8-, 16-, or 32-bit data access in 8-, 16-, 32-bit-wide external memory and 16-, 32-bit program access in 16-/32-bitwide external memory. IOSTRB address space supports 32-bit data/program access in 32-bit-wide external memory. Internally, the 'C32 has a 32-bit architecture, hence, the memory interface packs and unpacks the data accessed accordingly. Figure 10-1. Memory Address Spaces `C32 8-, 16-, 32-bit data in 8-, 16-, 32-bit-wide memory Program in 16-, 32-bit-wide memory STRB0 32-bit CPU PRGW pin STRB1 8-, 16-, 32-bit data in 8-, 16-, 32-bit-wide memory Program in 16-, 32-bit-wide memory Strobe control registers Memory interface IOSTRB 32-bit data in 32-bit-wide memory Program in 32-bit-wide memory 10.2.2 Program Memory Access The 'C32 supports program execution from 16- or 32-bit external memory width. The PRGW pin configures the width of the external program memory. When this pin is pulled high, the 'C32 executes from 16-bit wide memory. When this pin is pulled low, the 'C32 executes from 32-bit wide memory. For 16-bit wide zero wait-state memory, the 'C32 takes two instruction cycles to fetch a single 32-bit instruction. During the first cycle the lower 16 bits of the instruction are fetched. During the second cycle, the upper 16 bits are fetched and concatenated with the lower 16 bits. 32-bit memory fetches are identical to those of the 'C30 and 'C31. 10-4 TMS320C32 Memory Overview The PRGW status bit field of the CPU status (ST) register reflects the setting of the PRGW pin. Figure 10-2 depicts all the bit fields of the CPU status (ST) register. Figure 10-2. Status Register 31-16 xx 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 PRGW status R INT config R/W GIE CC CE CF xx RM OVM R/W LUF LV UF N Z V C R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W Notes: 1) xx = reserved bit, read as 0 The status of the PRGW pin also affects the reset value of the physical memory width bit fields of the STRB0 and STRB1 bus-control registers. The physical memory width is set to 32-bit memory width if the PRGW pin is logic low after the device reset. The physical memory width is set to 16-bit memory width if the PRGW pin is logic high after the device reset (see Section 10.3 for more information). The cycle before and the cycle after changing the PRGW should not perform a program fetch over the external memory interface. 10.2.3 Data Memory Access The 'C32 can load and store 8-, 16-, or 32-bit data quantities from and into memory. Because the CPU has a 32-bit architecture, the device internally handles all 8-, 16-, or 32-bit data quantities as a 32-bit value. Hence, the external memory interface handles the conversion between 8- and 16-bit data quantities to the internal 32-bit representation. The external memory interface also handles the storage of 32-, 16-, or 8-bit data quantities into 32-, 16-, or 8-bit wide memories. 10.2.3.1 8-, 16-, or 32-Bit Integers Data Types The 'C32 supports 8-, 16- or 32-bit integer data quantities. When 8- or 16-bit integers are read from external memory, the value is loaded into the LSBs of the register with the MSBs sign-extended or zero-filled. The polarity of the sign ext/zero-fill bit field of the corresponding STRB control register controls the sign extension or zero fill (see paragraphs 10.3.1.1 and 10.3.1.2). The 32-bit integer data access is identical to that of the 'C30 and 'C31. TMS320C32 Enhanced External Memory Interface 10-5 TMS320C32 Memory Overview 10.2.3.2 16- or 32-Bit Floating-Point Data Types The 'C32 supports 16- or 32-bit floating point data. For 16-bit floating-point reads, the eight MSBs are the signed exponent and the eight LSBs are the signed mantissa (see Section 5.3.2, 'C32 Short Floating-Point Format for External 16-Bit Data, on page 5-6). When a 16-bit floating-point value is loaded into a 40-bit register, the external memory interface zero fills the least significant 24 bits of the register. When a 16-bit floating-point value is used as a 32-bit on-chip input operand, the external memory interface zero fills the 16 LSBs of the 32-bit input operand. The 32-bit floating-point data access is identical to that of the 'C30 and 'C31. 10-6 Configuration 10.3 Configuration To access 8-, 16-, or 32-bit data (types) from 8-, 16-, or 32-bit wide memory, the memory interface of the 'C32 device uses either strobe STRB0 or STRB1 with four pins each. These pins serve as byte-enable and/or additional-address pins. In conjunction with a shifted version of the internal address presented to the external address, the 'C32 can select a single byte from one external memory location or combine up to four bytes from contiguous memory locations. The behavior of these pins is controlled by the external memory width and the data type size. The selected data size also determines the amount of internal-to-physical address shift. You can assign these values to the 'C32 memory interface through bit fields in the bus control registers. 10.3.1 External Interface Control Registers The following sections describe the bus control registers used to manipulate the byte addressability features of the 'C32. Figure 10-3 shows the external interface control memory map. Figure 10-3. Memory-Mapped External Interface Control Registers Address 808060h 808061h 808062h 808063h 808064h 808065h 808066h 808067h 808068h 808069h Register IOSTRB control Reserved Reserved Reserved Reserved Reserved Reserved Reserved . . . STRB0 control STRB1 control 80806Fh Reserved TMS320C32 Enhanced External Memory Interface 10-7 Configuration 10.3.1.1 STRB0 Control Register The STRB0 control register (Figure 10-4) is a 32-bit register that contains the control bits for the portion of the external bus memory space that is mapped to STRB0. The following table lists the register bits with the bit names and functions. At the system reset, 0F10F8h is written to the STRB0 control register if the PRGW pin is logic low and 0710F8h is written to the STRB0 control register if the PRGW pin is logic high. Figure 10-4. STRB0 Control Register 31 28 27 24 23 22 21 20 19 18 17 16 xx STRB switch R/W STRB config R/W Sign ext/ Physical memory zero fill width R/W R/W 3 Data type size R/W R/W R/W 15 13 12 11 8 7 5 4 2 1 0 xx BNKCMP R/W WTCNT R/W SWW R/W HIZ NOHOLD HOLDST R/W R R/W Notes: 1) R = read, W = write 2) xx = reserved, read as 0 10.3.1.2 STRB1 Control Register The STRB1 control register (Figure 10-5) is a 32-bit register that contains the control bits for the portion of the external bus memory space that is mapped to STRB1. Figure 10-5 shows the register bits with their names and functions. At system reset, 0F10F8h is written to the STRB1 control register if the PRGW pin is logic low and 0710F8h is written to the STRB1 control register if the PRGW pin is logic high. Figure 10-5. STRB1 Control Register 31 24 23 21 20 19 18 17 16 15 13 12 8 7 5 4 3 2 0 xx xx Sign ext/ zero fill R/W Physical memory width R/W Datatype size R/W xx BNKCMP R/W WTCNT R/W SWW R/W xx R/W Notes: 1) R = read, W = write 2) xx = reserved, read as 0 10-8 Configuration The instruction immediately preceding a change in the data-size or memory-width bit fields should not perform a multicycle store. Do not follow a change in the data-size or memory-width bit fields with a store instruction. Also, do not perform a load in the next two instructions following a change in the data-size or memory-width bit fields 10.3.1.3 IOSTRB Control Register The IOSTRB control register (Figure 10-6) is a 32-bit register that contains the control bits for the portion of the external bus memory space that is mapped to IOSTRB. Unlike the STRB0 and STRB1, there is no byte-enable signal for the IOSTRB. The data access through the IOSTRB is always 32-bit. The following table lists the register bits with the bit names and functions. At the system reset, 0F8h is written to the IOSTRB control register. The IOSTRB timing is identical to the `C30 IOSTRB timing. 31 16 15 12 11 8 7 5 4 3 2 0 xx xx xx WTCNT R/W SWW R/W xx Notes: 1) R = read, W = write 2) xx = reserved, read as 0 Figure 10-6. IOSTRB Control Register Note: After changing the bit fields of the IOSTRB control register, up to three instructions are fetched before the IOSTRB bus is reconfigured. TMS320C32 Enhanced External Memory Interface 10-9 Configuration Table 10-1 describes the bits in the STRBO, STRB1, and the IOSTRB control registers. Table 10-1. STRB0, STRB1, and IOSTRB Control Register Bits Abbreviation HOLDST Reset Value 0 Name Hold status bit Description This bit signals whether the port is being held (HOLDST = 1), or is not being held (HOLDST = 1). This status bit is valid whether the port has been held through hardware or software. (STRB0 control register only) NOHOLD allows or disallows the port to be held by an external HOLD signal. When NOHOLD = 1, the 'C3x takes over the external bus and controls it, regardless of serviced or pending requests by external devices. No hold acknowledge (HOLDA) is asserted when a HOLD is received. However, it is asserted if an internal hold is generated (HIZ = 1). (STRB0 control register only) When set (HIZ = 1), the port is put in hold mode. This is equivalent to the external HOLD signal. By forcing the highimpedance condition, the 'C3x can relinquish the external memory port through software. HOLDA goes low when the port is placed in the high impendance state. (STRB0 control register only) In conjunction with WTCNT, this 2-bit field defines the mode of wait-state generation. This 3-bit field specifies the number of cycles to use when in the software wait mode for the generation of internal wait state. The range is 0 (WTCNT = 0 0 0) to 7 (WTCNT = 111) H1/H3 cycles. This 5-bit field specifies the number of MSBs of the address to be used to define the bank size. (STRB0 and STRB1 control registers only) Indicates the size of the data type written in memory. Bit 17 0 0 1 1 Bit 16 0 1 0 1 Data Type Size 8 bit 16 bit Reserved 32 bit NOHOLD 0 Port hold signal HIZ 0 Internal hold SWW 11 Software wait mode WTCNT 111 Software wait mode BNKCMP 10000 Bank compare Data type size 11 (STRB0 and STRB1 control registers only) 10-10 Configuration Table 10-1. STRB0, STRB1, and IOSTRB Control Register Bits (Continued) Abbreviation Physical memory width Reset Value 01 or 11 Name (STRB0 and STRB1 control registers only) Description Indicates the size of the physical memory connected to the device. The "reset" value depends on the status of the PRGW pin. If the PRGW pin is logic low, the memory width is configured to 32 bits (= 112). If the PRGW pin is logic high, the physical memory width is configured to 16 bits (= 012). This field can have the following values: Bit 17 0 0 1 1 Bit 16 0 1 0 1 Data Type Size 8 bit 16 bit (reset value if PRGW = 1) Reserved 32 bit (reset value if PRGW = 0) Setting the physical memory width field of the STRB0 or STRB1 control registers changes the functionality of the STRB0 or STRB1 signals. - When the physical memory width field is configured to 32 bits, the corresponding STRBx_B0-STRBx_B3 signals are configured as byte-enable pins (see Figure 10-10 on page 10-20). When the physical memory width field is configured to 16 bits, the corresponding STRBx_B3/A-1 signal is configured as an address pin while the STRBx_B0 and STRBx_B1 signals are configured as byte-enable pins (see Figure 10-14 on page 10-26). When the physical memory width field is configured to 8 bits, the STRBx_B3/A-3 and STRBx_B2/A-2 signals are configured as byte-enable pins (see Figure 10-18 on page 10-32). - - Once an STRBx_Bx signal is configured as an address pin, it is active for any external memory access (STRB0, STRB1, IOSTRB, or external fetch). TMS320C32 Enhanced External Memory Interface 10-11 Configuration Table 10-1. STRB0, STRB1, and IOSTRB Control Register Bits (Continued) Abbreviation Sign ext/ zero-fill Reset Value 0 Name (STRB0 and STRB1 control registers only) Description Selects the method of converting 8- and 16-bit integer data into 32-bit integer data when transferring data from external memory to an internal register or memory location. This field can have the following values: Bit 20 0 1 Physical Memory Width 8- or 16-bit integer reads are sign-extended to 32 bits (reset value). The MSBs of 8- or 16-bit integer reads are zerofilled to make the number 32 bits. STRB config 0 STRB configuration Activates the STRB0 Bx signals when accessing data from STRB0 or STRB1 memory spaces. This mode is useful when accessing a single external memory bank that stores two different data types, each mapped to a different STRB. This field can have the following values. Bit 21 0 Physical Memory Width STRB0_Bx signals are active for locations 0h-7FFFFFh and 880000h-8FFFFFh. STRB1_Bx signals are active for locations 900000h-FFFFFFh (reset value). STRB0_Bx signals are active for locations 0h-7FFFFFh, 880000h-8FFFFFh and 900000h-FFFFFFh. STRB1_Bx signals are active for locations 900000h-FFFFFFh. 1 A functional representation of this configuration is shown in Figure 10-7 on page 10-13. STRB switch 0 (STRB0 control register only) Defines whether a single cycle is inserted between back-toback reads when crossing STRB0 or STRB1 to STRB1 to STRB0 boundaries (switching STRBs). The extra cycle toggles the strobe signal during back-to-back reads. Otherwise, the strobe remains low during back-to-back reads. This field has the following values: Bit 22 0 Physical Memory Width Does not insert a single cycle between backto-back reads that switch from STRB0 to STRB1 or vice-versa (reset value). Inserts a single cycle between back-to-back reads that switch from STRB0 to STRB1 or vice-versa (reset value). 1 10-12 Configuration Figure 10-7. STRB Configuration STRB0_Bx STRB0_Bx STRB config STRB1_Bx STRB1_Bx 10.3.2 Using Physical Memory Width and Data-Type Size Fields Consider a 'C32 connected to two banks of external memory. In this configuration, one bank is mapped to STRB0 while the other bank is mapped to STRB1. The STRB0 bank of memory is 32 bits wide and stores 32-bit data types. The STRB1 bank of memory is 16 bits wide and stores 16-bit data types. You can transfer these configurations to the 'C32 by setting the physical memory width and data-type size fields of the respective STRB0 and STRB1 control registers. You also must clear the STRB config bit field to 0 since the banks are separate memories. Note that `C32 address pins A23A22A21...A1A0 are connected to the STRB0 memory bank address pins A23A22A21...A1A0. But 'C32 address pins A22A21...A1A0 A-1 are connected to the STRB1 memory-bank address pins A23A22A21...A1A0. Executing the following code on this device results in the data-access sequence shown in Table 10-2. 1) 2) 3) 4) 5) 6) 7) 8) 9) LDI LDI ADDI ADDI ADDI LDI LSH LDI ADDI 4000h, AR1 *AR1++, R2 *AR1++, R2 *AR1++, R2 *AR1++, R2 900h, AR2 12, AR2 *AR2++, R3 *AR2, R3 ; ; ; ; ; ; ; ; ; AR1 = 4000h R2 = *4000h and AR1 = AR1 + 1 R2 = R2 + *4001h and AR1 = AR1 + 1 R2 = R2 + *4002h and AR1 = AR1 + 1 R2 = R2 + *4003h and AR1 = AR1 + 1 AR2 = 900h AR2 = 900000h R3 = *900000h and AR2 = AR2 + 1 R3 = R3 + 900001h TMS320C32 Enhanced External Memory Interface 10-13 Configuration By setting the bit fields of the STRB0 bus control register with a physicalmemory width of 32 bits and a data type size of 32 bits, the external address referring to the STRB0 location is identical to the internal address used by the `C32 CPU. Alternatively, setting the bit fields of the STRB1 bus control register with a physical memory width of 16-bit and a data-type size of 16-bit, the address presented by the `C32 external pins is the internal address shifted right by one bit with A23 driving A23 and A22. Since the STRB1 memory-bank address pins A23A22A21...A1A0 are connected to the `C32 address pins A22A21...A1A0A-1, the address seen by the STRB1 memory bank is identical to the `C32 CPU internal address. Table 10-2. Data-Access Sequence for a Memory Configuration with Two Banks Instruction # (2) (3) (4) (5) (8) (9) Internal Address Bus 4000h 4001h 4002h 4003h External Address Pins 4000h 4001h 4002h 4003h Active Strobe Byte Enable STRB0_B0 / B1 / B2 / B3 STRB0_B0 / B1 / B2 / B3 STRB0_B0 / B1 / B2 / B3 STRB0_B0 / B1 / B2 / B3 Accessed Data Pins D31-0 D31-0 D31-0 D31-0 D15-0 D15-0 4000h 4001h 4002h 4003h 900000h C80000h STRB1_B0 / B1 and STRB1_B3 / A-1 = 0 STRB1_B0 / B1 and 900000h 900001h 900001h C80001h STRB1_B3 / A-1 = 1 The ability of the `C32 device to select a single byte from a single external memory location or combinations of bytes from several contiguous memory locations dictates that the internal address seen by the CPU correspond to a shifted version of the address presented to the external pins. The 'C32 external memory interface handles this conversion automatically as long as you configure the bus control register to match the external memory configuration present in your hardware implementation. As seen in Figure 2-8 on page 2-20, 'C32 handles nine different memory access cases. The following sections discuss these cases in detail. 10-14 Programmable Wait States 10.4 Programmable Wait States The 'C3x has its own internal software-configurable ready-generation capability for each strobe. This software wait-state generator is controlled by configuring two fields in the primary or expansion bus interface control registers. Use the WTCNT field to specify the number of software wait states to generate and use the SWW field to select one of the following four modes of wait-state generation: - External RDY. Wait states are generated solely by the external RDY line ignoring software wait states. - WTCNT-generated RDYwtcnt. Wait states generated solely by the software wait-state generator ignoring external RDY signals. - Logical-AND of RDY and RDYwtcnt. Wait states generated with a logical AND of internal and external ready signals. Both signals must occur. - Logical-OR of RDY and RDYwtcnt. Wait states are generated with a logical OR of internal and external ready signals. Either signal can generate ready. The four modes are used to generate the internal ready signal, RDYint, that controls accesses. As long as RDYint = 1, the current external access is delayed. When RDYint = 0, the current access completes. Since the use of programmable wait states for both external interfaces is identical, only the primary bus interface is described in the following paragraphs. RDYwtcnt is an internally generated ready signal. When an external access is begun, the value in WTCNT is loaded into a counter. WTCNT can be any value from 0 through 7. The counter is decremented every H1/H3 clock cycle until it becomes 0. Once the counter is set to 0, it remains set to 0 until the next access. While the counter is nonzero, RDYwtcnt = 1. While the counter is 0, RDYwtcnt = 0. Table 10-3 shows the truth table for each value of SWW and the different combinations of RDY, RDYwtcnt, and RDYint. Note: At reset, the `C3x is programmed with seven wait states for each external memory access. These wait states are inserted to ensure the system can function with slow memories. To maximize system performance when accessing external memories, you need to decrease the number of wait states. After changing wait states, up to three instructions will be fetched before the change in the wait-state occurs. TMS320C32 Enhanced External Memory Interface 10-15 Programmable Wait States Table 10-3. Wait-State Generation Inputs SWW Bit Field 00 /RDYext 0 1 01 x x 10 0 0 1 1 11 0 0 1 1 /RDYwtcnt x x 0 1 0 1 0 1 0 1 0 1 Output /RDYint 0 1 0 1 0 0 0 1 0 1 1 1 Wait until both external RDY is signaled and wait state generator counts down to 0 (logical AND) Wait until internal wait state generator counts down to 0 Wait until first signal: external RDY or the internal wait state generator (logical OR) Functional Description Wait until external RDY is signaled 10-16 Programmable Bank Switching 10.5 Programmable Bank Switching Programmable bank switching allows you to switch between external memory banks without having to insert wait states externally due to memories that require several cycles to turn off. Bank switching is implemented on STRB0 and STRB1 only. The size of a bank is determined by the number of bits specified to be examined on the BNKCMP field of the primary bus control register. For example, if BNKCMP = 16, the 16 MSBs of the address are used to define a bank (see Figure 9-4). Since addresses are 24 bits, the bank size is specified by the eight LSBs, yielding a bank size of 256 words. If BNKCMP 16, only the 16 MSBs are compared. Bank sizes from 28 = 256 to 224 = 16M are allowed. Table 9-6 summarizes the relationship between BNKCMP, the address bits used to define a bank, and the resulting bank size. Figure 10-8. BNKCMP Example 24-bit address 23 8 7 0 Number of bits to compare Defines bank size Table 10-4. BNKCMP and Bank Size BNKCMP 00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001-11111 MSBs Defining a Bank None 23 23-22 23-21 23-20 23-19 23-18 23-17 23-16 23-15 23-14 23-13 23-12 23-11 23-10 23-9 23-8 Reserved Bank Size (32-Bit Words) 224 = 16M 223 = 8M 222 = 4M 221 = 2M 220 = 1M 219 = 512K 218 = 256K 217 = 128K 216 = 64K 215 = 32K 214 = 16K 213 = 8K 212 = 4K 211 = 2K 210 = 1K 29 = 512 28 = 256 Undefined TMS320C32 Enhanced External Memory Interface 10-17 Programmable Bank Switching The 'C3x has an internal register that contains the MSBs (as defined by the BNKCMP field) of the last address used for a read or write over the primary interface. At reset, the register bits are set to 0. If the MSBs of the address being used for the current primary interface read do not match those contained in this internal register, a read cycle is not asserted for one H1/H3 clock cycle. During this extra clock cycle, the address bus switches over to the new address, but STRB is inactive (high). The contents of the internal register are replaced with the MSBs being used for the current read of the current address. If the MSBs of the address being used for the current read match the bits in the register, a normal read cycle takes place. If repeated reads are performed from the same memory bank, no extra cycles are inserted. When a read is performed from a different memory bank, memory conflicts are avoided by the insertion of an extra cycle. This feature can be disabled by setting BNKCMP to 0. The insertion of the extra cycle occurs only when a read is performed. The changing of the MSBs in the internal register occurs for all reads and writes over the primary interface. Figure 9-5 shows the addition of an inactive cycle when switches between banks of memory occur. Figure 10-9. Bank-Switching Example H3 H1 STRB R/W A D Read Read Read RDY Extra cycle 10-18 Programmable Bank Switching Note: After changing BNKCMP, up to three instructions are fetched before the change in bank size occurs. TMS320C32 Enhanced External Memory Interface 10-19 32-Bit-Wide Memory Interface 10.6 32-Bit-Wide Memory Interface The 'C32 memory interface to 32-bit-wide external memory uses STRBx_B3 through STRBx_B0 pins as strobe-byte-enable pins as shown in Figure 10-10. In this manner, the 'C32 can read from, or write to, a single 32-, 16-, or 8-bit value from the external 32-bit-wide memory. Figure 10-10. TMS320C32 External Memory Interface for 32-Bit SRAMs 'C32 AXX R/W AXX WE CS STRBx_B3 STRBx_B2 STRBx_B1 STRBx_B0 D(31-24) D(23-16) D(15-8) D(7-0) I/O(7-0) AXX WE CS I/O(7-0) AXX WE CS I/O(7-0) AXX WE CS I/O(7-0) Case 1: 32-Bit-Wide Memory With 8-Bit Data-Type Size When the data-type size is 8 bits, the 'C32 shifts the internal address two bits to the right before presenting it to the external-address pins. In this shift, the memory interface copies the value of the internal-address A23 to the externaladdress pins A23, A22, and A21. The memory interface activates the STRBx_B3 through STRBx_B0 pins according to the value of the internal address bits A1 and A0 as shown in Table 10-5. Figure 10-11 shows a functional diagram of the memory interface for 32-bit-wide memory with an 8-bit data-type size. 10-20 32-Bit-Wide Memory Interface Table 10-5. Strobe Byte-Enable for 32-Bit-Wide Memory With 8-Bit Data-Type Size Figure 10-11. Functional Diagram for 8-Bit Data-Type Size and 32-Bit External-Memory Width 'C32 Memory interface A 23 A 22 A 21 A 20 . . . A2 A1 A0 A 23 A 22 A 21 A 20 A 19 A 18 . . . A0 A21 A20 A19 A18 . . . A0 CS I/O(7-0) 11 10 01 00 D(31-24) D(23-16) D(15-8) D(7-0) A21 A20 A19 A18 . . . A0 CS I/O(7-0) A21 A20 A19 A18 . . . A0 CS I/O(7-0) A21 A20 A19 A18 . . . A0 CS I/O(7-0) STRBx_B3 STRBx_B2 STRBx_B1 STRBx_B0 Internal A1 0 0 1 1 Internal A0 0 1 0 1 Active Strobe Byte Enable STRBx_B0 STRBx_B1 STRBx_B2 STRBx_B3 TMS320C32 Enhanced External Memory Interface 10-21 32-Bit-Wide Memory Interface For example, reading from or writing to memory locations 90 4000h to 90 4004h involves the pins listed in Table 10-6. Table 10-6. Example of 8-Bit Data-Type Size Case 2: 32-Bit-Wide Memory With 16-Bit Data-Type Size Table 10-7. Strobe Byte-Enable for 32-Bit-Wide Memory With 16-Bit Data-Type Size 10-22 Internal Address Bus 904000h 904001h 904002h 904003h 904004h External Address Pins E41000h E41000h E41000h E41000h E41001h Active Strobe Byte Enable STRB1_B0 STRB1_B1 STRB1_B2 STRB1_B3 STRB1_B0 Accessed Data Pins D7-0 D15-8 D23-16 D31-24 D7-0 When the data-type size is 16 bits, the 'C32 shifts the internal address one bit to the right before presenting it to the external-address pins. In this shift, the memory interface copies the value of the internal-address A23 to the externaladdress pins A23 and A22. Also, the memory interface activates the STRBX-B3 through STRBx_B0 pins according to the value of the internal address bit A0 as shown in Table 10-7. Figure 10-12 shows a functional diagram of the memory interface for 32-bit-wide memory with 16-bit data-type size. Internal A0 0 1 Active Strobe Byte Enable STRBx_B1 and STRBx_B0 STRBx_B3 and STRBx_B2 32-Bit-Wide Memory Interface Figure 10-12. Functional Diagram for 16-Bit Data-Type Size and 32-Bit External-Memory Width 'C32 Memory interface 1 0 D(31-24) D(23-16) D(15-8) D(7-0) For example, reading or writing to memory locations 904000h to 904004h involves the pins listed in Table 10-8. Table 10-8. Example of 16-Bit Data-Type Size and 32-Bit-Wide External Memory Internal Address Bus 904000h 904001h 904002h 904003h 904004h STRBx_B3 STRBx_B2 STRBx_B1 STRBx_B0 A23 A22 A21 A20 . . . A2 A1 A0 'C32's core address bus A23 A22 A21 A20 A19 . . . A1 A0 A22 A21 A20 A19 . . . A1 A0 CS I/O(7-0) A22 A21 A20 A19 . . . A1 A0 CS I/O(7-0) A22 A21 A20 A19 . . . A1 A0 CS I/O(7-0) A22 A21 A20 A19 . . . A1 A0 CS I/O(7-0) External Address Pins C82000h C82000h C82001h C82001h C82002h Active Strobe Byte Enable STRB1_B1 and STRB1_B0 STRB1_B3 and STRB1_B2 STRB1_B1 and STRB1_B0 STRB1_B3 and STRB1_B2 STRB1_B1 and STRB1_B0 Accessed Data Pins D15 -0 D31 -16 D15 -0 D31 -16 D15 -0 TMS320C32 Enhanced External Memory Interface 10-23 32-Bit-Wide Memory Interface Case 3: 32-Bit-Wide Memory With 32-Bit Data-Type Size When the data size is 32 bits, the 'C32 does not shift the internal address before presenting it to the external address pins. In this case, the memory interface copies the value of the internal address bus to the respective externaladdress pins. Also, the memory interface activates STRBx_B3 through STRBx_B0 pins during accesses. Figure 10-13 shows a functional diagram of the memory interface for 32-bit-wide memory with 32-bit data size. Figure 10-13. Functional Diagram for 32-Bit Data Size and 32-Bit External-Memory Width 'C32 Memory interface STRBx logic D(31-24) D(23-16) D(15-8) D(7-0) 10-24 STRBx_B3 STRBx_B2 STRBx_B1 STRBx_B0 A23 A22 A21 A20 . . . A2 A1 A0 A23 A22 A21 A20 . . . A2 A1 A0 A23 A22 A21 A20 . . . A2 A1 A0 CS I/O(7-0) A23 A22 A21 A20 . . . A2 A1 A0 CS I/O(7-0) A23 A22 A21 A20 . . . A2 A1 A0 CS I/O(7-0) A23 A22 A21 A20 . . . A2 A1 A0 CS I/O(7-0) 'C32's core address bus 32-Bit-Wide Memory Interface For example, reading or writing to memory locations 904000h to 904004h involves the pins listed in Table 10-9. Table 10-9. Example of 32-Bit-Wide Memory With 32-Bit Data-Type Size Internal Address Bus 904000h External Address Pins 904000h Active Strobe Byte Enable Accessed Data Pins D31-0 D31-0 D31-0 D31-0 D31-0 STRB1_B0, STRB1_B1, STRB1_B2, and STRB1_B3 STRB1_B0, STRB1_B1, STRB1_B2, and STRB1_B3 STRB1_B0, STRB1_B1, STRB1_B2, and STRB1_B3 STRB1_B0, STRB1_B1, STRB1_B2, and STRB1_B3 STRB1_B0, STRB1_B1, STRB1_B2, and STRB1_B3 904001h 904001h 904002h 904002h 904003h 904003h 904004h 904004h TMS320C32 Enhanced External Memory Interface 10-25 16-Bit-Wide Memory Interface 10.7 16-Bit-Wide Memory Interface The 'C32 memory interface to 16-bit-wide external memory uses STRBx_B3 pin as an additional address pin, A-1, while using STRBx_B0 and STRBx_B1 as strobe byte-enable pins as shown in Figure 10-14. Note that the externalmemory address pins are connected to the 'C32 address pins A22A21...A1A0A-1. In this manner, the 'C32 can read/write a single 32-, 16-, or 8-bit value from the external 16-bit-wide memory. Figure 10-14. External-Memory Interface for 16-Bit SRAMs 'C32 A23 A22 A21 . . . A1 A0 STRBx_B3/A-1 R/W STRBx_B2 STRBx_B1 STRBx_B0 D(31-24) D(23-16) D(15-8) D(7-0) A23 A22 . . . A2 A1 A0 WE CS I/O(7-0) A23 A22 . . . A2 A1 A0 WE CS I/O(7-0) Case 4: 16-Bit-Wide Memory With 8-Bit Data-Type Size When the data type size is 8 bits, the 'C32 shifts the internal address two bits to the right before presenting it to the external-address pins. In this shift, the memory interface copies the value of the internal-address A23 to the externaladdress pins A23, A22, and A21. The memory interface also copies the value of the internal-address A1 to the external STRBx_B3/ A-1 pin. Furthermore, the memory interface activates the STRBx_B1 and STRBx_B0 pins according to the value of the internal address bit A0 as shown in Table 10-10. Figure 10-15 shows a functional diagram of the memory interface for 16-bit-wide memory with 8-bit data-type size. 10-26 16-Bit-Wide Memory Interface Table 10-10. Strobe-Byte Enable Behavior for 16-Bit-Wide Memory with 8-Bit Data-Type Size Figure 10-15. Functional Diagram for 8-Bit Data-Type Size and 16-Bit External-Memory Width 'C32 A23 A22 A21 A20 . . . A2 A1 A0 1 'C32's core address bus Internal A0 0 1 Active Strobe Byte Enable STRBx_B0 STRBx_B1 Memory interface A23 A22 A21 A20 A19 A18 . . . A0 STRBx_B3/A1 STRBx_B1 A22 A21 A20 A19 . . . A1 A0 CS I/O(7-0) A22 A21 A20 A19 . . . A1 A0 CS I/O(7-0) 0 D(15-8) D(7-0) STRBx_B0 For example, reading or writing to memory locations 4000h to 4004h involves the pins listed in Table 10-11. TMS320C32 Enhanced External Memory Interface 10-27 16-Bit-Wide Memory Interface Table 10-11. Example of 8-Bit Data-Type Size and 16-Bit-Wide External Memory Internal Address Bus 4000h 4001h 4002h 4003h 4004h External Address Pins 1000h 1000h 1000h 1000h 1001h STRB0_B3/A-1 0 0 1 1 0 Active Strobe Byte Enable STRB0_B0 STRB0_B1 STRB0_B0 STRB0_B1 STRB0_B0 Accessed Data Pins D7 -0 D15 -8 D7 -0 D15 -8 D7 -0 Case 5: 16-Bit-Wide Memory With 16-Bit Data-Type Size When the data-type size is 16 bits, the 'C32 shifts the internal address one bit to the right before presenting it to the external address pins. In this shift, the memory interface copies the value of the internal-address A23 to the externaladdress pins A23 and A22. Also, the memory interface copies the value of the internal-address A1 to the external STRBx_B3/ A-1 pin. Moreover, the memory interface activates the STRBx_B1 and STRBx_B0 during accesses. Figure 10-16 shows a functional diagram of the memory interface for 16-bitwide memory with 16-bit data-type size. 10-28 16-Bit-Wide Memory Interface Figure 10-16. Functional Diagram for 16-Bit Data-Type Size and 16-Bit External-Memory Width 'C32 Memory interface A23 A22 A21 A20 . . . A2 A1 A0 'C32's core address bus STRBx logic D(15-8) D(7-0) For example, reading or writing to memory locations 4000h to 4004h involves the pins listed in Table 10-12. Table 10-12. Example of 16-Bit-Wide Memory With 16-Bit Data-Type Size Internal Address Bus 4000h 4001h 4002h 4003h 4004h External Address Pins 2000h 2000h 2001h 2001h 2002h STRB0_B3 / A-1 0 1 0 1 0 TMS320C32 Enhanced External Memory Interface STRBx_B1 STRBx_B0 A23 A22 A21 A20 A19 . . . A1 A0 STRBx_B3/A1 A23 A22 A21 A20 . . . A2 A1 A0 CS I/O(7-0) A23 A22 A21 A20 . . . A2 A1 A0 CS I/O(7-0) Active Strobe Byte Enable STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 Accessed Data Pins D15-0 D15-0 D15-0 D15-0 D15-0 10-29 16-Bit-Wide Memory Interface Case 6: 16-Bit-Wide Memory with 32-Bit Data-Type Size When the data type size is 32 bits, the 'C32 does not shift the internal address before presenting it to the external address pins. In this case, the memory interface copies the value of the internal address bus to the respective external address pins. The memory interface also toggles STRBx_B3/ A-1 twice to perform two 16-bit memory accesses. In the consecutive memory accesses, the memory interface activates STRBx_B1 and STRBx_B0. In summary, the memory interface seems to add one wait state to the 32-bit data access. Figure 10-17 depicts a functional diagram of the memory interface for 16-bit wide memory with 32-bit data type size. Figure 10-17. Functional Diagram for 32-Bit Data-Type Size and 16-Bit External-Memory Width 'C32 Memory interface A23 A22 A21 A20 . . . A2 A1 A0 toggle A23 A22 A21 A20 . . . A2 A1 A0 STRBx_B3/A1 STRBx_B1 STRBx_B0 A24 A23 A22 A21 . . . A3 A2 A1 A0 CS I/O(7-0) A24 A23 A22 A21 . . . A3 A2 A1 A0 CS I/O(7-0) 'C32's core address bus STRBx logic D(15-8) D(7-0) For example, reading or writing to memory locations 4000h to 4004h involves the pins listed in Table 10-13. 10-30 Table 10-13. Example of 16-Bit-Wide Memory With 32-Bit Data-Type Size 4004h 4003h 4002h 4001h 4000h Internal Address Bus 4004h 4004h 4003h 4003h 4002h 4002h 4001h 4001h 4000h 4000h External Address Pins STRB0_B3 / A-1 1 0 1 0 1 0 1 0 1 0 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 STRB0_B0 and STRB0_B1 Active Strobe Byte Enable 16-Bit-Wide Memory Interface D15-0 D15-0 D15-0 D15-0 D15-0 D15-0 D15-0 D15-0 D15-0 D15-0 Accessed Data Pins TMS320C32 Enhanced External Memory Interface 10-31 8-Bit-Wide Memory Interface 10.8 8-Bit-Wide Memory Interface 'C32 memory interface to an 8-bit wide external memory uses STRBx_B3 and STRBx_B2 pins as additional address pins, A-1 and A-2, respectively, while using STRBx_B0 as strobe byte-enable pin as shown in Figure 10-18. The external-memory address pins are connected to the 'C32's address pins A21A20...A1A0A-1A-2. In this manner, the 'C32 can read/write a single 32-, 16-, or 8-bit value from the external 8-bit-wide memory. Figure 10-18. External Memory Interface for 8-Bit SRAMs 'C32 A23 A22 A21 . . A1 A0 STRBx_B3/A-1 STRBx_B2/A-2 R/W A23 . . A3 A2 A1 A0 WE CS I/O(7-0) STRBx_B1 STRBx_B0 D(31-24) D(23-16) D(15-8) D(7-0) Case 7: 8-Bit-Wide Memory With 8-Bit Data-Type Size Similarly to case 4, the 'C32 shifts the internal address two bits to the right before presenting it to the external-address pins when the data type is 8-bit. As in case 4, the memory interface copies the value of the internal-address A23 to the external-address pins A23, A22, and A21. But in case 7, the memory interface also copies the value of the internal-address A1 to the external STRBx_B3/A-1 pin and the value of A0 to the external STRBx_B2/A-2. Moreover, the memory interface only activates the STRBx_B0 pin during the external memory access. Figure 10-19 shows a functional diagram of the memory interface for 8-bit-wide memory with an 8-bit data-type size. 10-32 8-Bit-Wide Memory Interface Figure 10-19. Functional Diagram for 8-Bit Data-Type Size and 8-Bit External-Memory Width 'C32 Memory interface A23 A22 A21 A20 . . . A2 A1 A0 A23 A22 A21 A20 A19 A18 . . . A0 STRBx_B3/A1 STRBx_B2/A2 STRBx logic STRBx_B0 'C32's core address bus A23 A22 A21 A20 . . . A2 A1 A0 CS I/O(7-0) D(7-0) For example, reading or writing to memory locations A04000h to A04004h involves the pins listed in Table 10-14. Table 10-14. Example of 8-Bit-Wide Memory With 8-Bit Data-Type Size Internal Address Bus A04000h A04001h A04002h A04003h A04004h External Address Pins E81000h E81000h E81000h E81000h E81001h STRB0_B3 / A-1 0 0 1 1 0 STRB0_B3 / A-2 0 1 0 1 0 Active Strobe Byte Enable STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 Accessed Data Pins D7 -0 D7 -0 D7 -0 D7 -0 D7 -0 TMS320C32 Enhanced External Memory Interface 10-33 8-Bit-Wide Memory Interface Case 8: 8-Bit Wide Memory With 16-Bit Data-Type Size When the data-type size is 16 bits, the `C32 shifts the internal address one bit to the right before presenting it to the external-address pins. In this shift, the memory interface copies the value of the internal-address A23 to the externaladdress pins A23 and A22. Also, the memory interface copies the value of the internal-address A0 to the external STRBx_B3 / A-1 pin. Furthermore, the memory interface toggles STRBx_B2 / A-2 twice to perform two 8-bit memory accesses. Moreover, the memory interface activates the STRBx_B0 during accesses. In summary, the memory interface adds one wait state to the 16-bit data access. Figure 10-20 shows a functional diagram of the memory interface for 8-bit-wide memory with 16-bit data-type size. Figure 10-20. Functional Diagram for 16-Bit Data-Type Size and 8-Bit External-Memory Width 'C32 Memory interface A23 A22 A21 A20 . . . A2 A1 A0 toggle STRBx logic A23 A22 A21 A20 A19 . . . A1 A0 STRBx_B3/A-1 STRBx_B2/A-2 STRBx_B0 A24 A23 A22 A21 . . . A3 A2 A1 A0 CS I/O(7-0) 'C32's core address bus D(7-0) 10-34 8-Bit-Wide Memory Interface For example, reading or writing to memory locations A04000h to A04002h involves the pins listed in Table 10-15. Table 10-15. Example of 8-Bit-Wide Memory With 16-Bit Data-Type Size Internal Address Bus A04000h External Address Pins D02000h D02000h D02001h D02001h D02002h D02002h STRB0_B3 / A-1 0 0 1 1 0 0 STRB0_B3 / A-2 0 1 0 1 0 1 Active Strobe Byte Enable STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 Accessed Data Pins D7-0 D7-0 D7-0 D7-0 D7-0 D7-0 A04001h A04002h Case 9: 8-Bit-Wide Memory With 32-Bit Data-Type Size When the data-type size is 32 bits, the `C32 does not shift the internal address before presenting it to the external-address pins. In this case, the memory interface copies the value of the internal-address bus to the respective externaladdress pins. The memory interface also toggles STRBx_B3/ A-1 and STRBx_B2/ A-2 to perform four 8-bit memory accesses. In the consecutive memory accesses, the memory interface activates STRBx_B0. In summary, the memory interface adds three wait states to the 32-bit data access. Figure 10-21 shows a functional diagram of the memory interface for 8-bitwide memory with 32-bit data-type size. TMS320C32 Enhanced External Memory Interface 10-35 8-Bit-Wide Memory Interface Figure 10-21. Functional Diagram for 32-Bit Data-Type Size and 8-Bit External-Memory Width 'C32 Memory interface A23 A22 A21 A20 . . . A2 A1 A0 toggle toggle A23 A22 A21 A20 . . . A1 A1 A0 STRBx_B3/A-1 STRBx_B2/A-2 STRBx_B0 A25 A24 A23 A22 . . . A.4 A3 A2 A1 A0 CS 'C32's core address bus STRBx logic I / O(7 -0) D(7 -0) 10-36 Table 10-16. Example of 32-Bit Data-Type Size and 8-Bit-Wide Memory A04001h A04000h Internal Address Bus A04001h A04001h A04001h A04001h A04000h A04000h A04000h A04000h External Address Pins For example, reading or writing to memory locations A04000h to A04001h involves the pins listed in Table 10-16. STRB0_B3 / A-1 1 1 0 0 1 1 0 0 TMS320C32 Enhanced External Memory Interface STRB0_B3 / A-2 1 0 1 0 1 0 1 0 STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 STRB1_B0 Active Strobe Byte Enable D7-0 D7-0 D7-0 D7-0 D7-0 D7-0 D7-0 D7-0 8-Bit-Wide Memory Interface Accessed Data Pins 10-37 External Ready Timing Improvement 10.9 External Ready Timing Improvement The ready (RDY) timing should relate to the H1 low signal as shown in Figure 10-22. This is equivalent to the 'C4x ready timing, which increases the time between valid address and the sampling of RDY. This facilitates the memory hardware interface by allowing a longer address decode-circuit response time to generate a ready signal. Figure 10-22. RDY Timing for Memory Read H3 H1 STRBx R/W A Address D Data tsu(RDY) RDY Do not change the RDY signal during its setup time [tsu(RDY)]. 10-38 Bus Timing 10.10 Bus Timing This section discusses functional timing of operations on the external memory bus. Detailed timing specifications are contained in the TMS320C32 Data Sheet. The timing of STRB0 and STRB1 bus cycles is identical and discussed in subsection 10.10.1. The abbreviation STRBx is used in references that pertain equally to STRB0 and STRB1. The IOSTRB bus cycles are timed differently and are discussed in subsection 10.10.2. 10.10.1 STRB0 and STRB1 Bus Cycles All bus cycles comprise integral numbers of H1 clock cycles. One H1 cycle is defined from one falling edge of H1 to the next falling edge of H1. For full speed (zero wait-state) accesses on STRB0 and STRB1, writes take two H1 cycles and reads take one cycle. However, if the read immediately follows a write, the read takes two cycles. Writes to internal memory take one cycle if no other accesses to that interface are in progress. The following discussion pertains to zero wait-state accesses, unless otherwise specified. The STRBx signal is low for the active portion of both reads and writes (one H1 cycle). Additionally, before and after the active portions of writes only (STRBx low), there is a transition of one H1 cycle. During this transition cycle the following might occur: - STRBx is high. - If required, R / W changes state on the rising edge of H1. - If required, address changes on the rising edge of H1 if the previous H1 cycle performed a write. If the previous H1 cycle performed a read, address changes on the falling edge of H1. Figure 10-23 illustrates a zero wait-state read-read-write sequence for STRBx active. The data is read as late in the cycle as possible to allow for the maximum access time from address valid. Although external writes take two cycles, writes to internal memory take one cycle if no other accesses to that interface are in progress. Similar to typical external interfaces, the R/W signal does not change until STRB0 and STRB1 are deactivated. TMS320C32 Enhanced External Memory Interface 10-39 Bus Timing Figure 10-23. Read-Read-Write Sequence for STRBx Active H3 H1 STRBx R/W A D Read Read Write RDY Figure 10-24 shows a zero wait-state write-write-read sequence for STRBx active. During back-to-back writes, the data is valid when STRBx changes for the first write, but for subsequent writes the data is valid when the address changes. Figure 10-24. Write-Write-Read Sequence for STRBx Active H3 H1 STRBx R/W A D RDY Write Write Read 10-40 Bus Timing Figure 10-25 shows a one wait-state read sequence and Figure 10-26 shows the write sequence for STRBx active. On the first H1 cycle, RDY is high; therefore, the read or write sequence is extended for one extra cycle. On the second H1 cycle, RDY is low and the read or write sequence is terminated. Figure 10-25. One Wait-State Read Sequence for STRBx Active H3 H1 STRBx R/W A D RDY Read Extra cycle TMS320C32 Enhanced External Memory Interface 10-41 Bus Timing Figure 10-26. One Wait-State Write Sequence for STRBx Active H3 H1 STRBx R/W A D Write RDY Extra cycle 10.10.2 IOSTRB Bus Cycles In contrast to STRB0 and STRB1 bus cycles, IOSTRB full speed (zero waitstate) reads and writes consume two H1 cycles. During these cycles, the IOSTRB signal is low from the rising edge of the first H1 cycle to the rising edge of the second H1 cycle. Also, the address changes on the falling edge of the first H1 cycle and R/ W changes state on the falling edge of H1. This provides a valid address to peripherals that may change their status bits when read or written while IOSTRB is active. Moreover, the IOSTRB signal is high between IOSTRB read and write cycles. 10-42 Bus Timing Figure 10-27 illustrates a zero wait-state read and write sequence for IOSTRB active. During writes, the data is valid when IOSTRB changes. Figure 10-27. Zero Wait-State Read and Write Sequence for IOSTRB Active H3 H1 IOSTRB R/W A D Read Write RDY Figure 10-28 depicts a one wait-state read sequence for IOSTRB active. Figure 10-29 shows a one wait-state write sequence for IOSTRB active. For each wait-state added, IOSTRB, R/W, and A are extended for one extra clock cycle. Writes hold the data on the bus for one extra clock cycle. RDY is sampled on each extra cycle and the sequence is terminated when RDY is low. TMS320C32 Enhanced External Memory Interface 10-43 Bus Timing Figure 10-28. One Wait-State Read Sequence for IOSTRB Active H3 H1 IOSTRB R/W A Read D RDY Extra cycle Figure 10-29. One Wait-State Write Sequence for IOSTRB Active H3 H1 IOSTRB R/W A D Write RDY Extra cycle Figure 10-30 and Figure 10-31 illustrate the transitions between STRBx reads and IOSTRB writes and reads, respectively. In these transitions, the address changes on the falling edge of the H1 cycle. 10-44 Bus Timing Figure 10-30. STRBx Read and IOSTRB Write H3 H1 STRB0,1 IOSTRB R/W A D Read I/O Write RDY Figure 10-31. STRBx Read and IOSTRB Read H3 H1 STRB0,1 IOSTRB R/W A D Read I/O read RDY TMS320C32 Enhanced External Memory Interface 10-45 Bus Timing Figure 10-32 and Figure 10-33 illustrate the transitions between STRBx writes and IOSTRB writes and reads, respectively. In these transitions, the address changes on the falling edge of the H3 cycle. Figure 10-32. STRBx Write and IOSTRB Write H3 H1 STRBx IOSTRB R/W A D Write I/O write RDY Figure 10-33. STRBx Write and IOSTRB Read H3 H1 STRBx IOSTRB R/W A Write I/O read D RDY 10-46 Bus Timing Figure 10-34 through Figure 10-37 show the transitions between IOSTRB writes/reads and STRBx writes/reads. In these transitions, the address changes on the rising edge of the H3 cycle. Figure 10-34. IOSTRB Write and STRBx Write H3 H1 STRBx IOSTRB R/W A D I/O write Write RDY TMS320C32 Enhanced External Memory Interface 10-47 Bus Timing Figure 10-35. IOSTRB Write and STRBx Read H3 H1 STRBx IOSTRB R/W A D I/O Write Read RDY Figure 10-36. IOSTRB Read and STRBx Write H3 H1 STRBx IOSTRB R/W A D I/O read Write RDY 10-48 Bus Timing Figure 10-37. IOSTRB Read and STRBx Read H3 H1 STRBx IOSTRB R/W A D I/O Read Read RDY Figure 10-38 through Figure 10-40 illustrate the transitions between reads and writes. TMS320C32 Enhanced External Memory Interface 10-49 Bus Timing Figure 10-38. IOSTRB Write and Read H3 H1 IOSTRB R/W A D I/O write I/O read RDY Figure 10-39. IOSTRB Write Write H3 and H1 IOSTRB R/W A D I/O write I/O write RDY 10-50 Bus Timing Figure 10-40. IOSTRB Read and Read H3 H1 IOSTRB R/W A D I/O Read I/O Read RDY 10.10.3 Inactive Bus States Figure 10-41 and Figure 10-42 show the signal states when a bus becomes inactive after an IOSTRB or STRBx, respectively. The strobes (STRB0, STRB1, IOSTRB, and R/ W) are deasserted going to a high level. The address bus preserves the last value and the ready signal (RDY) is ignored. Figure 10-41. Inactive Bus States Following IOSTRB Bus Cycle H3 H1 IOSTRB R/W A I/O Write D RDY Bus inactive RDY ignored TMS320C32 Enhanced External Memory Interface 10-51 Bus Timing Figure 10-42. Inactive Bus States Following STRBx Bus Cycle H3 H1 STRBx R/W A I/O write D RDY Bus inactive RDY ignored 10-52 Chapter 11 Using the TMS320C31/VC33 and TMS320C32 Boot Loaders The 'C31/VC33 and 'C32 have on-chip boot loaders that can load and execute programs received from a host processor, standard memory devices (including EPROM), or via serial port. Topic Page 11.1 TMS320C31/VC33 Boot Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2 11.2 TMS320C32 Boot Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14 11-1 TMS320C31/VC33 Boot Loader 11.1 TMS320C31/VC33 Boot Loader This section describes how to use the 'C31/VC33 microcomputer/boot loader (MCBL/MP) function. This feature is unique to the 'C31/VC33 and 'C32, and is not available on the 'C30 devices. 11.1.1 TMS320C31/VC33 Boot-Loader Description The boot loader lets you load and execute programs that are received from a host processor, inexpensive EPROMs, or other standard memory devices. The programs to be loaded reside in one of three memory-mapped areas identified as Boot 1, Boot 2, and Boot 3 (see the shaded areas of Figure 4-2 on page 4-6), or they are received by means of the serial port. The boot loader supports user-definable byte, half-word, and word-data formats, as well as 32-bit fixed-burst loads from the 'C31/VC33 serial port. See Section 12.2, Serial Ports, on page 12-15 for a detailed description of the serial-port operation. The boot-loader code starts at location 0x45 in the on-chip ROM. The source code is supplied in Appendix B. 11.1.2 TMS320C31/VC33 Boot-Loader Mode Selection The 'C31/VC33 boot loader functions as a memory boot loader or a serial-port boot loader. The boot-loader function is selected by resetting the processor while driving the MCBL/MP pin high. Use interrupt pins INT3 - INT0 to select the boot-load operation. Figure 11-1 shows the flow of this operation, which depends on the mode selected (external memory or serial boot). - The memory boot loader supports user-definable byte, half-word, and full- word data formats, allowing the flexibility to load a source program from memories having widths of 8-, 16-, or 32 bits. The source program must reside in one of three memory locations as listed in Table 11-1. Figure 11-2 shows the memory boot-loader flow. - The serial-port boot loader supports 32-bit fixed-burst transfers, with externally generated serial-port clock and frame-sync signals. The format of the incoming data stream is similar to that of the memory boot loader, except the source memory width and memory configuration word are omitted. Figure 11-3 shows the serial-port boot-loader flow. 11-2 TMS320C31/VC33 Boot Loader Table 11-1. Boot-Loader Mode Selection INT0 0 1 1 1 INT1 1 0 1 1 INT2 1 1 0 1 INT3 1 1 1 0 Loader Mode External memory External memory External memory 32-bit serial Memory Addresses Boot 1 address 0x001000 Boot 2 address 0x400000 Boot 3 address 0xFFF000 Serial port 0 Figure 11-1.TMS320C31/VC33 Boot-Loader Mode-Selection Flowchart Begin Reset MCBL/MP = 1 Is register bit INT3 set? No Is register bit INT0 set? No Is register bit INT1 set? No Is register bit INT2 set? No Yes Serial-port load Yes Memory load from 1000h Yes Memory load from 400000h Yes Memory load from FFF000h Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-3 TMS320C31/VC33 Boot Loader 11.1.3 TMS320C31/VC33 Boot-Loading Sequence The following is the sequence of events that occur during the boot load of a source program. Table 11-2 shows the structure of the source program. 1) Select the boot loader by resetting the 'C31/VC33 while driving the MCBL/ MP pin high and the corresponding INT3 -INT0 pin low. The MCBL/ MP must stay high during boot loading, but can be changed anytime after boot loading has terminated. No reset is necessary when changing the INT3 -INT0 pin, as long as the 'C31/VC33 is not accessing the overlapping memory (0h -FFFh) during this transition (see Section 11.1.6). The INT3 -INT0 pin can be driven low anytime after deasserting the RESET pin (driven low and then high). 2) The status of the interrupt flag (IF) register's INT3 -INT0 bit fields dictate the boot-loading mode. The bits are polled in the order described in the flow chart in Figure 11-1. 3) If only the IF register's INT3 bit field is set, the boot loader configures the serial port for 32-bit fixed-burst mode reads with an externally generated serial-port clock and FSR. Then, it proceeds to boot load the source program from the serial port. The transferred data-bit order supplied to the serial port must begin with the most significant bit (MSB) and end with the least significant bit (LSB). Figure 11-3 depicts the boot-loader serial-port flow. 4) Otherwise, the boot loader attempts a memory boot load. Figure 11-2 shows the boot-loader memory flow. If the IF register's INT0 bit field is set, the source program is loaded from memory location 1000h. If the IF register's INT1 bit field is set, the source program is loaded from memory location 400000h. If the IF register's INT2 bit field is set, the source program is loaded from memory location FFF000h. The memory boot-load source program has a header indicating the boot memory width and memory configuration control word. This word is copied into the STRB control register to configure the external primary bus interface. 5) After reading the header, the boot loader copies the source-program blocks. The source-program blocks have two entries preceding the source-programblock data. The first entry in the source-program block indicates the size of the block. A block size of zero signals the end of the source program code. The second entry indicates the address where the block is to be loaded. The boot loader cannot load the source program to any memory address below 1000h, unless the address decode logic is remapped. 6) The boot loader branches to the destination address of the first source block loaded and begins program execution. 11-4 TMS320C31/VC33 Boot Loader Figure 11-2.Boot-Loader Memory-Load Flowchart Memory load End of source program code (block size = 0)? No Load destination address Yes Branch to address boot 1, boot 2, or boot 3 Determine mode 8, 16, or 32 Set memory configuration control word Yes Block size = 0? No Transfer data from source to destination Load block size Block size -1 Load next block size Branch to destination address of first block loaded Begin program execution Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-5 TMS320C31/VC33 Boot Loader Figure 11-3.Boot-Loader Serial-Port Load-Mode Flowchart Yes Block size = 0? No Wait for serial port input Transfer data from serial port to destination address Block size -1 Block size = 0? No Wait for serialport input Load destination address Yes Branch to destination address of first block loaded Begin program execution 11-6 TMS320C31/VC33 Boot Loader 11.1.4 TMS320C31/VC33 Boot Data Stream Structure Table 11-2 shows the data stream structure. The data stream is composed of a header of 1 (serial-port load) or 2 (memory load) words and one or more blocks of source data. The boot loader uses this header to determine the physical memory width where the source program resides (memory load) and to configure the primary bus interface before source program boot load. The blocks of source data have two entries in addition to the raw data. The first entry in this block indicates the size of the block. The second entry in this block indicates the memory address where the boot loader copies this source block. Words 5 through n of the shaded entries in Table 11-2 contain the source data for the first block. Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-7 TMS320C31/VC33 Boot Loader Table 11-2. Source Data Stream Structure Word 1 Content Valid Data Entries Memory width (8, 16, or 32 bits) where source program resides 8h, 10h, or 20h, respectively Value to set the STRB control register See subsection 10.7 Size of first data block. The block size is the number of 32-bit 0 size 224 words in the data block. A 0 in this entry signifies the end of the source data stream Destination address to load the first block First word of first block . . . Last word of first block . . . 2 3 4 5 . . . n . . . A valid 'C31/VC33 24-bit address A 'C31/VC33 valid instruction or any 32-bit wide data value (LSB first) . . . A 'C31/VC33 valid instruction or any 32-bit wide data value . . . m Size of last data block. The block size is the number of 32-bit 0 size 224 words in the data block. If the next word following this block is not 0, another block is loaded. Destination address to load the last block First word of last block . . . Last word of last source block A valid 'C31/VC33 24-bit address A 'C31/VC33 valid instruction or any 32-bit wide data value (LSB first) . . . m+1 m+2 . . . j j+1 Zero word. If more than one source block was read, word j 0h would be the last word of the last block. Each block consists of header and data portions. The block's header is shaded darker than the block's data section. Words 1 and 2 do not exist in serial-port boot load since the source program does not reside in memory. Each source block of data can be loaded to different memory locations. Each block specifies its own size and destination address. The last source block of the data stream is appended with a zero word. 11-8 TMS320C31/VC33 Boot Loader 11.1.4.1 Examples of External TMS320C31/VC33 Memory Loads Table 11-3, Table 11-4, and Table 11-5 show memory images for byte-wide, 16-bit-wide, and 32-bit-wide configured memory (see Figure 4-2 on page 4-6). These examples assume the following: - An INT0 signal was detected after reset was deasserted (signifying an external memory load from boot 1). - The source program header resides at memory location 0x1000 and defines the following: J J J Boot memory-type EPROMs that require two wait states and SWW = 11 A loader destination address at the beginning of the 'C31/VC33 internal RAM block 1 A single block of memory that is 0x1FF in length Table 11-3. Byte-Wide Configured Memory Address 0x1000 0x1001 0x1002 0x1003 0x1004 0x1005 0x1006 0x1007 0x1008 0x1009 0x100A 0x100B 0x100C 0x100D 0x100E 0x100F Value 0x08 0x00 0x00 0x00 0x58 0x10 0x00 0x00 0xFF 0x01 0x00 0x00 0x00 0x9C 0x80 0x00 Program load starting address = 0x809C00 Program block size in words = 0x1FF Memory type = SWW = 11, WCNT = 2 Comments Memory width = 8 bits Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-9 TMS320C31/VC33 Boot Loader Table 11-4. 16-Bit-Wide Configured Memory Address 0x1000 0x1001 0x1002 0x1003 0x1004 0x1005 0x1006 0x1007 Value 0x10 0x0000 0x1058 0x0000 0x1FF 0x0000 0x9C00 0x0080 Program load starting address = 0x809C00 Program block size in words = 0x1FF Memory type = SWW = 11, WCNT = 2 Comments Memory width = 16 Table 11-5. 32-Bit-Wide Configured Memory Address 0x1000 0x1001 0x1002 0x1003 Value 0x00000020 0x00001058 0x000001FF 0x00809C00 Comments Memory width = 32 Memory type = SWW = 11, WCNT = 2 Program block size in words = 0x1FF Program load starting address = 0x809C00 After reading the header, the loader transfers 0x IFF 32-bit words, beginning at a specified destination address 0x 809C00. Code blocks require the same byte and half-word ordering conventions. The loader can also load multiple code blocks at different address destinations. After loading all code blocks, the boot loader branches to the destination address of the first block loaded and begins program execution. Consequently, the first code lock loaded is a start-up routine to access the other loaded programs. It is assumed that at least one block of code is loaded when the loader is invoked. Initial loader invocation with a block size of 0x00000000 produces unpredictable results. 11-10 TMS320C31/VC33 Boot Loader 11.1.4.2 Serial-Port Loading Boot loads, by way of the 'C31/VC33 serial port, are selected by driving the INT3 pin active (low) following reset. The loader automatically configures the serial port for 32-bit fixed-burst-mode reads. It is interrupt-driven by the frame synchronization receive (FSR) signal. You cannot change this mode for boot loads. Your hardware must generate the serial-port clock and FSR externally. As with memory loads, a header must precede the actual program to be loaded. However, you need only supply the block size and destination address because the loader and your hardware have predefined serial-port speed and data format (that is, skip data words 0 and 1). The transferred data-bit order must begin with the MSB and end with the LSB. 11.1.5 Interrupt and Trap-Vector Mapping Unlike the microprocessor mode, the microcomputer/boot-loader (MCBL) mode uses a dual-vectoring scheme to service interrupt and trap requests. Dual vectoring was implemented to ensure code compatibility with future versions of 'C3x devices. In a dual-vectoring scheme, branch instructions to an address, rather than direct-interrupt vectoring, are used. The normal interrupt and trap vectors are defined to vector to the last 63 locations in the on-chip RAM, starting at address 809FC1h. When the loader is invoked, the interrupt vector table is remapped by the processor to the last 63 locations in RAM block 1 of the 'C31/VC33. These locations are assumed to contain branch instructions to the interrupt source routines. Make sure that these locations are not inadvertently overwritten by loaded program or data values. Table 11-6 shows the MCBL/MP mode interrupt and trap instruction memory maps. Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-11 TMS320C31/VC33 Boot Loader Table 11-6. TMS320C31/VC33 Interrupt and Trap Memory Maps Address 809FC1 809FC2 809FC3 809FC4 809FC5 809FC6 809FC7 809FC8 809FC9 809FCA 809FCB 809FCC-809FDF 809FE0 809FE1 809FFB 809FFC-809FFF Description INT0 INT1 INT2 INT3 XINT0 RINT0 XINT1 (Reserved) RINT1 (Reserved) TINT0 TINT1 DINT0 Reserved TRAP0 TRAP1 TRAP27 Reserved 11-12 TMS320C31/VC33 Boot Loader 11.1.6 TMS320C31/VC33 Boot-Loader Precautions The boot loader builds a one-word-deep stack, starting at location 809801h. Avoid loading code at location 809801h. The interrupt flags are not reset by the boot-loader function. If pending interrupts are to be avoided when interrupts are enabled, clear the IF register before enabling interrupts. The MCBL/MP pin must remain high during the entire boot-loader execution, but it can be changed subsequently at any time. The 'C31/VC33 does not need to be reset after the MCBL/MP pin is changed. During the change, the 'C31/VC33 must not access addresses 0h-FFFh. The memory space 0h-FFFh will be mapped to external memory three clock cycles after changing the MCBL/MP pin. Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-13 TMS320C32 Boot Loader 11.2 TMS320C32 Boot Loader This section describes how to use the 'C32 microcomputer/boot loader (MCBL/MP) functions. 11.2.1 TMS320C32 Boot-Loader Description The 'C32 boot loader is an enhanced version of that found in the 'C31/VC33. The boot loader can load and execute programs received from a host processor through standard memory devices (including EPROM), with and without handshake, or through the serial port. The 'C32 boot loader supports 16- and 32-bit program external memory widths, as well as 8-, 16-, and 32-bit datatype sizes and external memory widths. The programs to be loaded reside in one of three memory-mapped areas identified as Boot 1, Boot 2, and Boot 3 (see shaded areas of Figure 4-3 on page 4-6) or they are received by means of the serial port. The boot-loader code starts at location 0x45 in the on-chip ROM. The source code is supplied in Appendix C. 11.2.2 TMS320C32 Boot-Loader Mode Selection The 'C32 boot loader functions as a memory boot loader, memory boot loader with handshake, or a serial-port boot loader. The boot-loader mode selection is determined by the status of the INT3-INT0 pins immediately following reset. Table 11-7 lists the boot-loader modes. - The memory boot loader supports user-definable byte, half-word, and full- word data formats, allowing the flexibility to load a source program from memories having widths of 8, 16, and 32 bits with or without handshaking. The source programs to be loaded reside in one of the three memory locations: 1000h, 810000h, and 900000h (see Table 11-7). - The memory boot-load handshaking mode uses XF0 as a data-acknowledge signal and XF1 as a data-ready signal. - The serial-port boot loader supports 32-bit fixed-burst loads from the 'C32 serial port with an externally generated serial-port clock and frame sync signals. The format is similar to that of the memory boot loader, except that the source memory width is omitted. 11-14 TMS320C32 Boot Loader Table 11-7. Boot-Loader Mode Selection INT0 0 1 1 1 0 1 1 INT1 1 0 1 1 1 0 1 INT2 1 1 0 1 1 1 0 INT3 1 1 1 0 0 0 0 Boot Loader Mode External memory External memory External memory Source Program Location Boot 1 address 1000h Boot 2 address 81 0000h Boot 3 address 90 0000h Serial Port 32-bit fixed-burst serial External memory with handshake External memory with handshake External memory with handshake Boot 1 address 1000h, XF0 and XF1 used in handshaking Boot 2 address 81 0000h, XF0 and XF1 used in handshaking Boot 3 address 90 0000h, XF0 and XF1 used in handshaking 11.2.3 TMS320C32 Boot-Loading Sequence The following is the sequence of events that occur during the boot load of a source program. Table 11-2 shows the structure of the source program. 1) Select the boot loader by resetting the 'C32 while driving the MCBL/MP pin high and the corresponding INT3-INT0 pins low. The MCBL/MP must stay high during boot loading, but can be changed anytime after boot loading has terminated. No reset is necessary when changing the INT3-INT0 pin, as long as the 'C32 is not accessing the overlapping memory (0h-FFFh) during this transition. In nonhandshake mode, one of the INT3-INT0 pins can be driven low any time after deasserting the RESET pin (driven low and then high). While in handshake mode, two interrupt pins must be asserted before deasserting the RESET pin. 2) The status of the IF register's INT3-INT0 bit fields dictates the boot-loading mode. The bits are polled in the order described in the flowchart in Figure 11-4. 3) If only the IF register's INT3 bit field is set, the boot loader configures the serial port for 32-bit fixed burst mode reads with an externally generated serial-port clock and FSR. Then, it proceeds to boot load the source program from the serial port. A header indicating the STRB0, STRB1, and IOSTRB control registers precedes the actual program (see Table 11-2). These header values are loaded into the corresponding locations at the completion of the boot-load operation. The transferred data-bit order supplied to the serial port must begin with the most significant bit (MSB) and end with the least significant bit (LSB). Figure 11-5 depicts the boot-loader serial-port flow. Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-15 TMS320C32 Boot Loader 4) Otherwise, the boot loader attempts a memory boot load. Figure 11-6 shows the boot-loader memory flow. If the IF register's INT0 bit field is set, the source program is loaded from memory location 1000h. If the IF register's INT1 bit field is set, the source program is loaded from memory location 810000h. If the IF register's INT2 bit field is set, the source program is loaded from memory location 900000h. After determining the memory location of the source program, the boot loader checks INT3 bit field in the IF register. If this bit is set, all data transfers are performed with synchronous handshake. The handshake protocol uses XF0 as a data-acknowledge and XF1 as a data-ready signals. 'C32's XF0 is an output pin while the XF1 is an input pin. Figure 11-7 shows the handshake data-transfer operation. The data-transfer operation occurs as follows: a) The 'C32 boot loader waits until the host sets XF1 low to read in the data. While the 'C32 waits for XF1 to drop low, the IACK pin pulses until XF1 is low. Setting XF1 low communicates to the 'C32 that the data is valid. The IACK pulse indicates that the 'C32 is waiting for data. b) The boot loader sets XF0 low after reading the data value. Dropping XF0 acknowledges to the host that the data was read. c) The host sets XF1 high to inform the 'C32 that the data is no longer valid. d) The 'C32 terminates the transfer by setting XF0 high. The memory boot-load source program has a header indicating the boot memory width and the contents of the STRB0, STRB1, and IOSTRB control registers (see Table 11-2). 5) After reading the header, the boot loader copies the source-program blocks. The source-program blocks have three entries preceding the source-program-block data. The first entry in the source-program block indicates the size of the block, the second entry indicates the address where the block is to be loaded, while the third entry contains the destinationmemory strobe including a pointer that identifies the destination-memory strobe (STRB0, STRB1, or IOSTRB) and a value that describes the strobe configuration for the memory width and data-type size. If the destination memory is internal, the third entry should contain a zero. The boot loader cannot load the source program to any memory address below 1000h, unless the address decode logic is remapped. 6) Once all the program blocks are loaded into their respective address locations with the given data-type sizes, the boot loader sets the IOSTRB, STRB0, and STRB1 control registers to the values read at the beginning of the boot-load process. 7) The boot loader branches to the destination address of the first source block loaded and begins program execution. 11-16 TMS320C32 Boot Loader Figure 11-4.TMS320C32 Boot-Loader Mode-Selection Flowchart Begin Reset MCBL/MP = 1 Is register bit INT3 set? No Is register bit INT1 set? No Is register bit INT0 set? No Is register bit INT2 set? No Yes Serial-port load Yes Memory load from 81000h Yes Memory load from 1000h Yes Memory load from 900000h Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-17 TMS320C32 Boot Loader Figure 11-5.Boot-Loader Serial-Port Load Flowchart Serial-port load Set up serial port for 32-bit fixed-burst mode Wait for serial-port Input Wait for serial-port Input Load block size Read IOSTRB control word End of source program code (block size = 0)? Yes Wait for serial-port Input No Read STRB0 control word Wait for serial-port input Load destination address Wait for serial-port Input Set STRB0, STRB1, and IOSTRB control registers Branch to destination address of first block loaded Begin program execution Wait for serial-port input Read STRB1 control word Read destination strobe control word According to the destination address, set corresponding STRB control register datatype size field Wait for serial-port input Transfer one word from serial port to destination address End of source program code (block size = 0)? No Yes 11-18 TMS320C32 Boot Loader Figure 11-6.Boot-Loader Memory-Load Flowchart Memory load Read block size Is IF register bit field INT3 set ? No Yes End of source program code (block size = 0)? Yes Enable handshake mode No Determine boot address: Boot 1, Boot 2, or Boot 3 Read memory width: 8, 16, or 32 bits Read IOSTRB control register Read destination address Set STRB0, STRB1, and IOSTRB control registers to the values read at the beginning of the load Branch to destination address of first block loaded Read destination strobe control word According to the destination address, set corresponding STRB control register to the previously read value Begin program execution Read STRB0 control register Transfer data source to destination address Read STRB1 control register End of source program code (block size = 0)? No Yes Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-19 TMS320C32 Boot Loader Figure 11-7.Handshake Data-Transfer Operation i ii iii iv XF1 XF0 D31-0 Valid data Valid data IACK 11.2.4 TMS320C32 Boot Data Stream Structure Table 11-8 shows the data stream structure. The data stream is composed of a header of three (serial-port load) or four (memory load) words and one or more blocks of source data. The boot loader uses this header to determine the physical memory width where the source program resides (memory load) and to configure the STRBs after completion of source program boot load. The blocks of source data have three entries in addition to the raw data. The first entry in this block indicates the size of the block. The second entry in this block indicates the memory address where the boot loader copies this source block. The third entry contains the destination memory strobe configuration including memory width and data-type size. This allows the boot loader to copy and store 8-, 16-, or 32-bit data values into 8-, 16-, or 32-bit wide memory. Words 8 through n of the shaded entries in Table 11-8 contain the source data for the first block. 11-20 TMS320C32 Boot Loader Table 11-8. Source Data Stream Structure Word 1 Content Valid Data Entries Memory width (8, 16, or 32 bits) where source program resides Value to set the IOSTRB control register at end of boot loader process 8h, 10h, or 20h, respectively 2 See Section 10.7 on page 10-26 3 Value to set the STRB0 control register at end of boot loader process Value to set the STRB1 control register at end of boot loader process See Section 10.3.1 on page 10-7 4 See Section 10.6 on page 10-20 0 size 224 5 Size of the first data block. The block size is the number of words in the data block (word length is specified by the datatype size). A 0 in this entry signifies the end of the source data stream. Destination address to load the first block First block destination memory width and data-type size in the format given in the Valid Data Entries column. First word of first block 6 7 A valid 'C32 24-bit address SSSSSS6x h 8 A 'C32 valid instruction or any 8-, 16-, or 32-bit wide data value . . . A 'C32 valid instruction or any 8-, 16-, or 32-bit wide data value . . . 0 size 224 . . . n . . . Last word of first block . . . m . . . Size of the last data block. The block size is the number of words in the data block (word length is specified by the data-type size). If the next word following this block is not 0, another block is loaded. Destination address to load the last block m+1 A valid 'C32 24-bit address Word 1 does not exist in serial-port boot load since the source program does not reside in memory. The SSSSSS hexadecimal digits refer to the lower 24 bits of the strobe control register. The x hexadecimal digit identifies the strobe as follows: 0 for IOSTRB, 4 for STRB0, and 8 for STRB1. SSSSSS6xh is cleared to 0 when loading the entire field into internal memory. Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-21 TMS320C32 Boot Loader Table 11-8. Source Data Stream Structure (Continued) Word m+2 m+3 . . . j j+1 Content Valid Data Entries SSSSSS6xh Last block destination memory width and data-type size in the format given in the Valid Data Entries column. First word of last block. . . . Last word of last source block Zero word. Note that if more than one source block was read, word j shown above would be the last word of the last block. Each block consists of header and data portions. The block's header is shaded darker than the block's data section. A 'C32 valid instruction or any 8-, 16-, or 32-bit wide data value . . . 0h Word 1 does not exist in serial-port boot load since the source program does not reside in memory. The SSSSSS hexadecimal digits refer to the lower 24 bits of the strobe control register. The x hexadecimal digit identifies the strobe as follows: 0 for IOSTRB, 4 for STRB0, and 8 for STRB1. SSSSSS6xh is cleared to 0 when loading the entire field into internal memory. Each source block can be loaded into a different memory location. Each block specifies its own size and destination address. The last source block of the data stream is appended with a zero word. Because the 'C32's STRBs can be configured to support different external memory widths and data-type sizes, each source block specifies its data-type size. The external memory width is set when the boot loader reads the STRBx control register values in the source data stream header. To build a 'C32 boot data stream with the HEX30 utility provided with the TMS320 floating-point code-generation tools, use the following steps: - Compile/assemble code with -v32 switch using v4.7 or later of the TMS320 floating-point C compiler/assembler. If the code-generation tools are invoked with CL30 and -z switch, include -v32 switch in the linker command file. - Link as usual. - Run Hex30 utility version 4.7 or later. The -v32 switch used in the compiler/ assembler will create a header in the COFF file, identifying it as a 'C32 for the Hex30. 11-22 TMS320C32 Boot Loader 11.2.5 Boot-Loader Hardware Interface The hardware interface for the memory boot load uses the STRBX_B3 through STRBX_B0 pins as strobe byte-enable pins (see Figure 11-8). The hardware interface is independent of the boot source memory width. This interface is identical to the 32-bit-wide memory interface described in Case 2, in Section 10.6 on page 10-20. For 16-bit memory widths, remove the two left-most memory devices of Figure 11-8. For 8-bit memory widths, remove all but the right-most of the memory devices of Figure 11-8. Figure 11-8. External Memory Interface for Source Data Stream Memory Boot Load 16-bit wide EPROM A2 A1 A0 STRBX_B3 STRBX_B2 STRBX_B1 STRBX_B0 D(31-24) D(23-16) D(15-8) D(7-0) A2 A1 A0 CS I/O(7-0) A2 A1 A0 CS I/O(7-0) A2 A1 A0 CS I/O(7-0) A2 A1 A0 CS I/O(7-0) 11.2.6 TMS320C32 Boot-Loader Precautions The interrupt flags are not reset by the boot-loader function. If pending interrupts are to be avoided when interrupts are enabled, clear the IF register before enabling interrupts. The MCBL/MP pin should remain high during the entire boot-loading execution, but it can be changed subsequently at any time. The 'C32 does not need to be reset after the MCBL/MP pin is changed. During the change, the 'C32 should not access addresses Oh-FFh. The memory space Oh-FFFh is mapped to external memory three clock cycles after changing the MCBL/MP pin. Using the TMS320C31/VC33 and TMS320C32 Boot Loaders 11-23 8-bit wide EPROM 'C32 32-bit wide EPROM ... ... ... ... ... A23 A22 A21 A20 A23 A22 A21 A20 A23 A22 A21 A20 A23 A22 A21 A20 A23 A22 A21 A20 TMS320C32 Boot Loader The 'C32 boot loader uses the following peripheral memory-mapped registers as a temporary stack: - Timer0 counter register (808024h) Timer0 period register (808028h) DMA0 source address register (808004h) DMA0 destination address register (808006h) DMA0 transfer counter register (808008h) These memory-mapped registers are not reset by the boot-loading process. Before using these peripherals, reprogram these registers with the appropriate values. 11-24 Chapter 12 Peripherals The 'C3x features two timers, a serial port (two serial ports for the 'C30), and an on-chip direct memory access (DMA) controller (2-channel DMA controller on the 'C32). These peripheral modules are controlled through memorymapped registers located on the dedicated peripheral bus. The DMA controller performs input/output operations without interfering with the operation of the CPU, making it possible to interface the 'C3x to slow, external memories and peripherals, analog-to-digital converters (A/Ds), serial ports, and so forth, without reducing the computational throughput of the CPU. The result is improved system performance and decreased system cost. Topic Page 12.1 Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2 12.2 Serial Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-15 12.3 DMA Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-48 12-1 Timers 12.1 Timers The 'C3x has two 32-bit general-purpose timer modules. Each timer has two signaling modes and internal or external clocking. You can use the timer modules to signal to the 'C3x or the external world at specified intervals or to count external events. With an internal clock, the timer can signal an external A/D converter to start a conversion, or it can interrupt the 'C3x DMA controller to begin a data transfer. The timer interrupt is one of the internal interrupts. With an external clock, the timer can count external events and interrupt the CPU after a specified number of events. Each timer has an I/O pin that you can use as an input clock to the timer, as an output clock signal, or as a generalpurpose I/O pin. Each timer consists of a 32-bit counter, a comparator, an input clock selector, a pulse generator, and supporting hardware (see Figure 12-1). A timer counts the cycles of a timer input clock with the counter register. When that counter register equals the value stored in the timer-period register, it resets the counter to 0 and produces a transition in the timer output signal. The timer input clock can be driven by either half the internal clock frequency of the 'C3x or an external clock on TCLKx pin. Figure 12-1. Timer Block Diagram H1/2 Counter (32-bit) Counter register (31 0) External clock INV Period register (31 0) 32 Comparator ? Period = counter 32 Pulse generator INV TSTAT Timer out 12-2 Timers 12.1.1 Timer Pins Each timer has one pin associated with the timer clock signal (TCLK) pin. This pin (TCK) is used as a general-purpose I/0 signal, as a timer output, or as an input for an external clock for a timer. Each timer has a TCLK pin: TCLK0 is connected to timer0, TCLK1 to timer1. 12.1.2 Timer Control Registers Three memory-mapped registers are used by each timer: - Global-control register The global-control register determines the operating mode of the timer, monitors the timer status, and controls the function of the I/O pin of the timer. - Period register The period register specifies the timer's signaling frequency. - Counter register The counter register contains the current value of the incrementing counter. You can increment the timer on the rising edge or the falling edge of the input clock. The counter is zeroed and can cause an internal interrupt whenever its value equals that in the period register. The pulse generator generates either of two types of external clock signals: pulse or clock. The memory map for the timer modules is shown in Figure 12-2. Peripherals 12-3 Timers Figure 12-2. Memory-Mapped Timer Locations 808020h Timer0 global control Timer0 counter Timer0 period Timer1 global control Timer1 counter Timer1 period 808024h 808028h 808030h 808034h 808038h See Section 12.1.3 See Section 12.1.4 12.1.3 Timer Global-Control Register The timer global-control register is a 32-bit register that contains the global and port control bits for the timer module. Figure 12-3 shows the format of the timer global-control register. Bits 3 -0 are the port control bits; bits 11 -6 are the timer global-control bits. At reset, all bits are set to 0 except for DATIN (which is set to the value read on TCLK). Table 12-1 describes the timer global-control register bits, their names, and functions. Figure 12-3. Timer Global-Control Register 31 xx 16 15 xx 12 11 TSTAT R Notes: 10 INV R/W 9 CLKSRC R/W 8 C/P R/W 7 HLD R/W 6 GO R/W 5 xx 4 xx 3 DATIN R 2 DATOUT R/W 1 I/O R/W 0 FUNC R/W 1) R = read, W = write 2) xx = reserved bit, read as 0 12-4 Timers Table 12-1. Timer Global-Control Register Bits Summary Abbreviation FUNC Reset Value 0 Name Function Description Controls the function of TCLK. If FUNC = 0, TCLK is configured as a general-purpose digital I/O port. If FUNC = 1, TCLK is configured as a timer pin. See section 12.1.6 Timer Operation Modes on page 12-10 for a description of the relationship between FUNC and CLKSRC. I/O 0 Input/output If FUNC = 0 and CLKSRC = 0, TCLK is configured as a generalpurpose I/O pin. If I/O = 0, TCLK is configured as a general-purpose input pin. If I/O = 1, TCLK is configured as a general-purpose output pin. DATOUT DATIN GO 0 x 0 Data output Data input Go Drives TCLK when the 'C3x is in I/O port mode. You can use DATOUT as an input to the timer. Data input on TCLK or DATOUT. A write has no effect. Resets and starts the timer counter. When GO = 1 and the timer is not held, the counter is zeroed and begins incrementing on the next rising edge of the timer input clock. The GO bit is cleared on the same rising edge. GO = 0 has no effect on the timer. HLD 0 Counter hold signal When this bit is 0, the counter is disabled and held in its current state. If the timer is driving TCLK, the state of TCLK is also held. The internal divide-by-2 counter is also held so that the counter can continue where it left off when HLD is set to 1. You can read and modify the timer registers while the timer is being held. RESET has priority over HLD. The effect of writing to GO and HOLD is shown below. GO 0 0 1 HLD Result 0 1 0 All timer operations are held. No reset is performed (reset value). Timer proceeds from state before write. All timer operations are held, including zeroing of the counter. The GO bit is not cleared until the timer is taken out of hold. Timer resets and starts. 1 x = 0 or 1 (set to value read on TCLK) 1 Peripherals 12-5 Timers Table 12-1. Timer Global-Control Register Bits Summary (Continued) Abbreviation C/P Reset Value 0 Name Clock/pulse mode control Description When C/P = 1, clock mode is chosen, and the signaling of the TSTAT flag and external output has a 50% duty cycle. When C/P = 0, the status flag and external output will be active for one H1 cycle during each timer period (see Figure 12-4 on page 12-8). CLKSRC 0 Clock source This bit specifies the source of the timer clock. When CLKSRC = 1, an internal clock with a frequency equal to one-half of the H1 frequency is used to increment the counter. The INV bit has no effect on the internal clock source. When CLKSRC = 0, you can use an external signal from the TCLK pin to increment the counter. The external clock is synchronized internally, thus allowing external asynchronous clock sources that do not exceed the specified maximum allowable external clock frequency. This is less than f(H1)/2. See section 12.1.6, Timer Operation Modes, on page 12-10 for a description of the relationship between FUNC and CLKSRC. INV 0 Inverter control bit If an external clock source is used and INV = 1, the external clock is inverted as it goes into the counter. If the output of the pulse generator is routed to TCLK and INV = 1, the output is inverted before it goes to TCLK (see Figure 12-1 on page 12-2). If INV = 0, no inversion is performed on the input or output of the timer. The INV bit has no effect, regardless of its value, when TCLK is used in I/O port mode. TSTAT 0 Timer status bit This bit indicates the status of the timer. It tracks the output of the uninverted TCLK pin. This flag sets a CPU interrupt on a transition from 0 to 1. A write has no effect. x = 0 or 1 (set to value read on TCLK) 12-6 Timers 12.1.4 Timer-Period and Counter Registers The 32-bit timer-period register is used to specify the frequency of the timer signaling. The timer-counter register is a 32-bit register, which is reset to 0 whenever it increments to the value of the period register. Both registers are set to 0 at reset. Certain boundary conditions affect timer operation. These conditions are listed below: - When the period and counter registers are 0, the operation of the timer is dependent upon the C/P mode selected. In pulse mode (C/P = 0), TSTAT is set and remains set. In clock mode (C/P = 1), the width of the cycle is 2/f(H1), and the external clocks are ignored. - When the counter register is not 0 and the period register = 0, the counter counts, rolls over to 0, and behaves as described above. - When the counter register is set to a value greater than the period register, the counter may overflow when incremented. Once the counter reaches its maximum 32-bit value (0FFFFFFFFh), it rolls over to 0 and continues. Writes from the peripheral bus override register updates from the counter and new status updates to the control register. 12.1.5 Timer Pulse Generation The timer pulse generator (see Figure 12-1 on page 12-2) can generate several external signals. You can invert these signals with the INV bit. The two basic modes are pulse mode and clock mode, as shown in Figure 12-4. In both modes, an internal clock source f (timer clock) has a frequency of f(H1)/2, and an externally generated clock source f (timer clock) can have a maximum frequency of f(H1)/2.6. In pulse mode (C/P = 0), the width of the pulse is 1/f(H1). Peripherals 12-7 Timers Figure 12-4. Timer Timing (a) TSTAT and timer output (INV = 0) when C/P = 0 (pulse mode) 2/f(H1) 1/f(H1) 1/f(CLKSRC) period register/f(CLKSRC) TINT TINT TINT (b) TSTAT and timer output (INV = 0) when C/P = 1 (clock mode) 1/f(CLKSRC) 2/f(H1) period register/f(CLKSRC) 2 x period register/f(CLKSRC) TINT TINT The timer signaling is determined by the frequency of the timer input clock and the period register. The following equations are valid with either an internal or an external timer clock: f(pulse mode) = f(timer clock) / period register f(clock mode) = f(timer clock) / (2 x period register) Note: Period register If the period register equals 0, see Section 12.1.4. Example 12-1 provides some examples of the TCLKx output when the period register is set to various values and clock or pulse mode is selected. 12-8 Timers Example 12-1. Timer Output Generation Examples (a) INV = 0, C/P = 0 (pulse mode) timer period = 1 Also, INV = 0, C/P = 1 (clock mode) timer period = 0 2H1 H1 (b) INV = 0, C/P = 0 (pulse mode) timer period = 2 4H1 H1 (c) 6H1 H1 INV = 0, C/P = 0 (pulse mode) timer period = 3 (d) 4H1 2H1 INV = 0, C/P = 1 (clock mode) timer period = 1 (e) 8H1 4H1 INV = 0, C/P = 1 (clock mode) timer period = 2 (f) 12H1 6H1 INV = 0, C/P = 1 (clock mode) timer period = 3 Peripherals 12-9 Timers 12.1.6 Timer Operation Modes The timer can receive its input and send its output in several different modes, depending upon the setting of CLKSRC, FUNC, and I/O. The four timer modes of operation are defined in the following sections. 12.1.6.1 CLKSRC = 1 and FUNC = 0 If CLKSRC = 1 and FUNC = 0, the timer input comes from the internal clock. The internal clock is not affected by the INV bit in the global-control register. In this mode, TCLK is connected to the I/O port control, and you use TCLK as a general-purpose I/O pin (see Figure 12-5). - If I/O = 0, TCLK is configured as a general-purpose input pin whose state you can read in DATIN. DATOUT has no effect on TCLK or DATIN. See Figure 12-5 (a). - If I/O = 1, TCLK is configured as a general-purpose output pin. DATOUT is placed on TCLK and can be read in DATIN. See Figure 12-5 (b). Figure 12-5. Timer Configuration with CLKSRC = 1 and FUNC = 0 (a) CLKSRC=1 (internal) FUNC=0 (I/O pin) I/O=0 (input) Internal Internal clock TCLK External (b) CLKSRC = 1 (internal) FUNC = 0 (I/O pin) I/O = 1 (output) Internal Internal clock External TSTAT 12-10 I/O port control DATIN Timer Input Output TSTAT DATOUT I/O port control DATIN Timer Input Output TCLK Timers 12.1.6.2 CLKSRC = 1 and FUNC = 1 If CLKSRC = 1 and FUNC = 1 (see Figure 12-6), the timer input comes from the internal clock, and the timer output goes to TCLK. This value can be inverted using INV, and you can read in DATIN the value output on TCLK. Figure 12-6. Timer Configuration with CLKSRC = 1 and FUNC = 1 Internal Internal clock TCLK DATIN CLKSRC = 1 (internal) FUNC = 1 (timer pin) External Timer In Out TSTAT 12.1.6.3 CLKSRC = 0 and FUNC = 0 If CLKSRC = 0 and FUNC = 0 (see Figure 12-7), the timer is driven according to the status of the I/O bit. - If I/O = 0, the timer input comes from TCLK. This value can be inverted using INV, and you can read in DATIN the value of TCLK. See Figure 12-7 (a). - If I/O = 1, TCLK is an output pin. Then, TCLK and the timer are both driven by DATOUT. All 0-to-1 transitions of DATOUT increment the counter. INV has no effect on DATOUT. You can read in DATIN the value of DATOUT. See Figure 12-7 (b). Figure 12-7. Timer Configuration with CLKSRC = 0 and FUNC = 0 CLKSRC = 0 (external) FUNC = 0 (I/O pin) I/O = 0 (input) (a) Timer In Out TSTAT I/O port control Internal External TCLK CLKSRC = 0 (external) FUNC = 0 (I/O pin) I/O = 1 (output) (b) Timer In Out TSTAT I/O port control Internal External TCLK DATIN DATOUT Peripherals 12-11 Timers 12.1.6.4 CLKSRC = 0 and FUNC = 1 If CLKSRC = 0 and FUNC = 1 (see Figure 12-8), TCLK drives the timer. - If INV = 0, all 0-to-1 transitions of TCLK increment the counter. - If INV = 1, all 1-to-0 transitions of TCLK increment the counter. You can read in DATIN the value of TCLK. Figure 12-8. Timer Configuration with CLKSRC = 0 and FUNC = 1 Timer In Out TSTAT DATIN CLKSRC = 0 (external) FUNC = 1 (timer pin) Internal External TCLK 12.1.7 Using TCLKx as General-Purpose I/O Pins When FUNC = 0, TCLKx can be used as an I/O pin. Figure 12-9 and Figure 12-10 show how the TCLKx is connected when it is configured as a general-purpose I/O pin. In Figure 12-9, the I/O bit equals 0 and TCLK is configured as an input pin whose value can be read in the DATIN bit. In Figure 12-10, the I/O bit equals 1 and TCLK is configured as an output pin that outputs the value you wrote in the DATOUT bit. Figure 12-9. TCLK as an Input (I/O = 0) Internal DATOUT (NC) External TCLK DATIN I/O = 0 FUNC = 0 Figure 12-10. TCLK as an Output (I/O = 1) Internal DATOUT External TCLK DATIN I/O = 1 FUNC = 0 12-12 Timers 12.1.8 Timer Interrupts A timer interrupt is generated whenever the TSTAT bit of the timer control register changes from a 0 to a 1. The frequency of timer interrupts depends on whether the timer is set up in pulse mode or clock mode. - In pulse mode, the interrupt frequency is determined by the following equation: f(interrupt) = f(timer clock) period register where: f(interrupt) = interrupt frequency f(timer clock) = timer frequency - In clock mode, the interrupt frequency is determined by the following equation: f(interrupt) = f(timer clock) 2 x period register where: f(interrupt) = interrupt frequency f(timer clock) = timer frequency The timer counter is automatically reset to 0 whenever it is equal to the value in the timer-period register. You can use the timer interrupt for either the CPU or the DMA. Interrupt-enable control for each timer, for either the CPU or the DMA, is found in the CPU/DMA interrupt-enable register. Refer to Section 3.1.8, CPU/DMA Interrupt-Enable Register (IE), on page 3-9 for more information. When a timer interrupt occurs, a change in the state of the corresponding TCLK pin is observed if FUNC = 1 and CLKSRC = 1 in the timer global-control register. The exact change in the state depends on the state of the C/P bit. In pulse mode (C/P = 0), the width of the pulse change is 1/f (H1). In clock mode (C/P = 1), the width of the pulse change is the period register divided by the frequency of the timer input clock. 12.1.9 Timer Initialization/Reconfiguration The timers are controlled through memory-mapped registers located on the dedicated peripheral bus. The general procedure for initializing and/or reconfiguring the timers follows: 1) Halt the timer by clearing the GO/HLD bits of the timer global-control register. To do this, write a 0 to the timer global-control register. Note that the timers are halted on RESET. Peripherals 12-13 Timers 2) Configure the timer through the timer global-control register (with GO = HLD = 0 ), the timer-counter register, and timer-period register, if necessary. 3) Start the timer by setting the GO/HLD bits of the timer global-control register. Example 12-2 shows how to set up the `C3x timer to generate the maximum clock frequency through the TCLKx pin. Example 12-2. Maximum Frequency Timer Clock Setup * * .data Timer0 TCTRL_RST TCTRL_GD TCNT TPRD .word .word .word .word .word .text . . . LDP LD1 LD1 ST1 LD1 ST1 LD1 ST1 LD1 ST1 LD1 ST1 808020h 301h 3C1h 0 0 ; Timer global control address Maximum Frequency Timer Clock Setup ; Timer counter value ; Timer-period value Timer0 @Timer0,AR0 0,R0 R0,*AR0 @TCTRL_RST,R0 R0,*AR0 @TCNT,R0 R0,*+AR0(4) @TPRD,R0 R0,**+AR0(8) @TCTRL_G0,R0 R0,*AR0 ; Load data page pointer ; Halt timer ; Configure timer ; Load timer counter ; Load timer period ; Start timer 12-14 Serial Ports 12.2 Serial Ports The 'C30 has two totally independent bidirectional serial ports. Both serial ports are identical, and there is a complementary set of control registers in each one. Only one serial port is available on the 'C31/VC33 and the 'C32. You can configure each serial port to transfer 8, 16, 24, or 32 bits of data per word simultaneously in both directions. The clock for each serial port can originate either internally, through the serial port timer and period registers, or externally, through a supplied clock. An internally generated clock is a divide down of the clockout frequency, f(H1). A continuous transfer mode is available, which allows the serial port to transmit and receive any number of words without new synchronization pulses. Eight memory-mapped registers are provided for each serial port: - Global-control register Two control registers for the six serial I/O pins Three receive/transmit timer registers Data-transmit register Data-receive register The global-control register controls the global functions of the serial port and determines the serial-port operating mode. Two port control registers control the functions of the six serial port pins. The transmit buffer contains the next complete word to be transmitted. The receive buffer contains the last complete word received. Three additional registers are associated with the transmit/ receive sections of the serial-port timer. A serial-port block diagram is shown in Figure 12-11 on page 12-16, and the memory map of the serial ports is shown in Figure 12-12 on page 12-17. Peripherals 12-15 Serial Ports Figure 12-11. Serial Port Block Diagram Receive Section CLKR TSTAT CLKR Transmit Section CLKX TSTAT Receive timer (16) CLKX Transmit timer (16) RINT Receive Clock Bit counter (8/16/24/32) FSR FSR FSX FSX Bit counter (8/16/24/32) XINT RSR (32) XSR (32) Load control DR DR Load control Load DX DX DX DRR (32) Load DXR (32) 12-16 Serial Ports Figure 12-12. Memory-Mapped Locations for the Serial Ports 808040h 808042h 808043h 808044h 808045h 808046h 808048h 80804Ch 808050h 808052h 808053h 808054h 808055h 808056h 808058h 80805Ch Serial-port 0 global control{ Serial port 0 FSX/DX/CLKX control Serial port 0 FSR/DR/CLKR control Serial port 0 R/X timer control Serial port 0 R/X timer counter# Serial port 0 R/X timer periodk Serial port 0 data transmitl Serial port 0 data receivej Serial-port 1 global control{ Serial port 1 FSX/DX/CLKX control Serial port 1 FSR/DR/CLKR control Serial port 1 R/X timer control Serial port 1 R/X timer counter# Serial port 1 R/X timer periodk Serial port 1 data transmitl Serial port 1 data receivej Note: Serial port1 locations are reserved on the 'C31/VC33 and 'C32. See Figure 12-13. See Figure 12-14. See Figure 12-15. See Figure 12-16. # See Figure 12-17. || See Figure 12-18. k See Figure 12-19. h See Figure 12-20. 12.2.1 Serial-Port Global-Control Register The serial-port global-control register is a 32-bit register that contains the globalcontrol bits for the serial port. The register is shown in Figure 12-13. Table 12-2 shows the register bits, bit names, and bit functions. Peripherals 12-17 Serial Ports Figure 12-13. Serial-Port Global-Control Register 31 xx 30 xx 29 xx 28 xx 27 RRESET R/W 15 DRP R/W 14 DXP R/W 13 CLKRP R/W 12 CLKXP R/W 26 XRESET R/W 11 RFSM R/W 25 RINT R/W 10 XFSM R/W 24 RTINT R/W 9 RVAREN R/W 23 XINT R/W 8 XVAREN R/W 22 XTINT R/W 7 RCLK SRCE R/W R/W 6 XCLK SRCE R/W 5 HS R/W 21 RLEN R/W 4 RSR FULL R R/W 3 XSR EMPTY R 20 19 XLEN R/W 2 FSXOUT R/W 18 17 FSRP R/W 1 XRDY R 16 FSXP R/W 0 RRDY R Notes: 1) R = read, W = write 2) xx = reserved bit, read as 0 Table 12-2. Serial-Port Global-Control Register Bits Summary Abbreviation RRDY Reset Value 0 Name Receive ready flag Description If RRDY = 1, the receive buffer has new data and is ready to be read. A three H1/H3 cycle delay occurs from the loading of DRR to RRDY = 1. The rising edge of this signal sets RINT. If RRDY = 0, the receive buffer does not have new data since the last read. RRDY = 0 at reset and after the receive buffer is read. XRDY 1 Transmit ready flag If XRDY = 1, the transmit buffer has written the last bit of data to the shifter and is ready for a new word. A three H1/H3 cycle delay occurs from the loading of the transmit shifter until XRDY is set to 1. The rising edge of this signal sets XINT. If XRDY = 0, the transmit buffer has not written the last bit of data to the transmit shifter and is not ready for a new word. FSXOUT Transmit frame sync configuration 0 Transmit-shift register empty flag FSXOUT = 0 configures the FSX pin as an input. FSXOUT = 1 configures the FSX pin as an output. If XSREMPTY = 0, the transmit-shift register is empty. If XSREMPTY = 1, the transmit-shift register is not empty. Reset or XRESET causes this bit to = 0. RSRFULL 0 Receive-shift register full flag If RSRFULL = 1, an overrun of the receiver has occurred. In continuous mode, RSRFULL is set to 1 when both RSR and DRR are full. In noncontinuous mode, RSRFULL is set to 1 when RSR and DRR are full and a new FSR is received. A read causes this bit to be set to 0. This bit can be set to 0 only by a system reset, a serial-port receive reset (RRESET = 1), or a read. When the receiver tries to set RSRFULL to 1 at the same time that the global register is read, the receiver dominates, and RSRFULL is set to 1. If RSRFULL = 0, no overrun of the receiver has occurred. XSREMPTY 12-18 Serial Ports Table 12-2. Serial-Port Global-Control Register Bits Summary (Continued) Abbreviation HS Reset Value 0 Name Handshake Description If HS = 1, the handshake mode is enabled. If HS = 0, the handshake mode is disabled. XCLK SRCE 0 Transmit clock source Receive clock source Transmit data rate mode If XCLK SRCE = 1, the internal transmit clock is used. If XCLK SRCE = 0, the external transmit clock is used. If RCLK SRCE = 1, the internal receive clock is used. If RCLK SRCE = 0, the external receive clock is used. Specifies a fixed or variable data rate mode when transmitting. With a fixed data rate, FSX is active for at least one XCLK cycle and then goes inactive before transmission begins. With variable data rate, FSX is active while all bits are being transmitted. When you use an external FSX and variable data rate signaling, the DX pin is driven by the transmitter when FSX is held active or when a word is being shifted out. RVAREN 0 Receive data rate mode Specifies a fixed or variable data rate mode when receiving. If RVAREN = 0 (fixed data rate), FSX is active for at least one RCLK cycle and then goes inactive before reception begins. If RVAREN = 1 (controlled data rate), FSX is active while all bits are being received. XFSM 0 Transmit frame sync mode Configures the port for continuous mode operation or standard mode operation. If XFSM = 1 (continuous mode), only the first word of a block generates a sync pulse, and the rest are transmitted continuously to the end of the block. If XFSM = 0 (standard mode), each word has an associated sync pulse. RFSM 0 Receive frame sync mode Configures the port for continuous mode operation or standard mode operation. If RFSM = 1 (continuous mode), only the first word of a block generates a sync pulse, and the rest are received continuously to the end of the block. If RFSM = 0 (standard mode), each word received has an associated sync pulse. CLKXP CLKX polarity If CLKXP = 0, CLKX is active high. If CLKXP = 1, CLKX is active low. RCLK SRCE 0 XVAREN 0 Peripherals 12-19 Serial Ports Table 12-2. Serial-Port Global-Control Register Bits Summary (Continued) Abbreviation CLKRP Reset Value 0 Name CLKR polarity Description If CLKRP = 0, CLKR is active (high). If CLKRP = 1, CLKR is active (low). DXP 0 DX polarity If DXP = 0, DX is active (high). If DXP = 1, DX is active (low). DRP 0 DR polarity If DRP = 0, DR is active (high). If DRP = 1, DR is active (low). FSXP 0 FSX polarity If FSXP = 0, FSX is active (high). If FSXP = 1, FSX is active (low). FSRP 0 FSR polarity If FSRP = 0, FSR is active (high). If FSRP = 1, FSR is active (low). XLEN 00 Transmit word length These two bits define the word length of serial data transmitted. All data is assumed to be right justified in the transmit buffer when fewer than 32 bits are specified. 0 0 -- 8 bits 0 1 -- 16 bits RLEN 00 Receive word length 1 0 -- 24 bits 1 1 -- 32 bits These two bits define the word length of serial data received. All data is right justified in the receive buffer. 0 0 -- 8 bits 0 1 -- 16 bits 1 0 -- 24 bits 1 1 -- 32 bits XTINT 0 Transmit timer interrupt enable Transmit interrupt enable If XTINT = 0, the transmit timer interrupt is disabled. If XTINT = 1, the transmit timer interrupt is enabled. If XINT = 0, the transmit interrupt is disabled. If XINT = 1, the transmit interrupt is enabled. Note: The CPU receive flag XINT and the serial-port-to-DMA interrupt (EXINT0 in the IE register) is the OR of the enabled transmit timer interrupt and the enabled transmit interrupt. XINT 0 RTINT 0 Receive timer interrupt enable If RTINT = 0, the receive timer interrupt is disabled. If RTINT = 1, the receive timer interrupt is enabled. 12-20 Serial Ports Table 12-2. Serial-Port Global-Control Register Bits Summary (Continued) Abbreviation RINT Reset Value 0 Name Receive interrupt enable Description If RINT = 0, the receive interrupt is disabled. If RINT = 1, the receive interrupt is enabled. Note: The CPU receive interrupt flag RINT and the serialport-to-DMA interrupt (ERINT0 in the IE register) are the OR of the enabled receive timer interrupt and the enabled receive interrupt. XRESET 0 Transmit reset If XRESET = 0, the transmit side of the serial port is reset. To take the transmit side of the serial port out of reset, set XRESET to 1. Do not set XRESET to 1 until at least three cycles after RESET goes inactive. This applies only to system reset. Setting XRESET to 0 does not change the contents of any of the serial-port control registers. It places the transmitter in a state corresponding to the beginning of a frame of data. Resetting the transmitter generates a transmit interrupt. Reset this bit during the time the mode of the transmitter is set. You can toggle XFSM without resetting the global-control register. RRESET 0 Receive reset If RRESET = 0, the receive side of the serial port is reset. To take the receive side of the serial port out of reset, set RRESET to 1. Do not set RRESET to 1 until at least three cycles after RESET goes inactive. This applies only to system reset. Setting RRESET to 0 does not change the contents of any of the serial-port control registers. It places the receiver in a state corresponding to the beginning of a frame of data. Reset this bit at the same time that the mode of the receiver is set. You can toggle without resetting the global-control register. Peripherals 12-21 Serial Ports 12.2.2 FSX/DX/CLKX Port-Control Register This 32-bit port-control register controls the function of the serial port FSX, DX, and CLKX pins. The register is shown in Figure 12-14. Table 12-3 shows the register bits, bit names, and bit functions. Figure 12-14. FSX/DX/CLKX Port-Control Register 31-16 xx 15-12 xx 11 FSX DATIN R 10 FSX DATOUT R/W 9 FSX I/O R/W 8 FSX FUNC R/W 7 DX DATIN R 6 DX DATOUT R/W 5 DX I/O R/W 4 DX FUNC R/W 3 CLKX DATIN R 2 CLKX DATOUT R/W 1 CLKX I/O R/W 0 CLKX FUNC R/W Notes: 1) R = read, W = write. 2) xx = reserved bit, read as 0. Table 12-3. FSX/DX/CLKX Port-Control Register Bits Summary Abbreviation CLKX FUNC Reset Value 0 Name Clock transmit function Description Controls the function of CLKX. If CLKX FUNC = 0, CLKX is configured as a general-purpose digital I/O port. If CLKX FUNC = 1, CLKX is configured as a serial port pin. CLKX I/O 0 Clock transmit input/output mode If CLKX I/O = 0, CLKX is configured as a general-purpose input pin. If CLKX I/O = 1, CLKX is configured as a general-purpose output pin. Data output on CLKX when configured as general-purpose output. Data input on CLKX when configured as general-purpose input. A write has no effect. DXFUNC controls the function of DX. If DXFUNC = 0, DX is configured as a general-purpose digital I/O port. If DXFUNC = 1, DX is configured as a serial port pin. DX I/O 0 DX input/output mode DX data output If DX I/O = 0, DX is configured as a general-purpose input pin. If DX I/O = 1, DX is configured as a general-purpose output pin. Data output on DX when configured as general-purpose output. CLKX DATOUT 0 x Clock transmit data ouput Clock transmit data input DX function CLKX DATIN DX FUNC 0 DX DATOUT x = 0 or 1 0 12-22 Serial Ports Table 12-3. FSX/DX/CLKX Port-Control Register Bits Summary (Continued) Abbreviation DX DATIN Reset Value x Name DX data input Description Data input on DX when configured as general-purpose input. A write has no effect. Controls the function of FSX. If FSX FUNC = 0, FSX is configured as a general-purpose digital I/O port. If FSX FUNC = 1, FSX is configured as a serial port pin. FSX I/O 0 FSX input/output mode If FSX I/O = 0, FSX is configured as a general-purpose input pin. If FSX I/O = 1, FSX is configured as a general-purpose output pin. FSX DATOUT FSX DATIN x = 0 or 1 FSX FUNC 0 FSX function 0 x FSX data output FSX data input Data output on FSX when configured as general-purpose output. Data input on FSX when configured as general-purpose input. A write has no effect. 12.2.3 FSR/DR/CLKR Port-Control Register This 32-bit port-control register is controlled by the function of the FSR, DR, and CLKR pins. At reset, all bits are set to 0. The register is shown in Figure 12-15. Table 12-4 shows the register bits, bit names, and bit functions. Figure 12-15. FSR/DR/CLKR Port-Control Register 31 xx 16 15 xx 12 11 FSR DATIN R 10 FSR DATOUT R/W 9 FSR I/O R/W 8 FSR FUNC R/W 7 DR DATIN R 6 DR DATOUT R/W 5 DR I/O R/W 4 DR FUNC R/W 3 CLKR DATIN R 2 CLKR DATOUT R/W 1 CLKR I/O R/W 0 CLKR FUNC R/W Notes: 1) R = read, W = write 2) xx = reserved bit, read as 0 Peripherals 12-23 Serial Ports Table 12-4. FSR/DR/CLKR Port-Control Register Bits Summary Abbreviation CLKR FUNC Reset Value 0 Name Clock receive function Description Controls the function of CLKR. If CLKR FUNC = 0, CLKR is configured as a general-purpose digital I/O port. If CLKR FUNC = 1, CLKR is configured as a serial port pin. CLKR I/O 0 Clock receive input/output mode If CLKR I/O = 0, CLKR is configured as a general-purpose input pin. If CLKR I/O = 1, CLKR is configured as a general-purpose output pin. Data output on CLKR when configured as general-purpose output. Data input on CLKR when configured as general-purpose input. A write has no effect. Controls the function of DR. If DR FUNC = 0, DR is configured as a general-purpose digital I/O port. If DR FUNC = 1, DR is configured as a serial port pin. DR I/O 0 DR input/output mode DR data output DR data input If DR I/O = 0, DR is configured as a general-purpose input pin. If DR I/O = 1, DR is configured as a general-purpose output pin. Data output on DR when configured as general-purpose output. Data input on DR when configured as general-purpose input. A write has no effect. FSR FUNC controls the function of FSR. If FSR FUNC = 0, FSR is configured as a general-purpose digital I/O port. If FSR FUNC = 1, FSR is configured as a serial port pin. FSR I/O 0 FSR input/output mode If FSR I/O = 0, FSR is configured as a general-purpose input pin. If FSR I/O = 1, FSR is configured as a general-purpose output pin. FSR DATOUT x = 0 or 1. CLKR DATOUT 0 x Clock receive data output Clock receive data input DR function CLKR DATIN DR FUNC 0 DR DATOUT DR DATIN 0 x FSR FUNC 0 FSR function 0 FSR data output Data output on FSR when configured as general-purpose output. 12-24 Serial Ports Table 12-4. FSR/DR/CLKR Port-Control Register Bits Summary (Continued) Abbreviation FSR DATIN x = 0 or 1. Reset Value x Name FSR data input Description Data input on FSR when configured as general-purpose input. A write has no effect. 12.2.4 Receive/Transmit Timer-Control Register A 32-bit receive/transmit timer-control register contains the control bits for the timer module. At reset, all bits are set to 0. Figure 12-16 shows the register. Bits 5-0 control the transmitter timer. Bits 11 -6 control the receiver timer. The serial port receive/transmit timer function is similar to timer module operation. It can be considered a 16-bit-wide timer. Table 12-5 describes the register bits, bit names, and bit functions. Figure 12-16. Receive/Transmit Timer-Control Register 31 xx 16 15 xx 12 11 RSTAT R 10 xx 9 RCLKSRC R/W 8 RC/P R/W 7 RHLD R/W 6 RGO R/W 5 XSTAT R 4 xx 3 XCLKSRC 2 XC/P R/W 1 XHLD 0 XGO R/W R/W R/W Notes: 1) R = read, W = write 2) xx = reserved bit, read as 0 Table 12-5. Receive/Transmit Timer-Control Register Register Bits Summary Abbreviation XGO Reset Value 0 Name Transmit timer counter restart Function Resets and restarts the transmit timer counter. If XGO = 1 and the timer is not held, the counter is zeroed and begins incrementing on the next rising edge of the timer input clock. The XGO bit is cleared on the same rising edge. Writing 0 to XGO has no effect on the transmit timer. XHLD 0 Transmit counter hold signal If XHLD = 0, the counter is disabled and held in its current state. If XHLD = 1, the internal divide-by-two counter is also held so that the counter continues where it left off. Peripherals 12-25 Serial Ports Table 12-5. Receive/Transmit Timer-Control Register Register Bits Summary (Continued) Abbreviation XC/P Reset Value 0 Name Transmit clock/pulse mode control Function When XC/P = 1, the clock mode is chosen. The signaling of the status flag and external output has a 50 percent duty cycle. When XC/P = 0, the status flag and external output are active for one CLKOUT cycle during each timer period. XCLKSRC 0 Transmit clock source Specifies the source of the transmit timer clock. When XCLKSRC = 1, an internal clock with frequency equal to one-half the CLKOUT frequency is used to increment the counter. When XCLKSRC = 0, you can use an external signal from the CLKX pin to increment the counter. The external clock source is synchronized internally, thus allowing for external asynchronous clock sources that do not exceed the specified maximum allowable external clock frequency, that is, less than f(H1)/2.6. XTSTAT 0 Transmit timer status Indicates the status of the transmit timer. It tracks what would be the output of the uninverted CLKX pin. This flag sets a CPU interrupt on a transition from 0 to 1. A write has no effect. RGO 0 Receive timer counter restart Resets and starts the receive timer counter. When RGO is set to 1 and the timer is not held, the counter is zeroed and begins incrementing on the next rising edge of the timer input clock. The RGO bit is cleared on the same rising edge. Writing 0 to RGO has no effect on the receive timer. RHLD 0 Receive counter hold signal If RHLD = 0, the counter is disabled and held in its current state. If RHLD = 1, the internal divide-by-2 counter is also held so that the counter will continue where it left off. You can read and modify the timer registers while the timer is being held. RESET has priority over RHLD. RC/P 0 Rclock/pulse mode control When RC/P = 1, the clock mode is chosen. The signaling of the status flag and external output has a 50% duty cycle. When RC/P = 0, the status flag and external output are active for one CLKOUT cycle during each timer period. 12-26 Serial Ports Table 12-5. Receive/Transmit Timer-Control Register Register Bits Summary (Continued) Abbreviation RCLKSRC Reset Value 0 Name Receive timer clock source Function Specifies the source of the receive timer clock. When RCLKSRC = 1, an internal clock with frequency equal to one-half the CLKOUT frequency is used to increment the counter. When RCLKSRC = 0, you can use an external signal from the CLKR pin to increment the counter. The external clock source is synchronized internally, allowing for external asynchronous clock sources that do not exceed the specified maximum allowable external clock frequency (that is, less than f(H1)/2.6). RTSTAT 0 Receive timer status Indicates the status of the receive timer. It tracks what would be the output of the uninverted CLKR pin. This flag sets a CPU interrupt on a transition from 0 to 1. A write has no effect. 12.2.5 Receive/Transmit Timer-Counter Register The receive/transmit timer-counter register is a 32-bit register (see Figure 12-17). Bits 15-0 are the transmit timer-counter, and bits 31 -16 are the receive timer-counter. Each counter is cleared to 0 whenever it increments to the value of the period register (see Section 12.2.6). It is also set to 0 at reset. Figure 12-17. Receive/Transmit Timer-Counter Register 31 Receive counter 15 Transmit counter Note: All bits are read/write. 0 16 Peripherals 12-27 Serial Ports 12.2.6 Receive/Transmit Timer-Period Register The receive/transmit timer-period register is a 32-bit register (see Figure 12-18). Bits 15-0 are the timer transmit period, and bits 31-16 are the receive period. Each register specifies the period of the timer and is cleared to 0 at reset. Figure 12-18. Receive/Transmit Timer-Period Register 31 Receive period 15 Transmit period Note: All bits are read/write. 0 16 12.2.7 Data-Transmit Register When the data-transmit register (DXR) is loaded, the transmitter loads the word into the transmit-shift register (XSR), and the bits are shifted out. The delay from a write to DXR until an FSX occurs (or can be accepted) is two CLKX cycles. The word is not loaded into the shift register until the shifter is empty. When DXR is loaded into XSR, the XRDY bit is set, specifying that the buffer is available to receive the next word. Four tap points within the transmit-shift register are used to transmit the word. These tap points correspond to the four-data word sizes and are illustrated in Figure 12-19. The shift is a left-shift (LSB to MSB) with the data shifted out of the MSB corresponding to the appropriate tap point. Figure 12-19. Transmit Buffer Shift Operation Shift direction 31 24 23 16 15 8 7 0 32-bit word tap 24-bit word tap 16-bit word tap 8-bit word tap 12.2.8 Data-Receive Register When serial data is input, the receiver shifts the bits into the receive-shift register (RSR). When the specified number of bits are shifted in, the data-receive register (DRR) is loaded from RSR, and the RRDY status bit is set. The receiver is doublebuffered. If the DRR has not been read and the RSR is full, the receiver is frozen. New data coming into the DR pin is ignored. The receive shifter does not write over the DRR. The DRR must be read to allow new data in the RSR to be transferred to the DRR. When a write to DRR occurs at the same time that an RSR-to-DRR transfer takes place, the RSR-to-DRR transfer has priority. 12-28 Serial Ports Data is shifted to the left (LSB to MSB). Figure 12-20 illustrates what happens when words less than 32 bits are shifted into the serial port. In this figure, it is assumed that an 8-bit word is being received and that the upper three bytes of the receive buffer are originally undefined. In the first portion of the figure, byte a has been shifted in. When byte b is shifted in, byte a is shifted to the left. When the data-receive register is read, both bytes a and b are read. Figure 12-20. Receive Buffer Shift Operation Shift direction 31 After byte a X 24 23 X 16 15 X 8 7 a 0 After byte b X X a b 12.2.9 Serial-Port Operation Configurations Several configurations are provided for the operation of the serial-port clocks and timer. The clocks for each serial port can originate either internally or externally. Figure 12-21 shows serial-port clocking in the I/O mode (CLKXFUNC = 0) when CLKX is either an input or an output. Figure 12-22 shows clocking in the serial-port mode (CLKXFUNC=1). Both figures use a transmit section for an example. The same relationship holds for a receive section. Peripherals 12-29 Serial Ports Figure 12-21. Serial-Port Clocking in I/O Mode CLKX FUNC= 0 (I/O mode) CLKX I/O = 1 (CLKX, an output) XCLK SRC = 1 (internal CLK for timer) (a) Internal TSTAT Timer in XSR DATOUT DATIN Internal clock External TSTAT Timer in CLKX XSR DATAOUT DATIN CLKX CLKX FUNC= 0 (I/O mode) CLKX I/O = 1 (CLKX, an output) XCLK SRC = 0 (external CLK for timer) (b) Internal External CLKX FUNC= 0 (I/O mode) CLKX I/O = 0 (CLKX, an input) XCLK SRC = 1 (internal CLK for timer) (c) Internal External TSTAT Timer in XSR DATOUT (NC) DATIN Internal clock CLKX CLKX FUNC= 0 (I/O mode) CLKX I/O = 0 (CLKX, an input) XCLK SRC = 0 (external CLK for timer) (d) Internal TSTAT Timer in CLKX XSR DATOUT (NC) DATIN External 12-30 Serial Ports Figure 12-22. Serial-Port Clocking in Serial-Port Mode CLKX FUNC= 1 (serial-port mode) CLKX I/O = 1 (output serial-port CLK) XCLK SRC = 0 or 1 (a) TSTAT Internal External Internal clock CLKX INV DATOUT (NC) DATIN TSTAT CLKX FUNC= 1 (serial-port mode) CLKX I/O = 0 (input serial-port CLK) XCLK SRC = 1 (internal CLK for timer) (b) Internal External Timer Internal clock CLKX INV Timer XSR DATOUT (NC) DATIN XSR CLKX FUNC= 1 (serial-port mode) CLKX I/O = 0 (input serial-port CLK) XCLK SRC = 0 (external CLK for timer) (c) Internal TSTAT Timer CLKX XSR DATOUT (NC) DATIN INV External 12.2.10 Serial-Port Timing The formula for calculating the frequency of the serial-port clock with an internally generated clock depends upon the operation mode of the serial-port timers, defined as: f (pulse mode) = f (timer clock)/period register f (clock mode) = f (timer clock)/(2 x period register) An internally generated clock source f (timer clock) has a maximum frequency of f(H1)/2. An externally generated serial-port clock f (timer clock) (CLKX or CLKR) has a maximum frequency of less than f(H1)/2.6. See section 12.1.5 on page 12-7 for information on timer pulse/clock generation. Transmit data is clocked out on the rising edge of the selected serial-port clock. Receive data is latched into the receive-shift register on the falling edge of the serial-port clock. All data is received MSB first and shifted to the left. If fewer than 32 bits are received, the data received is right-justified in the receive buffer. Peripherals 12-31 Serial Ports The transmit ready (XRDY) signal specifies that the data-transmit register (DXR) is available to be loaded with new data. XRDY goes active as soon as the data is loaded into the transmit-shift register (XSR). The last word may still be shifting out when XRDY goes active. If DXR is loaded before the last word has completed transmission, the data bits transmitted are consecutive; that is, the LSB of the first word immediately precedes the MSB of the second, with all signaling valid as in two separate transmits. XRDY goes inactive when DXR is loaded and remains inactive until the data is loaded into the shifter. The receive ready (RRDY) signal is active as long as a new word of data is loaded into the data-receive register and has not been read. As soon as the data is read, the RRDY bit is turned off. When FSX is specified as an output, the activity of the signal is determined by the internal state of the serial port. If a fixed data rate is specified, FSX goes active when DXR is loaded into XSR. One serial-clock cycle later FSX turns inactive and data transmission begins. If a variable data rate is specified, the FSX pin is activated when the data transmission begins and remains active during the entire transmission of the word. Again, the data is transmitted one clock cycle after it is loaded into the data-transmit register. An input FSX in the fixed data-rate mode must go active for at least one serialclock cycle and then inactive to initiate the data transfer. The transmitter then sends the number of bits specified by the XLEN (bit field 19, serial-port globalcontrol register) bits. In the variable data-rate mode, the transmitter begins sending from the time FSX goes active until the number of specified bits have been shifted out. In the variable data-rate mode, when the FSX status changes prior to all the data bits being shifted out, the transmission completes, and the DX pin is placed in a high-impedance state. An FSR input is exactly complementary to the FSX. When using an external FSX, if DXR and XSR are empty, a write to DXR results in a DXR-to-XSR transfer. This data is held in the XSR until an FSX occurs. When the external FSX is received, the XSR begins shifting the data. If XSR is waiting for the external FSX, a write to DXR changes DXR, but a DXR-to-XSR transfer does not occur. XSR begins shifting when the external FSX is received, or when it is reset using XRESET. 12-32 Serial Ports 12.2.10.1 Continuous Transmit and Receive Modes When you choose continuous mode, consecutive writes do not generate or expect new sync pulse signaling. Only the first word of a block begins with an active synchronization. Thereafter, data is transmitted as long as new data is loaded into DXR before the last word has been transmitted. As soon as TXRDY is active and all of the data has been transmitted out of the shift register, the DX pin is placed in a high-impedance state, and a subsequent write to DXR initiates a new block and a new FSX. Similarly with FSR, the receiver continues shifting in new data and loading DRR. If the data-receive buffer is not read before the next word is shifted in, you will lose subsequent incoming data. You can use the RFSM bit to terminate the receive-continuous mode. 12.2.10.2 Handshake Mode The handshake mode (HS = 1) allows for direct connection between processors. In this mode, all data words are transmitted with a leading 1 (see Figure 12-23). For example, in order to transmit an 8-bit word, the first bit sent is a 1, followed by the 8-bit data word. Once the serial port transmits a word in this mode, it does not transmit another word until it receives a separately transmitted 0 bit. Therefore, the 1 bit that precedes every data word is a request bit. Figure 12-23. Data Word Format in Handshake Mode Data word (8 bits) DX 1 Leading 1 After a serial port receives a word that has been read from the DRR (with the leading 1), the receiving serial port sends a single 0 to the transmitting serial port. The single 0 bit acts as an acknowledge bit (see Figure 12-24). This single acknowledge bit is sent every time the DRR is read, even if the DRR does not contain new data. Figure 12-24. Single 0 Sent as an Acknowledge Bit DX 0 Single 0 Peripherals 12-33 Serial Ports When the serial port is placed in the handshake mode, the insertion and deletion of a leading 1 for transmitted data, the sending of a 0 for acknowledgement of received data, and the waiting for this acknowledge bit are all performed automatically. Using this scheme, it is simple to connect processors with no external hardware and to guarantee secure communication. Figure 12-25 is a typical configuration. In the handshake mode, FSX is automatically configured as an output. Continuous mode is automatically disabled. After a system reset or XRESET, the transmitter is always permitted to transmit. The transmitter and receiver must be reset when entering the handshake mode. Figure 12-25. Direct Connection Using Handshake Mode 'C3x #1 CLKX FSX DX CLKR FSR DR 'C3x #2 CLKR FSR DR CLKX FSX DX 12.2.11 Serial-Port Interrupt Sources A serial port has the following interrupt sources: - Transmit-timer interrupt. The rising edge of XTSTAT causes a single- cycle interrupt pulse to occur. When XTINT is 0, this interrupt pulse is disabled. - Receive-timer interrupt. The rising edge of RTSTAT causes a single- cycle interrupt pulse to occur. When RTINT is 0, this interrupt pulse is disabled. - Transmitter-interrupt. Occurs immediately following a DXR-to-XSR transfer. The transmitter interrupt is a single-cycle pulse. When the serialport global-control register bit XINT is 0, this interrupt pulse is disabled. - Receiver-interrupt. Occurs immediately following an RSR-to-DRR trans- fer. The receiver interrupt is a single-cycle pulse. When the serial-port global-control register bit RINT is 0, this interrupt pulse is disabled. The transmit-timer interrupt pulse is ORed with the transmitter interrupt pulse to create the CPU-transmit interrupt flag XINT. The receive-timer interrupt pulse is ORed with the receiver interrupt pulse to create the CPU receive-interrupt flag RINT. 12-34 Serial Ports 12.2.12 Serial-Port Functional Operation The following paragraphs and figures illustrate the functional timing of the various serial-port modes of operation. The timing descriptions are presented with the assumption that all signal polarities are configured to be positive (that is, CLKXP = CLKRP = DXP = DRP = FSXP = FSRP = 0). Logical timing, in situations where one or more of these polarities are inverted, is the same except with respect to the opposite polarity reference points (that is, rising vs. falling edges, etc.). These discussions pertain to the numerous operating modes and configurations of the serial-port logic. When it is necessary to switch operating modes or change configurations of the serial port, you should do so only when XRESET or RRESET are asserted (low), as appropriate. When transmit configurations are modified, XRESET should be low, and when receive configurations are modified, RRESET should be low. When you use handshake mode, however, since the transmitter and receiver are interrelated, you should make any configuration changes with XRESET and RRESET both low. All of the serial-port operating configurations can be classified in two categories: fixed data-rate timing and variable data-rate timing. Both categories support operation in either burst or continuous mode. Burst-mode operation with variable data-rate timing is similar to burst-mode operation with fixed data-rate timing. With variable data-rate timing, however, FSX/R and data timing differ slightly at the beginning and end of transfers. Specifically, there are three major differences between fixed and variable datarate timing: - FSX/R pulses typically last for the entire transfer interval in variable data- rate timing operation, although FSR and external FSX are ignored after the first bit transferred. FSX/R pulses in fixed data-rate mode typically last only one CLKX/R cycle but can last longer. - With variable data-rate timing, data transfer begins during the CLKX/R cycle in which FSX/R occurs. With fixed data-rate timing, data transfer begins in the CLKX/R cycle following FSX/R. - With variable data-rate timing, frame sync inputs are ignored until the end of the last bit transferred. With fixed data-rate timing, frame sync inputs are ignored until the beginning of the last bit transferred. The following paragraphs discuss fixed and variable data-rate operation and all of their variations. Peripherals 12-35 Serial Ports 12.2.12.1 Fixed Data-Rate Timing Operation Fixed data-rate serial-port transfers can occur in two varieties: burst mode and continuous mode. In burst mode, transfers of single words are separated by periods of inactivity on the serial port. In continuous mode, there are no gaps between successive word transfers; the first bit of a new word is transferred on the next CLKX/R pulse following the last bit of the previous word. This occurs continuously until the process is terminated. The following variations are included in fixed data-rate timing operations. - Fixed Burst Mode In burst mode with fixed data-rate timing, FSX/FSR pulses initiate transfers, and each transfer involves a single word. With an internally generated FSX (see Figure 12-26), transmission is initiated by loading DXR. In this mode, there is a delay of approximately 2.5 CLKX cycles (depending on CLKX and H1 frequencies) from the time DXR is loaded until FSX occurs. With an external FSX, the FSX pulse initiates the transfer, and the 2.5-cycle delay effectively becomes a setup requirement for loading DXR with respect to FSX. In this case, you must load DXR no later than three CLKX cycles before FSX occurs. Once the XSR is loaded from the DXR, an XINT is generated. Figure 12-26. Fixed Burst Mode CLKX/R FSR/FSX (external) FSX (internal) DX/DR A1 AN R/XVAREN = 0 R/XFSM = 0 DXR loaded XINT RINT In receive operations, once a transfer is initiated, FSR is ignored until the last bit. For burst-mode transfers, FSR must be low during the last bit, or another transfer will be initiated. After a full word has been received and transferred to the DRR, an RINT is generated. - Fixed Standard Mode In fixed data-rate mode, you can perform continuous transfers even if R/XFSM = 0, as long as properly timed frame synchronization is provided, or as long as DXR is reloaded each cycle with an internally generated FSX (see Figure 12-27). 12-36 Serial Ports Figure 12-27. Fixed Standard Mode With Back-to-Back Frame Sync CLKX/R FSX (Internal) FSR/FSX (External) DR/DX A1 AN B1 BN C1 R/XVAREN = 0 R/XFSM = 0 DXR loaded with A XINT DXR loaded with B XINT RINT XINT RINT Load DXR with C read DRR Load DXR with Dread DRR For receive operations and with externally generated FSX, once transfers have begun, frame sync pulses are required only during the last bit transferred to initiate another contiguous transfer. Otherwise, frame sync inputs are ignored. Continuous transfers occur if the frame sync is held high. With an internally generated FSX, there is a delay of approximately 2.5 CLKX cycles from the time DXR is loaded until FSX occurs. This delay occurs each time DXR is loaded; therefore, during continuous transmission, the instruction that loads DXR must be executed by the N-3 bit for an N-bit transmission. Since delays due to pipelining vary, you should incorporate a conservative margin of safety in allowing for this delay. Once the process begins, an XINT and an RINT are generated at the beginning of each transfer. The XINT indicates that the XSR has been loaded from DXR and can be used to cause DXR to be reloaded. To maintain continuous transmission in fixed rate mode with frame sync, especially with an internally generated FSX, DXR must be reloaded early in the ongoing transfer. The RINT indicates that a full word has been received and transferred into the DRR; RINT indicates an appropriate time to read DRR. Continuous transfers are terminated by discontinuing frame sync pulses or, in the case of an internally-generated FSX, not reloading DXR. - Fixed Continuous Mode You can accomplish continuous serial-port transfers, without the use of frame sync pulses, if R/XFSM is set to 1. In this mode, operation of the serial port is similar to continuous operation with frame sync, except that a frame sync pulse is involved only in the first word transferred, and no further frame sync pulses are used. Following the first word transferred (see Figure 12-28), no internal frame sync pulses are generated, and frame Peripherals 12-37 Serial Ports sync inputs are ignored. Additionally, you should set R/XFSM prior to or during the first word transferred; you must set R/XFSM no later than the transfer of the N-1 bit of the first word, except for transmit operations. For transmit operations in the fixed data-rate mode, XFSM must be set no later than the N-2 bit. You must clear R/XFSM no later than the N-1 bit to be recognized in the current cycle. Figure 12-28. Fixed Continuous Mode Without Frame Sync CLKX/R FSR/FSX (external) FSX (internal) DR/DX A1 AN B1 BN C1 R/XVAREN = 0 R/XFSM = 1 XINT DXR loaded Set R/XFSM XINT RINT Load DXR read DRR XINT RINT Load DXR read DRR DXR loaded The timing of RINT and XINT and data transfers to and from DXR and DRR, respectively, are the same as in fixed data-rate standard mode with back-to-back frame syncs. This mode of operation also exhibits the same delay of 2.5 CLKX cycles after DXR is loaded before an internal FSX is generated. As in the case of continuous operation in fixed data-rate mode with frame sync, you must reload DXR no later than transmission of the N-3 bit. - Enabling or Disabling Frame Syncs in Fixed Mode When you use continuous operation in fixed data-rate mode, you can set and clear R/XFSM as desired, even during active transfers, to enable or disable the use of frame sync pulses as dictated by system requirements. Under most conditions, changing the state of R/XFSM occurs during the transfer in which the R/XFSM change was made, provided the change was made early enough in the transfer. For transmit operations with internal FSX in fixed data-rate mode, however, a 1-word delay occurs before frame sync pulse generation resumes when clearing XFSM to 0 (see Figure 12-29). In this case, one additional word is transferred before the next FSX pulse is generated. The clearing of XFSM is recognized during the transmission of the word currently being transmitted as long as XFSM is cleared no later than the N-1 bit. The setting of XFSM is recognized as long as XFSM is set no later than the N-2 bit. 12-38 Serial Ports Figure 12-29. Exiting Fixed Continuous Mode Without Frame Sync, FSX Internal 1st word CLKX FSX (internal) DX A1 AN B1 BN C1 CN D1 DN E1 EN F1 FN 2nd word 3rd word 4th word 5th word LOAD DXR SET XFSM RESET XFSM 12.2.12.2 Variable Data-Rate Timing Operation The following variations are included in variable data-rate timing operations. - Variable Burst Mode In burst mode with variable data-rate timing, FSX/FSR pulse lasts for the entire duration of transfer. With an internally generated FSX (see Figure 12-30), transmission is initiated by loading DXR. In this mode there is a delay of approximately 3.5 CLKX cycles (depending on CLKX and H1 freqency) from the time DXR is loaded until FSX occurs. With an external FSX, the FSX pulse initiates the transfer and the 3.5-cycle delay effectively becomes a setup requirement for loading DXR with respect to FSX. Therefore, in this case, you must load DXR no later than four CLKX cycles before FSX occurs. Once the XSR is loaded from the DXR, an XINT is generated. Figure 12-30. Variable Burst Mode CLKX/R FSR/FSX (external) FSX (internal) DX/DR A1 AN R/XVAREN = 1 R/XFSM = 0 DXR loaded XINT RINT Peripherals 12-39 Serial Ports - Variable Standard Mode When you transmit continuously in variable data-rate mode with frame sync, timing is the same as for fixed data-rate mode, except for the differences between these two modes as described in Section 12.2.12 Serial-Port Functional Operation, on page 12-35. The only other exception is that you must reload DXR no later than the N-4 bit to maintain continuous operation of the variable data-rate mode (see Figure 12-31); you must reload DXR no later than the N-3 bit to maintain continuous operation of the fixed data-rate mode. Figure 12-31. Variable Standard Mode With Back-to-Back Frame Syncs CLKX/R FSR/FSX (External) FSX (Internal) DX/DR A1 AN B1 BN C1 C2 R/XVAREN = 1 R/XFSM = 0 DXR Loaded with A XINT Load DSR with B XINT RINT Load DXR with C Read DRR XINT RINT Load DXR with D Read DRR Continuous operation in variable data-rate mode without frame sync (see Figure 12-32) is similar to continuous operation without frame sync in fixed data-rate mode (see Figure 12-28). As with variable data-rate standard mode with back-to-back frame syncs, you must reload DXR no later than the N-4 bit to maintain continuous operation. Additionally, when R/XFSM is set or cleared in the variable data-rate mode, you must make the modification no later than the N-1 bit for the result to be affected in the current transfer. 12-40 Serial Ports Figure 12-32. Variable Continuous Mode Without Frame Sync CLKX/R FSR/FSX (external) FSX (internal) DX/DR A1 AN B1 BN C1 C2 R/XVAREN = 1 R/XFSM = 1 XINT DXR loaded with A Set R/XFS M XINT RINT XINT RINT DXR loaded with B Load DXR with C read DRR Load DXR with D read DRR 12.2.13 Serial-Port Initialization/Reconfiguration The serial ports are controlled through memory-mapped registers on the dedicated peripheral bus. A general procedure for initializing and/or reconfiguring the serial ports follows. 1) Halt the serial port by clearing the XRESET and/or RRESET bits of the serialport global-control register. To do this, write a 0 to the serial-port globalcontrol register. The serial ports are halted on RESET. 2) Configure the serial port via the serial-port global-control register (with XRESET = RRESET = 0) and the FSX/DX/CLKX and FSR/DR/CLKR portcontrol registers. If necessary, configure the receive/transmit registers; timer control (with XHLD = RHLD = 0), timer counter, and timer period. Refer to section 12.2.14 for more information. 3) Start the serial-port operation by setting the XRESET and RRESET bits of the serial-port global-control register and the XHLD and RHLD bits of the serial-port receive/transmit timer-control register, if necessary. 12.2.14 TMS320C3x Serial-Port Interface Examples In addition to the examples presented in this section, you can find DMA/serial port initialization examples in Example 12-9 and Example 12-10 on pages 12-78 and 12-79, respectively. Peripherals 12-41 Serial Ports 12.2.14.1 Handshake Mode Example When using the handshake mode, the transmit (FSX/DS/CLKX) and receive (FSR/DR/CLKR) signals transmit and receive data, respectively. Even if the 'C3x serial port is receiving data only with handshake mode, the transmit signals are still needed to transmit the acknowledge signal. Example 12-3 shows the serial-port register setup for the 'C3x serial-port handshake communication, as shown in Figure 12-25 on page 12-34. Example 12-3. Serial-Port Register Setup #1 Global control Transmit port control Receive port control S_port timer control S_port timer count S_port timer period Note: x = user-configurable = = = = = 011x0x0xxxx00000000xx01100100b, 0111h 0111h 0Fh 0h 01h (if two C3xs have the same system clock). Since FSX is set as an output and continuous mode is disabled when handshake mode is selected, follow these steps: 1) Set the XFSM and RFSM bits to 0 and the FSXOUT bit to 1 in the globalcontrol register. 2) Set the XRESET, RRESET, and HS bits to 1 in order to start the handshake communication. 3) Set the polarity of the serial-port pins active (high) for simplification. 4) Although the CLKX/CLKR can be set as either input or output, set the CLKX as output and the CLKR as input. The rest of the bits are user-configurable as long as both serial ports have consistent setup. You need the serial-port timer only if the CLKX or CLKR is configured as an output. Since only the CLKX is configured as an output, set the timer control register to 0Fh. When you use the serial-port timer, set the serial timer register to the proper value for the clock speed. The serial-port timer clock speed setup is similar to the 'C3x timer. Refer to Section 12.1, Timers, on page 12-2 for detailed information on timer clock generation. The maximum clock frequency for serial transfers is f(CLKIN)/4 if the internal clock is used and f(CLKIN)/5.2 if an external clock is used. If two 'C3xs have the same system clock, the timer-period register should be set equal to or greater than 1, which makes the clock frequency equal to f(CLKIN)/8. 12-42 Serial Ports Example 12-4 and Example 12-5 are serial-port register setups for the above case. (Assume two 'C3xs have the same system clock.) Example 12-4. Serial-Port Register Setup #1 Global control Transmit port control Receive port control S_port timer control S_port timer count S_port timer period = = = = = 0EBC0064h; 32 bits, fixed data rate, burst mode, 0111h ; FSX (output), CLKX (output) = F(CLKIN)/8 0111h ; CLKR (input), handshake mode, transmit 0Fh ; and receive interrupt is enabled. 0h 01h Example 12-5. Serial-Port Register Setup #2 Global control Transmit port control Receive port control S_port timer control S_port timer count S_port timer period = = = = = 0C000364h; 8 bits, variable data rate, burst mode, 0111h; FSX (output), CLKX (output) = f(CLKIN)/24 0111h ; CLKR (input), handshake mode, transmit 0Fh ; and receive interrupt is disabled. 0h 01h Since the data has a leading 1 and the acknowledge signal is a 0 in the handshake mode, the 'C3x serial port can distinguish between the data and the acknowledge signal. Even if the 'C3x serial port receives the data before the acknowledge signal, the data is not misinterpreted as the acknowledge signal and lost. Additionally, the acknowledge signal is not generated until the data is read from the data-receive register (DRR); the 'C3x does not transmit the data and the acknowledge signal simultaneously. 12.2.14.2 CPU Transfer With Serial Port Transmit Polling Method Example 12-6 sets up the CPU to transfer data (128 words) from an array buffer to the serial port 0 output register when the previous value stored in the serialport output register has been sent. Serial port 0 is initialized to transmit 32-bit data words with an internally generated frame sync and a bit-transfer rate of 8H1 cycles/bit. Peripherals 12-43 Serial Ports Example 12-6. CPU Transfer With Serial Port Transmit Polling Method * TITLE: CPU TRANSFER WITH SERIAL-PORT TRANSMIT POLLING METHOD * .GLOBAL START .DATA SOURCE .WORD _ARRAY .BSS _ARRAY,128 ; DATA ARRAY LOCATED IN .BSS SECTION ; THE UNDERSCORE USED IS JUST TO MAKE IT ; ACCESSIBLE FROM C (OPTIONAL) SPORT .WORD 808040H ; SERIAL-PORT GLOBAL CONTROL REG ADDRESS SPRESET .WORD 008C0044 ; SERIAL-PORT RESET SGCCTRL .WORD 048C0044H ; SERIAL-PORT GLOBAL CONTROL REG INITIALIZATION SXCTRL .WORD 111H ; SERIAL-PORT TX PORT CONTROL REG INITIALIZATION STCTRL .WORD 00FH ; SERIAL-PORT TIMER CONTROL REG INITIALIZATION STPERIOD .WORD 00000002h ; SERIAL-PORT TIMER PERIOD RESET .WORD 0H ; SERIAL-PORT TIMER RESET VALUE .TEXT START LDP RESET ; LOAD DATA PAGE POINTER ANDN 10H,IE ; DISABLE SERIAL-PORT TRANSMIT INTERRUPT TO CPU * SERIAL PORT INITIALIZATION LDI @SPORT,AR1 LDI @RESET,R0 LDI 4,IR0 STI R0,*+AR1(IR0) LDI @SPRESET,R0 STI R0,*AR1 LDI @SXCTRL,R0 STI R0,*+AR1(3) LDI @STPERIOD,R0 STI R0,*+AR1(6) LDI @STCTRL,R0 STI R0,*+AR1(4) LDI @SGCCTRL,R0 STI R0,*AR1 * CPU WRITES THE FIRST WORD LDI @SOURCE,AR0 LDI *AR0++,R1 STI R1,*+AR1(8) * CPU WRITES 127 WORDS TO THE SERIAL PORT OUTPUT REG LDI 8,IR0 LDI 2,R0 LDI 126,RC RPTB LOOP WAIT AND *AR1,R0,R2 BZ WAIT LOOP STI R1,*+AR1(IR0) || LDI *++AR0(1),R1 BU $ .END ; SERIAL-PORT TIMER RESET ; SERIAL-PORT RESET ; SERIAL-PORT TX CONTROL REG INITIALIZATON ; SERIAL-PORT TIMER PERIOD INITIALIZATION ; SERIAL-PORT TIMER CONTROL REG INITIALIZATION ; SERIAL-PORT GLOBAL CONTROL REG INITIALIZATION ; WAIT UNTIL XRDY BIT = 1 12-44 Serial Ports 12.2.14.3 DMA Transfer With Serial Port Interrupt Example 12-8 and Example 12-9 of Section 12.3.11 on page 12-76 use the DMA synchronized to serial port interrupts to transfer data (128 words) from an array buffer to the serial port0 output register. 12.2.14.4 Serial Analog Interface Chips Interface Example The TLC320C4x analog interface chips (AIC) from Texas Instruments offer a zero-glue-logic interface to the 'C3x family of DSPs. The interface is shown in Figure 12-33 as an example of the 'C3x serial-port configuration and operation. Figure 12-33. TMS320C3x Zero-Glue-Logic Interface to TLC320C4x Example TMS320C3x XF0 CLKR0 CLKX0 FSR0 DR0 FSX0 DX0 TCLK0 TLC320C4x RESET SCLK FSR DR FSX DX MCLK WORD OUT+ OUT- IN+ IN- GND VCC Analog Out Analog In The 'C3x resets the AIC through the external pin XF0. It also generates the master clock for the AIC through the timer 0 output pin, TCLK0. (Precise selection of a sample rate may require the use of an external oscillator rather than the TCLK0 output to drive the AIC MCLK input.) In turn, the AIC generates the CLKR0 and CLKX0 shift clocks as well as the FSR0 and FSX0 frame synchronization signals. A typical use of the AIC requires an 8-kHz sample rate of the analog signal. If the clock input frequency to the 'C3x device is 30 MHz, you should load the following values into the serial port and timer registers. Serial Port: Port global-control register FSX/DX/CLKX port-control register FSR/DR/CLKR port-control register Timer: Timer global-control register Timer-period register 0E970300h 00000111h 00000111h 000002C1h 00000001h Peripherals 12-45 Serial Ports 12.2.14.5 Serial Analog-to-Digital (A/D) and Digital-to-Analog (D/A) Interface Example The DSP201/2 and DSP101/2 family of D/As and A/Ds from Burr Brown also offer a zero-glue-logic interface to the 'C3x family of DSPs. The interface is shown in Example 12-7. This interface is used as an example of the 'C3x serial port configuration and operation. Example 12-7. TMS320C3x Zero-Glue-Logic Interface to Burr Brown A/D and D/A Burr Brown DSP102 A/D CASC +5 V 'C3x XCLK SOUTA SYNC 2.75 V VINB OSC0 OSC1 1 M 12.29 MHz SSF +5 V +5 V +5 V TCLK0 SSF SWL CONV CLKR0 CLKX0 DR0 FSR0 FSX0 DX0 XCLK SINA SINB SYNC VOUTB 3V +5 V Burr Brown DSP202 D/A CASC 2.75 V VINA VOUTA 3V CONV 22 pF 22 pF The DSP102 A/D is interfaced to the 'C3x serial-port receive side; the DSP202 D/A is interfaced to the transmit side. The A/Ds and D/As are hard-wired to run in cascade mode. In this mode, when the 'C3x initiates a convert command to the A/D via the TCLK0 pin, both analog inputs are converted into two 16-bit words, which are concatenated to form one 32-bit word. 1) The A/D signals the 'C3x via the A/D's SYNC signal (connected to the FSR0 pin) that serial data is to be transmitted. 2) The 32-bit word is then serially transmitted, MSB first, out the SOUTA serial pin of the DSP102 to the DR0 pin of the 'C3x serial port. 3) The 'C3x is programmed to drive the analog interface bit clock from the CLKX0 pin of the 'C3x. 12-46 Serial Ports 4) The bit clock drives both the A/D's and D/A's XCLK input. 5) The 'C3x transmit clock also acts as the input clock on the receive side of the 'C3x serial port. 6) Since the receive clock is synchronous to the internal clock of the 'C3x, the receive clock can run at full speed (that is, f(H1)/2). Similarly, on receiving a convert command, the pipelined D/A converts the last word received from the 'C3x and signals the 'C3x via the SYNC signal (connected to the 'C3x FSX0 pin) to begin transmitting a 32-bit word representing the two channels of data to be converted. The data transmitted from the 'C3x DX0 pin is input to both the SINA and SINB inputs of the D/A as shown in Example 12-7. The 'C3x is set up to transfer bits at the maximum rate of about 8 Mbps, with a dual-channel sample rate of about 44.1 kHz. Assuming a 32-MHz CLKIN, you can configure this standard-mode fixed-data-rate signaling interface by setting the registers as described below: Serial Port: Port global-control register FSX/DX/CLKX port-control register FSR/DR/CLKR port-control register Receive/transmit timer-control register Timer: Timer global-control register Timer-period register 0EBC0040h 00000111h 00000111h 0000000Fh 000002C1h 000000B5h Peripherals 12-47 DMA Controller 12.3 DMA Controller The DMA controller is a programmable peripheral that transfers blocks of data to any location in the memory map without interfering with CPU operation. The 'C3x can interface to slow, external memories and peripherals without reducing throughput to the CPU. The 'C3x DMA controller features are: - Transfers to and from anywhere in the processor's memory map. For example, transfers can be made to and from on-chip memory, off-chip memory, and on-chip serial ports. - One DMA channel for memory-to-memory transfers in `C30 and `C31/VC33. Two DMA channels for memory-to-memory transfers in `C32. - Concurrent CPU and DMA controller operation with DMA transfers at the same rate as the CPU (supported by separate internal DMA address and data buses). - Source and destination-address registers with auto increment/decrement. - Synchronization of data transfers via external and internal interrupts. 12.3.1 DMA Functional Description The DMA controller supports one (`C30 and `C31/VC33) or two (`C32) DMA channels that perform transfers to and from anywhere in the `C3x memory map. Each DMA channel is controlled by four registers that are mapped in the `C3x peripheral address space, as shown in Figure 12-35. The major DMA registers are described in Section 12.3.3. The DMA controller has dedicated on-chip address and data buses (see Figure 2-5 through Figure 2-7 on pages 2-14 through 2-16 for a block diagram of the peripherals of the `C3x). All accesses made by the DMA channels are arbitrated in the DMA controller and take place over these dedicated buses. The DMA channels transfer data in a sequential time-slice fashion, rather than simultaneously, because they share common buses. The DMA channels can run constantly or can be triggered by external (INT3-0) or internal (on-chip timers and serial ports) interrupts. 12-48 DMA Controller 12.3.1.1 TMS320C30 and TMS320C31/VC33 DMA Controller The 'C30 and 'C31/VC33 have an on-chip direct memory access (DMA) controller that reduces the need for the CPU to perform input/output functions. The DMA controller can perform input/output operations without interfering with the operation of the CPU. Therefore, it is possible to interface the 'C30 and 'C31/VC33 to slow external memories and peripherals (A/Ds, serial ports, etc.) without reducing the computational throughput of the CPU. The result is improved system performance and decreased system cost. 12.3.1.2 TMS320C32 Two-Channel DMA Controller The 'C32 has an improved DMA that supports two channels and configurable priorities. The next sections discuss the new features. The 'C32 has a two-channel (channel 0 and channel 1) DMA instead of a onechannel DMA as in the 'C30/'C31/VC33 devices. The 'C32's DMA functions similarly to that of the 'C30/'C31/VC33 DMA but with the addition of DMA/CPU priority scheme and inter-DMA priority mode. Although the 'C32 CPU supports both floating-point and integer data access with different data size from the external memory, the 'C32's DMA transfer is strictly an integer data transfer. The integer data access of the 'C32 DMA is the same as the CPU integer data access -- 32-bit internal and data size conversion at the external memory interface port. Peripherals 12-49 DMA Controller 12.3.2 DMA Basic Operation If a block of data is to be transferred from one region in memory to another region in memory (as shown in Figure 12-34), the following sequence is performed: DMA Registers Initialization 1) The source-address register of a DMA channel is loaded with the address of the memory location to read from. 2) The destination-address register of the same DMA channel is loaded with the address of the memory location to write to. 3) The transfer counter is loaded with the number of words to be transferred. 4) The DMA channel control register is loaded with the appropriate modes to synchronize the DMA controller reads and writes with interrupts. DMA Start 5) The DMA controller is started through the DMA START field in the DMA channel control register. Word Transfers 6) The DMA channel reads a word from the source-address register and writes it to a temporary register within the DMA channel. 7) After a read by the DMA channel, the source-address register is incremented, decremented, or unchanged depending on the INCSRC or DECSRC bit fields of DMA channel control register. 8) After the read operation completes, the DMA channel writes the temporary register value to the destination-address pointed to by the destinationaddress register. 9) After the destination-address has been fetched, the transfer-counter register is decremented and the destination-address register is incremented, decremented, or unchanged, depending on the INCDST or DECDST bit fields of the DMA channel control register. 10) During every data write, the transfer counter is decremented. The block transfer terminates when the transfer counter reaches zero and the write of the last transfer is completed. The DMA channel sets the transfer-counter interrupt (TCINT) flag in the DMA channel control register. 12-50 DMA Controller After the completion of a block transfer, the DMA controller can be programmed to do several things: - Stop until reprogrammed (TC = 1) - Continue transferring data (TC = 0) - Generate an interrupt to signal the CPU that the block transfer is complete (TCINT = 1) The DMA can be stopped by setting the START bits to 00, 01, or 10. When the DMA is restarted (START = 11), it completes any pending transfer. Figure 12-34. DMA Basic Operation External or Internal memory DMA channel Temporary register External or Internal memory Memory pointed to by DMA destination-address register Memory pointed to by DMA source-address register 12.3.3 DMA Registers Each DMA channel has four registers designated as follows: - Control register: contains the status and mode information about the associated DMA channel - Source-address register: contains the memory address of data to be read - Destination-address register: contains the memory address where data is written - Transfer-counter register: contains the block size to move After reset, the control register, the transfer counter, and the auxiliary transfercounter registers are set to 0s and the other registers are undefined. Figure 12-36 shows these registers for 'C30 and 'C31/VC33. Figure 12-37 shows these registers for 'C32. The format of the DMA-channel control register is shown in Figure 12-35. The text following the figure describes the functions of each field in the register. Peripherals 12-51 DMA Controller At reset, each DMA-channel control register is set to 0. This makes the DMA channels lower-priority than the CPU, sets up the source address and destination address to be calculated through linear addressing, and configures the DMA channel in the unified mode. Figure 12-35. Memory-Mapped Locations for DMA Channels 12-52 Address 808000h Register DMA 0 global control 808004h DMA 0 source address 808006h DMA 0 destination address 808008h DMA 0 transfer counter DMA 1 global control 808010h 808014h DMA 1 source address 808016h DMA 1 destination address DMA 1 transfer counter 808018h 'C32 only DMA Controller 12.3.3.1 DMA Global-Control Register The global-control register controls the state in which the DMA controller operates. This register also indicates the status of the DMA, which changes every cycle. Source and destination addresses can be incremented, decremented, or synchronized using specified global-control register bits. At system reset, all bits in the DMA control register are cleared to 0. Figure 12-36 shows the global-control registers for the 'C30 and 'C31/VC33 devices. Figure 12-37 and Figure 12-38 show the global-control registers for the 'C32. Table 12-6 shows the register bits, bit names, and bit functions. Figure 12-36. TMS320C30 and TMS320C31/VC33 DMA Global-Control Register 31 xx 15 14 xx 12 11 TCINT R/W Notes: 1) R = read, W = write 2) xx = reserved bit, read as 0 10 TC R/W 9 8 7 6 5 DECSRC R/W 4 INCSRC R/W 3 2 STAT R 1 0 START R/W SYNC R/W DECDST INCDST R/W R/W Figure 12-37. TMS320C32 DMA0 Global-Control Register 31 xx 15 14 PRIORITY MODE R/W 13 12 11 TCINT R/W 10 TC R/W 9 SYNC R/W 8 7 DECDST R/W 6 INCDST R/W 5 DECSRC R/W 4 INCSRC R/W 3 STAT R 2 1 0 DMAO PRI R/W START R/W Notes: 1) R = read, W = write 2) xx = reserved bit, read as 0 Figure 12-38. TMS320C32 DMA1 Global-Control Register 31 xx 15 14 xx 13 12 11 TCINT R/W 10 TC R/W 9 SYNC R/W 8 7 DECDST R/W 6 INCDST R/W 5 DECSRC R/W 4 INCSRC R/W 3 STAT R 2 1 0 DMA1 PRI R/W START R/W Notes: 1) R = read, W = write 2) xx = reserved bit, read as 0 Peripherals 12-53 DMA Controller Table 12-6. DMA Global-Control Register Bits Summary Abbreviation START Reset Value 00 Name DMA start control Description Controls the state in which the DMA starts and stops. The DMA may be stopped without any loss of data. The following table summarizes the START bits and DMA operation: Bit 1 0 Bit 0 0 Function DMA read or write cycles in progress are completed; any data read is ignored. Any pending read or write is cancelled. The DMA is reset so that when it starts, a new transaction begins; that is, a read is performed (Reset value). If a read or write has begun, it is completed before it stops. If a read or write has not begun, no read or write is started. If a DMA transfer has begun, the entire transfer is complete (including both read and write operations) before stopping. If a transfer has not begun, none is started. DMA starts from reset or restarts from the previous state. 0 1 1 0 1 1 When the DMA completes a transfer, the START bits remain in 11 (base 2). The DMA starts when the START bits are set to 11 and one of the following conditions applies: - The transfer counter is set to a value different from 0x0. The TC bit is set to 0. STAT 00 DMA status Indicates the status of the DMA and changes every cycle. The following table summarizes the STAT bits and DMA status. Bit 3 0 Bit 2 0 Function The DMA is being held between DMA transfer (between a write and a read). This is the value at reset. DMA is being held in the middle of a DMA transfer (between a read and a write). Reserved. DMA busy. DMA is performing a read or write or waiting for a source or destination synchronization interrupt. 0 1 1 1 0 1 12-54 DMA Controller Table 12-6. DMA Global-Control Register Bits Summary (Continued) Abbreviation INCSRC DECSRC Reset Value 0 0 Name DMA source address increment mode DMA source address decrement mode Description If INCSRC = 1, the source address is incremented after every read. If DECSRC = 1, the source address is decremented after every read. If INCSRC = DECSRC, the source address is not modified after a read. INCDST 0 DMA destination address increment mode DMA destination address decrement mode If INCDST = 1, the destination address is incremented after every write. If DECDST = 1, the destination address is decremented after every write. If INCDST = DECDST, the destination address is not modified after a write. Determines the timing synchronization between the events initiating the source and destination transfers. The following table summarizes the SYNC bits and DMA synchronization. Bit 9 0 0 1 1 Bit 8 0 1 0 1 Function No synchronization. Enabled interrupts are ignored (reset value). Source synchronization. A read is performed when an enabled interrupt occurs. Destination synchronization. A write is performed when an enabled interrupt occurs. Source and destination synchronization. A read is performed when an enabled interrupt occurs. A write is then performed when the next enabled interrupt occurs. DECDST 0 SYNC 0 DMA synchronization mode TC 0 DMA transfer mode Affects the operation of the transfer counter. If TC = 0, transfers are not terminated when the transfer counter becomes 0. If TC = 1, transfers are terminated when the transfer counter becomes 0. TCINT 0 DMA transfer counter interrupt mode If TCINT = 1, the DMA interrupt is set when the transfer counter makes a transition to 0. If TCINT = 0, the DMA interrupt is not set when the transfer counter makes a transition to 0. Peripherals 12-55 DMA Controller Table 12-6. DMA Global-Control Register Bits Summary (Continued) Abbreviation DMA0 PRI Reset Value 00 00 DMA1 PRI Name CPU/DMA channel 0 priority mode CPU/DMA channel 1 priority mode Description (on the DMA0 control register) ('C32 only) (on the DMA1 control register) (`C32 only) Configures CPU/DMA controller priority. (See Section 12.3.6 on page 12-64). The following table explains the DMA PRI bits and CPU/ DMA priorities. Bit 13 Bit 12 Function 0 0 DMA has lower priority than the CPU access. If the DMA channel and the CPU are requesting the same resource, the CPU has priority (reset value). Reserved. Rotating arbitration, which sets priorities be tween the CPU and DMA channel by alternating their accesses (but not exactly equally). Priority rotates between the CPU and DMA accesses when they conflict during consecutive instruction cycles. DMA has higher priority than the CPU access. Ift he DMA channel and the CPU are requesting the same resource, the DMA has priority. 0 1 1 0 1 1 PRIORITY MODE 0 DMA channels priority mode If PRIORITY MODE = 0, fixed priority for the two DMA channels. DMA channel 0 always has priority over DMA channel 1. If priority mode = 1, rotating priority for the two DMA channels. DMA channel 0 has priority after the device is reset. After reset, the last channel serviced has the lowest priority. The arbitration is performed at DMA service boundaries, that is, after either a DMA read or DMA write. See Section 12.3.5 on page 12-62 for more information. 12-56 DMA Controller 12.3.3.2 Destination-Address and Source-Address Registers The DMA destination-address and source-address registers are 24-bit registers whose contents specify destination and source addresses. As specified by control bits DECSRC, INCSRC, DECDST, and INCDST of the DMA globalcontrol register, these registers are incremented, decremented, or remain unchanged at the end of the corresponding memory access; that is, the source register for a read and the destination register for a write (see Figure 12-39). On system reset, 0 is written to these registers. Figure 12-39. DMA Controller Address Generation DMA address bus DMA source-address register DMA source-address generator 0 1 -1 DMA destination-address register DMA destination-address generator Peripherals DMA address bus 0 1 -1 INCSRC DECSRC INCDST DECDST 12-57 DMA Controller 12.3.3.3 Transfer-Counter Register The transfer-counter register is a 24-bit register that contains the number of words to be transmitted. Figure 12-40 shows the transfer-counter operation. It is controlled by a 24-bit counter that decrements at the beginning of a DMA memory write. In this way, it can control the size of a block of data transferred. The transfer-counter register is set to 0 at system reset. When the TCINT bit of the DMA global-control register is set, the transfer-counter register causes a DMA interrupt flag to be set when 0 is reached. The counter is decremented after completing the destination-address fetch. The interrupt is generated after the transfer counter is decremented and after the completion of the write of the last transfer. The decrementer checks whether the transfer counter equals 0 after the decrement is performed. As a result, if the counter register has a value of 1, then the DMA channel can be halted after only one transfer is performed. Thus, by setting the transfer counter to 1, the DMA channel transfers the minimum possible number of words (1 time). The value of the transfer counter is treated as an unsigned integer. Transfers can be halted when a 0 value is detected after a decrement. If the DMA controller channel is not halted after the transfer reaches zero, the counter continues decrementing below 0. Thus, by setting the transfer counter to 0, the DMA channel transfers the maximum possible number of words (100 0000h times). 12-58 DMA Controller Figure 12-40. Transfer-Counter Operation 12.3.4 CPU/DMA Interrupt-Enable Register The CPU/DMA interrupt-enable register (IE) is a 32-bit register located in the CPU register file. The CPU interrupt-enable bits are in locations 10-1. The DMA interrupt-enable bits are in locations 26-16. A 1 in a CPU/DMA interrupt-enable register bit enables the corresponding interrupt. A 0 disables the corresponding interrupt. At reset, 0 is written to this register. Figure 12-41 shows the CPU/DMA interrupt-enable registers for the `C30 and `C31/VC33. Figure 12-42 shows the CPU/DMA interrupt-enable register for the `C32. Table 12-7 describes the register bits, bit names, and bit functions. Transfer-counter register Decrementer Compare to 0 ? Yes Is TCINT=1 ? Yes No No No DMA interrupt generated Is TC=1 ? Yes Halt Peripherals 12-59 DMA Controller Figure 12-41. TMS320C30 and TMS320C31/VC33 CPU/DMA Interrupt-Enable Register 31 30 29 28 27 xx xx xx xx xx 26 EDINT (DMA) R/W 15 14 13 12 11 xx xx xx xx xx 10 EDINT (CPU) R/W 25 ETINT1 (DMA) R/W 9 ETINT1 (CPU) R/W 24 ETINT0 (DMA) R/W 8 ETINT0 (CPU) R/W 23 ERINT1 (DMA) R/W 7 ERINT1 (CPU) R/W 22 EXINT1 (DMA) R/W 6 EXINT1 (CPU) R/W 21 ERINT0 (DMA) R/W 5 ERINT0 (CPU) R/W 20 EXINT0 (DMA) R/W 4 EXINT0 (CPU) R/W 19 EINT3 (DMA) R/W 3 EINT3 (CPU) R/W 18 EINT2 (DMA) R/W 2 EINT2 (CPU) R/W 17 EINT1 (DMA) R/W 1 EINT1 (CPU) R/W 16 EINT0 (DMA) R/W 0 EINT0 (CPU) R/W Notes: 1) R = read, W = write 2) xx = reserved bit, read as 0 Figure 12-42. TMS320C32 CPU/DMA Interrupt-Enable Register 31 EINT3 (DMA1) R/W 30 EINT2 (DMA1) R/W 29 EINT1 28 EINT0 27 EDINT0 (DMA1) R/W 26 25 24 23 ETINT1 (DMA1) R/W 22 ETINT0 (DMA1) R/W 21 ERINT0 (DMA1) R/W 20 EXINT0 (DMA0) R/W 19 EINT3 (DMA0) R/W 18 EINT2 (DMA0) R/W 17 EINT1 16 EINT0 EDINT1 ETINT1 ETINT0 (DMA0) R/W (DMA0) (DMA0) R/W R/W (DMA1) (DMA1) R/W R/W (DMA0) (DMA0) R/W R/W 15 xx 14 xx 13 xx 12 xx 11 EDINT1 (CPU) R/W 10 EDINT0 (CPU) R/W 9 ETINT1 (CPU) R/W 8 ETINT0 (CPU) R/W 7 xx 6 xx 5 4 3 EINT3 (CPU) R/W 2 EINT2 (CPU) R/W 1 EINT1 (CPU) R/W 0 EINT0 (CPU) R/W ERINT0 EXINT0 (CPU) (CPU) R/W R/W Notes: 1) R = read, W = write 2) xx = reserved bit, read as 0 12-60 DMA Controller Table 12-7. CPU/DMA Interrupt-Enable Register Bits Abbreviation EINT0 (CPU) EINT1 (CPU) EINT2 (CPU) EINT3 (CPU) EXINT0 (CPU) ERINT0 (CPU) EXINT1 (CPU) ERINT1 (CPU) ETINT0 (CPU) ETINT1 (CPU) EDINT (CPU) EDINT0 (CPU) EDINT1 (CPU) EINT0 (DMA) EINT1 (DMA) EINT2 (DMA) EINT3 (DMA) EINT0 (DMA0) EINT1 (DMA0) EINT2 (DMA0) EINT3 (DMA0) EXINT0 (DMA) ERINT0 (DMA) EXINT1 (DMA) Reset Value Description 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 CPU external interrupt 0 enable CPU external interrupt 1 enable CPU external interrupt 2 enable CPU external interrupt 3 enable CPU serial port 0 transmit interrupt enable CPU serial port 0 receive interrupt enable CPU serial port 1 transmit interrupt enable ('C30 only) CPU serial port 1 receive interrupt enable ('C30 only) CPU timer0 interrupt enable CPU timer1 interrupt enable CPU DMA controller interrupt enable ('C30 and 'C31/VC33 only) CPU DMA0 controller interrupt enable ('C32 only) CPU DMA1 controller interrupt enable ('C32 only) DMA external interrupt 0 enable ('C30 and 'C31/VC33 only) DMA external interrupt 1 enable ('C30 and 'C31/VC33 only) DMA external interrupt 2 enable ('C30 and 'C31/VC33 only) DMA external interrupt 3 enable ('C30 and 'C31/VC33 only) DMA0 external interrupt 0 enable ('C32 only) DMA0 external interrupt 1 enable ('C32 only) DMA0 external interrupt 2 enable ('C32 only) DMA0 external interrupt 3 enable ('C32 only) DMA serial port 0 transmit interrupt enable ('C30 and 'C31/VC33 only) DMA serial port 0 receive interrupt enable ('C30 and 'C31/VC33 only) DMA serial port 1 transmit interrupt enable ('C30 only) Peripherals 12-61 DMA Controller Table 12-7. CPU/DMA Interrupt-Enable Register Bits (Continued) Abbreviation ERINT1 (DMA) EXINT0 (DMA0) ERINT0 (DMA1) ETINT0 (DMA) ETINT1 (DMA) ETINT0 (DMA0) ETINT1 (DMA0) ETINT0 (DMA1) ETINT1 (DMA1) EDINT (DMA) EDINT1 (DMA0) EDINT0 (DMA1) EINT0 (DMA1) EINT1 (DMA1) EINT2 (DMA1) EINT3 (DMA1) Reset Value Description 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 DMA serial port 1 receive interrupt enable ('C30 only) DMA0 serial port 1 transmit interrupt enable ('C32 only) DMA1 serial port 1 receive interrupt enable ('C32 only) DMA timer0 interrupt enable ('C30 and 'C31/VC33) DMA timer1 interrupt enable ('C30 and 'C31/VC33 only) DMA0 timer1 interrupt enable ('C32 only) DMA0 timer1 interrupt enable ('C32 only) DMA1 timer0 interrupt enable ('C32 only) DMA1 timer1 interrupt enable ('C32 only) DMA controller interrupt enable ('C30 and 'C31/VC33) DMA0-DMA1 controller interrupt enable ('C32 only) DMA1-DMA0 controller interrupt enable ('C32 only) DMA1 external interrupt 0 enable ('C32 only) DMA1 external interrupt 1 enable ('C32 only) DMA1 external interrupt 2 enable ('C32 only) DMA1 external interrupt 2 enable ('C32 only) 12.3.5 TMS320C32 DMA Internal Priority Schemes Because all accesses made by the two DMA channels take place over one common internal DMA data and address bus, a priority scheme for bus arbitration is required. Within the DMA controller, two priority schemes are used to designate which channel is serviced next: - A fixed priority scheme with channel 0 always having the highest priority and channel 1 the lowest - A rotating priority scheme that places the most recently serviced channel at the bottom of the priority list (default setup after reset) 12.3.5.1 Fixed Priority Scheme This scheme provides a fixed (unchanging) priority for each channel as follows: 12-62 DMA Controller Priority Highest Lowest Channel 0 1 To select fixed priority, set the PRIORITY MODE bit (bit 14) of channel 0's DMA-channel control register to 1. Peripherals 12-63 DMA Controller 12.3.5.2 Rotating Priority Scheme In a rotating priority scheme, the last channel serviced becomes the lowest priority channel. The other channel sequentially rotates through the priority list with the lowest channel next to the last-serviced channel becoming the highest priority on the following request. The priority rotates every time the channel most recently granted priority completes its access. At system reset, the channels are ordered from highest to lowest priority (0, 1). To select this scheme, set the PRIORITY MODE bit (bit 14) of channel 0's DMA control register to 0. 12.3.6 CPU and DMA Controller Arbitration The DMA controller transfers data on its own internal buses. Arbitration is necessary only when a resource conflict exists between the DMA controller and the CPU. The arbitration causes no delay. When there is no conflict, the CPU and DMA controller accesses proceed in parallel. All arbitration between the CPU and the DMA controller is on an access basis. DMA controller internal memory access starts during H3 (see Section 8.5, Clocking Memory Access, for more information). When the CPU and DMA controllers request the same resource, priority is determined as follows: - For the `C30 and `C31/VC33, the CPU always has higher priority, thus the DMA must wait until the CPU frees the resource. - For the `C32, the DMA channel's DMA PRI bits (bits 12 and 13 of the channel control register) define the arbitration rules (as shown in Table 12-8). The CPU has higher priority than the DMA when DMA PRI = 002; it has lower priority than the DMA when DMA PRI = 112. They rotate priority when DMA PRI = 012. 12-64 DMA Controller Table 12-8.TMS320C32 DMA PRI Bits and CPU/DMA Arbitration Rules DMA PRI (Bits 13-12) 00 Description DMA access is lower priority than the CPU access. If the DMA channel and the CPU request the same resource, then the CPU has priority. (DMA PRI bits are set to 002 at reset.) This setting selects rotating arbitration, which sets priorities between the CPU and DMA channel by alternating their accesses, but not exactly equally. Priority rotates between CPU and DMA accesses when they conflict during consecutive instruction cycles. The first time the DMA channel and the CPU request the same resource, the CPU has priority. If, in the following instruction cycle, the DMA controller and the CPU again request the same resource, the DMA has priority. Alternate access continues as long as the CPU and DMA requests conflict in consecutive instruction cycles. When there is no conflict in a previous instruction cycle, the CPU has priority. Reserved DMA access is higher priority than the CPU access. If the DMA channel and the CPU request the same resource, the DMA has priority. 01 10 11 12.3.7 DMA and Interrupts The DMA controller uses interrupts in the following way: - It can send interrupts to the CPU or other DMA channel when a block transfer finishes. See the TCINT bit field in the DMA global-control register (Figure 12-36, Figure 12-37, or Figure 12-38 on page 12-53). The EDINT bit field ('C30 and 'C31/VC33) or the EDINT0 and EDINT1 bit fields ('C32) in the interrupt-enable register must be set to allow the CPU to be interrupted by the DMA. - It can receive interrupts from the external interrupt pins (INT3 -0), the timers, the serial ports, or other DMA channel. This section explains how the DMA receives interrupts. This process is called synchronization. All of the interrupts that the DMA controller receives are detected by the CPU interrupt controller and latched by the CPU in the appropriate interrupt-flag register. Peripherals 12-65 DMA Controller The DMA and the CPU can respond to the same interrupt if the CPU is not involved in any pipeline conflict or in any instruction that halts instruction fetching. Refer to section 7.6.2, Interrupt Vector Table and Prioritization, on page 7-29 for more details. It is also possible for different DMA channels to respond to the same interrupt. If the same interrupt is selected for source and destination synchronization, both read and write cycles are enabled with a single incoming interrupt. 12.3.7.1 Interrupts and Synchronization of DMA Channels You can use interrupts to synchronize DMA channels. This section describes the following four synchronization mechanisms: - No synchronization (SYNC = 0 0) When SYNC = 0 0, no synchronization is performed. The DMA performs reads and writes whenever there are no conflicts. All interrupts are ignored and are considered to be globally disabled. However, no bits in the DMA interrupt-enable register are changed. Figure 12-43 shows the synchronization mechanism when SYNC = 0 0. Figure 12-43. Mechanism for No DMA Synchronization Start DMA channel performs a read DMA channel performs a write Go to start - Source synchronization (SYNC = 0 1) When SYNC = 0 1, the DMA is synchronized to the source (see Figure 12-44). A read is not performed until an interrupt is received by the DMA. Then all DMA interrupts are disabled globally. However, no bits in the DMA interrupt-enable register are changed. 12-66 DMA Controller Figure 12-44. Mechanism for DMA Source Synchronization Start Idle until enabled interrupt is received Disable DMA interrupts globally Clear corresponding IF bit DMA channel performs a read Enable DMA interrupts globally DMA channel performs a write Go to start - Destination synchronization (SYNC = 1 0) When SYNC = 1 0, the DMA is synchronized to the destination. First, all interrupts are ignored until the read is complete. Though the DMA interrupts are considered globally disabled, no bits in the DMA interrupt-enable register are changed. A write is not performed until an interrupt is received by the DMA, while the read is performed without waiting for the interrupt. Figure 12-45 shows the synchronization mechanism when SYNC = 1 0. Figure 12-45. Mechanism for DMA Destination Synchronization Start DMA channel performs a read Idle until enabled interrupt is received Disable DMA interrupts globally Clear corresponding IF bit DMA channel performs a write DMA interrupts are enabled globally Go to start Peripherals 12-67 DMA Controller - Source and destination synchronization (SYNC = 1 1) When SYNC = 1 1, the DMA is synchronized to both the source and destination. A read is performed when an interrupt is received. Then, a write is performed on the following interrupt. Figure 12-46 shows source and destination synchronization when SYNC = 1 1. Figure 12-46. Mechanism for DMA Source and Destination Synchronization Start Idle until enabled interrupt is received Disable DMA interrupts globally Clear corresponding IF bit DMA channel performs a read Enable DMA interrupts globally Idle until enabled interrupt is received Disable DMA interrupts globally Clear corresponding IF bit DMA channel performs a write Enable DMA interrupts globally Go to start 12.3.8 DMA Memory Transfer Timing The 'C30 and 'C31/VC33 devices provide one DMA channel, while the 'C32 device provides two DMA channels. The maximum data transfer rate that the 'C3x DMA sustains is one word every two cycles. In the 'C32, the two DMA channels transfer data in a sequential time-slice fashion, rather than simultaneously, because the two channels share one common set of busses. 12-68 DMA Controller The data transfer rate for a DMA channel (assuming a single-channel access with no conflicts between CPU or other DMA channels) is as follows: - On-chip memory and peripheral J J DMA read: DMA write: One cycle One cycle - External memory (STRB, STRB0, STRB1, MSTRB) J J DMA read: DMA write: Two cycles (one cycle external read followed by one cycle load of internal DMA register) Two cycles (identical to CPU write) - External memory (IOSTRB) J J DMA read: DMA write: Three cycles (two-cycle external read followed by one cycle load of internal DMA register) Two cycles (identical to CPU write) If the DMA started and is transferring data over either external bus, do not modify the bus-control register associated with that bus. If you must modify the bus-control register (see Chapter 9 or 10), stop the DMA, make the modification, and then restart the DMA. Failure to do this may produce an unexpected zero-wait-state bus access. DMA memory transfer timing can be very complicated, especially if bus resource conflicts occur. However, some rules help you calculate the transfer timing for certain DMA setups. For simplification, the following section focuses on a singlechannel DMA memory transfer timing with no conflict with the CPU or other DMA channels. You can obtain the actual DMA transfer timing by combining the calculations for single-channel DMA transfer timing with those for bus resource conflict situations. 12.3.8.1 Single DMA Memory Transfer Timing When the DMA memory transfer has no conflict with the CPU or any other DMA channels, the number of cycles of a DMA transfer depends on whether the source and destination location are designated as on-chip memory, peripheral, or external ports. When the external port is used, the DMA transfer speed is affected by two factors: the external bus wait state and the read/write conflict (for example, if a write is followed by a read, the read takes one extra half-cycle. See Figure 12-48 footnote on page 12-72). Figure 12-47 through Figure 12-49 show the number of cycles a DMA transfer requires from different sources to different destinations. Entries in the table represent the number of cycles required to do the T transfers, assuming that there are no pipeline conflicts. A timing diagram for the DMA transfers accompanies each figure. Peripherals 12-69 Figure 12-47. DMA Timing When Destination is On Chip 1 R1 W1 R1 Cr W1 R1 Cr W1 W2 Cr Cr W3 R1 R1 R1 I R2 R2 R2 R2 I R3 R3 R3 R3 I W2 W3 Cr Cr R1 R1 I R2 R2 R2 I R3 R3 R3 I W2 W3 W4 W5 W6 W7 R2 R3 R4 R5 R6 R7 R8 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Rate Cycles (H1) Source on chip (1 + 1) T Destination on chip Source STRB, STRB0, STRB1, MSTRB bus (2 + Cr +1) T Destination on chip Source IOSTRB bus (3 + Cr + 1) T Destination on chip Legend: T = Number of transfers Cr = Source-read wait states Cw = Destination-write wait states R = Single-cycle reads W Rn Wn I = = = = Single-cycle writes Multicycle reads Multicycle writes Internal register cycle Peripherals DMA Controller 12-71 12-72 DMA Controller 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Rate Figure 12-48. DMA Timing When Destination is an STRB, STRB0, STRB1, MSTRB Bus Cycles (H1) 1 2 Source on chip R2 (1 + 2 + Cw) T W1 W1 W1 W2 W2 W2 W2 W3 W3 W3 W3 W4 W4 W4 W4 ... R3 R4 R5 R1 W1 Destination STRB, STRB0, STRB1, MSTRB bus Cw Cw Cw Cw R1 Cr W1 Cw R1 Cr W1 W1 W1 W1 Cw = = = = Single-cycle writes Multicycle reads Multicycle writes Internal register cycle W2 W2 W2 W2 Cw W3 Cr Cr W3 R1 I R2 R2 R2 R2 I R3 R3 R3 R3 I R4 R4 R4 Cr W3 W3 Cw Cw R4 W1 W1 W1 W2 W2 W2 W2 ... (3.5 + Cr + 2 + Cw) T + .5 (T - 1){ Cr I R2 R2 R2 I (2 + Cr + 2 + Cw) T + 0.5 (T - 1){ Source STRB, STRB0, STRB1 bus R1 R1 Destination STRB, STRB0, STRB1 bus ('C30 only) Source IOSTRB R1 R1 Destination STRB bus (3 + Cr + 2 + Cw) + (2 + Cw + max[1, Cr - Cw + 1]) (T-1) Legend: T = Number of transfers Cr = Source-read wait states Cw = Destination-write wait states R = Single-cycle reads W Rn Wn I Write followed by read incurs in one extra half-cycle. Figure 12-48. DMA Timing When Destination is an STRB, STRB0, STRB1, MSTRB Bus (Continued) Cycles (H1) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Rate 1 2 R1 Cw (3 + Cr + 2 + Cw) T + 0.5 (T - 1) W1 W1 W1 W1 W2 W2 W2 W2 Cw Source IOSTRB bus R1 R1 R1 I R2 R2 R2 R2 I Destination STRB0, STRB1, or MSTRB bus Cw R1 Cr W1 Cw W Rn Wn I = = = = Single-cycle writes Multicycle reads Multicycle writes Internal register cycle Cw W1 W1 W1 W2 W2 W2 W2 W3 W3 W3 W3 Cr Cr I R2 R2 R2 I R3 R3 R3 I Cw ('C30 only) Source STRB bus R1 R1 Destination MSTRB bus Cw (2 + Cr + 2 + Cw) + (2 + Cw + max[1, Cr - Cw + 1]) (T-1) Legend: T = Number of transfers Cr = Source-read wait states Cw = Destination-write wait states R = Single-cycle reads Write followed by read incurs in one extra half-cycle. Peripherals DMA Controller 12-73 12-74 1 R1 W1 Cw R1 Cr W1 Cw R1 Cr W1 Cw Cw W1 W1 W1 W2 W2 W2 W2 Cr R1 R1 I R2 R2 R2 I Cw Cw W1 W1 W1 W2 W2 W2 W2 W3 W3 W3 W3 Cr Cr R1 R1 I R2 R2 R2 I R3 R3 R3 I (2 + Cr + 2 + Cw) + (2 + Cw + max (1, Cr - Cw + 1)) (T - 1) Cw Cw Cw 1 + (2 + Cw) T W1 W1 W1 W2 W2 W2 W2 W3 W3 W3 W3 W4 W4 W4 W4 R2 R3 R4 R5 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Rate Figure 12-49. DMA Timing When Destination is an IOSTRB Bus Cycles (H1) DMA Controller Source on chip Destination IOSTRB ('C30 only) Source STRB bus Destination IOSTRB bus Source STRB0, STRB1, MSTRB bus Destination IOSTRB (2 + Cr + 2 + Cw) T + (T-1){ Legend: T = Number of transfers Cr = Source-read wait states Cw = Destination-write wait states R = Single-cycle reads W Rn Wn I = = = = Single-cycle writes Multicycle reads Multicycle writes Internal register cycle Write followed by read incurs in one extra cycle. DMA Controller 12.3.9 DMA Initialization/Reconfiguration You can control the DMA through memory-mapped registers located on the dedicated peripheral bus. Following is the general procedure for initializing and/or reconfiguring the DMA: 1) Halt the DMA by clearing the START bits of the DMA global-control register. You can do this by writing a 0 to the DMA global-control register. The DMA is halted on RESET. 2) Configure the DMA through the DMA global-control register (with START = 00), as well as the DMA source, destination, and transfercounter registers, if necessary. Refer to Section 12.3.11 on page 12-76 for more information. 3) Start the DMA by setting the START bits of the DMA global-control register as necessary. 12.3.10 Hints for DMA Programming The following hints help you to improve your DMA programming and avoid unexpected results: - Reset the DMA register before starting it. This clears any previously latched interrupt that may no longer exist. - In the event of a CPU-DMA access conflict, the CPU always prevails. Care- fully allocate the different sections of the program in memory for faster execution. If a CPU program access conflicts with a DMA access, enabling the cache helps if the program is located in external memory. DMA on-chip access happens during the H3 phase. Note: Expansion and Peripheral Buses The expansion and peripheral buses cannot be accessed simultaneously because they are multiplexed into a common port (see Figure 2-1 on page 2-3). This might increase CPU-DMA access conflicts. - Ensure that each interrupt is received when you use interrupt synchroniza- tion; otherwise, the DMA will never complete the block transfer. - Use read/write synchronization when reading from or writing to serial ports to guarantee data validity. The following are indications that the DMA has finished a set of transfers: - The DINT bit in the IF register is set to 1 (interrupt polling). This requires that you set the TCINT bit in the DMA control register first. This interruptpolling method does not cause any additional CPU-DMA access conflict. Peripherals 12-75 DMA Controller - The transfer counter has a zero value. However, the transfer counter is decremented after the DMA read operation finishes (not after the write operation). Nevertheless, a transfer counter with a 0 value can be used as an indication of a transfer completion. - The STAT bits in the DMA channel-control register are set to 002. You can poll the DMA channel-control register for this value. However, because the DMA registers are memory-mapped into the peripheral bus address space, this option can cause further CPU/DMA access conflicts. 12.3.11 DMA Programming Examples Example 12-8, Example 12-9, and Example 12-10 illustrate initialization procedures for the DMA. When linking the examples, you should allocate section memory addresses carefully to avoid CPU-DMA conflict. In the C3x, the CPU always prevails in cases of conflict. In the event of a CPU program/DMA data conflict, cache enabling helps if the .text section is in external memory. For example, when linking the code in Example 12-8, Example 12-9, and Example 12-10, the .text section can be allocated into RAM0, .data into RAM1, and .bss into RAM1, where RAM0 corresponds to on-chip RAM block 0 and RAM1 corresponds to on-chip RAM block 1. In Example 12-8, the DMA initializes a 128-element array to 0. The DMA sends an interrupt to the CPU after the transfer is completed. This program assumes previous initialization of the CPU interrupt-vector table (specifically the DMA-to-CPU interrupt). The program initializes the ST and IE registers for interrupt processing. 12-76 DMA Controller Example 12-8. Array Initialization With DMA * TITLE: ARRAY INITIALIZATION WITH DMA * .GLOBAL START .DATA DMA .WORD 808000H ; DMA GLOBAL-CONTROL REG ADDRESS RESET .WORD 0C40H ; DMA GLOBAL-CONTROL REG RESET VALUE CONTROL .WORD 0C43H ; DMA GLOBAL-CONTROL REG INITIALIZATION SOURCE .WORD ZERO ; DATA SOURCE ADDRESS DESTIN .WORD _ARRAY ; DATA DESTINATION ADDRESS COUNT .WORD 128 ; NUMBER OF WORDS TO TRANSFER ZERO .FLOAT 0.0 ; ARRAY INITIALIZATION VALUE 0.0 = 0x80000000 .BSS _ARRAY,128 ; DATA ARRAY LOCATED IN .BSS SECTION .TEXT START LDP DMA LDI @DMA,AR0 LDI @RESET,R0 STI R0,*AR0 LDI @SOURCE,R0 STI R0,*+AR0(4) LDI @DESTIN,R0 STI R0,*+AR0(6) LDI @COUNT,R0 STI R0,*+AR0(8) OR 400H,IE OR 2000H,ST LDI @CONTROL,R0 STI R0,*AR0 BU $ .END ; LOAD DATA PAGE POINTER ; POINT TO DMA GLOBAL CONTROL REGISTER ; RESET DMA ; INITIALIZE DMA SOURCE-ADDRESS REGISTER ; INITIALIZE DMA DESTINATION-ADDRESS REGISTER ; INITIALIZE DMA TRANSFER COUNTER REGISTER ; ; ; ; ENABLE INTERRUPT FROM DMA TO CPU ENABLE CPU INTERRUPTS GLOBALLY INITIALIZE DMA GLOBAL CONTROL REGISTER START DMA TRANSFER Example 12-9 sets up the DMA to transfer data (128 words) from the serial port 0 input register to an array buffer with serial port receive interrupt (RINT0). The DMA sends an interrupt to the CPU when the data transfer completes. Serial port 0 is initialized to receive 32-bit data words with an internally generated receive-bit clock and a bit-transfer rate of 8H1 cycles/bit. This program assumes previous initialization of the CPU interrupt vector table (specifically the DMA-to-CPU interrupt). The serial port interrupt directly affects only the DMA; no CPU serial-port interrupt-vector setting is required. Peripherals 12-77 DMA Controller Example 12-9. DMA Transfer With Serial-Port Receive Interrupt * TITLE DMA TRANSFER WITH SERIAL * .GLOBAL START .DATA DMA .WORD 808000H CONTROL .WORD 0D43H SOURCE .WORD 80804CH DESTIN .WORD _ARRAY COUNT .WORD 128 IEVAL .WORD 00200400H RESET1 .WORD 0D40H .BSS _ARRAY,128 PORT RECEIVE INTERRUPT ; DMA GLOBAL-CONTROL REG ADDRESS ; DMA GLOBAL-CONTROL REG INITIALIZATION ; DATA SOURCE-ADDRESS: SERIAL PORT INPUT REG ; DATA DESTINATION ADDRESS ; NUMBER OF WORDS TO TRANSFER ; IE REGISTER VALUE ; DMA RESET ; DATA ARRAY LOCATED IN .BSS SECTION ; THE UNDERSCORE USED IS JUST TO MAKE IT ; ACCESSIBLE FROM C (OPTIONAL) SERIAL-PORT GLOBAL-CONTROL REG ADDRESS SERIAL-PORT GLOBAL-CONTROL REG INITIALIZATION SERIAL-PORT RX PORT CONTROL REG INITIALIZATION SERIAL-PORT TIMER-CONTROL REG INITIALIZATION SERIAL-PORT TIMER PERIOD ; SERIAL-PORT RESET ; SERIAL-PORT TIMER RESET ; LOAD DATA PAGE POINTER ; ; ; ; ; SPORT SGCCTRL SRCTRL STCTRL STPERIOD SPRESET RESET START .WORD .WORD .WORD .WORD .WORD .WORD .WORD .TEXT LDP DMA 808040H 0A300080H 111H 3C0H 00020000H 01300080H 0H * DMA INITIALIZATION LDI LDI LDI STI LDI STI LDI STI LDI STI LDI STI LDI STI OR OR LDI STI @DMA,AR0 @SPORT,AR1 @RESET,R0 R0,*+AR1(4) @RESET1,R0 R0,*AR0 @SPRESET,R0 R0,*AR1 @SOURCE,R0 R0,*+AR0(4) @DESTIN,R0 R0,*+AR0(6) @COUNT,R0 R0,*+AR0(8) @IEVAL,IE 2000H,ST @CONTROL,R0 R0,*AR0 ; POINT TO DMA GLOBAL CONTROL REGISTER ; RESET SPORT TIMER ; RESET DMA ; RESET SPORT ; INITIALIZE DMA SOURCE-ADDRESS REGISTER ; INITIALIZE DMA DESTINATION-ADDRESS REGISTER ; INITIALIZE DMA TRANSFER COUNTER REGISTER ; ; ; ; ENABLE INTERRUPTS ENABLE CPU INTERRUPTS GLOBALLY INITIALIZE DMA GLOBAL CONTROL REGISTER START DMA TRANSFER * SERIAL PORT INITIALIZATION LDI @SRCTRL,R0 STI R0,*+AR1(3) LDI @STPERIOD,R0 STI R0,*+AR1(6) LDI @STCTRL,R0 STI R0,*+AR1(4) LDI @SGCCTRL,R0 STI R0,*AR1 BU $ .END ; SERIAL-PORT RECEIVE CONTROL REG INITIALIZATION ; SERIAL-PORT TIMER-PERIOD INITIALIZATION ; SERIAL-PORT TIMER CONTROL REG INITIALIZATION ; SERIAL-PORT GLOBAL CONTROL REG INITIALIZATION 12-78 DMA Controller Example 12-10 sets up the DMA to transfer data (128 words) from an array buffer to the serial port 0 output register with serial port transmit interrupt XINT0. The DMA sends an interrupt to the CPU when the data transfer completes. Serial port 0 is initialized to transmit 32-bit data words with an internally generated frame sync and a bit-transfer rate of 8(H1) cycles/bit. The receive-bit clock is internally generated and equal in frequency to one-half of the 'C3x H1 frequency. This program assumes previous initialization of the CPU interrupt-vector table (specifically the DMA-to-CPU interrupt). The serial-port interrupt directly affects only the DMA; no CPU serial-port interrupt-vector setting is required. Note: Serial-Port Transmit Synchronization The DMA uses serial-port transmit interrupt XINT0 to synchronize transfers. Because the XINT0 is generated when the transmit buffer has written the last bit of data to the shifter, an initial CPU write to the serial port is required to trigger XINT0 to enable the first DMA transfer. Example 12-10. DMA Transfer With Serial-Port Transmit Interrupt * TITLE: DMA TRANSFER WITH SERIAL PORT TRANSMIT INTERRUPT * .GLOBAL START .DATA DMA .WORD 808000H ; DMA GLOBAL-CONTROL REG ADDRESS CONTROL .WORD 0E13H ; DMA GLOBAL-CONTROL REG INITIALIZATION SOURCE .WORD (_ARRAY+1) ; DATA SOURCE ADDRESS DESTIN .WORD 80804CH ; DATA DESTIN ADDRESS: SERIAL-PORT OUTPUT REG COUNT .WORD 127 ; NUMBER OF WORDS TO TRANSFER =(MSG LENGHT-1) IEVAL .WORD 00100400H ; IE REGISTER VALUE .BSS _ARRAY,128 ; DATA ARRAY LOCATED IN .BSS SECTION ; THE UNDERSCORE USED IS JUST TO MAKE IT ; ACCESSIBLE FROM C (OPTIONAL) RESET1 .WORD 0E10H ; DMA RESET SPORT .WORD 808040H ; SERIAL-PORT GLOBAL-CONTROL REG ADDRESS SGCCTRL .WORD 048C0044H ; SERIAL-PORT GLOBAL-CONTROL REG INITIALIZATION SXCTRL .WORD 111H ; SERIAL-PORT TX PORT CONTROL REG INITIALIZATION STCTRL .WORD 00FH ; SERIAL-PORT TIMER CONTROL REG INITIALIZATION STPERIOD .WORD 00000002H ; SERIAL-PORT TIMER PERIOD SPRESET .WORD 00880044H ; SERIAL-PORT RESET RESET .WORD 0H ; SERIAL-PORT TIMER RESET .TEXT START LDP DMA ; LOAD DATA PAGE POINTER Peripherals 12-79 DMA Controller Example 12-10. DMA Transfer With Serial-Port Transmit Interrupt (Continued) * DMA INITIALIZATION LDI @DMA,AR0 LDI @SPORT,AR1 LDI @RESET,R0 STI R0,*+AR1(4) STI R0,*AR0 STI R0,*AR1 LDI @SOURCE,R0 STI R0,*+AR0(4) LDI @DESTIN,R0 STI R0,*+AR0(6) LDI @COUNT,R0 STI R0,*+AR0(8) OR @IEVAL,IE OR 2000H,ST LDI @CONTROL,R0 STI R0,*AR0 * SERIAL PORT INITIALIZATION LDI @SXCTRL,R0 STI R0,*+AR1(2) LDI @STPERIOD,R0 STI R0,*+AR1(6) LDI @STCTRL,R0 STI R0,*+AR1(4) LDI @SGCCTRL,R0 STI R0,*AR1 ; SERIAL-PORT TX CONTROL REG INITIALIZATION ; SERIAL-PORT TIMER-PERIOD INITIALIZATION ; SERIAL-PORT TIMER-CONTROL REG INITIALIZATION ; SERIAL-PORT GLOBAL-CONTROL REG INITIALIZATION ; POINT TO DMA GLOBAL CONTROL REGISTER ; ; ; ; RESET SPORT TIMER RESET DMA RESET SPORT INITIALIZE DMA SOURCE-ADDRESS REGISTER ; INITIALIZE DMA DESTINATION-ADDRESS REGISTER ; INITIALIZE DMA TRANSFER COUNTER REGISTER ; ; ; ; ENABLE INTERRUPT FROM DMA TO CPU ENABLE CPU INTERRUPTS GLOBALLY INITIALIZE DMA GLOBAL CONTROL REGISTER START DMA TRANSFER * CPU WRITES THE FIRST WORD (TRIGGERING EVENT ---> XINT IS GENERATED) LDI @SOURCE,AR0 LDI *-AR0(1),R0 STI R0,*+AR1(8) BU $ .END Other examples are as follows: - Transfer a 256-word block of data from off-chip memory to on-chip memory and generate an interrupt on completion. Maintain the memory order. DMA source address: DMA destination address: DMA transfer counter: DMA global control: CPU/DMA interrupt enable (IE): 12-80 800000h 809800h 00000100h 00000C53h 00000400h DMA Controller - Transfer a 128-word block of data from on-chip memory to off-chip memory and generate an interrupt on completion. Invert the memory order; the highest addressed member of the block is to become the lowest addressed member. DMA source address: DMA destination address: DMA transfer counter: DMA global control: CPU/DMA interrupt-enable (IE): 809800h 800000h 00000080h 00000C93h 00000400h - Transfer a 200-word block of data from the serial-port 0 receive register to on-chip memory and generate an interrupt on completion. Synchronize the transfer with the serial-port 0 receive interrupt. DMA source address: DMA destination address: DMA transfer counter: DMA global control: CPU/DMA interrupt-enable (IE): 80804Ch 809C00h 000000C8h 00000D43h 00200400h - Transfer a 200-word block of data from off-chip memory to the serial-port 0 transmit register and generate an interrupt on completion. Synchronize with the serial-port 0 transmit interrupt. DMA source address: DMA destination address: DMA transfer counter: DMA global control: CPU/DMA interrupt-enable (IE): 809C00h 808048h 000000C8h 00000E13h 00400400h - Transfer data continuously between the serial-port 0 receive register and the serial-port 0 transmit register to create a digital loop back. Synchronize with the serial-port 0 receive and transmit interrupts. DMA source address: DMA destination address: DMA transfer counter: DMA global control: CPU/DMA interrupt-enable (IE): 80804Ch 808048h 00000000h 00000303h 00300000h Peripherals 12-81 12-82 Chapter 13 Assembly Language Instructions The 'C3x assembly language instruction set supports numeric-intensive, signalprocessing, and general-purpose applications. (The addressing modes used with the instructions are described in Chapter 5.) The 'C3x instruction set can also use one of 20 condition codes with any of the 10 conditional instructions, such as LDFcond. This chapter defines the condition codes and flags. The assembler allows optional syntax forms to simplify the assembly language for special-case instructions. These optional forms are listed and explained. Each of the individual instructions is described and listed in alphabetical order (see subsection 13.6.2, Optional Assembler Syntax, on page 13-34). Example instructions demonstrate the special format and explain its content. This chapter discusses these topics: Topic Page 13.1 Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2 13.2 Instruction Set Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-10 13.3 Parallel Instruction Set Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-17 13.4 Group Addressing Mode Instruction Encoding . . . . . . . . . . . . . . . . 13-20 13.5 Condition Codes and Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-28 13.6 Individual Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-32 13-1 mnemonic Running Title--Attribute Reference 13.1 Instruction Set The 'C3x instruction set is well suited to digital signal processing and other numeric-intensive applications. All instructions are a single machine word long, and most instructions require one cycle to execute. In addition to multiply and accumulate instructions, the 'C3x possesses a full complement of generalpurpose instructions. The instruction set contains 113 instructions organized into the following functional groups: - Load and store 2-operand arithmetic/logical 3-operand arithmetic/logical Program control Interlocked operations Parallel operations Each of these groups is discussed in the following subsections. 13.1.1 Load and Store Instructions The 'C3x supports 13 load and store instructions (see Table 13-1). These instructions can: - Load a word from memory into a register - Store a word from a register into memory - Manipulate data on the system stack Two of these instructions can load data conditionally. This is useful for locating the maximum or minimum value in a data set. See Section 13.5 on page 13-28 for detailed information on condition codes. Table 13-1. Load and Store Instructions Instruction LDE LDF LDFcond Description Load floating-point exponent Load floating-point value Load floating-point value conditionally Load integer Load integer conditionally Load floating-point mantissa Load data page pointer Instruction POP POPF PUSH Description Pop integer from stack Pop floating-point value from stack Push integer on stack LDI LDIcond LDM LDP PUSHF STF STI Push floating-point value on stack Store floating-point value Store integer 13-2 Instruction Set mnemonic 13.1.2 2-Operand Instructions The 'C3x supports 35 2-operand arithmetic and logical instructions. The two operands are the source and destination. The source operand can be a memory word, a register, or a part of the instruction word. The destination operand is always a register. As shown in Table 13-2, these instructions provide integer, floating-point or logical operations, and multiprecision arithmetic. Table 13-2. 2-Operand Instructions Instruction ABSF ABSI ADDC ADDF ADDI AND ANDN Description Absolute value of a floatingpoint number Absolute value of an integer Add integers with carry Add floating-point values Add integers Bitwise-logical AND Bitwise-logical AND with complement ASH CMPF CMPI FIX FLOAT LSH MPYF MPYI NEGB NEGF NEGI Arithmetic shift Compare floating-point values Compare integers Convert floating-point value to integer Convert integer to floating-point value Logical shift Multiply floating-point values Multiply integers Negate integer with borrow Negate floating-point value Negate integer RORC SUBB SUBC SUBF SUBI SUBRB SUBRF SUBRI TSTB XOR Rotate right through carry Subtract integers with borrow Subtract integers conditionally Subtract floating-point values Subtract integer Subtract reverse integer with borrow Subtract reverse floating-point value Subtract reverse integer Test bit fields Bitwise-exclusive OR Instruction NORM NOT OR RND ROL ROLC ROR Description Normalize floating-point value Bitwise-logical complement Bitwise-logical OR Round floating-point value Rotate left Rotate left through carry Rotate right 2- and 3-operand versions Assembly Language Instructions 13-3 mnemonic Instruction Set 13.1.3 3-Operand Instructions Whereas 2-operand instructions have a single source operand (or shift count) and a destination operand, 3-operand instructions can have two source operands (or one source operand and a count operand) and a destination operand. A source operand can be a memory word or a register. The destination of a 3-operand instruction is always a register. Table 13-3 lists the instructions that have 3-operand versions. You can omit the 3 in the mnemonic from 3-operand instructions (see subsection 13.6.2 on page 13-34). Table 13-3. 3-Operand Instructions Instruction ADDC3 ADDF3 ADDI3 AND3 ANDN3 ASH3 CMPF3 CMPI3 LSH3 Description Add with carry Add floating-point values Add integers Bitwise-logical AND Bitwise-logical AND with complement Arithmetic shift Compare floating-point values Compare integers Logical shift Instruction MPYF3 MPYI3 OR3 SUBB3 SUBF3 SUBI3 TSTB3 XOR3 Description Multiply floating-point values Multiply integers Bitwise-logical OR Subtract integers with borrow Subtract floating-point values Subtract integers Test bit fields Bitwise-exclusive OR 13.1.4 Program-Control Instructions The program-control instruction group consists of all of those instructions (17) that affect program flow. The repeat mode allows repetition of a block of code (RPTB) or of a single line of code (RPTS). Both standard and delayed (single-cycle) branching are supported. Several program-control instructions can perform conditional operations. (See Section 13.5 on page 13-28 for detailed information on condition codes.) Table 13-4 lists the programcontrol instructions. 13-4 Instruction Set mnemonic Table 13-4. Program-Control Instructions Instruction Bcond BcondD BR BRD CALL CALLcond DBcond Description Branch conditionally (standard) Branch conditionally (delayed) Branch unconditionally (standard) Branch unconditionally (delayed) Call subroutine Call subroutine conditionally Decrement and branch conditionally (standard) Decrement and branch conditionally (delayed) Interrupt acknowledge Instruction IDLE NOP RETIcond RETScond RPTB RPTS SWI Description Idle until interrupt No operation Return from interrupt conditionally Return from subroutine conditionally Repeat block of instructions Repeat single instruction Software interrupt DBcondD TRAPcond Trap conditionally IACK 13.1.5 Low-Power Control Instructions The low-power control instruction group consists of three instructions that affect the low-power modes. The low-power idle (IDLE2) instruction allows extremely low-power mode. The divide-clock-by-16 (LOPOWER) instruction reduces the rate of the input clock frequency. The restore-clock-to-regular-speed (MAXSPEED) instruction causes the resumption of full-speed operation. Table 13-5 lists the low-power control instructions. Table 13-5. Low-Power Control Instructions Instruction IDLE2 LOPOWER Description Low-power idle Divide clock by 16 Instruction MAXSPEED Description Restore clock to regular speed 13.1.6 Interlocked-Operations Instructions The five interlocked-operations instructions (Table 13-6) support multiprocessor communication and the use of external signals to allow for powerful synchronization mechanisms. They also ensure the integrity of the communication and result in a high-speed operation. Refer to Chapter 7 for examples of the use of interlocked instructions. Assembly Language Instructions 13-5 mnemonic Instruction Set Table 13-6. Interlocked-Operations Instructions Instruction LDFI LDII SIGI Description Load floating-point value, interlocked Load integer, interlocked Signal, interlocked Instruction STFI STII Description Store floating-point value, interlocked Store integer, interlocked 13.1.7 Parallel-Operations Instructions The 13 parallel-operations instructions make a high degree of parallelism possible. Some of the 'C3x instructions can occur in pairs that are executed in parallel. These instructions offer the following features: - Parallel loading of registers - Parallel arithmetic operations - Arithmetic/logical instructions used in parallel with a store instruction Each instruction in a pair is entered as a separate source statement. The second instruction in the pair must be preceded by two vertical bars (||). Table 13-7 lists the valid instruction pairs. Table 13-7. Parallel Instructions (a) Parallel arithmetic with store instructions Mnemonic || ABSF STF ABSI STI ADDF3 STF ADDI3 STI AND3 STI ASH3 STI FIX STI Description Absolute value of a floating-point number and store floatingpoint value Absolute value of an integer and store integer || Add floating-point values and store floating-point value || Add integers and store integer || Bitwise-logical AND and store integer || Arithmetic shift and store integer || Convert floating-point to integer and store integer || 13-6 Instruction Set mnemonic Table 13-7. Parallel Instructions (Continued) (a) Parallel arithmetic with store instructions (Continued) Mnemonic || || || || || || || || || || || || || || || FLOAT STF LDF STF LDI STI LSH3 STI MPYF3 STF MPYI3 STI NEGF STF NEGI STI NOT STI OR3 STI STF STF STI STI SUBF3 STF SUBI3 STI XOR3 STI Description Convert integer to floating-point value and store floatingpoint value Load floating-point value and store floating-point value Load integer and store integer Logical shift and store integer Multiply floating-point values and store floating-point value Multiply integer and store integer Negate floating-point value and store floating-point value Negate integer and store integer Complement value and store integer Bitwise-logical OR value and store integer Store floating-point values Store integers Subtract floating-point value and store floating-point value Subtract integer and store integer Bitwise-exclusive OR values and store integer Assembly Language Instructions 13-7 mnemonic Instruction Set Table 13-7. Parallel Instructions (Continued) (b) Parallel load instructions Mnemonic || LDF LDF LDI LDI Description Load floating-point value Load integer || (c) Parallel multiply and add/subtract instructions Mnemonic || MPYF3 ADDF3 MPYF3 SUBF3 MPYI3 ADDI3 MPYI3 SUBI3 Description Multiply and add floating-point value Multiply and subtract floating-point value || Multiply and add integer || Multiply and subtract integer || These parallel instructions have been enhanced on the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater These devices support greater combinations of operands by also allowing the use of any CPU register whenever an indirect operand is required. The particular instruction description details the operand combination. To support these new modes, you need to invoke the TMS320 floating-point code generation tools (version 5.0 or later) with the following switches: - C Compiler J J `C31: `C32: CL30 CL30 -v31 -v32 -gsrev6 -gsrev2 - Assembler J J `C31: `C32: asm30 asm30 -v31 -v32 -msrev6 -msrev2 13-8 Running Title--Attribute Reference mnemonic 13.1.8 Illegal Instructions The 'C3x has no illegal instruction-detection mechanism. Fetching an illegal (undefined) opcode can cause the execution of an undefined operation. Proper use of the TI TMS320 floating-point software tools will not generate an illegal opcode. Only the following conditions can cause the generation of an illegal opcode: - Misuse of the tools - An error in the ROM code - Defective RAM Chapter Title--Attribute Reference 13-9 mnemonic Instruction Set Summary 13.2 Instruction Set Summary Table 13-8 lists the 'C3x instruction set in alphabetical order. Each table entry provides the instruction mnemonic, description, and operation. Table 13-8. Instruction Set Summary Mnemonic ABSF ABSI ADDC ADDC3 ADDF ADDF3 ADDI ADDI3 AND AND3 ANDN ANDN3 ASH Description Absolute value of a floating-point number Absolute value of an integer Add integers with carry Add integers with carry (3-operand) Add floating-point values Add floating-point values (3-operand) Add integers Add integers (3 operand) Bitwise-logical AND Bitwise-logical AND (3-operand) Bitwise-logical AND with complement Bitwise-logical ANDN (3-operand) Arithmetic shift Operation |src| Rn |src| Dreg src + Dreg + C Dreg src1 + src2 + C Dreg src + Rn Rn src1 + src2 Rn src + Dreg Dreg src1 + src2 + Dreg Dreg AND src Dreg src1 AND src2 Dreg Dreg AND src Dreg src1 AND src2 Dreg If count 0: (Shifted Dreg left by count) Dreg Else: (Shifted Dreg right by |count|) Dreg ASH3 Arithmetic shift (3-operand) If count 0: (Shifted src left by count) Dreg Else: (Shifted src right by |count|) Dreg Legend: ARn C Csrc count cond Daddr Dreg GIE N PC RC auxiliary register n (AR7-AR0) carry bit conditional-branch addressing modes shift value (general addressing modes) condition code destination memory address register address (any register) global interrupt enable register any trap vector 0-27 program counter repeat counter register RE RM Rn RS SP Sreg ST src src1 src2 TOS repeat interrupt register repeat mode bit register address (R7-R0) repeat start register stack pointer register address (any register) status register general addressing modes 3-operand addressing modes 3-operand addressing modes top of stack 13-10 Instruction Set Summary mnemonic Table 13-8. Instruction Set Summary (Continued) Mnemonic Bcond Description Branch conditionally (standard) Operation If cond = true: If Csrc is a register, Csrc PC If Csrc is a value, Csrc + PC PC Else, PC + 1 PC BcondD Branch conditionally (delayed) If cond = true: If Csrc is a register, Csrc PC If Csrc is a value, Csrc + PC + 3 PC Else, PC + 1 PC BR BRD CALL Branch unconditionally (standard) Branch unconditionally (delayed) Call subroutine Value PC Value PC PC + 1 TOS Value PC CALLcond Call subroutine conditionally If cond = true: PC + 1 TOS If Csrc is a register, Csrc PC If Csrc is a value, Csrc + PC PC Else, PC + 1 PC CMPF CMPF3 Compare floating-point values Compare floating-point values (3-operand) CMPI CMPI3 Legend: Set flags on Rn - src Set flags on src1 - src2 Compare integers Compare integers (3-operand) ARn C Csrc count cond Daddr Dreg GIE N PC RC auxiliary register n (AR7-AR0) carry bit conditional-branch addressing modes shift value (general addressing modes) condition code destination memory address register address (any register) global interrupt enable register any trap vector 0-27 program counter repeat counter register Set flags on Dreg - src Set flags on src1 - src2 RE RM Rn RS SP Sreg ST src src1 src2 TOS repeat interrupt register repeat mode bit register address (R7-R0) repeat start register stack pointer register address (any register) status register general addressing modes 3-operand addressing modes 3-operand addressing modes top of stack Assembly Language Instructions 13-11 mnemonic Instruction Set Summary Table 13-8. Instruction Set Summary (Continued) Mnemonic DBcond Description Decrement and branch conditionally (standard) Operation ARn - 1 ARn If cond = true and ARn 0: If Csrc is a register, Csrc PC If Csrc is a value, Csrc + PC + 1 PC Else, PC + 1 PC DBcondD Decrement and branch conditionally (delayed) ARn - 1 ARn If cond = true and ARn 0: If Csrc is a register, Csrc PC If Csrc is a value, Csrc + PC + 3 PC Else, PC + 1 PC FIX FLOAT IACK IDLE Convert floating-point value to integer Convert integer to floating-point value Interrupt acknowledge Idle until interrupt Fix (src) Dreg Float(src) Rn Dummy read of src IACK toggled low, then high PC + 1 PC Idle until next interrupt IDLE2 LDE LDF LDFcond Low-power idle Load floating-point exponent Load floating-point value Load floating-point value conditionally Idle until next interrupt stopping internal clocks src(exponent) Rn(exponent) src Rn If cond = true, src Rn Else, Rn is not changed LDFI LDI Legend: Load floating-point value, interlocked Load integer ARn C Csrc count cond Daddr Dreg GIE N PC RC auxiliary register n (AR7-AR0) carry bit conditional-branch addressing modes shift value (general addressing modes) condition code destination memory address register address (any register) global interrupt enable register any trap vector 0-27 program counter repeat counter register Signal interlocked operation src Rn src Dreg RE RM Rn RS SP Sreg ST src src1 src2 TOS repeat interrupt register repeat mode bit register address (R7-R0) repeat start register stack pointer register address (any register) status register general addressing modes 3-operand addressing modes 3-operand addressing modes top of stack 13-12 Instruction Set Summary mnemonic Table 13-8. Instruction Set Summary (Continued) Mnemonic LDIcond Description Load integer conditionally Operation If cond = true, src Dreg Else, Dreg is not changed LDII LDM LDP LOPOWER LSH Load integer, interlocked Load floating-point mantissa Load data page pointer Divide clock by 16 Logical shift Signal interlocked operation src Dreg src (mantissa) Rn (mantissa) src data page pointer H1/16 H1 If count 0: (Dreg left-shifted by count) Dreg Else: (Dreg right-shifted by |count|) Dreg LSH3 Logical shift (3-operand) If count 0: (src left-shifted by count) Dreg Else: (src right-shifted by |count|) Dreg MAXSPEED MPYF MPYF3 MPYI MPYI3 NEGB NEGF NEGI Legend: Restore clock to regular speed Multiply floating-point values Multiply floating-point value (3-operand) Multiply integers Multiply integers (3-operand) Negate integer with borrow Negate floating-point value Negate integer H1/16 H1 src Rn Rn src1 src2 Rn src Dreg Dreg src1 src2 Dreg 0 - src - C Dreg 0 - src Rn 0 - src Dreg RE RM Rn RS SP Sreg ST src src1 src2 TOS repeat interrupt register repeat mode bit register address (R7-R0) repeat start register stack pointer register address (any register) status register general addressing modes 3-operand addressing modes 3-operand addressing modes top of stack ARn C Csrc count cond Daddr Dreg GIE N PC RC auxiliary register n (AR7-AR0) carry bit conditional-branch addressing modes shift value (general addressing modes) condition code destination memory address register address (any register) global interrupt enable register any trap vector 0-27 program counter repeat counter register Assembly Language Instructions 13-13 mnemonic Instruction Set Summary Table 13-8. Instruction Set Summary (Continued) Mnemonic NOP NORM NOT OR OR3 POP POPF PUSH PUSHF RETIcond Description No operation Normalize floating-point value Bitwise-logical complement Bitwise-logical OR Bitwise-logical OR (3-operand) Pop integer from stack Pop floating-point value from stack Push integer on stack Push floating-point value on stack Return from interrupt conditionally Operation Modify ARn if specified Normalize (src) Rn src Dreg Dreg OR src Dreg src1 OR src2 Dreg *SP-- Dreg *SP-- Rn Sreg *++ SP Rn *++ SP If cond = true or missing: *SP-- PC 1 ST (GIE) Else, continue RETScond Return from subroutine conditionally If cond = true or missing: *SP-- PC Else, continue RND ROL ROLC ROR RORC Legend: Round floating-point value Rotate left Rotate left through carry Rotate right Rotate right through carry ARn C Csrc count cond Daddr Dreg GIE N PC RC auxiliary register n (AR7-AR0) carry bit conditional-branch addressing modes shift value (general addressing modes) condition code destination memory address register address (any register) global interrupt enable register any trap vector 0-27 program counter repeat counter register Round (src) Rn Dreg rotated left 1 bit Dreg Dreg rotated left 1 bit through carry Dreg Dreg rotated right 1 bit Dreg Dreg rotated right 1 bit through carry Dreg RE RM Rn RS SP Sreg ST src src1 src2 TOS repeat interrupt register repeat mode bit register address (R7-R0) repeat start register stack pointer register address (any register) status register general addressing modes 3-operand addressing modes 3-operand addressing modes top of stack 13-14 Instruction Set Summary mnemonic Table 13-8. Instruction Set Summary (Continued) Mnemonic RPTB Description Repeat block of instructions Operation src RE 1 ST (RM) Next PC RS RPTS Repeat single instruction src RC 1 ST (RM) Next PC RS Next PC RE SIGI Signal, interlocked Signal interlocked operation Wait for interlock acknowledge Clear interlock STF STFI Store floating-point value Store floating-point value, interlocked Rn Daddr Rn Daddr Signal end of interlocked operation STI STII Store integer Store integer, interlocked Sreg Daddr Sreg Daddr Signal end of interlocked operation SUBB SUBB3 SUBC Subtract integers with borrow Subtract integers with borrow (3-operand) Subtract integers conditionally Dreg - src - C Dreg src1 - src2 - C Dreg If Dreg - src 0: [(Dreg - src) << 1] OR 1 Dreg Else, Dreg << 1 Dreg SUBF SUBF3 Legend: Subtract floating-point values Subtract floating-point values (3-operand) ARn C Csrc count cond Daddr Dreg GIE N PC RC auxiliary register n (AR7-AR0) carry bit conditional-branch addressing modes shift value (general addressing modes) condition code destination memory address register address (any register) global interrupt enable register any trap vector 0-27 program counter repeat counter register Rn - src Rn src1 - src2 Rn RE RM Rn RS SP Sreg ST src src1 src2 TOS repeat interrupt register repeat mode bit register address (R7-R0) repeat start register stack pointer register address (any register) status register general addressing modes 3-operand addressing modes 3-operand addressing modes top of stack Assembly Language Instructions 13-15 mnemonic Instruction Set Summary Table 13-8. Instruction Set Summary (Continued) Mnemonic SUBI SUBI3 SUBRB SUBRF SUBRI SWI TRAPcond Description Subtract integers Subtract integers (3-operand) Subtract reverse integer with borrow Subtract reverse floating-point value Subtract reverse integer Software interrupt Trap conditionally Operation Dreg - src Dreg src1 - src2 Dreg src - Dreg - C Dreg src - Rn Rn src - Dreg Dreg Perform emulator interrupt sequence If cond = true or missing: Next PC * ++ SP Trap vector N PC 0 ST (GIE) Else, continue TSTB TSTB3 XOR XOR3 Legend: Test bit fields Test bit fields (3-operand) Bitwise-exclusive OR Bitwise-exclusive OR (3-operand) ARn C Csrc count cond Daddr Dreg GIE N PC RC auxiliary register n (AR7-AR0) carry bit conditional-branch addressing modes shift value (general addressing modes) condition code destination memory address register address (any register) global interrupt enable register any trap vector 0-27 program counter repeat counter register Dreg AND src src1 AND src2 Dreg XOR src Dreg src1 XOR src2 Dreg RE RM Rn RS SP Sreg ST src src1 src2 TOS repeat interrupt register repeat mode bit register address (R7-R0) repeat start register stack pointer register address (any register) status register general addressing modes 3-operand addressing modes 3-operand addressing modes top of stack 13-16 Parallel Instruction Set Summary mnemonic 13.3 Parallel Instruction Set Summary Table 13-9 lists the 'C3x instruction set in alphabetical order. Each table entry shows the instruction mnemonic, description, and operation. Refer to Section 13.1 for a functional listing of the instructions and individual instruction descriptions. Table 13-9. Parallel Instruction Set Summary (a) Parallel arithmetic with store instructions Mnemonic ABSF || STF ABSI || STI ADDF3 || STF ADDI3 || STI AND3 || STI ASH3 || STI || Arithmetic shift Bitwise-logical AND || Add integer || Add floating-point value || Absolute value of an integer || Description Absolute value of a floating point || Operation |src2| dst1 src3 dst2 |src2| dst1 src3 dst2 src1 + src2 dst1 src3 dst2 src1 + src2 dst1 src3 dst2 src1 AND src2 dst1 src3 dst2 (src2 << count) dst1 src3 dst2 (src2 >> |count|) dst1 || FIX || STI FLOAT || STF count register addr (R7-R0) dst1 register addr (R7-R0) dst2 indirect addr (disp = 0, 1, IR0, IR1) op1, op2, op4, and op5 Any two of these operands must be specified using register addr; the remaining two must be specified using indirect. op3 op6 src1 src2 src3 If count 0: Else: src3 dst2 src3 dst2 Float(src2) dst1 || src3 dst2 Convert floating-point value to integer Fix (src2) dst1 || Convert integer to floating-point value Legend: register addr (R0 or R1) register addr (R2 or R3) register addr (R7-R0) indirect addr (disp = 0, 1, IR0, IR1) register addr (R7-R0) Architectural Overview 13-17 mnemonic Parallel Instruction Set Summary Table 13-9. Parallel Instruction Set Summary (Continued) (a) Parallel arithmetic with store instructions (Continued) Mnemonic LDF || STF LDI || STI LSH3 || STI || Logical shift Load integer || Description Load floating-point value || Operation src2 dst1 src3 dst2 src2 dst1 src3 dst2 src2 << count dst1 src3 dst2 src2 >> |count| dst1 || MPYF3 || STF MPYI3 || STI NEGF || STF NEGI || STI NOT || STI OR3 || STI STF || STF STI || STI count register addr (R7-R0) dst1 register addr (R7-R0) dst2 indirect addr (disp = 0, 1, IR0, IR1) op1, op2, op4, and op5 Any two of these operands must be specified using register addr; the remaining two must be specified using indirect. op3 op6 src1 src2 src3 If count 0: Else: src3 dst2 src1 x src2 dst1 || Multiply integer || Negate floating-point value || Negate integer || Complement || Bitwise-logical OR || Store floating-point value || Store integer || src3 dst2 src1 x src2 dst1 src3 dst2 0 - src2 dst1 src3 dst2 0 - src2 dst1 src3 dst2 src1 dst1 src3 dst2 src1 OR src2 dst1 src3 dst2 src1 dst1 src3 dst2 src1 dst1 src3 dst2 Multiply floating-point value Legend: register addr (R0 or R1) register addr (R2 or R3) register addr (R7-R0) indirect addr (disp = 0, 1, IR0, IR1) register addr (R7-R0) 13-18 Parallel Instruction Set Summary mnemonic Table 13-9. Parallel Instruction Set Summary (Continued) (a) Parallel arithmetic with store instructions (Continued) Mnemonic SUBF3 || STF SUBI3 || STI XOR3 || STI Bitwise-exclusive OR || Subtract integer || Description Subtract floating-point value || Operation src1 - src2 dst1 src3 dst2 src1 - src2 dst1 src3 dst2 src1 XOR src2 dst1 src3 dst2 (b) Parallel load instructions Mnemonic LDF || LDF LDI || LDI Load integer || Description Load floating-point value || Operation src2 dst1 src4 dst2 src2 dst1 src4 dst2 (c) Parallel multiply and add/subtract instructions Mnemonic MPYF3 || ADDF3 MPYF3 || SUBF3 MPYI3 || ADDI3 MPYI3 || SUBI3 count register addr (R7-R0) dst1 register addr (R7-R0) dst2 indirect addr (disp = 0, 1, IR0, IR1) op1, op2, op4, and op5 Any two of these operands must be specified using register addr; the remaining two must be specified using indirect. op3 op6 src1 src2 src3 Description Multiply and add floating-point value Operation op1 x op2 op3 || op4 + op5 op6 op1 x op2 op3 || op4 - op5 op6 op1 x op2 op3 || op4 + op5 op6 op1 x op2 op3 || op4 - op5 op6 Multiply and subtract floating-point value Multiply and add integer Multiply and subtract integer Legend: register addr (R0 or R1) register addr (R2 or R3) register addr (R7-R0) indirect addr (disp = 0, 1, IR0, IR1) register addr (R7-R0) Assembly Language Instructions 13-19 mnemonic Groups of Addressing Modes 13.4 Group Addressing Mode Instruction Encoding The six addressing types (covered in Section 6.1, Addressing Types, on page 6-2) form these four groups of addressing modes: - General addressing modes (G) 3-operand addressing modes (T) Parallel addressing modes (P) Conditional-branch addressing modes (B) 13.4.1 General Addressing Modes Instructions that use the general addressing modes are general-purpose instructions, such as ADDI, MPYF, and LSH. Such instructions usually have this form: dst operation src dst In the syntax, the destination operand is signified by dst and the source operand by src; operation defines an operation to be performed on the operands using the general addressing modes. Bits 31-29 are 0, indicating general addressing mode instructions. Bits 22 and 21 specify the general addressing mode (G) field, which defines how bits 15-0 are to be interpreted for addressing the src operand. Options for bits 22 and 21 (G field) are as follows: G 00 01 10 11 Mode Register (all CPU registers unless specified otherwise) Direct Indirect Immediate If the src and dst fields contain register specifications, the value in these fields contains the CPU register addresses as defined by Table 13-10. For the general addressing modes, the following values of ARn are valid: ARn, 0 n 7 13-20 Running Title--Attribute Reference mnemonic Figure 13-1 shows the encoding for the general addressing modes. The notation modn indicates the modification field that goes with the ARn field. Refer to Table 13-10 on page 13-22 for further information. Figure 13-1. Encoding for General Addressing Modes G 31 0 0 0 0 0 0 0 0 29 0 0 0 0 28 23 22 0 0 1 1 21 0 1 0 1 Destination 20 16 15 0 0 0 11 0 0 10 0 0 0 Source Operands 8 0 7 0 0 5 4 0 operation operation operation operation dst dst dst dst src direct modn ARn immediate disp Chapter Title--Attribute Reference 13-21 mnemonic Types of Addressing Table 13-10. Indirect Addressing (a) Indirect addressing with displacement Mod Field 00000 00001 00010 00011 00100 00101 00110 00111 Syntax *+ARn(disp) *-ARn(disp) *++ARn(disp) *--ARn(disp) *ARn++(disp) *ARn --(disp) *ARn++(disp)% *ARn--(disp)% Operation addr = ARn + disp addr = ARn - disp addr = ARn + disp ARn = ARn + disp addr = ARn - disp ARn = ARn - disp addr = ARn ARn = ARn + disp addr = ARn ARn = ARn - disp addr = ARn ARn = circ(ARn + disp) addr = ARn ARn = circ(ARn - disp) Description With predisplacement add With predisplacement subtract With predisplacement add and modify With predisplacement subtract and modify With postdisplacement add and modify With postdisplacement subtract and modify With postdisplacement add and circular modify With postdisplacement subtract and circular modify (b) Indirect addressing with index register IR0 Mod Field 01000 01001 01010 01011 01100 01101 01110 01111 Legend: Syntax *+ARn(IR0) *-ARn(IR0) *++ARn(IR0) * --ARn(IR0) *ARn++(IR0) *ARn --(IR0) *ARn++(IR0)% *ARn --(IR0)% addr ARn circ( ) disp Operation addr = ARn + IR0 addr = ARn - IR0 addr = ARn + IR0 ARn = ARn + IR0 addr = ARn - IR0 ARn = ARn - IR0 addr = ARn ARn = ARn + IR0 addr= ARn ARn = ARn - IR0 addr = ARn ARn = circ(ARn + IR0) addr = ARn ARn = circ(ARn - IR0) Description With preindex (IR0) add With preindex (IR0) subtract With preindex (IR0) add and modify With preindex (IR0) subtract and modify With postindex (IR0) add and modify With postindex (IR0) subtract and modify With postindex (IR0) add and circular modify With postindex (IR0) subtract and circular modify ++ -- % IRn add and modify subtract and modify where circular addressing is performed index register IR0 or IR1 memory address auxiliary registers AR0-AR7 address in circular addressing displacement 13-22 Running Title--Attribute Reference mnemonic Table 13-10. Indirect Addressing (Continued) (c) Indirect addressing with index register IR1 Mod Field 10000 10001 10010 10011 10100 10101 10110 10111 Syntax *+ ARn(IR1) * -ARn(IR1) * ++ ARn(IR1) * --ARn(IR1) * ARn ++ (IR1) *ARn --(IR1) * ARn ++ (IR1)% * ARn --(IR1)% Operation addr = ARn + IR1 addr = ARn - IR1 addr = ARn + IR1 ARn = ARn + IR1 addr = ARn - IR1 ARn = ARn - IR1 addr = ARn ARn = ARn + IR1 addr = ARn ARn = ARn - IR1 addr = ARn ARn = circ(ARn + IR1) addr = ARn ARn = circ(ARn - IR1) Description With preindex (IR1) add With preindex (IR1) subtract With preindex (IR1) add and modify With preindex (IR1) subtract and modify With postindex (IR1) add and modify With postindex (IR1) subtract and modify With postindex (IR1) add and circular modify With postindex (IR1) subtract and circular modify (d) Indirect addressing (special cases) Mod Field 11000 11001 Syntax *ARn *ARn ++ (IR0)B Operation addr = ARn addr = ARn ARn = B(ARn + IR0) Legend: addr ARn B B() memory address auxiliary registers AR0-AR7 where bit-reversed addressing is performed bit-reversed address circ( ) ++ % IRn -- Description Indirect With postindex (IR0) add and bit-reversed modify address in circular addressing add and modify by one where circular addressing is performed index register IR0 or IR1 subtract and modify by one Chapter Title--Attribute Reference 13-23 mnemonic Groups of Addressing Modes 13.4.2 3-Operand Addressing Modes Instructions that use the 3-operand addressing modes, such as ADDI3, LSH3, CMPF3, or XOR3, usually have this form: src1 operation src2 dst where the destination operand is signified by dst and the source operands by src1 and src2; operation defines an operation to be performed. Note: The 3 can be omitted from a 3-operand instruction mnemonic. Bits 31-29 are set to the value of 001, indicating 3-operand addressing mode instructions. Bits 22 and 21 specify the 3-operand addressing mode (T) field, which defines how bits 15-0 are to be interpreted for addressing the SRC operands. Bits 15-8 define the SRC1 address; bits 7-0 define the SRC2 address. Options for bits 22 and 21 (T) are as follows: T 00 src1 addressing modes Register mode (any CPU register) Indirect mode (disp = 0, 1, IR0, IR1) Register mode (any CPU register) Indirect mode (disp = 0, 1, IR0, IR1) src2 addressing modes Register mode (any CPU register) Register mode (any CPU register) Indirect mode (disp = 0, 1, IR0, IR1) Indirect mode (disp = 0, 1, IR0, IR1) 01 10 11 Figure 13-2 shows the encoding for 3-operand addressing. If the src1 and src2 fields both modify the same auxiliary register, both addresses are correctly generated. However, only the value created by the src1 field is saved in the auxiliary register specified. The assembler issues a warning if you specify this condition. 13-24 Groups of Addressing Modes mnemonic The following values of ARn and ARm are valid: ARn,0 n 7 ARm,0 m 7 The notation modm or modn indicates the modification field that goes with the ARm or ARn field, respectively. Refer to Table 13-10 on page 13-22 for further information. In indirect addressing of the 3-operand addressing mode, displacements (if used) are allowed to be 0 or 1, and the index registers (IR0 and IR1) can be used. The displacement of 1 is implied and is not explicitly coded in the instruction word. Figure 13-2. Encoding for 3-Operand Addressing Modes T 31 0 0 28 1 27 23 22 21 Destination 20 16 15 src1 13 12 11 10 8 7 src2 5 4 3 2 0 operation operation operation operation 0 0 1 1 0 1 0 1 dst dst dst dst 0 0 0 modn src1 ARn src1 ARn 0 0 0 0 0 0 modn modm src2 src2 ARn ARm 0 0 0 0 0 0 1 1 1 0 0 0 modn 13.4.3 Parallel Addressing Modes Instructions that use parallel addressing, indicated by || (two vertical bars), allow the most parallelism possible. The destination operands are indicated as d1 and d2, signifying dst1 and dst2, respectively (see Figure 13-3). The source operands, signified by src1 and src2, use the extended-precision registers. Operation refers to the parallel operation to be performed. Figure 13-3. Encoding for Parallel Addressing Modes 31 30 29 26 25 24 23 22 21 19 18 16 15 11 10 8 7 3 2 0 1 0 operation P d1 d2 src1 src2 modn ARn modm ARm The parallel addressing mode (P) field specifies how the operands are to be used, that is, whether they are source or destination. The specific relationship between the P field and the operands is detailed in the description of the individual parallel instructions. However, the operands are always encoded in the same way. Bits 31 and 30 are set to the value of 10, indicating parallel addressing mode instructions. Bits 25 and 24 specify the parallel addressing mode (P) field, which defines how to interpret bits 21-0 for addressing the src operands. Bits 21-19 define the src1 address, bits 18-16 define the src2 Addressing Modes 13-25 mnemonic Groups of Addressing Modes address, bits 15-8 the src3 address, and bits 7-0 the src 4 address. The notations modn and modm indicate which modification field goes with which ARn or ARm (auxiliary register) field, respectively. The following list describes the parallel addressing operands: src1 = Rn src2 = Rn d1 d2 P src3 src4 0 n 7 (extended-precision registers R0 -R7) 0 n 7 (extended-precision registers R0-R7) If 0, dst1 is R0. If 1, dst1 is R1. If 0, dst2 is R2. If 1, dst2 is R3. 0P3 indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) As in the 3-operand addressing mode, indirect addressing in the parallel addressing mode allows for displacements of 0 or 1 and the use of the index registers (IR0 and IR1). The displacement of 1 is implied and is not explicitly coded in the instruction word. In the encoding shown for this mode in Figure 13-3, if the src3 and src4 fields use the same auxiliary register, both addresses are correctly generated, but only the value created by the src3 field is saved in the auxiliary register specified. The assembler issues a warning if you specify this condition. The encoding of these parallel addressing modes has been extended in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater These addressing mode extensions also allow the use of any CPU register whenever an indirect operand is required in src3 and/or src4 operand. Figure 13-4 shows the encoding for extended parallel addressing instructions. Figure 13-4. Encoding for Extended Parallel Addressing Instructions 31 30 29 28 26 25 24 23 22 21 19 18 16 15 13 12 8 9 5 4 0 1 0 operation P d1 d2 src1 src2 1 1 1 src3 1 1 1 src4 13-26 Groups of Addressing Modes mnemonic 13.4.4 Conditional-Branch Addressing Modes Instructions using the conditional-branch addressing modes (Bcond, BcondD, CALLcond, DBcond, and DBcondD) can perform a variety of conditional operations. Bits 31-27 are set to the value of 01101, indicating conditional-branch addressing mode instructions. Bit 26 is set to 0 or 1; 0 selects DBcond, 1 selects Bcond. Selection of bit 25 determines the conditional-branch addressing mode (B). If B = 0, register addressing is used; if B = 1, PC-relative addressing is used. Bit 21 sets the type of branch: D = 0 for a standard branch or D = 1 for a delayed branch. The condition field (cond) specifies the condition checked to determine what action to take, that is, whether to branch (see Table 13-12 on page 13-30 for a list of condition codes). Figure 13-5 shows the encoding for conditionalbranch addressing. Figure 13-5. Encoding for Conditional-Branch Addressing Modes (a) DBcond (D) 31 26 25 24 22 21 20 16 15 5 4 0 0 0 1 1 1 1 0 0 1 1 1 1 B B ARn ARn D D cond cond 0 0 0 0 0 0 0 0 0 0 0 src reg immediate (PC relative) (b) Bcond (D) 31 26 25 B B 24 22 21 20 16 15 5 4 0 0 0 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 D D cond cond 0 0 0 0 0 0 0 0 0 0 0 src reg immediate (PC relative) (c) CALLcond 31 26 25 24 22 21 20 16 15 5 4 0 0 0 1 1 1 1 1 1 0 0 0 0 B B 0 0 0 0 0 0 0 0 cond cond 0 0 0 0 0 0 0 0 0 0 0 src reg immediate (PC relative) Addressing Modes 13-27 mnemonic Condition Codes and Flags 13.5 Condition Codes and Flags The 'C3x provides 20 condition codes (00000-10100, excluding 01011) that you can place in the cond field of any of the conditional instructions, such as RETScond or LDFcond. The conditions include signed and unsigned comparisons, comparisons to 0, and comparisons based on the status of individual condition flags. All conditional instructions can accept the suffix U to indicate unconditional operation. Seven condition flags provide information about properties of the result of arithmetic and logical instructions. The condition flags are stored in the status register (ST) and are affected by an instruction only when either of the following two cases occurs: - The destination register is one of the extended-precision registers (R7-R0). (This allows for modification of the registers used for addressing but does not affect the condition flags during computation.) - The instruction is one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3). (This makes it possible to set the condition flags according to the contents of any of the CPU registers.) The condition flags are modified by most instructions when either of the preceding conditions is established and either of the following two cases occurs: - A result is generated when the specified operation is performed to infinite precision. This is appropriate for compare and test instructions that do not store results in a register. It is also appropriate for arithmetic instructions that produce underflow or overflow. - The output is written to the destination register, as shown in Table 13-11. This is appropriate for other instructions that modify the condition flags. Table 13-11. Output Value Formats Type of Operation Floating point Integer Logical Output Format 8-bit exponent, one sign bit, 31-bit fraction 32-bit integer 32-bit unsigned integer Figure 13-6 shows the condition flags in the low-order bits of the status register. Following the figure is a list of status register condition flags with a description of how the flags are set by most instructions. For specific details of the effect of a particular instruction on the condition flags, see the description of that instruction in Section 13.6, Individual Instruction Descriptions, on page 13-32. 13-28 Running Title--Attribute Reference mnemonic Figure 13-6. Status Register 13 xx 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0 1 PRGW INT GIE CC CE CF xx RM OVM LUF LV UF N Z V C status config ('C32 only) ('C32 only) R R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W xx = reserved bit, read as 0 R = read, W = write Note: LUF Latched floating-point underflow condition flag. LUF is set whenever UF (floating-point underflow flag) is set. LUF can be cleared only by a processor reset or by modifying it in the status register (ST). Latched overflow conditionfFlag. LV is set whenever V (overflow condition flag) is set. Otherwise, it is unchanged. LV can be cleared only by a processor reset or by modifying it in the status register (ST). Floating-point underflow conditionflag. A floating-point underflow occurs whenever the exponent of the result is less than or equal to -128. If a floatingpoint underflow occurs, UF is set, and the output value is set to 0. UF is cleared if a floating-point underflow does not occur. Negative condition flag. Logical operations assign N the state of the MSB of the output value. For logical operations, V is set to the state of the MSB. For integer and floating-point operations, N is set if the result is negative and cleared otherwise. A 0 is positive. Zero condition flag. For logical, integer, and floating-point operations, Z is set if the output is 0 and cleared otherwise. Overflow condition flag. For integer operations, V is set if the result does not fit into the format specified for the destination (that is, -2 32 result 2 32 - 1). Otherwise, V is cleared. For floating-point operations, V is set if the exponent of the result is greater than 127; otherwise,V is cleared. Logical operations always clear V. Carry flag. When an integer addition is performed, C is set if a carry occurs out of the bit corresponding to the MSB of the output. When an integer subtraction is performed, C is set if a borrow occurs into the bit corresponding to the MSB of the output. Otherwise, for integer operations, C is cleared. The carry flag is unaffected by floating-point and logical operations. For shift instructions, this flag is set to the last bit shifted out; for a 0 shift count, this is set to 0. LV UF N Z V C Chapter Title--Attribute Reference 13-29 mnemonic Condition Codes and Flags Table 13-12 lists the condition mnemonic, code, description, and flag for each of the 20 condition codes. Table 13-12. Condition Codes and Flags (a) Unconditional compares Condition U Code 00000 Description Unconditional Flag Irrevelant (b) Unsigned compares Condition LO LS HI HS EQ NE Code 00001 00010 00011 00100 00101 00110 Description Lower than Lower than or same as Higher than Higher than or same as Equal to Not equal to Flag C C OR Z C AND Z C Z Z (c) Signed compares Condition LT LE GT GE EQ NE Code 00111 01000 01001 01010 00101 00110 Description Less than Less than or equal to Greater than Greater than or equal to Equal to Not equal to Flag N N OR Z N AND Z N Z Z = logical complement (not true condition) 13-30 Running Title--Attribute Reference mnemonic Table 13-12. Condition Codes and Flags (Continued) (d) Compare to zero Condition Z NZ P N NN Code 00101 00110 01001 00111 01010 Description Zero Not zero Positive Negative Non-negative Flag Z Z N AND Z N N (e) Compare to condition flags Condition NN N NZ Z NV V NUF UF NC C NLV LV NLUF LUF ZUF Code 01010 00111 00110 00101 01100 01101 01110 01111 00100 00001 10000 10001 10010 10011 10100 Description Non-negative Negative Nonzero Zero No overflow Overflow No underflow Underflow No carry Carry No latched overflow Latched overflow No latched floating-point underflow Latched floating-point underflow Zero or floating-point underflow Flag N Z Z N V V UF UF C C LV LV LUF LUF Z OR UF = logical complement (not true condition) Chapter Title--Attribute Reference 13-31 mnemonic Individual Instructions 13.6 Individual Instructions This section contains the individual assembly language instructions for the 'C3x. The instructions are listed in alphabetical order. Information for each instruction includes assembler syntax, operation, operands, encoding, description, cycles, status bits, mode bit, and examples. Definitions of the symbols and abbreviations, as well as optional syntax forms allowed by the assembler, precede the individual instruction description section. Also, an example instruction shows the special format used and explains its content. A functional grouping of the instructions, as well as a complete instruction set summary, can be found in Section 13.1 on page 13-2. Appendix A lists the opcodes for all of the instructions. Refer to Chapter 6 for information on memory addressing. Code examples using many of the instructions are provided in Chapter 1, Software Applications, of the TMS320C3x GeneralPurpose Applications User's Guide. 13.6.1 Symbols and Abbreviations Table 13-13 lists the symbols and abbreviations used in the individual instruction descriptions. 13-32 Individual Instructions mnemonic Table 13-13. Instruction Symbols Symbol src src1 src2 src3 src4 dst dst1 dst2 disp cond count G T P B |x| xy x(man) x(exp) op1 || op2 x AND y x OR y x XOR y x x << y x >> y *++SP *SP- - ARn IRn Rn RC RE RS ST Meaning Source operand Source operand 1 Source operand 2 Source operand 3 Source operand 4 Destination operand Destination operand 1 Destination operand 2 Displacement Condition Shift count General addressing modes 3-operand addressing modes Parallel addressing modes Conditional-branch addressing modes Absolute value of x Assign the value of x to destination y Mantissa field (sign + fraction) of x Exponent field of x Operation 1 performed in parallel with operation 2 Bitwise-logical AND of x and y Bitwise-logical OR of x and y Bitwise-logical XOR of x and y Bitwise-logical complement of x Shift x to the left y bits Shift x to the right y bits Increment SP and use incremented SP as address Use SP as address and decrement SP Auxiliary register n Index register n Register address n Repeat count register Repeat end address register Repeat start address register Status register Assembly Language Instructions 13-33 mnemonic Individual Instructions C GIE N PC RM SP Carry bit Global interrupt enable bit Trap vector Program counter Repeat mode flag System stack pointer 13.6.2 Optional Assembler Syntax The assembler allows a relaxed syntax form for some instructions. These optional forms simplify the assembly language so that special-case syntax can be ignored. A list of the optional syntax forms follows. - You can omit the destination register on unary arithmetic and logical oper- ations when the same register is used as a source. For example, ABSI R0,R0 can be written as ABSI R0 Instructions affected: ABSI, ABSF, FIX, FLOAT, NEGB, NEGF, NEGI, NORM, NOT, RND - You can write all 3-operand instructions without the 3. For example, ADDI3 R0,R1,R2 can be written as ADDI R0,R1,R2 Instructions affected: ADDC3, ADDF3, ADDI3, AND3, ANDN3, ASH3, LSH3, MPYF3, MPYI3, OR3, SUBB3, SUBF3, SUBI3, XOR3 This also applies to all of the pertinent parallel instructions. - You can write all 3-operand comparison instructions without the 3. For example, CMPI3 R0,*AR0 can be written as CMPI R0,*AR0 Instructions affected: CMPI3, CMPF3, TSTB3 - Indirect operands with an explicit 0 displacement are allowed. In 3-operand or parallel instructions, operands with 0 displacement are automatically converted to no-displacement mode. For example: LDI Also ADDI3 *+AR0(0),R1,R2 is equivalent to ADDI3 *AR0,R1,R2 - You can write indirect operands with no displacement, in which case a *+AR0(0),R1 is legal. displacement of 1 is assumed. For example, LDI *AR0++(1),R0 13-34 can be written as LDI *AR0++,R0 Individual Instructions mnemonic - All conditional instructions accept the suffix U to indicate unconditional operation. Also, you can omit the U from unconditional short branch instructions. For example: BU label can be written as B label - You can write labels with or without a trailing colon. For example: label0: label1 label2: NOP NOP label assembles to next source line - Empty expressions are not allowed for the displacement in indirect mode: LDI *+AR0(),R0 is not legal. - You can precede long immediate mode operands (destination of BR and CALL) with an @ sign: BR label can be written as BR @label - You can use the LDP pseudo-op to load a register (usually DP) with the eight most significant bits (MSBs) of a relocatable address: LDP addr,REG or LDP @addr,REG The @ sign is optional. If the destination register is the DP, you can omit the DP in the operand. LDP generates an LDI instruction with an immediate operand and a special relocation type. - You can write parallel instructions in either order. For example: ADDI || STI can be written as STI || ADDI - You can write the parallel bars indicating part 2 of a parallel instruction anywhere on the line from column 0 to the mnemonic. For example: ADDI || STI can be written as ADDI || STI - If the second operand of a parallel instruction is the same as the third (desti- nation register) operand, you can omit the third operand. This allows you to write 3-operand parallel instructions that look like normal 2-operand instructions. For example, ADDI *AR0,R2,R2 || MPYI *AR1,R0,R0 can be written as ADD *AR0,R2 || MPYI *AR1,R0 Instructions affected (applies to all parallel instructions that have a register second operand): ADDI, ADDF, AND, MPYI, MPYF, OR, SUBI, SUBF, XOR. Assembly Language Instructions 13-35 mnemonic Individual Instructions - You can write all commutative operations in parallel instructions in either order. For example, you can write the ADDI part of a parallel instruction in either of two ways: ADDI *AR0,R1,R2 or ADDI R1,*AR0,R2 Instructions affected include: parallel instructions containing any of the following: ADDI, ADDF, MPYI, MPYF, AND, OR, XOR. - Use the syntax in Table 13-14 to designate CPU registers in operands. Note the alternate notation Rn, 0 v n v 27, which is used to designate any CPU register. 13-36 Running Title--Attribute Reference mnemonic Table 13-14. CPU Register Syntax Assemblers Syntax R0 R1 R2 R3 R4 R5 R6 R7 AR0 AR1 AR2 AR3 AR4 AR5 AR6 AR7 DP IR0 IR1 BK SP ST IE IF IOF RS RE RC Alternate Register Syntax R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 Assigned Function Extended-precision register Extended-precision register Extended-precision register Extended-precision register Extended-precision register Extended-precision register Extended-precision register Extended-precision register Auxiliary register Auxiliary register Auxiliary register Auxiliary register Auxiliary register Auxiliary register Auxiliary register Auxiliary register Data-page pointer Index register 0 Index register 1 Block-size register Active stack pointer Status register CPU/DMA interrupt enable CPU interrupt flags I/O flags Repeat start address Repeat end address Repeat counter Chapter Title--Attribute Reference 13-37 mnemonic Individual Instructions 13.6.3 Individual Instruction Descriptions Each assembly language instruction for the 'C3x is described in this section in alphabetical order. The description includes the assembler syntax, operation, operands, encoding, description, cycles, status bits, mode bit, and examples. 13-38 Example Instruction EXAMPLE Syntax INST src, dst or INST1 src2, dst1 || INST2 src3, dst2 Each instruction begins with an assembler syntax expression. You can place labels either before the command (instruction mnemonic) on the same line or on the preceding line in the first column. The optional comment field that concludes the syntax is not included in the syntax expression. Space(s) are required between each field (label, command, operand, and comment fields). The syntax examples illustrate the common one-line syntax and the two-line syntax used in parallel addressing. Note that the two vertical bars || that indicate a parallel addressing pair can be placed anywhere before the mnemonic on the second line. The first instruction in the pair can have a label, but the second instruction cannot have a label. Operation |src | dst or |src2 | dst1 || src3 dst2 The instruction operation sequence describes the processing that occurs when the instruction is executed. For parallel instructions, the operation sequence is performed in parallel. Conditional effects of status-register-specified modes are listed for such conditional instructions as Bcond. Operands src general-addressing modes (G): 00 01 10 11 dst or src2 dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) register (Rn, 0 n 27) direct indirect immediate register (Rn, 0 n 27) Operands are defined according to the addressing mode and/or the type of addressing used. Note that indirect addressing uses displacements and the index registers. See Chapter 6 for detailed information on addressing. Assembly Language Instructions 13-39 EXAMPLE Example Instruction Opcode 31 0 0 0 INST 24 23 G dst 16 15 8 7 src 0 or 31 1 1 INST1INST2 24 23 dst1 0 0 0 16 15 src3 dst2 8 7 src2 0 Encoding examples are shown using general addressing and parallel addressing. The instruction pair for the parallel addressing example consists of INST1 and INST2. Description Instruction execution and its effect on the rest of the processor or memory contents is described. Any constraints on the operands imposed by the processor or the assembler are discussed. The description parallels and supplements the information given by the operation block. 1 The digit specifies the number of cycles required to execute the instruction. Status Bits LUF LV UF N Z V C Latched floating-point underflow condition flag. 1 if a floating-point underflow occurs; unchanged otherwise. Latched overflow condition flag. 1 if an integer or floating-point overflow occurs; unchanged otherwise. Floating-point underflow condition flag. 1 if a floating-point underflow occurs; 0 otherwise. Negative condition flag. 1 if a negative result is generated; 0 otherwise. In some instructions, this flag is the MSB of the output. Zero condition flag. 1 if a 0 result is generated; 0 otherwise. For logical and shift instructions, 1 if a 0 output is generated; 0 otherwise. Overflow condition flag. 1 if an integer or floating-point overflow occurs; 0 otherwise. Carry flag. 1 if a carry or borrow occurs; 0 otherwise. For shift instructions, this flag is set to the value of the last bit shifted out; 0 for a shift count of 0. Cycles The seven condition flags stored in the status register (ST) are modified by the majority of instructions only if the destination register is R7-R0. The flags provide information about the properties of the result or the output of arithmetic or logical operations. Mode Bit OVM Overflow mode flag. In general, integer operations are affected by the OVM bit value (described in Table 3-2 on page 3-6). 13-40 Example Instruction EXAMPLE Example INST @98AEh,R5 Before Instruction R5 R5 decimal DP LUF LV UF N Z V C Data memory 8098AEh 0200h 5CDF 1234 8098AEh 0200h 5CDF 1234 07 6690 0000 2.30562500e+02 080 0 0 0 0 0 0 0 R5 R5 decimal DP LUF LV UV N Z V C After Instruction 00 6690 1000 1.80126953e+00 080 0 0 0 0 0 0 0 The sample code presented in the above format shows the effect of the code on system pointers (for example, DP or SP), registers (for example, R1 or R5), memory at specific locations, and the seven status bits. The values given for the registers include the leading 0s to show the exponent in floating-point operations. Decimal conversions are provided for all register and memory locations. The seven status bits are listed in the order in which they appear in the assembler and simulator (see Section 13.5 on page 13-28 and Table 13-12 on page 13-30 for further information on these seven status bits). Assembly Language Instructions 13-41 ABSF Absolute Value of Floating Point Syntax Operation Operands ABSF src, dst |src| dst src general addressing modes (G): 00 01 10 11 dst Opcode 31 24 23 G dst 16 15 8 7 src 0 register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate register (Rn, 0 n 7) 0 0 0 0 0 0 0 0 0 Description The absolute value of the src operand is loaded into the dst register. The src and dst operands are assumed to be floating-point numbers. An overflow occurs if src (man) = 80000000h and src (exp) = 7Fh. The result is dst (man) = 7FFFFFFFh and dst (exp) = 7Fh. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7- R0. LUF LV UF N Z V C Unaffected 1 if a floating-point overflow occurs; unchanged otherwise 0 0 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. R4,R7 After Instruction R4 R7 LUF LV UF N Z V C 5C 8000 F971 -9.90337307e+27 5C 7FFF 068F 0 0 0 0 0 0 0 9.90337307e+27 5C 8000 F971 -9.90337307e+27 7D 2511 00AE 5.48527255e+37 0 0 0 0 0 0 0 Mode Bit Example OVM ABSF R4 R7 LUF LV UF N Z V C Before Instruction 13-42 Parallel ABSF and STF ABSF||STF Syntax || Operation || Operands ABSF src2, dst1 STF src3, dst2 |src2 | dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) src2 dst1 src3 dst2 This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 0 0 0 16 15 src3 dst2 8 7 src2 0 1 1 0 0 1 0 0 Description A floating-point absolute value and a floating-point store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STF) reads from a register and the operation being performed in parallel (ABSF) writes to the same register, STF accepts the contents of the register as input before it is modified by the ABSF. If src2 and dst2 point to the same location, src2 is read before the write to dst2. If src3 and dst1 point to the same register, src3 is read before the write to dst1. An overflow occurs if src (man) = 80000000h and src (exp) = 7Fh. The result is dst (man) = 7FFFFFFFh and dst (exp) = 7Fh. Cycles Status Bits 1 LUF LV UF N Z V C Unaffected 1 if a floating-point overflow occurs; unchanged otherwise 0 0 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Assembly Language Instructions 13-43 ABSF||STF Parallel ABSF and STF Mode Bit Example R4 AR3 AR7 IR1 LUF LV UF N Z V C Data Memory 8098AF 8098C4 58B4000 -6.118750e+01 8098AF 0 8098C4 58B4000 -6.118750e+01 733C000 1.79750e+02 OVM Operation is not affected by OVM bit value. ABSF STF Before Instruction 07 33C0 0000 1.79750e+02 80 9800 80 98C5 0AF 0 0 0 0 0 0 0 R4 AR3 AR7 IR1 LUF LV UF N Z V C *++AR3(IR1) ,R4 R4,*- AR7(1) After Instruction 05 74C0 0000 8098AF 8098C5 0AF 0 0 0 0 0 0 0 6.118750e+01 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-44 Absolute Value of Integer ABSI Syntax Operation Operands ABSI src, dst |src| dst src general addressing modes (G): 00 01 10 11 any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate dst any CPU register Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 0 0 0 0 0 1 Description The absolute value of the src operand is loaded into the dst register. The src and dst operands are assumed to be signed integers. An overflow occurs if src = 80000000h. If ST(OVM) = 1, the result is dst = 7FFFFFFFh. If ST(OVM) = 0, the result is dst = 80000000h. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7- R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 0 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Unaffected Operation is affected by OVM bit value. Mode Bit OVM Assembly Language Instructions 13-45 ABSI Absolute Value of Integer Example 1 ABSI or ABSI R0,R0 R0 Before Instruction R0 00 FFFF FFCB -53 R0 After Instruction 00 0000 0035 53 Example 2 ABSI *AR1,R3 Before Instruction R3 AR1 00 0000 0000 00 0020 R3 AR1 After Instruction 00 0000 0035 00 0020 53 Data memory 20 0FFFFFFCB -53 20 0FFFFFFCB -53 13-46 Parallel ABSI and STI ABSI||STI Syntax ABSI || STI src2, dst1 src3, dst2 Operation || Operands |src2 | dst1 src3 dst2 indirect register register indirect (disp = 0, 1, IR0, IR1) (Rn1, 0 1 7) (Rn2, 0 n2 7) (disp = 0, 1, IR0, IR1) src2 dst1 src3 dst2 This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 0 0 0 16 15 src3 dst2 8 7 src2 0 1 1 0 0 1 0 1 Description An integer absolute value and an integer store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STI) reads from a register and the operation being performed in parallel (ABSI) writes to the same register, STI accepts the contents of the register as input before it is modified by the ABSI. If src2 and dst2 point to the same location, src2 is read before the write to dst2. An overflow occurs if src = 80000000h. If ST(OVM) = 1, the result is dst = 7FFFFFFFh. If ST(OVM) = 0, the result is dst = 80000000h. Cycles 1 Assembly Language Instructions 13-47 ABSI||STI Parallel ABSI and STI Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Mode Bit Example || OVM Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 0 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Unaffected Operation is affected by OVM bit value. ABSI STI *-AR5(1),R5 R1,*AR2--(IR1) After Instruction 66 R1 R5 AR2 AR5 IR1 LUF LV UF N Z V C 00 0000 0042 00 0000 0035 80 98F0 80 99E2 0F 0 0 0 0 0 0 0 66 53 Before Instruction R1 R5 AR2 AR5 IR1 LUF LV UF N Z V C Data memory 8098FF 8099E1 2 -53 0FFFFFFCB 2 8098FF 8099E1 00 0000 0042 00 0000 0000 80 98FF 80 99E2 0F 0 0 0 0 0 0 0 42 -53 0FFFFFFCB 66 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-48 Add Integer With Carry ADDC Syntax Operation Operands ADDC src, dst dst + src + C dst src general addressing modes (G): 00 01 10 11 any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate dst any CPU register Opcode 31 0 0 0 0 0 2423 0 1 0 G dst 1615 8 7 src 0 Description Cycles Status Bits The sum of the dst and src operands and the carry (C) flag is loaded into the dst register. The dst and src operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a carry occurs; 0 otherwise Operation is affected by OVM bit value. R1,R5 Before Instruction R1 R5 LUF LV UF N Z V C 00 FFFF 5C25 00 FFFF 019E 0 0 0 0 0 0 0 -41,947 -65,122 R1 R5 LUF LV UF N Z V C After Instruction 00 FFFF 5C25 00 FFFE 5DC4 0 0 0 0 0 0 0 -41,947 -107,068 Mode Bit Example OVM ADDC Assembly Language Instructions 13-49 ADDC3 Add Integer With Carry, 3-Operand Syntax Operation Operands ADDC3 src2, src1, dst src1 + src2 + C dst src1 3-operand addressing modes (T): 00 01 10 11 any CPU register indirect (disp = 0, 1, IR0, IR1) any CPU register indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 any CPU register any CPU register indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) dst any CPU register Opcode 31 24 23 T dst 16 15 src1 8 7 src2 0 0 0 1 0 0 0 0 0 0 Description The sum of the src1 and src2 operands and the carry (C) flag is loaded into the dst register. The src1, src2, and dst operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV U N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a carry occurs; 0 otherwise Operation is affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-50 Add Integer With Carry, 3-Operand ADDC3 Example 1 ADDC3 or ADDC3 *AR5++(IR0),R5,R2 R5,*AR5++(IR0),R2 Before Instruction R2 R5 AR5 IR0 LUF LV UF N Z V C 00 0000 0000 00 0000 0066 102 80 9908 10 0 0 0 0 0 0 1 R2 R5 AR5 IR0 LUF LV UF N Z V C After Instruction 00 0000 0032 00 0000 0066 80 9918 10 0 0 0 0 0 0 1 50 102 Data memory 809908 0FFFFFFCB -53 809908 0FFFFFFCB -53 Example 2 ADDC3 R2, R7, R0 Before Instruction R0 R2 R7 LUF LV UF N Z V C 00 0000 0000 00 0000 02BC 700 R0 R2 R7 LUF LV UF N Z V C After Instruction 00 0000 123F 4671 00 0000 02BC 700 00 0000 0F82 3970 0 0 0 0 0 0 1 00 0000 0F82 3970 0 0 0 0 0 0 0 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-51 ADDF Syntax Add Floating-Point Values ADDF src, dst dst + src dst src general addressing modes (G): 00 01 10 11 dst register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate Operation Operands register (Rn, 0 n 7) 2423 G dst 16 15 8 7 src 0 Opcode 31 0 0 0 0 0 0 0 1 1 Description The sum of the dst and src operands is loaded into the dst register. The dst and src operands are assumed to be floating-point numbers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-52 Add Floating-Point Values ADDF Example ADDF *AR4++(IR1),R5 Before Instruction R5 AR IR LUF LV UF N Z V C Data memory 809800 86B2800 4.7031250e+02 809800 86B2800 4.7013250e+02 05 7980 0000 6.23750e+01 4809800 112B 0 0 0 0 0 0 0 R5 AR4 IR1 LUF LV UF N Z V C After Instruction 09 052C 0000 5.3268750e+02 80992B 12B 0 0 0 0 0 0 0 Assembly Language Instructions 13-53 ADDF3 Syntax Add Floating Point, 3-Operand ADDF3 src2, src1, dst Operation Operands src1 + src2 dst src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 dst Opcode 31 24 23 T dst 16 15 src1 8 7 src2 0 register (Rn2, 0 n2 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) register (Rn, 0 n 7) 0 0 1 0 0 0 0 0 1 Description The sum of the src1 and src2 operands is loaded into the dst register. The src1, src2, and dst operands are assumed to be floating-point numbers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-54 Add Floating Point, 3-Operand ADDF3 Example 1 ADDF3 or ADDF3 R1 R5 R6 LUF LV UF N Z V C R6,R5,R1 R5,R6,R1 After Instruction R1 R5 09 052C 0000 5.3268750e+02 05 7980 0000 6.23750e+01 08 6B28 0000 4.7031250e+02 0 0 0 0 0 0 0 Before Instruction 00 0000 0000 05 7980 0000 6.23750e+01 08 6B28 0000 4.7031250e+02 R6 0 0 0 0 0 0 0 LUF LV UF N Z V C Example 2 ADDF3 *+AR1(1),*AR7++(IR0),R4 After Instruction R4 AR1 AR7 IR0 LUF LV UV N Z V C 07 0DB2 0000 1.41695313e+02 80 9820 80 99F8 8 0 0 0 0 0 0 0 Before Instruction R4 AR1 AR7 IR0 LUF LV UF N Z V C Data memory 809821h 8099F0h 700F000 1.28940e+02 34C2000 1.27590e+01 809821h 8099F0h 00 0000 0000 80 9820 80 99FO 8 0 0 0 0 0 0 0 700F000 1.28940e+02 34C2000 1.27590e+01 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-55 ADDF3||STF Syntax Parallel ADDF3 and STF || Operation Operands ADDF3 STF src2, src1, dst1 src3, dst2 src1 + src2 dst1 || src3 dst2 src1 src2 dst1 src3 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 src2 dst1 src3 dst2 Opcode 31 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 src1 16 15 src3 dst2 8 7 src2 0 1 1 0 0 1 1 0 Description A floating-point addition and a floating-point store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STF) reads from a register and the operation being performed in parallel (ADDF3) writes to the same register, STF accepts as input the contents of the register before it is modified by the ADDF3. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected 13-56 Parallel ADDF3 and STF ADDF3||STF Mode Bit Example OVM Operation is not affected by OVM bit value. ADDF3 STF *+AR3(IR1),R2,R5 R4,*AR2 After Instruction 1.4050e+02 6.281250e+01 R2 R4 R5 AR2 AR3 IR1 LUF LV UV N Z V C 07 0C80 0000 05 7B40 0000 08 2020 0000 80 98F3 80 9800 0A5 0 0 0 0 0 0 0 1.4050e+02 6.281250e+01 3.20250e+02 || R2 R4 R5 AR2 AR3 IR1 LUF LV UF N Z V C Data memory 8098A5h 8098F3h Before Instruction 07 0C80 0000 05 7B40 0000 00 0000 0000 80 98F3 80 9800 0A5 0 0 0 0 0 0 0 733C000 0 1.79750e+02 8098A5h 8098F3h 733C000 57B4000 1.79750e+02 6.28125e+01 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-57 ADDI Add Integer Syntax Operation Operands ADDI src, dst dst + src dst src general addressing modes (G): 00 01 10 11 dst Opcode 31 24 23 G dst 16 15 8 7 src 0 any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate any CPU register 0 0 0 0 0 0 1 0 0 Description Cycles Status Bits The sum of the dst and src operands is loaded into the the dst register. The dst and src operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a carry occurs; 0 otherwise Operation is affected by OVM bit value. R3,R7 Before Instruction R3 R7 LUF LV UF N Z V C 00 FFFF FFCB -53 35 0 0 0 0 0 0 0 53 R3 R7 LUF LV UF N Z V C After Instruction 00 FFFF FFCB -53 00 0000 0000 0 0 0 0 0 0 0 Mode Bit Example OVM ADDI 13-58 Add Integer, 3-Operand ADDI3 Syntax Operation Operands ADDI3 <src2 >,<src1 >,<dst > src1 + src2 dst src1 3-operand addressing modes (T): 00 01 10 11 any CPU register indirect (disp = 0, 1, IR0, IR1) any CPU register indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 dst Opcode 31 24 23 T dst 16 15 src1 8 7 src2 0 any CPU register any CPU register indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) any CPU register 0 0 1 0 0 0 0 1 0 Description The sum of the src1 and src2 operands is loaded into the dst register. The src1, src2, and dst operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a carry occurs; 0 otherwise Operation is affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-59 ADDl3 Add Integer, 3-Operand Example 1 ADDI3 R4,R7,R5 Before Instruction R4 R5 R7 LUF LV UF N Z V C 00 0000 00DC 220 00 0000 0010 16 R4 R5 R7 LUF LV UF N Z V C After Instruction 00 0000 00DC 220 00 0000 017C 380 00 0000 00A0 160 0 0 0 0 0 0 0 00 0000 00A0 160 0 0 0 0 0 0 0 Example 2 ADDI3 *-AR3(1),*AR6--(IR0),R2 Before Instruction R2 AR3 AR6 IR0 LUF LV UF N Z V C 00 0000 0010 80 9802 80 9930 18 0 0 0 0 0 0 0 16 R2 AR3 AR6 IR0 LUF LV UV N Z V C After Instruction 00 0000 6598 26,000 80 9802 80 9918 18 0 0 0 0 0 0 0 Data memory 809801 809930 2AF8 11,000 3A98 15,000 809801 809930 2AF8 11,000 3A98 15,000 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-60 Parallel ADDI3 and STI ADDI3||STI Syntax || Operation Operands ADDI3 STI src2, src1, dst1 src3, dst2 src1 + src2 dst1 || src3 dst2 src1 src2 dst1 src3 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 src2 dst1 src3 dst2 Opcode 31 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) 2423 dst1 src1 16 15 src3 dst2 8 7 src2 0 1 1 0 0 1 1 1 Description An integer addition and an integer store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STI) reads from a register and the operation being performed in parallel (ADDI3) writes to the same register, STI accepts the contents of the register as input before it is modified by the ADDI3. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a carry occurs; 0 otherwise Assembly Language Instructions 13-61 ADDl3||STI Parallel ADDl3 and STI Mode Bit Example OVM Operation is affected by OVM bit value. ADDI3 STI R0 R3 R5 AR0 AR7 IR0 LUF LV UF N Z V C Data memory 80992C 80983B 12C 300 0 80992C 80983B 12C 300 35 53 *AR0--(IR0),R5,R0 R3,*AR7 After Instruction R0 53 220 R3 R5 AR0 AR7 IR0 LUF LV UV N Z V C 00 0000 0208 00 0000 0035 00 0000 00DC 80 9920 80 983B OC 0 0 0 0 0 0 0 520 53 220 Before Instruction 00 0000 0000 00 0000 0035 00 0000 00DC 80 992C 80 983B OC 0 0 0 0 0 0 0 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-62 Bitwise-Logical AND AND Syntax Operands Operands AND src, dst dst AND src dst src general addressing modes (G): 00 01 10 11 dst any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate (not sign extended) any CPU register Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 0 0 0 1 0 1 Description Cycles Status Bits The bitwise-logical AND between the dst and src operands is loaded into the dst register. The dst and src operands are assumed to be unsigned integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. R1,R2 Before Instruction R1 R2 LUF LV UF N Z V C 00 0000 0080 00 0000 0AFF 0 0 0 0 0 0 1 R1 R2 LUF LV UF N Z V C After Instruction 00 0000 0080 00 0000 0080 0 0 0 0 0 0 1 Mode Bit Example OVM AND Assembly Language Instructions 13-63 AND3 Bitwise-Logical AND, 3-Operand Syntax Operation Operands AND3 src2, src1, dst src1 AND src2 dst src1 3-operand addressing modes (T): 00 01 10 11 any CPU register indirect (disp = 0, 1, IR0, IR1) any CPU register indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 Opcode 31 24 23 T dst 16 15 src1 8 7 src2 0 any CPU register any CPU register indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) 0 0 1 0 0 0 0 1 1 Description The bitwise-logical AND between the src1 and src2 operands is loaded into the destination register. The src1, src2, and dst operands are assumed to be unsigned integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-64 Bitwise-Logical AND, 3-Operand AND3 Example 1 AND3 *AR0--(IR0),*+AR1,R4 Before Instruction R4 AR0 AR1 IR0 LUF LV UF N Z V C 00 0000 0000 80 98F4 80 9951 50 0 0 0 0 0 0 0 R4 AR0 AR1 IR0 LUF LV UF N Z V C After Instruction 00 0000 0020 80 98A4 80 9951 50 0 0 0 0 0 0 0 Data memory 8098F4h 809952h 30 123 8098F4h 809952h 30 123 Example 2 AND3 *-AR5,R7,R4 Before Instruction R4 R7 AR5 LUF LV UF N Z V C 00 0000 0000 00 0000 0002 80 985C 0 0 0 0 0 0 0 R4 R7 AR5 LUF LV UF N Z V C After Instruction 00 0000 0002 00 0000 0002 80 985C 0 0 0 0 0 0 0 Data memory 80985Bh 0AFF 80985Bh 0AFF Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-65 AND3||STI Parallel AND3 and STI Syntax Operation AND3 src2, src1, dst1 STI src3, dst2 src1 AND src2 dst1 || src3 dst2 src1 src2 dst1 src3 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) Operands This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 src2 dst1 src3 dst2 Opcode 31 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 src1 16 15 src3 dst2 8 7 src2 0 1 1 0 1 0 0 0 Description A bitwise-logical AND and an integer store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STI) reads from a register and the operation being performed in parallel (AND3) writes to the same register, STI accepts the contents of the register as input before it is modified by the AND3. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles 1 13-66 Running Title--Attribute Reference mnemonic Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Chapter Title--Attribute Reference 13-67 AND3||STI Parallel AND3 and STI Mode Bit Example || OVM Operation is not affected by OVM bit value. AND3 STI *+AR1(IR0),R4,R7 R3,*AR2 After Instruction R0 53 R3 R4 R7 AR1 AR2 LUF LV UF N Z V C 00 0000 0008 00 0000 0035 00 0000 A323 00 0000 0003 80 99F1 80 983F 0 0 0 0 0 0 0 53 Before Instruction R0 R3 R4 R7 AR1 AR2 LUF LV UF N Z V C Data memory 8099F9h 80983Fh 5C53 0 8099F9h 80983Fh 00 0000 0008 00 0000 0035 00 0000 A323 00 0000 0000 80 99F1 80 983F 0 0 0 0 0 0 0 5C53 35 53 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-68 Bitwise-Logical AND With Complement ANDN Syntax Operation Operands ANDN src, dst dst AND src dst src general addressing modes (G): 00 01 10 11 dst any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate (not sign extended) any CPU register Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 0 0 0 1 1 0 Description The bitwise-logical AND between the dst operand and the bitwise-logical complement () of the src operand is loaded into the dst register. The dst and src operands are assumed to be unsigned integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-69 ANDN Bitwise-Logical AND With Complement Example ANDN @980Ch,R2 Before Instruction R2 DP LUF LV UF N Z V C Data memory 80980Ch 0A02 80980Ch 0A02 00 0000 0C2F 080 0 0 0 0 0 0 0 R2 DP LUF LV UF N Z V C After Instruction 00 0000 042D 080 0 0 0 0 0 0 0 13-70 Bitwise-Logical ANDN, 3-Operand ANDN3 Syntax Operation Operands ANDN3 src2, src1, dst src1 AND src2 dst src1 3-operand addressing modes (T): 00 01 10 11 any CPU register indirect (disp = 0, 1, IR0, IR1) any CPU register indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 dst Opcode 31 24 23 T dst 16 15 src1 8 7 src2 0 any CPU register any CPU register indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IO0, IR1) register (Rn, 0 n 27) 0 0 1 0 0 0 1 0 0 Description The bitwise-logical AND between the src1 operand and the bitwise-logical complement () of the src2 operand is loaded into the dst register. The src1, src2, and dst operands are assumed to be unsigned integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-71 ANDN3 Bitwise-Logical ANDN, 3-Operand Example 1 ANDN3 R5,R3,R7 Before Instruction R3 R5 R7 LUF LV UF N Z V C 00 0000 0C2F 00 0000 0A02 00 0000 0000 0 0 0 0 0 0 0 R3 R5 R7 LUF LV UF N Z V C After Instruction 00 0000 0C2F 00 0000 0A02 00 0000 042D 0 0 0 0 0 0 0 Example 2 ANDN3 R1,*AR5++(IR0),R0 Before Instruction R0 R1 AR5 IR0 LUF LV UF N Z V C Data memory 809825h 0FFF 809825h 0FFF 00 0000 0000 00 0000 00CF 80 9825 5 0 0 0 0 0 0 0 R0 R1 AR5 IR0 LUF LV UF N Z V C After Instruction 00 0000 0F30 00 0000 00CF 80 982A 5 0 0 0 0 0 0 0 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-72 Arithmetic Shift ASH Syntax Operation ASH count, dst If (count 0): dst << count dst Else: dst >> |count | dst Operands count general addressing modes (G): 00 01 10 11 any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate dst any CPU register Opcode 31 24 23 G dst 16 15 8 7 count 0 0 0 0 0 0 0 1 1 1 Description The seven LSBs of the count operand are used to generate the 2s-complement shift count of up to 32 bits. If the count operand is greater than 0, the dst operand is left shifted by the value of the count operand. Low-order bits that are shifted in are zero filled, and highorder bits are shifted out through the carry (C) bit. Arithmetic left shift: C dst 0 If the count operand is less than 0, the dst operand is right shifted by the absolute value of the count operand. The high-order bits of the dst operand are signextended as it is right shifted. Low-order bits are shifted out through the C bit. Arithmetic right shift: sign of dst dst C If the count operand is 0, no shift is performed, and the C bit is set to 0. The count and dst operands are assumed to be signed integers. Cycles 1 Assembly Language Instructions 13-73 ASH Arithmetic Shift Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Mode Bit Example 1 OVM Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Set to the value of the last bit shifted out; 0 for a shift count of 0 Operation is not affected by OVM bit value. ASH R1,R3 Before Instruction R1 R3 LUF LV UF N Z V C 00 0000 0010 00 000A E000 0 0 0 0 0 0 0 16 R1 R3 LUF LV UF N Z V C After Instruction 00 0000 0010 00 E000 0000 0 1 0 1 0 1 0 Example 2 ASH @98C3h,R5 Before Instruction R5 DP LUF LV UF N Z V C Data memory 8098C3h 0FFE8 -24 8098C3h 0FFE8 -24 00 AEC0 0001 80 0 0 0 0 0 0 0 R5 DP LUF LV UF N Z V C After Instruction 00 FFFF FFAE 80 0 0 0 1 0 0 1 13-74 Arithmetic Shift, 3-Operand ASH3 Syntax Operation ASH3 count, src, dst If (count 0): src << count dst Else: src >> |count | dst Operands count 3-operand addressing modes (T): 00 01 10 11 register (Rn2, 0 n2 27) register (Rn2, 0 n2 27) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) src 3-operand addressing modes (T): 00 01 10 11 dst Opcode 31 24 23 T dst 16 15 src 8 7 count 0 register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) register (Rn, 0 n 27) 0 0 1 0 0 0 1 0 1 Description The seven LSBs of the count operand are used to generate the 2s-complement shift count of up to 32 bits. If the count operand is greater than 0, the src operand is left shifted by the value of the count operand. Low-order bits that are shifted in are zero filled, and highorder bits are shifted out through the status register's C bit. Arithmetic left shift: C src 0 If the count operand is less than 0, the src operand is right shifted by the absolute value of the count operand. The high-order bits of the src operand are sign extended as they are right shifted. Low-order bits are shifted out through the C (carry) bit. Arithmetic right shift: sign of src src C If the count operand is 0, no shift is performed, and the C bit is set to 0. The count, src, and dst operands are assumed to be signed integers. Cycles 1 Assembly Language Instructions 13-75 ASH3 Arithmetic Shift, 3-Operand Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Mode Bit Example 1 OVM ASH3 Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Set to the value of the last bit shifted out; 0 for a shift count of 0 Operation is not affected by OVM bit value. *AR3--(1),R5,R0 Before Instruction R0 R5 AR3 LUF LV UF N Z V C Data memory 809921h 10 16 809921h 10 16 00 0000 0000 00 0000 02B0 80 9921 0 0 0 0 0 0 0 R0 R5 AR3 LUF LV UF N Z V C After Instruction 00 02B0 0000 00 0000 02B0 80 9920 0 0 0 0 0 0 0 13-76 Arithmetic Shift, 3-Operand ASH3 Example 2 ASH3 R1,R3,R5 Before Instruction R1 R3 R5 LUF LV UF N Z V C 00 FFFF FFF8 -8 00 FFFF CB00 00 0000 0000 0 0 0 0 0 0 0 R1 R3 R5 LUF LV UF N Z V C After Instruction 00 FFFF FFF8 00 FFFF CB00 00 FFFF FFCB 0 0 0 1 0 0 0 -8 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8.5.2 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-77 ASH3||STI Parallel ASH3 and STI Syntax || Operation ASH3 count, src2, dst1 STI src3, dst2 If (count 0): src2 << count dst1 Else: src2 >> |count| dst1 || src3 dst2 Operands count register (Rn1, 0 n1 7) src2 dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 count 16 15 src3 dst2 8 7 src2 0 1 1 0 1 0 0 1 Description The seven LSBs of the count operand register are used to generate the 2scomplement shift count of up to 32 bits. If the count operand is greater than 0, the src2 operand is left shifted by the value of the count operand. Low-order bits shifted in are zero filled, and highorder bits are shifted out through the C bit. Arithmetic left shift: C src2 0 If the count operand is less than 0, the src2 operand is right hifted by the absolute value of the count operand. The high-order bits of the src2 operand are sign extended as they are right shifted. Low-order bits are shifted out through the C bit. 13-78 Parallel ASH3 and STI ASH3||STI Arithmetic right shift: sign of src2 src2 C If the count operand is 0, no shift is performed, and the C bit is set to 0. The count and dst operands are assumed to be signed integers. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STI) reads from a register and the operation being performed in parallel (ASH3) writes to the same register, STI accepts the contents of the register as input before it is modified by the ASH3. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Mode Bit OVM Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Set to the value of the last bit shifted out; 0 for a shift count of 0 Operation is not affected by OVM bit value. Assembly Language Instructions 13-79 ASH3||STI Parallel ASH3 and STI Example || ASH3 STI R0 R1 R5 AR2 AR6 IR1 LUF LV UF N Z V C Data memory 809900h 8098A2h R1,*AR6++(IR1),R0 R5,*AR2 After Instruction R0 -24 53 R1 R5 AR2 AR6 IR1 LUF LV UF N Z V C 00 FFFF FFAE 00 0000 FFE8 -24 00 0000 0035 80 98A2 80 998C 8C 0 0 0 0 0 0 0 53 00 0000 0000 00 0000 FFE8 00 0000 0035 80 98A2 80 9900 8C 0 0 0 0 0 0 0 Before Instruction 0AE000000 0 809900h 8098A2h 0AE000000 35 53 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-80 Branch Conditionally (Standard) Bcond Syntax Operation Bcond src If cond is true: If src is in register-addressing mode (Rn, 0 n 27), src PC. If src is in PC-relative mode (label or address), displacement + PC + 1 PC. Else, continue src conditional-branch addressing modes (B): 0 1 register PC relative Operands Opcode 31 24 23 cond 16 15 8 7 Register or displacement 0 0 1 1 0 1 0 B 0 0 0 0 Description Bcond signifies a standard branch that executes in four cycles. A branch is performed if the condition is true (since a pipeline flush also occurs on a true condition; see Section 8.2, Pipeline Conflicts, on page 8-4). If the src operand is expressed in register addressing mode, the contents of the specified register are loaded into the PC. If the src operand is expressed in PC-relative mode, the assembler generates a displacement: displacement = label - (PC of branch instruction + 1). This displacement is stored as a 16-bit signed integer in the 16 LSBs of the branch instruction word. This displacement is added to the PC of the branch instruction plus 1 to generate the new PC. The 'C3x provides 20 condition codes that you can use with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes and flags). Condition flags are set on a previous instruction only when the destination register is one of the extended-precision registers (R7-R0) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Cycles Status Bits 4 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Assembly Language Instructions 13-81 Mode Bit Bcond Example Branch Conditionally (Standard) BZ R0 Before Instruction R0 PC LUF LV UF N Z V C 00 0003 FF00 2B00 0 0 0 0 1 0 0 R0 PC LUF LV UF N Z V C After Instruction 00 0003 FF00 3 FF00 0 0 0 0 1 0 0 Note: If a BZ instruction is executed immediately following a RND instruction with a 0 operand, the branch is not performed, because the 0 flag is not set. To circumvent this problem, execute a BZUF instead of a BZ instruction. 13-82 Branch Conditionally (Delayed) BcondD Syntax Operation Bcond D src If cond is true: If src is in register-addressing mode (Rn, 0 n 27), src PC. If src is in PC-relative mode (label or address), displacement + PC + 3 PC. Else, continue src conditional-branch addressing modes (B): 0 1 register PC relative Operands Opcode 31 24 23 cond 16 15 8 7 Register or displacement 0 0 1 1 0 1 0 B 0 0 0 1 Description BcondD signifies a delayed branch that allows the three instructions after the delayed branch to be fetched before the PC is modified. The effect is a singlecycle branch, and the three instructions following BcondD do not affect the condition. A branch is performed if the condition is true. If the src operand is expressed in register-addressing mode, the contents of the specified register are loaded into the PC. If the src operand is expressed in PC-relative mode, the assembler generates a displacement: displacement = label - (PC of branch instruction + 3). This displacement is stored as a 16-bit signed integer in the 16 LSBs of the branch instruction. This displacement is added to the PC of the branch instruction plus 3 to generate the new PC. The 'C3x provides 20 condition codes that you can use with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes, and flags). Condition flags are set on the previous instruction only when the destination register is one of the extended-precision registers (R7-R0) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Cycles Status Bits 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Assembly Language Instructions 13-83 Mode Bit BcondD Example Branch Conditionally (Delayed) BNZD 36 (36 = 24h) Before Instruction PC LUF LV UF N Z V C 0050 0 0 0 0 0 0 0 PC LUF LV UF N Z V C After Instruction 0077 0 0 0 0 0 0 0 Note: Delayed branches disable interrupts until the completion of the three instructions that follow the delayed branch, regardless if the branch is or is not performed. The following instructions cannot be used in the next three instructions following a delayed branch: Bcond, BcondD, BR, BRD, CALL, CALLcond, DBcond, DBcondD, IDLE, IDLE2, RETIcond, RETScond, RPTB, RPTS, TRAPcond. 13-84 Branch Unconditionally (Standard) BR Syntax Operation Operands Opcode BR src src PC src long-immediate addressing mode 31 24 23 16 15 src 8 7 0 0 1 1 0 0 0 0 0 Description BR performs a PC-relative branch that executes in four cycles, since a pipeline flush also occurs upon execution of the branch (see Section 8.2, Pipeline Conflicts, on page 8-4). An unconditional branch is performed. The src operand is assumed to be a 24-bit unsigned integer. Note that bit 24 = 0 for a standard branch. 4 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Example BR 805Ch Before Instruction PC LUF LV UF N Z V C 0080 0 0 0 0 0 0 0 PC LUF LV UF N Z V C After Instruction 805C 0 0 0 0 0 0 0 Assembly Language Instructions 13-85 BRD Branch Unconditionally (Delayed) Syntax Operation Operands Opcode 31 24 23 16 15 src 8 7 0 BRD src src PC src long-immediate addressing mode 0 1 1 0 0 0 0 1 Description BRD signifies a delayed branch that allows the three instructions after the delayed branch to be fetched before the PC is modified. The effect is a single-cycle branch. An unconditional branch is performed. The src operand is assumed to be a 24-bit unsigned integer. Note that bit 24 = 1 for a delayed branch. Cycles Status Bits 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit Example BRD 2Ch Before Instruction PC LUF LV UF N Z V C 001B 0 0 0 0 0 0 0 PC LUF LV UF N Z V C After Instruction 002C 0 0 0 0 0 0 0 13-86 Call Subroutine CALL Syntax Operation CALL src Next PC *++SP src PC src long-immediate addressing mode Operands Opcode 31 24 23 16 15 src 8 7 0 0 1 1 0 0 0 1 0 Description A call is performed. The next PC value is pushed onto the system stack. The src operand is loaded into the PC. The src operand is assumed to be a 24-bit unsigned-immediate operand. Since the CALL instruction takes 4 cycles to execute, the pipeline is flushed. 4 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Example CALL 123456h Before Instruction PC SP LUF LV UF N Z V C Data memory 809802h 6 0005 809801 0 0 0 0 0 0 0 PC SP LUF LV UF N Z V C After Instruction 123456 809802 0 0 0 0 0 0 0 Assembly Language Instructions 13-87 CALLcond Syntax Operation Call Subroutine Conditionally CALLcond src If cond is true: Next PC *++SP If src is in register addressing mode (Rn, 0 n 27), src PC. If src is in PC-relative mode (label or address), displacement + PC + 1 PC. Else, continue Operands src conditional-branch addressing modes (B): 0 1 register PC relative Opcode 31 24 23 cond 16 15 8 7 Register or displacement 0 0 1 1 1 0 0 B 0 0 0 0 Description A call is performed if the condition is true. If the condition is true, the next PC value is pushed onto the system stack. If the src operand is expressed in register addressing mode, the contents of the specified register are loaded into the PC. If the src operand is expressed in PC-relative mode, the assembler generates a displacement: displacement = label - (PC of call instruction + 1). This displacement is stored as a 16-bit signed integer in the 16 LSBs of the call instruction word. This displacement is added to the PC of the call instruction plus 1 to generate the new PC. This instruction flushes the pipeline as shown in Example 8-13 on page 8-18. The 'C3x provides 20 condition codes that can be used with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes, and flags). Condition flags are set on a previous instruction only when the destination register is one of the extended-precision registers (R7-R0) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Cycles Status Bits 5 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit 13-88 Call Subroutine Conditionally CALLcond Example CALLNZ R5 Before Instruction R5 PC SP LUF LV UF N Z V C Data memory 809836h 124 00 0000 0789 0123 809835 0 0 0 0 0 0 0 R5 PC SP LUF LV UF N Z V C After Instruction 00 0000 0789 0789 809836 0 0 0 0 0 0 0 Assembly Language Instructions 13-89 CMPF Syntax Compare Floating-Point Value CMPF src, dst dst - src src general addressing modes (G): 00 01 10 11 dst register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate Operation Operands register (Rn, 0 n 7) Opcode 31 24 23 G dst 1615 8 7 src 0 0 0 0 0 0 1 0 0 0 Description The src operand is subtracted from the dst operand. The result is not loaded into any register, which allows for nondestructive compares. The dst and src operands are assumed to be floating-point numbers. 1 These condition flags are modified for all destination registers (R27 -R0). LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-90 Compare Floating-Point Value CMPF Example CMPF *+AR4,R6 Before Instruction R6 AR4 LUF LV UF N Z V C Data memory 8098F3h 070C8000 1.4050e+02 8098F3h 070C8000 1.4050e+02 07 0C80 0000 1.4050e+02 80 98F2 0 0 0 0 0 0 0 R6 AR4 LUF LV UF N Z V C After Instruction 07 0C80 0000 1.4050e+02 80 98F2 0 0 0 0 1 0 0 Assembly Language Instructions 13-91 CMPF3 Syntax Operation Operands Compare Floating-Point Value, 3-Operand CMPF3 src2, src1 src1 - src2 src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 Opcode 31 24 23 T 16 15 0 0 0 0 0 src1 8 7 src2 0 register (Rn2, 0 n2 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) 0 0 1 0 0 0 1 1 0 Description The src2 operand is subtracted from the src1 operand. The result is not loaded into any register, which allows for nondestructive compares. The src1 and src2 operands are assumed to be floating-point numbers. Although this instruction has only two operands, it is designated as a 3-operand instruction because operands are specified in the 3-operand format. 1 These condition flags are modified for all destination registers (R27 -R0). LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-92 Compare Floating-Point Value, 3-Operand CMPF3 Example CMPF3 AR2 AR3 LUF LV UF N Z V C Data memory 809831h 809852h *AR2,*AR3--(1) Before Instruction 80 9831 80 9852 0 0 0 0 0 0 0 AR2 AR4 LUF LV UF N Z V C After Instruction 80 9831 80 9851 0 0 0 1 0 0 0 77A7000 2.5044e+02 57A2000 6.253125e+01 809831h 809852h 77A7000 2.5044e+02 57A2000 6.253125e+01 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-93 CMPI Compare Integer Syntax Operation Operands CMPI src, dst dst - src src general addressing modes (G): 00 01 10 11 dst Opcode 31 24 23 G dst 16 15 8 7 src 0 register (Rn, 0 n 27) direct indirect (disp = 0-255, IR0, IR1) immediate register (Rn, 0 n 27) 0 0 0 0 0 1 0 0 1 Description The src operand is subtracted from the dst operand. The result is not loaded into any register, thus allowing for nondestructive compares. The dst and src operands are assumed to be signed integers. 1 These condition flags are modified for all destination registers (R27 -R0). LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Example OVM CMPI R3,R7 Before Instruction R3 R7 LUF LV UF N Z V C 00 0000 0898 2200 00 0000 03E8 1000 0 0 0 0 0 0 0 R3 R7 LUF LV UF N Z V C After Instruction 00 0000 0898 2200 00 0000 03E8 1000 0 0 0 1 0 0 1 13-94 Compare Integer, 3-Operand CMPI3 Syntax Operation Operands CMPI3 src2, src1 src1 - src2 src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 Opcode 31 24 23 T 16 15 0 0 0 0 0 src1 8 7 src2 0 register (Rn2, 0 n2 27) register (Rn2, 0 n2 27) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) 0 0 1 0 0 0 1 1 1 Description The src2 operand is subtracted from the src1 operand. The result is not loaded into any register, which allows for nondestructive compares. The src1 and src2 operands are assumed to be signed integers. Although this instruction has only two operands, it is designated as a 3-operand instruction because operands are specified in the 3-operand format. 1 These condition flags are modified for all destination registers (R27 -R0). LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-95 CMPI3 Example Compare Integer, 3-Operand CMPI3 R7,R4 Before Instruction R4 R7 LUF LV UF N Z V C 00 0000 0898 2200 00 0000 03E8 1000 0 0 0 0 0 0 0 R4 R7 LUF LV UF N Z V C After Instruction 00 0000 0898 2200 00 0000 03E8 1000 0 0 0 0 0 0 0 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-96 Decrement and Branch Conditionally (Standard) DBcond Syntax Operation DBcond ARn, src ARn - 1 ARn If cond is true and ARn 0 : If src is in register addressing mode (Rn, 0 n 27), src PC. If src is in PC-relative mode (label or address), displacement + PC + 1 PC. Else, continue src conditional-branch addressing modes (B): 0 1 register PC relative Operands ARn register (0 n 7) Opcode 31 0 1 1 0 1 1 B 24 23 ARn 0 cond 16 15 8 7 Register or displacement 0 Description DBcond signifies a standard branch that executes in four cycles because the pipeline must be flushed if cond is true. The specified auxiliary register is decremented and a branch is performed if the condition is true and the specified auxiliary register is greater than or equal to 0. The condition flags are those set by the last previous instruction that affects the status bits. The auxiliary register is treated as a 24-bit signed integer. The 8 MSBs are unmodified by the decrement operation. The comparison of the auxiliary register uses only the 24 LSBs of the auxiliary register. Note that the branch condition does not depend on the auxiliary register decrement. If the src operand is expressed in register addressing mode, the contents of the specified register are loaded into the PC. If the src operand is expressed in PC-relative addressing mode, the assembler generates a displacement: displacement = label - (PC of branch instruction + 1). This integer is stored as a 16-bit signed integer in the 16 LSBs of the branch instruction word. This displacement is added to the PC of the branch instruction plus 1 to generate the new PC. The 'C3x provides 20 condition codes that can be used with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes, and flags). Condition flags are set on a previous instruction only when the destination register is one of the extended-precision registers (R0-R7) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Assembly Language Instructions 13-97 DBcond Cycles Decrement and Branch Conditionally (Standard) 4 LUF LV UF N Z V C OVM CMPI DBLT Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. 200,R3 AR3,R2 Before Instruction R2 R3 AR3 PC LUF LV UF N Z V C 00 0000 009F 00 0000 0080 00 0012 005F 0 0 0 1 0 0 0 R2 R3 AR3 PC LUF LV UF N Z V C After Instruction 00 0000 009F 00 0000 0080 00 0011 009F 0 0 0 1 0 0 0 Status Bits Mode Bit Example 13-98 Decrement and Branch Conditionally (Delayed) DBcondD Syntax Operation DBcond D ARn, src ARn - 1 ARn If cond is true and ARn 0: If src is in register addressing mode (Rn, 0 n 27) src PC If src is in PC-relative mode (label or address) displacement + PC + 3 PC. Else, continue Operands src conditional-branch addressing modes (B): 0 1 register PC relative ARn register (0 n 7) Opcode 31 0 1 1 0 1 1 B 24 23 ARn 1 cond 16 15 8 7 Register or displacement 0 Description DBcond D signifies a delayed branch that allows the three instructions after the delayed branch to be fetched before the PC is modified. The effect is a single-cycle branch. The specified auxiliary register is decremented, and a branch is performed if the condition is true and the specified auxiliary register is greater than or equal to 0. The condition flags are those set by the last previous instruction that affects the status bits. The three instructions following the DBcondD do not affect the condition. The auxiliary register is treated as a 24-bit signed integer. The 8 MSBs are unmodified by the decrement operation. The comparison of the auxiliary register uses only the 24 LSBs of the auxiliary register. The branch condition does not depend on the auxiliary register decrement. If the src operand is expressed in register-addressing mode, the contents of the specified register are loaded into the PC. If the src is expressed in PC-relative addressing, the assembler generates a displacement: displacement = label - (PC of branch instruction + 3). This displacement is added to the PC of the branch instruction plus 3 to generate the new PC. Note that bit 21 = 1 for a delayed branch. The 'C3x provides 20 condition codes that you can use with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes, and flags). Condition flags are set on a previous instruction only when the destination register is one of the extended-precision registers (R7-R0) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Assembly Language Instructions 13-99 DBcondD Cycles Status Bits Decrement and Branch Conditionally (Delayed) 1 LUF LV UF N Z V C OVM CMPI DBZD Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. 26h,R2 AR5, $+110h Before Instruction R2 AR5 PC LUF LV UF N Z V C 00 0000 0026 00 0067 0100 0 0 0 0 0 0 0 R2 AR5 PC LUF LV UF N Z V C After Instruction 00 0000 0026 00 0066 0210 0 0 0 0 1 0 0 Mode Bit Example 13-100 Floating-Point-to-Integer Conversion FIX Syntax Operation Operands FIX src, dst fix(src) dst src general addressing modes (G): 00 01 10 11 dst register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate any CPU register Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 0 0 1 0 1 0 Description The floating-point operand src is rounded down to the nearest integral value less than or equal to floating-point value, and the result is loaded into the dst register. The src operand is assumed to be a floating-point number and the dst operand a signed integer. The exponent field of the dst register (bits 39-32) is not modified. Integer overflow occurs when the floating-point number is too large to be represented as a 32-bit 2s-complement integer. In the case of integer overflow, the result is saturated in the direction of overflow. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Mode Bit OVM Assembly Language Instructions 13-101 FIX Floating-Point-to-Integer Conversion Example FIX R1,R2 Before Instruction R1 R2 LUF LV UF N Z V C 0A 2820 0000 1.3454e+3 00 0000 0000 0 0 0 0 0 0 0 R1 R2 LUF LV UF N Z V C After Instruction 0A 2820 0000 13454e+3 00 0000 0541 1345 0 0 0 0 0 0 0 13-102 Parallel FIX and STI FIX||STI Syntax || Operation FIX src2, dst1 STI src3, dst2 fix(src2 ) dst1 || src3 dst2 src2 dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) Operands This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 0 0 0 16 15 src3 dst2 8 7 src2 0 1 1 0 1 0 1 0 Description A floating-point-to-integer conversion is performed. All registers are read at the beginning and loaded at the end of the execute cycle. This means that, if one of the parallel operations (STI) reads from a register, and the operation being performed in parallel (FIX) writes to the same register, STI accepts the contents of the register as input before it is modified by FIX. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Integer overflow occurs when the floating-point number is too large to be represented as a 32-bit 2s-complement integer. In the case of integer overflow, the result is saturated in the direction of overflow. Cycles 1 Assembly Language Instructions 13-103 FIX||STI Parallell FIX and STI Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Mode Bit Example || R0 R1 AR2 AR4 LUF LV UF N Z V C Data memory 8098A3h 80983Ch 733C000 1.7950e+02 0 8098A3 80983C 733C000 1.79750e+02 0DC 220 Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. FIX STI *++AR4(1),R1 R0,*AR2 Before Instruction 00 0000 00DC 220 00 0000 0000 80 983C 80 98A2 0 0 0 0 0 0 0 R0 R1 AR2 AR4 LUF LV UF N Z V C After Instruction 00 0000 00DC 220 00 0000 00B3 179 80 983C 80 98A3 0 0 0 0 0 0 0 OVM Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-104 Integer-to-Floating-Point Conversion FLOAT Syntax Operation Operands FLOAT src, dst float (src) dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 27) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 7) Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 0 0 1 0 1 1 Description The integer operand src is converted to the floating-point value equal to it; the result is loaded into the dst register. The src operand is assumed to be a signed integer; the dst operand is assumed to be a floating-point number. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-105 FLOAT Example Integer-to-Floating-Point Conversion FLOAT *++AR2(2),R5 Before Instruction R5 AR2 LUF LV UF N Z V C Data memory 809802 0AE 174 809802 0AE 174 00 034C 2000 1.27578125e+01 80 9800 0 0 0 0 0 0 0 R5 AR2 LUF LV UF N Z V C After Instruction 00 72E0 0000 1.74e+02 80 9802 0 0 0 0 0 0 0 13-106 Parallel FLOAT and STF FLOAT||STF Syntax || Operation Operands FLOAT src2, dst1 STF src3, dst2 float(src2 ) dst1 || src3 dst2 src2 dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) register (disp = 0, 1, IR0, IR1) This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) register (disp = 0, 1, IR0, IR1) 24 23 dst1 0 0 0 16 15 src3 dst2 8 7 src2 0 1 1 0 1 0 1 1 Description An integer-to-floating-point conversion is performed. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STF) reads from a register and the operation being performed in parallel (FLOAT) writes to the same register, then STF accepts the contents of the register as input before it is modified by FLOAT. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is affected by OVM bit value. Assembly Language Instructions 13-107 Mode Bit OVM FLOAT||STF Example Parallel FLOAT and STF || R6 R7 AR1 AR2 IR0 LUF LV UF N Z V C Data memory 8098CD 809933 FLOAT STF Before Instruction 00 0000 0000 *+AR2(IR0),R6 R7,*AR1 After Instruction R6 R7 AR1 AR2 IR0 LUF LV UF N Z V C 07 2E00 0000 1.740e+02 03 4C20 0000 1.27578125e+01 80 9933 80 98C5 8 0 0 0 0 0 0 0 03 4C20 0000 1.27578125e+01 80 9933 80 98C5 8 0 0 0 0 0 0 0 0AE 174 0 8098CD 809933 0AE 174 034C2000 1.27578125e+01 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-108 Interrupt Acknowledge IACK Syntax Operation IACK src Perform a dummy read operation with IACK = 0. At end of dummy read, set IACK to 1. src general addressing modes (G): 01 10 direct indirect Operands Opcode 31 0 0 0 1 1 24 23 0 1 1 0 G 16 15 0 0 0 0 0 87 src 0 Description A dummy read operation is performed if off-chip memory is specified. IACK is set to 0, regardless of src location, a half H1 cycle after the beginning of the decode phase of the IACK instruction. At the first half of the H1 cycle of the completion of the dummy read, IACK is set to 1. The IACK signal will not be extended due to multicycle reads with wait states. This instruction can be used to generate an external interrupt acknowledge. The IACK signal and the address can be used to signal interrupt acknowledge to external devices. The data read by the processor is unused. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Assembly Language Instructions 13-109 IACK Interrupt Acknowledge Example IACK *AR5 Before Instruction IACK PC LUF LV UF N Z V C 1 300 0 0 0 0 0 0 0 IACK PC LUF LV UF N Z V C After Instruction 1 301 0 0 0 0 0 0 0 13-110 Idle Until Interrupt IDLE Syntax Operation IDLE 1 ST(GIE) Next PC PC Idle until interrupt. None Operands Opcode 31 0 0 0 24 23 16 15 87 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description The global-interrupt-enable bit is set, the next PC value is loaded into the PC, and the CPU idles until an unmasked interrupt is received. When the interrupt is received, the contents of the PC are pushed onto the active system stack, the interrupt vector is read, and the interrupt service routine is executed. 1 LUF LV UF N Z V C OVM IDLE Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. ; The processor idles until a reset ; or unmasked interrupt occurs. Cycles Status Bits Mode Bit Example For correct device operation, the three instructions after a delayed branch should not be IDLE or IDLE2 instructions. Assembly Language Instructions 13-111 IDLE2 Syntax Low-Power Idle IDLE2 (supported by: 'LC31, 'C32, 'C30 silicon revision 7.x or greater, 'C31 silicon revision 5.x or greater) Operation 1 ST(GIE) Next PC PC Idle until interrupt. None Operands Opcode 31 0 0 0 24 23 16 15 87 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Description The IDLE2 instruction serves the same function as IDLE, except that it removes the functional clock input from the internal device. This allows for extremely low power mode. The PC is incremented once, and the device remains in an idle state until one of the external interrupts (INT0-3) is asserted. In IDLE2 mode, the 'C3x devices that support this mode behave as follows: - The CPU, peripherals, and memory retain their previous states. - When the device is in the functional (nonemulation) mode, the clocks stop with H1 high and H3 low. - The device remains in IDLE2 until one of the four external interrupts (INT3 -INT0) is asserted for at least two H1 cycles. When one of the four interrupts is asserted, the clocks start after a delay of one H1 cycle. The clocks can start up in the phase opposite that in which they were stopped (that is, H1 might start high when H3 was high before stopping, and H3 might start high when H1 was high before stopping). However, the H1 and H3 clocks remain 180 out of phase with each other. - During IDLE2 operation, one of the four external interrupts must be as- serted for at least two H2 cycles to be recognized and serviced by the CPU. For the processor to recognize only one interrupt when it restarts operation, the interrupt must be asserted for less than three cycles. - When the device is in emulation mode, the H1 and H3 clocks continue to run normally, and the CPU operates as if an IDLE instruction had been executed. The clocks continue to run for correct operation of the emulator. 13-112 Low-Power Idle IDLE2 For correct device operation, the three instructions after a delayed branch should not be IDLE or IDLE2 instructions. Cycles Status Bits 1 LUF LV UF N Z V C OVM IDLE2 Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. ; The processor idles until a reset ; or interrupt occurs. Mode Bit Example Assembly Language Instructions 13-113 LDE Load Floating-Point Exponent Syntax Operation Operands LDE src, dst src(exp) dst(exp) src general addressing modes (G): 00 01 10 11 dst Opcode 31 0 0 0 24 23 0 0 1 1 0 1 G dst 16 15 87 src 0 register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate register (Rn, 0 n 7) Description The exponent field of the src operand is loaded into the exponent field of the dst register. No modification of the dst register mantissa field is made unless the value of the exponent loaded is the reserved value of the exponent for 0 as determined by the precision of the src operand. Then the mantissa field of the dst register is set to 0. The src and dst operands are assumed to be floating-point numbers. Immediate values are evaluated in the short floating-point format. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit 13-114 Load Floating-Point Exponent LDE Example LDE R0,R5 Before Instruction R0 R5 LUF LV UF N Z V C 02 0005 6F30 4.00066337e+00 0A 056F E332 1.06749648e+03 0 0 0 0 0 0 0 R0 R5 LUF LV UF N Z V C After Instruction 02 0005 6F30 4.00066337e+00 02 056F E332 4.16990814e+00 0 0 0 0 0 0 0 Assembly Language Instructions 13-115 LDF Load Floating-Point Value Syntax Operation Operands LDF src, dst src dst src general addressing modes (G): 00 01 10 11 dst register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate register (Rn, 0 n 7) 24 23 0 0 1 1 1 0 G dst 16 15 87 src 0 Opcode 31 0 0 0 Description Cycles Status Bits The src operand is loaded into the dst register. The dst and src operands are assumed to be floating-point numbers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. @9800h,R2 After Instruction R2 DP LUF LV UF N Z V C 01 0C52 A000 2.19254303e+00 080 0 0 0 0 0 0 0 00 0000 0000 080 0 0 0 0 0 0 0 Mode Bit Example R2 DP LUF LV UF N Z V C Data memory 809800 OVM LDF Before Instruction 010C52A0 2.19254303e+00 809800 010C52A0 2.19254303e+00 13-116 Load Floating-Point Value Conditionally LDFcond Syntax Operation LDFcond src, dst If cond is true: src dst. Else: dst is unchanged. Operands src general addressing modes (G): 00 01 10 11 dst register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate register (Rn, 0 n 7) Opcode 31 0 1 0 0 24 23 cond G dst 16 15 87 src 0 Description If the condition is true, the src operand is loaded into the dst register; otherwise, the dst register is unchanged. The dst and src operands are assumed to be floating-point numbers. The 'C3x provides 20 condition codes that can be used with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes, and flags). Note that an LDFU (load floating-point unconditionally) instruction is useful for loading R7-R0 without affecting condition flags. Condition flags are set on a previous instruction only when the destination register is one of the extended-precision registers (R7-R0) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Cycles Status Bits 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Assembly Language Instructions 13-117 Mode Bit LDFcond Example Load Floating-Point Value Conditionally LDFZ R3 R5 LUF LV UF N Z V C R3,R5 Before Instruction 2C FF2C D500 1.77055560e+13 5F 0000 003E 3.96140824e+28 0 0 0 0 1 0 0 R3 R5 LUF LV UF N Z V C After Instruction 2C FF2C D500 1.77055560e+13 2C FF2C D500 1.77055560e+13 0 0 0 0 1 0 0 13-118 Load Floating-Point Value, Interlocked LDFI Syntax Operation LDFI src, dst Signal interlocked operation src dst src general addressing modes (G): 01 10 dst direct indirect (disp = 0-255, IR0, IR1) Operands register (Rn, 0 n 7) Opcode 31 0 0 0 24 23 0 0 1 1 1 1 G dst 16 15 87 src 0 Description The src operand is loaded into the dst register. An interlocked operation is signaled over XF0 and XF1. The src and dst operands are assumed to be floatingpoint numbers. Only direct and indirect modes are allowed. See Section 7.4, Interlocked Operations, on page 7-13 for a detailed description. 1 if XF1 = 0 (see Section 7.4 on page 7-13) These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-119 LDFI Load Floating-Point Value, Interlocked Example R7 AR2 LUF LV UF N Z V C Data memory 8098F2h LDFI *+AR2,R7 Before Instruction 00 0000 0000 80 98F1 0 0 0 0 0 0 0 R7 AR2 LUF LV UF N Z V C After Instruction 05 84C0 0000 80 98F1 0 0 0 0 0 0 0 -6.28125e+01 584C000 -6.28125e+01 8098F2h 584C000 -6.28125e+01 13-120 Parallel LDF and LDF LDF||LDF Syntax || Operation LDF src2, dst2 LDF src1, dst1 src2 dst2 || src1 dst1 src1 dst1 src2 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) Operands This instruction's operands have been augmented on the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 dst1 src2 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) 24 23 dst2 dst1 16 15 0 0 0 src1 87 src2 0 1 1 0 0 0 1 0 Description Two floating-point loads are performed in parallel. If the LDFs load the same register, the assembler issues a warning. The result is that of LDF src2, dst2. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Assembly Language Instructions 13-121 LDF||LDF Example Parallel LDF and LDF || R3 R7 AR1 AR7 IR0 LUF LV UF N Z V C Data memory 809857h 80988Ah LDF LDF Before Instruction 00 0000 0000 00 0000 0000 80 985F 80 988A 8 0 0 0 0 0 0 0 *-- AR1(IR0),R7 *AR7++(1),R3 After Instruction R0 R3 R7 AR1 AR7 LUF LV UF N Z V C 00 0000 0008 05 7B40 0000 6.281250e+01 07 0C80 0000 1.4050e+02 80 9857 80 988B 0 0 0 0 0 0 0 70C8000 1.4050e+02 809857h 70C8000 1.4050e+02 57B4000 6.281250e+01 57B4000 6.281250e+01 80988Ah Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-122 Parallel LDF and STF LDF||STF Syntax || Operation LDF src2, dst1 STF src3, dst2 src2 dst1 || src3 dst2 src2 dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) Operands This instruction's operands have been augmented on the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 0 0 0 16 15 src3 dst2 87 src2 0 1 1 0 1 1 0 0 Description A floating-point load and a floating-point store are performed in parallel. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles Status Bits 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit Assembly Language Instructions 13-123 LDF||STF Example Parallel LDF and STF || R1 R3 AR2 AR4 IR1 LUF LV UF N Z V C Data memory 8098E7h 809900h LDF STF Before Instruction 00 0000 0000 *AR2-- (1),R1 R3,*AR4++(IR1) After Instruction R1 R3 AR2 AR4 IR1 LUF LV UF N Z V C 07 0C80 0000 1.4050e+02 05 7B40 0000 6.28125e+01 80 98E6 80 9910 10 0 0 0 0 0 0 0 05 7B40 0000 6.28125e+01 80 98E7 80 9900 10 0 0 0 0 0 0 0 70C8000 1.4050e+02 0 8098E7h 809900h 70C8000 1.4050e+02 57B4000 6.28125e+01 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-124 Load Integer LDI Syntax Operation Operands LDI src, dst src dst src general addressing modes (G): 00 01 10 11 dst any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate any CPU register Opcode 31 0 0 0 24 23 0 1 0 0 0 0 G dst 16 15 87 src 0 Description The src operand is loaded into the dst register. The dst and src operands are assumed to be signed integers. An alternate form of LDI, LDP, is used to load the data-page pointer register (DP). See the LDP instruction in Section 13.6.2 Optional Assembler Syntax beginning on page 13-34. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-125 LDI Load Integer Example LDI *-AR1(IR0),R5 Before Instruction R5 AR1 IR0 LUF LV UF N Z V C Data memory 27h 26 38 27h 26 38 00 0000 03C5 965 2C 5 0 0 0 0 0 0 0 R5 AR1 IR0 LUF LV UF N Z V C After Instruction 00 0000 0026 38 2C 5 0 0 0 0 0 0 0 13-126 Load Integer Conditionally LDIcond Syntax Operation LDIcond src, dst If cond is true: src dst, Else: dst is unchanged. Operands src general addressing modes (G): 00 01 10 11 dst any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate any CPU register Opcode 31 0 1 0 1 24 23 cond G dst 16 15 87 src 0 Description If the condition is true, the src operand is loaded into the dst register. Otherwise, the dst register is unchanged. Regardless of the condition, a read of the src takes place. The dst and src operands are assumed to be signed integers. The 'C3x provides 20 condition codes that can be used with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes, and flags). Note that an LDIU (load integer unconditionally) instruction is useful for loading R7-R0 without affecting the condition flags. Condition flags are set on a previous instruction only when the destination register is one of the extended-precision registers (R7-R0) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Cycles Status Bits 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Assembly Language Instructions 13-127 Mode Bit LDIcond Example Load Integer Conditionally LDIZ *ARO++,R6 Before Instruction R6 AR0 LUF LV UF N Z V C Data memory 8098F0h 027C 636 8098F0h 027C 636 00 0000 0FE2 4,066 80 98F0 0 0 0 0 0 0 0 R6 AR0 LUF LV UF N Z V C After Instruction 00 0000 0FE2 4,066 80 98F1 0 0 0 0 0 0 0 Note: Auxiliary Register Arithmetic The test condition does not affect the auxiliary register arithmetic. (AR modification always occurs.) 13-128 Load Integer, Interlocked LDII Syntax Operation LDII src, dst Signal interlocked operation src dst src general addressing modes (G): 01 10 direct indirect (disp = 0-255, IR0, IR1) Operands dst any CPU register Opcode 31 0 0 0 24 23 0 1 0 0 0 1 G dst 16 15 87 src 0 Description The src operand is loaded into the dst register. An interlocked operation is signaled over XF0 and XF1. The src and dst operands are assumed to be signed integers. Note that only the direct and indirect modes are allowed. See Section 7.4, Interlocked Operations, on page 7-13 for a detailed description. 1 if XF = 0 (see Section 7.4 on page 7-13) These condition flags are modified only if the destination register is R7- R0. LUF LV UF N Z V C Unaffected Unaffected 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-129 LDII Load Integer, Interlocked Example LDII @985Fh,R3 Before Instruction R3 DP LUF LV UF N Z V C Data memory 80985Fh 0DC 80985Fh 0DC 00 0000 0000 80 0 0 0 0 0 0 0 R3 DP LUF LV UF N Z V C After Instruction 00 0000 00DC 80 0 0 0 0 0 0 0 13-130 Parallel LDI and LDI LDI||LDI Syntax || Operation LDI src2, dst2 LDI src1, dst1 src2 dst2 || src1 dst1 src1 dst1 src2 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) Operands This instruction's operands have been augmented on the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 dst1 src2 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) 24 23 dst2 dst1 16 15 0 0 0 src1 87 src2 0 1 1 0 0 0 1 1 Description Two integer loads are performed in parallel. The assembler issues a warning if the LDIs load the same register. The result is that of LDI src2, dst2. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Assembly Language Instructions 13-131 LDI||LDI Example Parallel LDI and LDI || R1 R7 AR1 AR7 IR0 LUF LV UF N Z V C Data memory 809825h 8098C8h LDI *-AR1(1),R7 LDI *AR7++(IR0),R1 Before Instruction 00 0000 0000 00 0000 0000 80 9826 80 98C8 10 0 0 0 0 0 0 0 R1 R7 AR1 AR7 IR0 LUF LV UF N Z V C After Instruction 00 0000 02EE 750 00 0000 00FA 250 80 9826 80 98D8 10 0 0 0 0 0 0 0 0FA 2EE 250 750 809825h 8098C8h 0FA 250 2EE 750 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-132 Parallel LDI and STI LDI||STI Syntax || Operation LDI src2, dst1 STI src3, dst2 src2 dst1 || src3 dst2 src2 dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) Operands This instruction's operands have been augmented on the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 0 0 0 16 15 src3 dst2 87 src2 0 1 1 0 1 1 0 1 Description An integer load and an integer store are performed in parallel. If src2 and dst2 point to the same location, src2 is read before the dst2 is written. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Assembly Language Instructions 13-133 LDI||STI Parallel LDI and STI Example || LDI *-AR1(1),R2 STI R7,*AR5++(IR0) Before Instruction R2 R7 AR1 AR5 IR0 LUF LV UF N Z V C Data memory 8098E6h 80982Ch 0DC 0 220 8098E6h 80982Ch 0DC 220 35 53 00 0000 0000 00 0000 0035 80 98E7 80 982C 8 0 0 0 0 0 0 0 53 R2 R7 AR1 AR5 IR0 LUF LV UF N Z V C After Instruction 00 0000 00DC 220 00 0000 0035 80 98E7 80 9834 8 0 0 0 0 0 0 0 53 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-134 Load Floating-Point Mantissa LDM Syntax Operation Operands LDM src, dst src (man) dst (man) src general addressing modes (G): 00 01 10 11 dst register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate register (Rn, 0 n 7) 24 23 0 1 0 0 1 0 G dst 16 15 87 src 0 Opcode 31 0 0 0 Description The mantissa field of the src operand is loaded into the mantissa field of the dst register. The dst exponent field is not modified. The src and dst operands are assumed to be floating-point numbers. If the src operand is from memory, the entire memory contents are loaded as the mantissa. If immediate addressing mode is used, bits 15-12 of the instruction word are forced to 0 by the assembler. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. After Instruction R2 LUF LV UF N Z V C 00 1CC0 0000 0 0 0 0 0 0 0 1.22460938e+00 Cycles Status Bits Mode Bit Example LDM 156.75,R2 (156.75 = 071CC00000h) Before Instruction R2 LUF LV UF N Z V C 00 0000 0000 0 0 0 0 0 0 0 Assembly Language Instructions 13-135 LDP Load Data-Page Pointer Syntax Operation Operands Opcode 31 0 0 0 24 23 16 15 87 src 0 LDP src, DP src data-page pointer src is the 8 MSBs of the absolute 24-bit source address (src). The "DP" in the operand is optional. 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 Description This pseudo-op is an alternate form of the LDUI instruction, except that LDP is always in the immediate addressing mode. The src operand field contains the eight MSBs of the absolute 24-bit src address (essentially, only bits 23 -16 of src are used). These eight bits are loaded into the eight LSBs of the data-page pointer. The eight LSBs of the pointer are used in direct addressing as a pointer to the page of data being addressed. There is a total of 256 pages, each page 64K words long. Bits 31-8 of the pointer are reserved and should be kept set to 0. Cycles Status Bits 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit Example LDP @809900h, DP or LDP @809900h Before Instruction DP LUF LV UF N Z V C 065 0 0 0 0 0 0 0 DP LUF LV UF N Z V C After Instruction 080 0 0 0 0 0 0 0 13-136 Divide Clock by 16 LOPOWER Syntax LOPOWER (supported by: 'LC31 and 'C32, 'C31 silicon revision 5.0 or greater, 'C30 silicon revision 7.0 or greater) Operation Operands Opcode H1 H1/16 None 31 0 0 0 23 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Description The device continues to execute instructions, but at the reduced rate of the CLKIN frequency divided by 16 (that is, in LOPOWER mode, a 'C3x device that supports this mode with a CLKIN frequency of 32 MHz performs in the same way as a 2-MHz 'C3x device, which has an instruction-cycle time of 1000 ns). This allows for low-power operation. The 'C3x CPUs slow down during the read phase of the LOPOWER instruction. To exit the LOPOWER power-down mode, invoke the MAXSPEED instruction (opcode = 1080 0000 h). The 'C3x resumes full-speed operation during the read phase of the MAXSPEED instruction. Do not run the IDLE2 instruction in the LOPOWER mode. Cycles Status Bits 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. ; The processor slows down operation to ; 1/16th of the H1 clock. Assembly Language Instructions 13-137 Mode Bit Example LOPOWER LSH Logical Shift Syntax Operation LSH count, dst If count 0: dst << count dst Else: dst >> |count | dst Operands count general addressing modes (G): 00 01 10 11 dst Opcode 31 0 0 0 24 23 0 1 0 0 1 1 G dst 16 15 87 count 0 any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate any CPU register Description The seven LSBs of the count operand are used to generate the 2s-complement shift count. If the count operand is greater than 0, the dst operand is left shifted by the value of the count operand. Low-order bits shifted in are zero filled, and high-order bits are shifted out through the carry (C) bit. Logical left shift: C dst 0 If the count operand is less than 0, the dst is right shifted by the absolute value of the count operand. The high-order bits of the dst operand are zero filled as they are shifted to the right. Low-order bits are shifted out through the C bit. Logical right shift: 0 dst C If the count operand is 0, no shift is performed, and the C bit is set to 0. The count operand is assumed to be a signed integer, and the dst operand is assumed to be an unsigned integer. 13-138 Logical Shift LSH Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Set to the value of the last bit shifted out; 0 for a shift count of 0 Operation is not affected by OVM bit value. R4,R7 Before Instruction R4 R7 LUF LV UF N Z V C 00 0000 0018 00 0000 02AC 0 0 0 0 0 0 0 24 R4 R7 LUF LV UF N Z V C After Instruction 00 0000 0018 00 AC00 0000 0 0 0 1 0 1 0 24 Mode Bit Example 1 OVM LSH Example 2 LSH *-AR5(IR1),R5 Before Instruction R5 AR5 IR0 LUF LV UF N Z V C Data memory 809904h 0FFFFFFF4 -12 809904h 0FFFFFFF4 -12 00 12C0 0000 80 9908 4 0 0 0 0 0 0 0 R5 AR5 IR0 LUF LV UF N Z V C After Instruction 00 0001 2C00 80 9908 4 0 0 0 0 0 0 0 Assembly Language Instructions 13-139 LSH3 Syntax Logical Shift, 3-Operand LSH3 count, src, dst If count 0: src << count dst Else: src >> |count | dst Operation Operands src 3-operand addressing modes (T): 00 01 10 11 any CPU register indirect (disp = 0, 1, IR0, IR1) any CPU register indirect (disp = 0, 1, IR0, IR1) count 3-operand addressing modes (T): 00 01 10 11 dst Opcode 31 0 0 1 24 23 0 0 1 0 0 0 T dst 16 15 src 87 count 0 any CPU register any CPU register indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) register (Rn, 0 n 27) Description The seven LSBs of the count operand are used to generate the 2s-complement shift count. If the count operand is greater than 0, a copy of the src operand is left shifted by the value of the count operand, and the result is written to the dst. (The src is not changed.) Low-order bits shifted in are zero filled, and high-order bits are shifted out through the carry (C) bit. Logical left shift: C src 0 If the count operand is less than 0, the src operand is right shifted by the absolute value of the count operand. The high-order bits of the dst operand are 0filled as they are shifted to the right. Low-order bits are shifted out through the C bit. Logical right shift: 0 src C If the count operand is 0, no shift is performed, and the C bit is set to 0. The count operand is assumed to be a signed integer. The src and dst operands are assumed to be unsigned integers. 13-140 Logical Shift, 3-Operand LSH3 Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Set to the value of the last bit shifted out; 0 for a shift count of 0; unaffected if dst is not R7-R0 Operation is not affected by OVM bit value. Mode Bit Example 1 OVM LSH3 R4,R7,R2 Before Instruction R2 R4 R7 LUF LV UF N Z V C 00 0000 0000 00 0000 0018 00 0000 02AC 0 0 0 0 0 0 0 24 R2 R4 R7 LUF LV UF N Z V C After Instruction 00 AC00 0000 00 0000 0018 24 00 0000 02AC 0 0 0 1 0 1 0 Assembly Language Instructions 13-141 LSH3 Logical Shift, 3-Operand Example 2 LSH3 *-AR4(IR1),R5,R3 Before Instruction R3 R5 AR4 IR1 LUF LV UF N Z V C Data memory 809904h 0FFFFFFF4 -12 809904h 0FFFFFFF4 -12 00 0000 0000 00 12C0 0000 80 9908 4 0 0 0 0 0 0 0 R3 R5 AR4 IR1 LUF LV UF N Z V C After Instruction 00 0001 2C00 00 12C0 0000 80 9908 4 0 0 0 0 0 0 0 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-142 Parallel LSH3 and STI LSH3||STI Syntax || Operation LSH3 STI count, src2, dst1 src3, dst2 If count 0: src2 << count dst1 Else: src2 >> |count | dst1 || src3 dst2 count register (Rn1, 0 n1 7) src1 indirect (disp = 0, 1, IR0, IR1) dst1 register (Rn3, 0 n3 7) src2 register (Rn4, 0 n4 7) dst2 indirect (disp = 0, 1, IR0, IR1) This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 Operands src2 dst1 src3 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 count 16 15 src3 dst2 87 src2 0 1 1 0 1 1 1 0 Description The seven LSBs of the count operand are used to generate the 2s-complement shift count. If the count operand is greater than 0, a copy of the src2 operand is left shifted by the value of the count operand, and the result is written to the dst1. (The src2 is not changed.) Low-order bits shifted in are zero filled, and high-order bits are shifted out through the carry (C) bit. Logical left shift: C src2 0 If the count operand is less than 0, the src2 operand is right shifted by the absolute value of the count operand. The high-order bits of the dst operand are 0filled as they are shifted to the right. Low-order bits are shifted out through the C bit. Assembly Language Instructions 13-143 LSH3||STI Parallel LSH3 and STI Logical right shift: 0 src2 C If the count operand is 0, no shift is performed, and the carry bit is set to 0. The count operand is assumed to be a 7-bit signed integer, and the src2 and dst1 operands are assumed to be unsigned integers. All registers are read at the beginning and loaded at the end of the execute cycle. This means that if one of the parallel operations (STI) reads from a register and the operation being performed in parallel (LSH3) writes to the same register, STI accepts as input the contents of the register before it is modified by the LSH3. If src2 and dst2 point to the same location, src2 is read before dst2 is written. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Mode Bit OVM Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Set to the value of the last bit shifted out; 0 for a shift count of 0 Operation is affected by OVM bit value. 13-144 Parallel LSH3 and STI LSH3||STI Example 1 LSH3 || STI R2,*++AR3(1),R0 R4,*-AR5 Before Instruction R0 R2 R4 AR3 AR5 LUF LV UF N Z V C 00 0000 0000 00 0000 0018 00 0000 00DC 80 98C2 80 98A3 0 0 0 0 0 0 0 24 220 R0 R2 R4 AR3 AR5 LUF LV UF N Z V C After Instruction 00 AC00 0000 00 0000 0018 24 00 0000 00DC 220 80 98C3 80 98A3 0 0 0 0 0 0 0 Data memory 8098C3h 8098A2h 0AC 0 8098C3h 8098A2h 0AC 0DC 220 Assembly Language Instructions 13-145 LSH3||STI Parallel LSH3 and STI Example 2 LSH3 || STI R7,*AR2-- (1),R2 R0,*+AR0(1) Before Instruction R0 R2 R7 AR0 AR2 LUF LV UF N Z V C 00 0000 012C 00 0000 0000 00 FFFF FFF4 80 98B7 80 9863 0 0 0 0 0 0 0 -12 300 R0 R2 R7 AR0 AR2 LUF LV UF N Z V C After Instruction 00 0000 012C 00 0002 C000 00 FFFF FFF4 80 98B7 80 9862 0 0 0 0 0 0 0 -12 300 Data memory 809863h 8098B8h 2C000000 0 809863h 8098B8h 2C000000 12C 300 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-146 Restore Clock to Regular Speed MAXSPEED Syntax MAXSPEED H1/16 H1 None (supported by 'C31, 'C32, 'C31 silicon revision 5.0 or greater, 'C30 silicon revision 7.0 or greater) Operation Operands Opcode 31 0 0 0 23 16 15 87 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description Exits LOPOWER power-down mode (invoked by LOPOWER instruction with opcode 10800001h). The 'LC31 or 'C32 resumes full-speed operation during the read phase of the MAXSPEED instruction. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. ; The processor resumes full-speed operation. Cycles Status Bits Mode Bit Example MAXSPEED Assembly Language Instructions 13-147 MPYF Multiply Floating-Point Value Syntax Operation Operands MPYF src, dst dst src dst src general addressing modes (G): 00 01 10 11 dst Opcode 31 0 0 0 24 23 0 1 0 1 0 0 G dst 16 15 87 src 0 register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate register (Rn, 0 n 7) Description The product of the dst and src operands is loaded into the dst register. The src operand is assumed to be a single-precision floating-point number, and the dst operand is an extended-precision floating-point number. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Example OVM MPYF R0,R2 Before Instruction R0 R2 LUF LV UF N Z V C 07 0C80 0000 1.4050e+02 03 4C20 0000 1.27578125e+01 0 0 0 0 0 0 0 R0 R2 LUF LV UF N Z V C After Instruction 07 0C80 0000 1.4050e+02 0A 600F 2000 1.79247266e+03 0 0 0 0 0 0 0 13-148 Multiply Floating-Point Value, 3-Operand MPYF3 Syntax Operation Operands MPYF3 src2, src1, dst src1 src2 dst src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 dst Opcode 31 0 0 1 24 23 0 0 1 0 0 1 T dst 16 15 src1 87 src2 0 register (Rn2, 0 n2 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) register (Rn, 0 n 7) Description The product of the src1 and src2 operands is loaded into the dst register. The src1 and src2 operands are assumed to be single-precision floating-point numbers, and the dst operand is an extended-precision floating-point number. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-149 MPYF3 Multiply Floating-Point Value, 3-Operand Example 1 MPYF3 R0,R7,R1 Before Instruction R0 R1 R7 LUF LV UF N Z V C 05 7B40 0000 6.281250e+01 R0 00 0000 0000 07 33C0 0000 1.79750e+02 0 0 0 0 0 0 0 R1 R7 LUF LV UF N Z V C After Instruction 05 7B40 0000 6.281250e+01 0D 306A 3000 1.12905469e+04 07 33C0 0000 1.79750e+02 0 0 0 0 0 0 0 Example 2 MPYF3 *+AR2(IR0),R7,R2 or MPYF3 R7,*+AR2(IR0),R2 Before Instruction R2 R7 AR2 IR0 LUF LV UF N Z V C Data memory 80992Ah 70C8000 1.4050e+02 80992Ah 70C8000 1.4050e+02 00 0000 0000 05 7B40 0000 6.281250e+01 80 9800 12A 0 0 0 0 0 0 0 R2 R7 AR2 IR0 LUF LV UF N Z V C After Instruction 0D 09E4 A000 8.82515625e+03 05 7B40 0000 6.281250e+01 80 9800 12A 0 0 0 0 0 0 0 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-150 Parallel MPYF3 and ADDF3 MPYF3||ADDF3 Syntax || Operation MPYF3 srcA, srcB, dst1 ADDF3 srcC, srcD, dst2 srcA srcB dst1 || srcC + srcD dst2 srcA srcB srcC srcD dst1 Operands Any two indirect (disp = 0, 1 IR0, IR1) Any two register (0 v Rn v 7) register (d1): 0 = R0 1 = R1 register (d2): 0 = R2 1 = R3 register (Rn, 0 n 7) register (Rn, 0 n 7) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0-255, IR0, IR1) parallel addressing modes (0 P 3) dst2 src1 src2 src3 src4 P Assembly Language Instructions 13-151 MPYF3||ADDF3 Parallel MPYF3 and ADDF3 This instruction's operands have been augmented in the following devices: - 'C31 silicon version 6.0 or greater - 'C32 silicon version 2.0 or greater srcA, srcB, srcC, srcD can be one of the following combinations: Register (0 v Rn v 7) 2 2 2 Indirect (disp = 0, 1, IR0, IR1) 2 1 - Any CPU Register - 1 2 dst1 register (d1): 0 = R0 1 = R1 register (d2): 0 = R2 1 = R3 register (Rn, 0 n 7) register (Rn, 0 n 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register indirect (disp = 0, 1, IR0, IR1) or any CPU register parallel addressing modes (0 P 3) dst2 src1 src2 src3 src4 P Version 4.7 or earlier of TMS320 floating-point code-generation tools P 00 01 10 11 Version 5.0 or later P 00 01 13-152 srcA src4 src3 src1 src3 srcB src3, src1, src2, src1, srcD src1 + src4 + src3 + src2 + srcC src2 src2 src4 src4 srcA srcB srcD srcC src3 src4, src1 + src2 src3 src1, src4 + src2 Parallel MPYF3 and ADDF3 MPYF3||ADDF3 10 11 Opcode 31 1 0 0 0 0 0 24 23 P src1 src2, src3 + src4 src3 src1, src2 + src4 16 15 src1 src2 src3 8 7 src4 0 d1 d2 Description A floating-point multiplication and a floating-point addition are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (MPYF3) reads from a register and the operation being performed in parallel (ADDF3) writes to the same register, then MPYF3 accepts the contents of the register as input before it is modified by the ADDF3. Any combination of addressing modes can be coded for the four possible source operands as long as two are coded as indirect and two are coded as register. The assignment of the source operands srcA - srcD to the src1 - src4 fields varies, depending on the combination of addressing modes used, and the P field is encoded accordingly. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles Status Bits 1 (see Note: Cycle Count) These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 0 0 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Mode Bit OVM Assembly Language Instructions 13-153 MPYF3||ADDF3 Parallel MPYF3 and ADDF3 Example || MPYF3 ADDF3 *AR5++(1),*-- AR1(IR0),R0 R5,R7,R3 Note: Cycle Count One cycle if: - src3 and src4 are in internal memory - src3 is in internal memory and src4 is in external memory Two cycles if: - src3 is in external memory and src4 is in internal memory - src3 and src4 are in external memory For more information see Section 8.5, Clocking Memory Accesses, on page 8-24. Before Instruction R0 R3 R5 R7 AR1 AR5 IR0 LUF LV UF N Z V C Data memory 8098C5h 8098A4h 34C0000 1.2750e+01 1110000 2.265625e+00 8098C5h 8098A4h 34C0000 1.2750e+01 1110000 2.265625e+00 00 0000 0000 00 0000 0000 6.281250e+01 07 33C0 0000 07 0C80 0000 80 98A8 80 98C5 4 0 0 0 0 0 0 0 1.79750e+02 1.4050e+02 R0 R3 R5 R7 AR1 AR5 IR0 LUF LV UF N Z V C After Instruction 04 6718 0000 2.88867188e+01 08 2020 0000 3.20250e+02 07 33C0 0000 1.79750e+02 07 0C80 0000 1.4050e+02 80 98A4 80 98C6 4 0 0 0 0 0 0 0 13-154 Parallel MPYF3 and STF MPYF3||STF Syntax || Operation MPYF3 src2, src1, dst STF src3, dst2 src1 src2 dst1 || src3 dst2 src1 src2 dst1 src3 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn3, 0 n3 7) register (Rn4, 0 n4 7) indirect (disp = 0, 1, IR0, IR1) Operands This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 src2 dst1 src3 dst2 Opcode 31 1 1 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) 24 23 0 1 1 1 1 dst1 src1 16 15 src3 dst2 8 7 src2 0 Description A floating-point multiplication and a floating-point store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (MPYF3) writes to a register and the operation being performed in parallel (STF) reads from the same register, then STF accepts the contents of the register as input before it is modified by the MPYF3. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles 1 Assembly Language Instructions 13-155 MPYF3||STF Parallel MPYF3 and STF Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Mode Bit Example || R0 R3 R7 AR0 AR2 IR0 LUF LV UF N Z V C Data memory 80982Ah 809860h 70C8000 1.4050e+02 0 80982Ah 809860h 70C8000 1.4050e+02 1 if a floating-point underflow occurs; 0 unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. MPYF3 STF *-AR2(1),R7,R0 R3,*AR0-- (IR0) After Instruction R0 R3 R7 AR0 AR2 IR0 LUF LV UF N Z V C 0D 09E4 A000 8.82515625e+03 08 6B28 0000 4.7031250e+02 05 7B40 0000 6.281250e+01 80 9858 80 982B 8 0 0 0 0 0 0 0 OVM Before Instruction 00 0000 0000 08 6B28 0000 4.7031250e+02 05 7B40 0000 6.281250e+01 80 9860 80 982B 8 0 0 0 0 0 0 0 86B280000 4.7031250e+02 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-156 Parallel MPYF3 and SUBF3 MPYF3||SUBF3 Syntax || Operation MPYF3 srcA, srcB, dst1 SUBF3 srcC, srcD, dst2 srcA srcB dst1 || srcD - srcC dst2 srcA srcB srcC srcD dst1 Operands Any two indirect (disp = 0, 1, IR0, IR1) Any two register (0 Rn 7) register (d1): 0 = R0 1 = R1 register (d2): 0 = R2 1 = R3 register (Rn, 0 n 7) register (Rn, 0 n 7) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) parallel addressing modes (0 P 3) dst2 src1 src2 src3 src4 P Assembly Language Instructions 13-157 MPYF3||ADDF3 Parallel MPYF3 and ADDF3 This instruction's operands have been augmented in the following devices: - 'C31 silicon version 6.0 or greater - 'C32 silicon version 2.0 or greater srcA, srcB, srcC, srcD can be one of the following combinations: Register (0 v Rn v 7) 2 2 2 Indirect (disp = 0, 1, IR0, IR1) 2 1 - Any CPU Register - 1 2 dst1 register (d1): 0 = R0 1 = R1 register (d2): 0 = R2 1 = R3 register (Rn, 0 n 7) register (Rn, 0 n 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register indirect (disp = 0, 1, IR0, IR1) or any CPU register parallel addressing modes (0 P 3) dst2 src1 src2 src3 src4 P Version 4.7 or earlier of TMS320 floating-point code-generation tools P 00 01 10 11 Version 5.0 or later P 00 01 10 11 13-158 srcA srcB srcD srcC src4 src3, src1 - src2 src3 src1, src4 - src2 src1 src2, src3 - src4 src3 src1, src2 - src4 srcA srcB srcD srcC src3 src4, src1 - src2 src3 src1, src4 - src2 src1 src2, src3 - src4 src3 src1, src2 - src4 Parallel MPYF3 and SUBF3 MPYF3||SUBF3 Opcode 31 1 0 0 0 0 1 24 23 P d1 d2 src1 16 15 src2 src3 8 7 src4 0 Description A floating-point multiplication and a floating-point subtraction are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (MPYF3) reads from a register and the operation being performed in parallel (SUBF3) writes to the same register, MPYF3 accepts as input the contents of the register before it is modified by the SUBF3. Any combination of addressing modes can be coded for the four possible source operands as long as two are coded as indirect and two are coded register. The assignment of the source operands srcA - srcD to the src1 - src4 fields varies, depending on the combination of addressing modes used, and the P field is encoded accordingly. Cycles 1 Note: Cycle Count One cycle if: - src3 and src4 are in internal memory - src3 is in internal memory and src4 is in external memory Two cycles if: - src3 is in external memory and src4 is in internal memory - src3 and src4 are in external memory For more information see Section 8.5, Clocking Memory Accesses, on page 8-24. Assembly Language Instructions 13-159 MPYF3||SUBF3 Parallel MPYF3 and SUBF3 Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Mode Bit Example || or || R0 R2 R5 R7 AR3 AR7 IR1 LUF LV UF N Z V C Data memory 80990Ch 8098B2h 1110000 2.250e+00 70C8000 1.4050e+02 80990Ch 8098B2h 1110000 2.250e+00 70C8000 1.4050e+02 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 0 0 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. MPYF3 SUBF3 MPYF3 SUBF3 Before Instruction 00 0000 0000 00 0000 0000 03 4C00 0000 1.2750e+01 07 33C0 0000 1.79750e+02 80 98B2 80 9904 8 0 0 0 0 0 0 0 R0 R2 R5 R7 AR3 AR7 IR1 LUF LV UF N Z V C OVM R5,*++AR7(IR1),R0 R7,*AR3-- (1),R2 *++AR7(IR1), R5,R0 R7,*AR3-- (1),R2 After Instruction 04 6718 0000 2.88867188e+01 05 E300 0000 -3.9250e+01 03 4C00 0000 07 33C0 0000 80 98B1 80 990C 8 0 0 0 0 0 0 0 1.2750e+01 1.79750e+02 13-160 Multiply Integer MPYI Syntax Operation Operands MPYI src, dst dst src dst src general addressing modes (G): 00 01 10 11 dst any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate any CPU register Opcode 31 0 0 0 24 23 0 1 0 1 0 1 G dst 16 15 8 7 src 0 Description The product of the dst and src operands is loaded into the dst register. The src and dst operands, when read, are assumed to be 24-bit signed integers. The result is assumed to be a 48-bit signed integer. The output to the dst register is the 32 LSBs of the result. Integer overflow occurs when any of the 16 MSBs of the 48-bit result differs from the MSB of the 32-bit output value. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Unaffected Operation is affected by OVM bit value. Mode Bit OVM Assembly Language Instructions 13-161 MPYI Multiply Integer Example MPYI R1,R5 Before Instruction R1 R5 LUF LV UF N Z V C 00 0033 C251 3,392,081 00 0078 B600 7,910,912 0 0 0 0 0 0 0 R1 R5 LUF LV UF N Z V C After Instruction 00 0033 C251 00 E21D 9600 0 1 0 1 0 1 0 3,392,081 -501,377,536 13-162 Multiply Integer, 3-Operand MPYI3 Syntax Operation Operands MPYI3 src2, src1, dst src1 src2 dst src1 3-operand addressing modes (T): 00 01 10 11 any CPU register indirect (disp = 0, 1, IR0, IR1) any CPU register indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 dst Opcode 31 0 0 1 24 23 0 0 1 0 1 0 T dst 16 15 src1 8 7 src2 0 any CPU register any CPU register indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) register (Rn, 0 n 27) Description The product of the src1 and src2 operands is loaded into the dst register. The src1 and src2 operands are assumed to be 24-bit signed integers. The result is assumed to be a signed 48-bit integer. The output to the dst register is the 32 LSBs of the result. Integer overflow occurs when any of the 16 MSBs of the 48-bit result differs from the MSB of the 32-bit output value. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Unaffected Operation is affected by OVM bit value. Assembly Language Instructions 13-163 Mode Bit OVM MPYI3 Multiply Integer, 3-Operand Example 1 MPYI3 *AR4,*-AR1(1),R2 Before Instruction R2 AR1 AR4 LUF LV UF N Z V C Data memory 809850h 8098F2h 0AD 0DC 173 220 809850h 8098F2h 0AD 0DC 173 220 00 0000 0000 80 98F3 80 9850 0 0 0 0 0 0 0 R2 AR1 AR4 LUF LV UF N Z V C After Instruction 00 0000 94AC 80 98F3 80 9850 0 0 0 0 0 0 0 38,060 Example 2 MPYI3 R2 R7 AR4 IR0 LUF LV UF N Z V C Data memory 8099F0h *- - AR4(IR0),R2,R7 Before Instruction 00 0000 00C8 00 0000 0000 80 99F8 8 0 0 0 0 0 0 0 200 R2 R7 AR4 IR0 LUF LV UF N Z V C After Instruction 00 0000 00C8 00 0000 2710 80 99F0 8 0 0 0 0 0 0 0 200 10,000 32 50 8099F0h 32 50 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-164 Parallel MPYI3 and ADDI3 MPYI3||ADDI3 Syntax || Operation || Operands MPYI3 ADDI3 srcA, srcB, dst1 srcC, srcD, dst2 srcA srcB dst1 srcD + srcC dst2 srcA srcB srcC srcD Any two indirect (disp = 0, 1, IR0, IR1) Any two register (0 v Rn v 7) srcA, srcB, srcC, srcD can be one of the following combinations: dst1 register (d1): 0 = R0 1 = R1 register (d2): 0 = R2 1 = R3 register (Rn, 0 n 7) register (Rn, 0 n 7) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) parallel addressing modes (0 P 3) dst2 src1 src2 src3 src4 P Assembly Language Instructions 13-165 MPYI3||ADDI3 Parallel MPYI3 and ADDI3 This instruction's operands have been augmented in the following devices: - 'C31 silicon version 6.0 or greater - 'C32 silicon version 2.0 or greater srcA, srcB, srcC, srcD can be one of the following combinations: Register (0 v Rn v 7) 2 2 2 Indirect (disp = 0,1,IR0,IR1) 2 1 - Any CPU Register - 1 2 dst1 register (d1): 0 = R0 1 = R1 register (d2): 0 = R2 1 = R3 register (Rn, 0 n 7) register (Rn, 0 n 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register indirect (disp = 0, 1, IR0, IR1) or any CPU register parallel addressing modes (0 P 3) dst2 src1 src2 src3 src4 P Version 4.7 or earlier of TMS320 floating-point code-generation tools P 00 01 10 11 Version 5.0 or later P 00 01 10 11 13-166 srcA src4 src3 src1 src3 srcB src3, src1, src2, src1, srcD src1 src4 src4 src2 + + + + srcC src2 src2 src4 src4 srcA src3 src3 src1 src3 srcB src4, src1, src2, src1, srcD src1 src4 src3 src2 + + + + srcC src2 src2 src4 src4 Parallel MPYI3 and ADDI3 MPYI3||ADDI3 Opcode 31 1 0 0 0 1 0 24 23 P d1 d2 src1 16 15 src2 src3 87 src4 0 Description An integer multiplication and an integer addition are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. This means that if one of the parallel operations (MPYI3) reads from a register and the operation being performed in parallel (ADDI3) writes to the same register, MPYI3 accepts the contents of the register as input before it is modified by the ADDI3. Any combination of addressing modes can be coded for the four possible source operands as long as two are coded as indirect and two are coded as register. The assignment of the source operands srcA - srcD to the src1 - src4 fields varies, depending on the combination of addressing modes used, and the P field is encoded accordingly. To simplify processing when the order is not significant, the assembler may change the order of operands in commutative operations. Cycles Status Bits 1 (see Note: Cycle Count on page 13-167) These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 0 0 1 if an integer overflow occurs; 0 otherwise Unaffected Operation is affected by OVM bit value. MPYI3 ADDI3 R7,R4,R0 *-AR3,*AR5--(1),R3 Mode Bit Example OVM || Assembly Language Instructions 13-167 MPYl3||ADDl3 Parallel MPYl3 and ADD13 Before Instruction R0 R3 R4 R7 AR3 AR5 LUF LV UF N Z V C Data memory 80981Eh 80996Eh 0FFFFFFCB 35 -53 53 80981Eh 80996Eh 0FFFFFFCB 35 -53 53 00 0000 0000 00 0000 0000 00 0000 0064 00 0000 0014 80 981F 80 996E 0 0 0 0 0 0 0 100 20 R0 R3 R4 R7 AR3 AR5 LUF LV UF N Z V C After Instruction 00 0000 07D0 00 0000 0000 00 0000 0064 00 0000 0014 80 981F 80 996D 0 0 0 0 0 0 0 100 20 2000 Note: Cycle Count One cycle if: - src3 and src4 are in internal memory - src3 is in internal memory and src4 is in external memory Two cycles if: - src3 is in external memory and src4 is in internal memory - src3 and src4 are in external memory For more information see Section 8.5, Clocking Memory Accesses, on page 8-24. 13-168 Parallel MPYI3 and STI MPYI3||STI Syntax || Operation || Operands MPYI3 STI src2, src1, dst1 src3, dst2 src1 src2 dst1 src3 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn3, 0 n3 7) register (Rn4, 0 n4 7) indirect (disp = 0, 1, IR0, IR1) src1 src2 dst1 src3 dst2 This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 src2 dst1 src3 dst2 Opcode 31 1 1 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) 24 23 1 0 0 0 0 dst1 src1 16 15 src3 dst2 8 7 src2 0 Description An integer multiplication and an integer store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STI) reads from a register and the operation being performed in parallel (MPYI3) writes to the same register, STI accepts as input the contents of the register before it is modified by the MPYI3. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Integer overflow occurs when any of the 16 MSBs of the 48-bit result differ from the MSB of the 32-bit output value. Cycles 1 Assembly Language Instructions 13-169 MPYI3||STI Parallel MPYl3 and STI Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Mode Bit Example || R2 R5 R7 AR0 AR3 LUF LV UF N Z V C Data memory 80995Bh 80982Eh 0C8 0 200 80995Bh 80982Eh 0C8 ODC 200 220 Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise Unaffected Operation is affected by OVM bit value. MPYI3 STI Before Instruction 00 0000 00DC 00 0000 0032 00 0000 0000 80 995A 80 982F 0 0 0 0 0 0 0 220 50 R2 R5 R7 AR0 AR3 LUF LV UF N Z V C OVM *++AR0(1),R5,R7 R2,*-AR3(1) After Instruction 00 0000 00DC 00 0000 0032 00 0000 2710 80 995B 80 982F 0 0 0 0 0 0 0 220 50 10000 Note: Cycle Count See Section 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-170 Parallel MPYI3 and SUBI3 MPYI3||SUBI3 Syntax || Operation MPYI3 srcA, srcB, dst1 SUBI3 srcC, srcD, dst2 srcA srcB dst1 || srcD - srcC dst2 srcA srcB srcC srcD Operands Any two indirect (disp = 0, 1, IR0, IR1) Any two register (0 v Rn v 7) srcA, srcB, srcC, srcD can be one of the following combinations: dst1 register (d1): 0 = R0 1 = R1 register (d2): 0 = R2 1 = R3 register (Rn, 0 n 7) register (Rn, 0 n 7) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) parallel addressing modes (0 P 3) dst2 src1 src2 src3 src4 P Assembly Language Instructions 13-171 MPYI3||SUBI3 Parallel MPYI3 and SUBI3 This instruction's operands have been augmented in the following devices: - 'C31 silicon version 6.0 or greater - 'C32 silicon version 2.0 or greater srcA, srcB, srcC, srcD can be one of the following combinations: Register (0 v Rn v 7) 2 2 2 Indirect (disp = 0, 1, IR0, IR1) 2 1 - Any CPU Register - 1 2 dst1 register (d1): 0 = R0 1 = R1 register (d2): 0 = R2 1 = R3 register (Rn, 0 n 7) register (Rn, 0 n 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register indirect (disp = 0, 1, IR0, IR1) or any CPU register parallel addressing modes (0 P 3) dst2 src1 src2 src3 src4 P Version 4.7 or earlier of TMS320 floating-point code-generation tools P 00 01 10 11 srcA src4 src3 src1 src3 srcB src3, src1, src2, src1, srcD src1 src4 src4 src2 srcC src2 src2 src4 src4 + + + + 13-172 Parallel MPYI3 and SUBI3 MPYI3||SUBI3 Version 5.0 or later P 00 01 10 11 Opcode 31 1 0 0 0 1 1 24 23 P d1 d2 src1 16 15 src2 src3 8 7 src4 0 srcA src3 src3 src1 src3 srcB src4, src1, src2, src1, srcD src1 src4 src3 src2 + + + + srcC src2 src2 src4 src4 Description An integer multiplication and an integer subtraction are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (MPYI3) reads from a register and the operation being performed in parallel (SUBI3) writes to the same register, MPYI3 accepts the contents of the register as input before it is modified by the SUBI3. Any combination of addressing modes can be coded for the four possible source operands as long as two are coded as indirect and two are coded as register. The assignment of the source operands srcA - srcD to the src1 - src4 fields varies, depending on the combination of addressing modes used, and the P field is encoded accordingly. To simplify processing when the order is not significant, the assembler may change the order of operands in commutative operations. Integer overflow occurs when any of the 16 MSBs of the 48-bit result differs from the MSB of the 32-bit output value. Cycles Status Bits 1 (see Note: Cycle Count on page 13-173) These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 1 if an integer underflow occurs; 0 otherwise 0 0 1 if an integer overflow occurs; 0 otherwise Unaffected Operation is affected by OVM bit value. MPYI3 SUBI3 R2,*++AR0(1),R0 *AR5--(IR1),R4,R2 Assembly Language Instructions 13-173 Mode Bit Example OVM || MPYI3||SUBI3 Parallel MPYI3 and SUBI3 or || R0 R2 R4 AR0 AR5 IR1 LUF LV UF N Z V C Data memory 8098E4h 8099FCh 62 98 8098E4h 8099FCh 62 4B0 98 1200 MPYI3 SUBI3 Before Instruction 00 0000 0000 00 0000 0032 *++AR0(1),R2,R0 *AR5--(IR1),R4,R2 After Instruction R0 50 R2 R4 AR0 AR5 IR1 LUF LV UF N Z V C 00 0000 1324 00 0000 0320 00 0000 07D0 80 98E4 80 99F0 0C 0 0 0 0 0 0 0 4900 800 2000 00 0000 07D0 2000 80 98E3 80 99FC 0C 0 0 0 0 0 0 0 4B0 1200 Note: Cycle Count One cycle if: - src3 and src4 are in internal memory - src3 is in internal memory and src4 is in external memory Two cycles if: - src3 is in external memory and src4 is in internal memory - src3 and src4 are in external memory For more information see Section 8.5, Clocking Memory Accesses, on page 8-24. 13-174 Negative Integer With Borrow NEGB Syntax Operation Operands NEGB src, dst 0 - src - C dst src general addressing modes (G): 00 01 10 11 dst any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate any CPU register Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 0 1 0 1 1 0 Description Cycles Status Bits The difference of the 0, src, and C operands is loaded into the dst register. The dst and src are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. Mode Bit Example OVM NEGB R5,R7 Before Instruction R5 R7 LUF LV UF N Z V C 00 FFFF FFCB 00 0000 0000 0 0 0 0 0 0 1 -53 R5 R7 LUF LV UF N Z V C After Instruction 00 FFFF FFCB 00 0000 0034 0 0 0 0 0 0 1 -53 52 Assembly Language Instructions 13-175 NEGF Negate Floating-Point Value Syntax Operation Operands NEGF src, dst 0 - src dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 7) Opcode 31 0 0 0 24 23 0 1 0 1 1 1 G dst 16 15 8 7 src 0 Description The difference of the 0 and src operands is loaded into the dst register. The dst and src operands are assumed to be floating-point numbers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-176 Negate Floating-Point Value NEGF Example NEGF *++AR3(2),R1 Before Instruction R1 AR3 LUF LV UF N Z V C Data memory 809802h 70C8000 1.4050e+02 809802h 70C8000 1.4050e+02 05 7B40 0025 6.28125006e+01 80 9800 0 0 0 0 0 0 0 R1 AR3 LUF LV UF N Z V C After Instruction 07 F380 0000 -1.4050e+02 80 9802 0 0 0 0 0 0 0 Assembly Language Instructions 13-177 NEGF||STF Parallel NEGF and STF Syntax || Operation || Operands NEGF src2, dst1 STF src3, dst2 0 - src2 dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) src2 dst1 src3 dst2 This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 1 1 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 1 0 0 0 1 dst1 0 0 0 16 15 src3 dst2 8 7 src2 0 Description A floating-point negation and a floating-point store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. This means that if one of the parallel operations (STF) reads from a register and the operation being performed in parallel (NEGF) writes to the same register, STF accepts the contents of the register as input before it is modified by the NEGF. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Mode Bit 13-178 OVM Parallel NEGF and STF NEGF||STF Example || R2 R7 AR4 AR5 LUF LV UF N Z V C Data memory 8098E1h 809804h NEGF STF *AR4--(1),R7 R2,*++AR5(1) After Instruction R2 R7 AR4 AR5 LUF LV UF N Z V C 07 33C0 0000 1.79750e+02 Before Instruction 07 33C0 0000 1.79750e+02 00 0000 0000 80 98E1 80 9803 0 0 0 0 0 0 0 05 84C0 0000 -6.281250e+01 80 98E0 80 9804 0 0 0 0 0 0 0 57B400000 6.281250e+01 0 8098E1h 809804h 57B4000 733C000 6.281250e+01 1.79750e+02 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-179 NEGI Negate Integer Syntax Operation Operands NEGI src, dst 0 - src dst src general addressing modes (G): 00 01 10 11 any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate dst any CPU register Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 0 1 1 0 0 0 Description The difference of the 0 and src operands is loaded into the dst register. The dst and src operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. (174 = 0AEh) After Instruction R5 LUF LV UF N Z V C 00 FFFF FF52 -174 0 0 0 1 0 0 1 Cycles Status Bits Mode Bit Example OVM NEGI 174,R5 R5 LUF LV UF N Z V C Before Instruction 00 0000 00DC 220 0 0 0 0 0 0 0 13-180 Parallel NEGI and STI NEGI||STI Syntax || Operation || Operands NEGI STI src2, dst1 src3, dst2 0 - src2 dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) src2 dst1 src3 dst2 This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 1 1 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 1 0 0 1 0 dst1 0 0 0 16 15 src3 dst2 8 7 src2 0 Description An integer negation and an integer store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STI) reads from a register and the operation being performed in parallel (NEGI) writes to the same register, STI accepts the contents of the register as input before it is modified by the NEGI. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. Assembly Language Instructions 13-181 Mode Bit OVM NEGI||STI Parallel NEGI and STI Example || R2 AR1 AR3 LUF LV UF N Z V C Data memory 80982Eh 8098A5h 0DC 0 220 80982Eh 8098A5h 0DC 19 220 25 NEGI STI Before Instruction 00 0000 0019 80 98A5 80 982F 0 0 0 0 0 0 0 *-AR3,R2 R2,*AR1++ After Instruction 25 R2 AR1 AR3 LUF LV UF N Z V C 00 FFFF FF24 80 98A6 80 982F 0 0 0 1 0 0 1 -220 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-182 No Operation NOP Syntax Operation NOP src No ALU or multiplier operations. ARn is modified if src is specified in indirect mode. src general addressing modes (G): 00 10 register(no operation) indirect (modify ARn, 0 n 7) (disp = 0-255, IR0, IR1) Operands Opcode 31 0 0 0 24 23 0 1 1 0 0 1 G 16 15 0 0 0 0 0 8 7 src 0 Description If the src operand is specified in the indirect mode, the specified addressing operation is performed, and a dummy memory read occurs. If the src operand is omitted, no operation is performed. 1 LUF LV UF N Z V C OVM NOP Before Instruction PC 3A PC After Instruction 3B Cycles Status Bits Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit Example 1 Example 2 NOP *AR3-- (1) Before Instruction AR3 PC 80 9900 5 AR3 PC After Instruction 80 98FF 6 Assembly Language Instructions 13-183 NORM Syntax Normalize NORM src, dst norm (src) dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate Operation Operands Opcode 31 0 0 0 24 23 0 1 1 0 1 0 G dst 16 15 8 7 src 0 Description The src operand is assumed to be an unnormalized floating-point number; that is, the implied bit is set equal to the sign bit. The dst is set equal to the normalized src operand with the implied bit removed. The dst operand exponent is set to the src operand exponent minus the size of the left shift necessary to normalize the src. The dst operand is assumed to be a normalized floatingpoint number. If src (exp) = -128 and src (man) = 0, then dst = 0, Z = 1, and UF = 0. If src (exp) = -128 and src (man) 0, then dst = 0, Z = 0, and UF = 1. For all other cases of the src, if a floating-point underflow occurs, then dst (man) is forced to 0 and dst (exp) = -128. If src (man) = 0, then dst (man) = 0 and dst (exp) = -128. Refer to Section 5.7, Normalization Using the NORM Instruction, on page 5-37 for more information. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise Unaffected 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Mode Bit 13-184 OVM Normalize NORM Example NORM R1,R2 Before Instruction R1 R2 LUF LV UF N Z V C 04 0000 3AF5 07 0C80 0000 0 0 0 0 0 0 0 R1 R2 LUF LV UF N Z V C After Instruction 04 0000 3AF5 F2 6BD4 0000 1.12451613e - 04 0 0 0 0 0 0 0 Assembly Language Instructions 13-185 NOT Syntax Bitwise-Logical Complement NOT src, dst src dst src general addressing modes (G): 00 01 10 11 any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate Operation Operands dst any CPU register Opcode 31 0 0 0 24 23 0 1 1 0 1 1 G dst 16 15 8 7 src 0 Description The bitwise-logical complement of the src operand is loaded into the dst register. The complement is formed by a logical NOT of each bit of the src operand. The dst and src operands are assumed to be unsigned integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-186 Bitwise-Logical Complement NOT Example NOT @982Ch,R4 Before Instruction R4 DP LUF LV UF N Z V C Data memory 80982Ch 5E2F 80982Ch 5E2F 00 0000 0000 080 0 0 0 0 0 0 0 R4 DP LUF LV UF N Z V C After Instruction 00 FFFF A1D0 080 0 0 0 1 0 0 0 Assembly Language Instructions 13-187 NOT||STI Parallel NOT and STI Syntax || Operation Operands NOT STI src2, dst1 src3, dst2 src2 dst1 || src3 dst2 src2 dst1 src3 dst2 indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src2 dst1 src3 dst2 Opcode 31 indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn1, 0 n1 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) 24 23 dst1 0 0 0 16 15 src3 dst2 8 7 src2 0 1 1 1 0 0 1 1 Description A bitwise-logical NOT and an integer store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. This means that if one of the parallel operations (STI) reads from a register and the operation being performed in parallel (NOT) writes to the same register, STI accepts the contents of the register as input before it is modified by the NOT. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Mode Bit 13-188 OVM Parallel NOT and STI NOT||STI Example || R3 R7 AR2 AR4 IR1 LUF LV UF N Z V C Data memory 8099CCh 809840h NOT STI Before Instruction 00 0000 0000 00 0000 00DC 80 99CB 80 9850 10 0 0 0 0 0 0 0 *+AR2,R3 R7,*--AR4 (IR1) After Instruction R3 220 R7 AR2 AR4 IR1 LUF LV UF N Z V C 00 FFFF F3D0 00 0000 00DC 80 99CB 80 9840 10 0 0 0 1 0 0 0 220 0C2F 0 8099CCh 809840h 0C2F 0DC 220 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-189 OR Bitwise-Logical OR Syntax Operation Operands OR src, dst dst OR src dst src general addressing modes (G): 00 01 10 11 any CPU register direct indirect (disp = 0-255, IR0, IR1) immediate (not sign-extended) dst any CPU register Opcode 31 0 0 0 24 23 1 0 0 0 0 0 G dst 16 15 8 7 src 0 Description The bitwise-logical OR between the src and dst operands is loaded into the dst register. The dst and src operands are assumed to be unsigned integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-190 Bitwise-Logical OR OR Example OR *++AR1(IR1),R2 Before Instruction R2 AR1 IR1 LUF LV UF N Z V C Data memory 809804h 2BCD 809804h 2BCD 00 1256 0000 80 9800 4 0 0 0 0 0 0 0 R2 AR1 IR1 LUF LV UF N Z V C After Instruction 00 1256 2BCD 80 9804 4 0 0 0 0 0 0 0 Assembly Language Instructions 13-191 OR3 Bitwise-Logical OR, 3-Operand Syntax Operation Operands OR3 src2, src1, dst src1 OR src2 dst src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 register (Rn2, 0 n2 27) register (Rn2, 0 n2 27) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) dst register (Rn, 0 n 27) Opcode 31 0 0 1 24 23 0 0 1 0 1 1 T dst 16 15 src1 8 7 src2 0 Description The bitwise-logical OR between the src1 and src2 operands is loaded into the dst register. The src1, src2, and dst operands are assumed to be unsigned integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-192 Bitwise-Logical OR, 3-Operand OR3 Example OR3 *++AR1(IR1),R2,R7 Before Instruction R2 R7 AR1 IR1 LUF LV UF N Z V C Data memory 809804h 2BCD 809804h 2BCD 00 1256 0000 00 0000 0000 80 9800 4 0 0 0 0 0 0 0 R2 R7 AR1 IR1 LUF LV UF N Z V C After Instruction 00 1256 0000 0 1256 2BCD 80 9804 4 0 0 0 0 0 0 0 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-193 OR3||STI Parallel OR3 and STI Syntax || Operation | Operands OR3 src2, src1, dst1 STI src3, dst2 src1 OR src2 dst1 src3 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) src1 src2 dst1 src3 dst2 This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 src2 dst1 src3 dst2 Opcode 31 1 1 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) 24 23 1 0 1 0 0 dst1 src1 16 15 src3 dst2 8 7 src2 0 A bitwise-logical OR and an integer store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. This means that if one of the parallel operations (STI) reads from a register and the operation being performed in parallel (OR3) writes to the same register, then STI accepts the contents of the register as input before it is modified by the OR3. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles 1 13-194 Parallel OR3 and STI OR3||STI Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. OR3 STI Before Instruction R2 R5 R6 AR1 AR2 LUF LV UF N Z V C Data memory 809831h 809883h 9800 0 809831h 809883h 9800 0DC 220 00 0000 0000 00 0080 0000 00 0000 00DC 80 9883 80 9830 0 0 0 0 0 0 0 220 R2 R5 R6 AR1 AR2 LUF LV UF N Z V C Mode Bit Example OVM || *++AR2,R5,R2 R6,*AR1-- After Instruction 00 0080 9800 00 0080 0000 00 0000 00DC 80 9882 80 9831 0 0 0 0 0 0 0 220 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-195 POP Pop Integer Syntax Operation Operands Opcode 31 0 0 0 24 23 0 1 1 1 0 0 01 dst 16 15 8 7 0 POP dst *SP-- dst dst register (Rn, 0 n 27) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description The top of the current system stack is popped and loaded into the dst register (32 LSBs). The top of the stack is assumed to be a signed integer. The POP is performed with a postdecrement of the stack pointer. The exponent bits of an extended-precision register (R7-R0) are left unmodified. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. R3 Before Instruction R3 SP LUF LV UF N Z V C Data memory 809856h FFFF0DA4 -62,044 809856h FFFF0DA4 -62,044 00 0000 12DA 809856 0 0 0 0 0 0 0 4,826 R3 SP LUF LV UF N Z V C After Instruction 00 FFFF 0DA4 -62,044 809855 0 0 0 1 0 0 0 Cycles Status Bits Mode Bit Example OVM POP 13-196 Pop Floating-Point Value POPF Syntax Operation Operands Opcode POPF dst *SP-- dst1 dst register (Rn, 0 n 7) 31 0 0 0 24 23 0 1 1 1 0 1 0 1 dst 16 15 8 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description The top of the current system stack (32 MSBs) is popped and loaded into the dst register. The top of the stack is assumed to be a floating-point number. The POP is performed with a postdecrement of the stack pointer. The eight LSBs of an extended-precision register (R7-R0) are zero-filled. 1 These condition flags are modified only if the destination register is R7 -R0. LUF UF LV N Z V C Unaffected 0 Unaffected 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Example R4 SP LUF LV UF N Z V C Data memory 80984Ah OVM POPF R4 Before Instruction 02 5D2E 0123 6.91186578e+00 80984A 0 0 0 0 0 0 0 R4 SP LUF LV UF N Z V C After Instruction 5F 2C13 0200 809849 0 0 0 0 0 0 0 5.32544007e+28 5F2C1302 5.32544007e+28 80984Ah 5F2C1302 5.32544007e+28 Assembly Language Instructions 13-197 PUSH PUSH Integer Syntax Operation Operands Opcode 31 0 0 0 24 23 0 1 1 1 1 0 0 1 src 16 15 8 7 0 PUSH src src *++SP src register (Rn, 0 n 27) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description The contents of the src register (32 LSBs) are pushed on the current system stack. The src is assumed to be a signed integer. The PUSH is performed with a preincrement of the stack pointer. The integer or mantissa portion of an extended-precision register (R7-R0) is saved with this instruction. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Example PUSH R6 Before Instruction R6 SP LUF LV UF N Z V C Data memory 8098AFh 0 -62,044 8098AFh 5C128081 1,544,716,417 02 5C12 8081 633,415,688 R6 8098AE 0 0 0 0 0 0 0 SP LUF LV UF N Z V C After Instruction 02 5C12 8081 8098AF 0 0 0 0 0 0 0 633,415,688 13-198 PUSH Floating-Point Value PUSHF Syntax Operation Operands Opcode PUSHF src src *++SP src register (Rn, 0 n 7) 31 0 0 0 24 23 0 1 1 1 1 1 0 1 src 16 15 8 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description The contents of the src register (32 MSBs) are pushed on the current system stack. The src is assumed to be a floating-point number. The PUSH is performed with a preincrement of the stack pointer. The eight LSBs of the mantissa are not saved. (Note the difference in R2 and the value on the stack in the example below.) 1 LUF LV UF N Z V C OVM PUSHF Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. R2 After Instruction R2 SP LUF LV UF N Z V C 02 5C12 8081 809802 0 0 0 0 0 0 0 6.87725854e+00 Cycles Status Bits Mode Bit Example Before Instruction R2 SP LUF LV UF N Z V C Data memory 809802h 0 809802h 02 5C12 8081 6.87725854e+00 809801 0 0 0 0 0 0 0 025C1280 6.87725830e+00 Assembly Language Instructions 13-199 RETIcond Syntax Operation Return From Interrupt Conditionally RETIcond If cond is true: *SP - - PC 1 ST (GIE). Else, continue. Operands Opcode None 31 0 1 1 1 1 24 23 0 0 0 0 0 0 cond 16 15 8 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description A conditional return is performed. If the condition is true, the top of the stack is popped to the PC, and a 1 is written to the global interrupt enable (GIE) bit of the status register. This has the effect of enabling all interrupts for which the corresponding interrupt enable bit is a 1. The 'C3x provides 20 condition codes that can be used with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes, and flags). Condition flags are set on a previous instruction only when the destination register is one of the extended-precision registers (R7-R0) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Cycles Status Bits 4 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit 13-200 Return From Interrupt Conditionally RETIcond Example RETINZ Before Instruction PC SP ST LUF LV UF N Z V C Data memory 809830h 123 809830h 123 0456 809830 0 0 0 0 0 0 0 0 PC SP ST LUF LV UF N Z V C After Instruction 0123 80982F 2000 0 0 0 0 0 0 0 Assembly Language Instructions 13-201 RETScond Syntax Operation Return From Subroutine Conditionally RETScond If cond is true: *SP- - PC. Else, continue. None Operands Opcode 31 0 1 1 1 1 24 23 0 0 0 1 0 0 cond 16 15 8 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description A conditional return is performed. If the condition is true, the top of the stack is popped to the PC. The 'C3x provides 20 condition codes that you can use with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes, and flags). Condition flags are set on a previous instruction only when the destination register is one of the extended-precision registers (R7-R0) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Cycles Status Bits 4 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit 13-202 Return From Subroutine Conditionally RETScond Example RETSGE Before Instruction PC SP LUF LV UF N Z V C Data memory 80983Ch 456 80983Ch 456 0123 80983C 0 0 0 0 0 0 0 PC SP LUF LV UF N Z V C After Instruction 0456 80983B 0 0 0 0 0 0 0 Assembly Language Instructions 13-203 RND Round Floating-Point Value Syntax Operation Operands RND src, dst rnd(src) dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 7) Opcode 31 0 0 0 24 23 1 0 0 0 1 0 G dst 16 15 8 7 src 0 Description The result of rounding the src operand is loaded into the dst register.The src operand is rounded to the nearest single-precision floating-point value. If the src operand is exactly halfway between two single-precision values, it is rounded to the most positive value. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs or the src operand is 0; 0 otherwise 1 if a negative result is generated; 0 otherwise Unaffected 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-204 Round Floating-Point Value RND Example RND R5,R2 Before Instruction R2 R5 LUF LV UF N Z V C 00 0000 0000 07 33C1 6EEF 1.79755599e+02 0 0 0 0 0 0 0 R2 R5 LUF LV UF N Z V C After Instruction 07 33C1 6F00 1.79755600e+02 07 33C1 6EEF 1.79755599e+02 0 0 0 0 0 0 0 Note: BZUF Instruction If a BZ instruction is executed immediately following an RND instruction with a 0 operand, the branch is not performed because the zero flag is not set. To circumvent this problem, execute a BZUF instruction instead of a BZ instruction. Assembly Language Instructions 13-205 ROL Syntax Rotate Left ROL dst dst left-rotated 1 bit dst dst register (Rn, 0 n 27) Operation Operands Opcode 31 0 0 0 24 23 1 0 0 0 1 1 1 1 dst 16 15 8 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Description The contents of the dst operand are left rotated one bit and loaded into the dst register. This is a circular rotation, with the MSB simultaneously transferred into the carry (C) bit and the LSB. Rotate left: C dst Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Set to the value of the bit rotated out of the high-order bit; unaffected if dst is not R7 - R0 Operation is not affected by OVM bit value. Mode Bit Example OVM ROL R3 Before Instruction R3 LUF LV UF N Z V C 00 8002 5CD4 0 0 0 0 0 0 0 R3 LUF LV UF N Z V C After Instruction 00 0004 B9A9 0 0 0 0 0 0 1 13-206 Rotate Left Through Carry ROLC Syntax Operation Operands Opcode ROLC dst dst left-rotated one bit through carry bit dst dst register (Rn, 0 n 27) 31 24 23 dst 16 15 8 7 0 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Description The contents of the dst operand are left rotated one bit through the carry (C) bit and loaded into the dst register. The MSB is rotated to the carry bit at the same time the carry bit is transferred to the LSB. Rotate left through carry bit: C dst Cycles Status Bits 1 These condition flags are modified only if the destination register is R7- R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Set to the value of the bit rotated out of the high-order bit; if dst is not R7-R0, then C is shifted into the dst but not changed Operation is not affected by OVM bit value. Mode Bit Example 1 OVM ROLC R3 Before Instruction R3 LUF LV UF N Z V C 00 0000 0420 0 0 0 0 0 0 1 R3 LUF LV UF N Z V C After Instruction 00 0000 0841 0 0 0 0 0 0 0 Assembly Language Instructions 13-207 ROLC Rotate Left Through Carry Example 2 ROLC R3 Before Instruction R3 LUF LV UF N Z V C 00 8000 4281 0 0 0 0 0 0 0 R3 LUF LV UF N Z V C After Instruction 00 0000 8502 0 0 0 0 0 0 1 13-208 Rotate Right ROR Syntax Operation Operands Opcode ROR dst dst right-rotated one bit through carry bit dst dst register (Rn, 0 n 27) 31 0 0 0 24 23 1 0 0 1 0 1 1 1 dst 16 15 8 7 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Description The contents of the dst operand are right rotated one bit and loaded into the dst register. The LSB is rotated into the carry (C) bit and also transferred into the MSB. Rotate right: dst C Cycles Status Bits 1 These condition flags are modified only if the destination register is R7- R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Set to the value of the bit rotated out of the high-order bit; unaffected if dst is not R7-R0 Operation is not affected by OVM bit value. Mode Bit Example OVM ROR R7 Before Instruction R7 LUF LV UF N Z V C 00 0000 0421 0 0 0 0 0 0 0 R7 LUF LV UF N Z V C After Instruction 00 8000 0210 0 0 0 1 0 0 1 Assembly Language Instructions 13-209 RORC Rotate Right Through Carry Syntax Operation Operands Opcode 31 0 0 0 24 23 1 0 0 1 1 0 1 1 dst 16 15 1 1 1 1 8 7 0 RORC dst dst right-rotated one bit through carry bit dst dst register (Rn, 0 n 27) 1 1 1 1 1 1 1 1 1 1 1 1 Description The contents of the dst operand are right rotated one bit through the status register's carry (C) bit. This could be viewed as a 33-bit shift. The carry bit value is rotated into the MSB of the dst, while at the same time the dst LSB is rotated into the carry bit. Rotate right through carry bit: C dst Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Set to the value of the bit rotated out of the high-order bit; if dst is not R7 - R0, then C is shifted in but not changed Operation is not affected by OVM bit value. Mode Bit Example OVM RORC R4 Before Instruction R4 LUF LV UF N Z V C 00 8000 0081 0 0 0 1 0 0 0 R4 LUF LV UF N Z V C After Instruction 00 4000 0040 0 0 0 0 0 0 1 13-210 Repeat Block RPTB Syntax Operation RPTB src src RE 1 ST (RM) Next PC RS src long-immediate addressing mode Operands Opcode 31 24 23 16 15 src 8 7 0 0 1 1 0 0 1 0 0 Description RPTB allows a block of instructions to be repeated RC register + 1 times without any penalty for looping. This instruction activates the block repeat mode of updating the PC. The src operand is a 24-bit unsigned immediate value that is loaded into the repeat end-address (RE) register. A 1 is written into the repeat mode bit of status register ST (RM) to indicate that the PC is being updated in the repeat mode. The address of the next instruction is loaded into the repeat start-address (RS) register. RE should be greater than or equal to RS (RE w RS). Otherwise, the code does not repeat, even though the RM bit remains set to 1. Cycles Status Bits 4 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit Assembly Language Instructions 13-211 RPTB Repeat Block Example RPTB 127h Before Instruction PC RE RS ST LUF LV UF N Z V C 0123 0 0 0 0 0 0 0 0 0 0 PC RE RS ST LUF LV UF N Z V C After Instruction 0124 127 124 100 0 0 0 0 0 0 0 Because the block-repeat modes modify the program counter, no other instruction can modify the program counter at the same time. The following two rules apply: Rule 1: The last instruction in the block (or the only instruction in a block of size 1) cannot be a Bcond, BR, DBcond, CALL, CALLcond, TRAPcond, RETIcond, RETScond, IDLE, IDLE2, RPTB, or RPTS. Example 7-3 on page 7-6 shows an incorrectly placed standard branch. Rule 2: None of the last four instructions at the bottom of the block (or the only instruction in a block of size 1) can be a BcondD, BRD, or DBcondD. Example 7-4 on page 7-7 shows an incorrectly placed delayed branch. If either rule is violated, the PC will be undefined. 13-212 Repeat Single Instruction RPTS Syntax Operation RPTS src src RC 1 ST (RM) 1S Next PC RS Next PC RE src general addressing modes (G): 00 01 10 11 register direct indirect (disp = 0-255, IR0, IR1) immediate Operands Opcode 31 0 0 0 24 23 1 0 0 1 1 1 G 16 15 1 1 0 1 1 8 7 src 0 Description The RPTS instruction allows you to repeat a single instruction src + 1 times without any penalty for looping. Fetches can also be made from the instruction register (IR), thus avoiding repeated memory access. The src operand is loaded into the repeat counter (RC). A 1 is written into the repeat mode bit of the status register ST (RM). A 1 is also written into the repeat single bit (S). This indicates that the program fetches are to be performed only from the instruction register. The next PC is loaded into the repeat end-address (RE) register and the repeat start-address (RS) register. For the immediate mode, the src operand is assumed to be an unsigned integer and is not sign extended. Cycles Status Bits 4 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit Assembly Language Instructions 13-213 RPTS Repeat Single Instruction Example RPTS AR5 Before Instruction AR5 PC RC RE RS ST LUF LV UF N Z V C 00 00FF 0123 0 0 0 0 0 0 0 0 0 0 0 AR5 PC RC RE RS ST LUF LV UF N Z V C After Instruction 00 00FF 0124 0FF 124 124 100 0 0 0 0 0 0 0 Because the block-repeat modes modify the program counter, no other instruction can modify the program counter at the same time. Therefore, the repeated instruction cannot be a Bcond, BR, DBcond, CALL, CALLcond, TRAPcond, RETIcond, RETScond, IDLE, IDLE2, RPTB, or RPTS. If this rule is violated, the PC will be undefined. Note: The RPTS instruction cannot be interrupted because instruction fetches are halted. 13-214 Signal, Interlocked SIGI Syntax Operation SIGI Signal interlocked operation. Wait for interlock acknowledge. Clear interlock. None Operands Opcode 31 0 0 0 24 23 16 15 8 7 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description An interlocked operation is signaled over XF0 and XF1. After the interlocked operation is acknowledged, the interlocked operation ends. SIGI ignores the external ready signals. Refer to Section 7.4, Interlocked Operations, on page 7-13 for detailed information. 1 LUF LV UF N Z V C OVM SIGI Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. ; The processor sets XF0 to 0, idles ; until XF1 is set to 0, and then ; sets XF0 to 1. Cycles Status Bits Mode Bit Example Assembly Language Instructions 13-215 STF Store Floating-Point Value Syntax Operation Operands STF src, dst src dst src register (Rn, 0 n 7) dst general addressing modes (G): 01 10 direct indirect (disp = 0-255, IR0, IR1) Opcode 31 0 0 0 24 23 1 0 1 0 0 0 G src 16 15 8 7 dst 0 Description The src register is loaded into the dst memory location. The src and dst operands are assumed to be floating-point numbers. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Example R2 DP LUF LV UF N Z V C Data memory 8098A1h STF R2,@98A1h Before Instruction 05 2C50 1900 080 0 0 0 0 0 0 0 4.30782204e+01 R2 DP LUF LV UF N Z V C After Instruction 05 2C50 1900 4.30782204e+01 080 0 0 0 0 0 0 0 0 8098A1h 52C5019 4.30782204e+01 13-216 Store Floating-Point Value, Interlocked STFI Syntax Operation Operands STFI src, dst src dst Signal end of interlocked operation. src register (Rn, 0 n 7) dst general addressing modes (G): 01 10 direct indirect (disp = 0-255, IR0, IR1) Opcode 31 0 0 0 1 0 1 24 23 0 0 1 G src 16 15 8 7 dst 0 Description The src register is loaded into the dst memory location. An interlocked operation is signaled over pins XF0 and XF1. The src and dst operands are assumed to be floating-point numbers. Refer to Section 7.4, Interlocked Operations, on page 7-13 for detailed information. 1 LUF LV UF N Z V C OVM STFI R3 AR4 LUF LV UF N Z V C Data memory 80993Bh 0 80993Bh 733C000 1.79750e+02 Cycles Status Bits Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. R3,*-AR4 After Instruction R3 AR4 LUF LV UF N Z V C 07 33C0 0000 80 993C 0 0 0 0 0 0 0 1.79750e+02 07 33C0 0000 1.79750e+02 80 993C 0 0 0 0 0 0 0 Mode Bit Example Before Instruction Assembly Language Instructions 13-217 STFI Store Floating-Point Value, Interlocked Note: The STFI instruction is not interruptible because it completes when ready is signaled. See Section 7.4, Interlocked Operations, on page 7-13. 13-218 Parallel Store Floating-Point Value STF||STF Syntax || Operation STF STF src2, dst2 src1, dst1 src2 dst2 || src1 dst1 src1 dst1 src2 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) Operands This instruction's operands have been augmented on the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 dst1 src2 dst2 Opcode 31 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register 24 23 src2 0 0 0 16 15 src1 dst1 8 7 dst2 0 1 1 0 0 0 0 0 Description Two STF instructions are executed in parallel. Both src1 and src2 are assumed to be floating-point numbers. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Assembly Language Instructions 13-219 STF||STF Example Parallel Store Floating-Point Value || R3 R4 AR3 AR5 LUF LV UF N Z V C Data memory 809835h 8099D3h STF STF Before Instruction R4,*AR3-- R3,*++AR5 After Instruction R3 R4 AR3 AR5 LUF LV UF N Z V C 07 33C0 0000 1.79750e+02 07 0C80 0000 1.4050e+02 80 9834 80 99D3 0 0 0 0 0 0 0 1.4050e+02 07 33C0 0000 1.79750e+02 07 0C80 0000 80 9835 80 99D2 0 0 0 0 0 0 0 0 0 809835h 8099D3h 070C8000 1.4050e+02 0733C000 1.79750e+02 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-220 Store Integer STI Syntax Operation Operands STI src, dst src dst src register (Rn, 0 n 27) dst general addressing modes (G): 01 10 direct indirect (disp = 0-255, IR0, IR1) Opcode 31 24 23 G src 16 15 8 7 dst 0 0 0 0 1 0 1 0 1 0 Description The src register is loaded into the dst memory location. The src and dst operands are assumed to be signed integers. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit Example STI R4,@982Bh Before Instruction R4 DP LUF LV UF N Z V C Data memory 80982Bh 0E5FC 58,876 80982Bh 42BD7 273,367 00 0004 2BD7 273,367 080 0 0 0 0 0 0 0 R4 DP LUF LV UF N Z V C After Instruction 00 0004 2BD7 273,367 080 0 0 0 0 0 0 0 Assembly Language Instructions 13-221 STII Store Integer, Interlocked Syntax Operation STII src, dst src dst Signal end of interlocked operation src register (Rn, 0 n 27) dst general addressing modes (G): 01 direct 10 indirect (disp = 0-255, IR0, IR1) Operands Opcode 31 24 23 G src 16 15 87 dst 0 0 0 0 1 0 1 0 1 1 Description The src register is loaded into the dst memory location. An interlocked operation is signaled over pins XF0 and XF1. The src and dst operands are assumed to be signed integers. Refer to Section 7.4, Interlocked Operations, on page 7-13 for detailed information. 1 LUF LV UF N Z V C OVM STII R1 DP Data memory 8098AEh 25C 8098AEh 78D Cycles Status Bits Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. R1,@98AEh Before Instruction 00 0000 078D 080 R1 DP After Instruction 00 0000 078D 080 Mode Bit Example Note: The STII instruction is not interruptible because it completes when ready is signaled. See Section 7.4, Interlocked Operations, on page 7-13. 13-222 Parallel STI and STI STI||STI Syntax || Operation Operands STI STI src2, dst2 src1, dst1 src2 dst2 || src1 dst1 src1 dst1 src2 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) This instruction's operands have been augmented on the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 dst1 src2 dst2 Opcode 31 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register 24 23 src2 0 0 0 16 15 src1 dst1 8 7 dst2 0 1 1 0 0 0 0 1 Description Cycles Status Bits Two integer stores are performed in parallel. If both stores are executed to the same address, the value written is that of STI src2, dst2. 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit Assembly Language Instructions 13-223 STI||STI Parallel STI and STI Example || R0 R5 AR0 AR2 IR0 LUF LV UF N Z V C Data memory 809838h 8098D3h 0 0 809838h 8098D3h 0DC 35 220 53 STI R0,*++AR2(IR0) STI R5,*AR0 Before Instruction 00 0000 00DC 00 0000 0035 80 98D3 80 9830 8 0 0 0 0 0 0 0 220 53 R0 R5 AR0 AR2 IR0 LUF LV UF N Z V C After Instruction 00 0000 00DC 00 0000 0035 80 98D3 80 9838 8 0 0 0 0 0 0 0 220 53 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-224 Subtract Integer With Borrow SUBB Syntax Operation Operands SUBB src, dst dst - src - C dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 27) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 27) Opcode 31 0 0 0 24 23 1 0 1 1 0 1 G dst 16 15 8 7 src 0 Description Cycles Status Bits The difference of the dst, src, and C operands is loaded into the dst register. The dst and src operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. Mode Bit Example OVM SUBB *AR5++(4),R5 Before Instruction R5 AR5 LUF LV UF N Z V C Data memory 809800h 0C7 199 809800h 0C7 199 00 0000 00FA 80 9800 0 0 0 0 0 0 1 250 R5 AR5 LUF LV UF N Z V C After Instruction 00 0000 0032 80 9804 0 0 0 0 0 0 0 50 Assembly Language Instructions 13-225 SUBB3 Subtract Integer With Borrow, 3-Operand Syntax Operation Operands SUBB3 src2, src1, dst src1 - src2 - C dst src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 register (Rn2, 0 n2 27) register (Rn2, 0 n2 27) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) dst register (Rn, 0 n 27) Opcode 31 0 0 1 24 23 0 0 1 1 0 0 T dst 16 15 src1 8 7 src2 0 Description The difference among the src1 and src2 operands and the C flag is loaded into the dst register. The src1, src2, and dst operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-226 Subtract Integer With Borrow, 3-Operand SUBB3 Example SUBB3 R5,*AR5++(IR0),R0 Before Instruction R0 R5 AR5 IR0 LUF LV UF N Z V C Data memory 809800h 0FA 250 809800h 0FA 250 00 0000 0000 00 0000 00C7 80 9800 4 0 0 0 0 0 0 1 199 R0 R5 AR5 IR0 LUF LV UF N Z V C After Instruction 00 0000 0032 00 0000 00C7 80 9804 4 0 0 0 0 0 0 0 50 199 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-227 SUBC Subtract Integer Conditionally Syntax Operation SUBC src, dst If (dst - src 0): (dst - src << 1) OR 1 dst Else: dst << 1 dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 27) direct indirect (disp = 0-255, IR0, IR1) immediate Operands dst register (Rn, 0 n 27) Opcode 31 0 0 0 24 23 1 0 1 1 1 0 G dst 16 15 8 7 src 0 Description The src operand is subtracted from the dst operand. The dst operand is loaded with a value dependent on the result of the subtraction. If (dst - src) is greater than or equal to 0, then (dst - src) is left-shifted one bit, the least significant bit is set to 1, and the result is loaded into the dst register. If (dst - src) is less than 0, dst is left-shifted one bit and loaded into the dst register. The dst and src operands are assumed to be unsigned integers. You can use SUBC to perform a single step of a multi-bit integer division. See the TMS320C3x General Purpose Applications Guide for a detailed description. Cycles Status Bits 1 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit 13-228 Subtract Integer Conditionally SUBC Example 1 SUBC R1 DP LUF LV UF N Z V C Data memory 8098C5h @98C5h,R1 Before Instruction 00 0000 04F6 080 0 0 0 0 0 0 0 1270 R1 DP LUF LV UF N Z V C After Instruction 00 0000 00C9 080 0 0 0 0 0 0 0 201 492 1170 8098C5h 492 1170 Example 2 SUBC 3000,R0 R0 LUF LV UF N Z V C (3000 = 0BB8h) After Instruction 2000 R0 LUF LV UF N Z V C 00 0000 0FA0 0 0 0 0 0 0 0 4000 Before Instruction 00 0000 07D0 0 0 0 0 0 0 0 Assembly Language Instructions 13-229 SUBF Subtract Floating-Point Value Syntax Operation Operands SUBF src, dst dst - src dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 7) Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 1 0 1 1 1 1 Description The difference between the dst operand and the src operand is loaded into the dst register. The dst and src operands are assumed to be floating-point numbers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-230 Subtract Floating-Point Value SUBF Example R5 AR0 IR0 LUF LV UF N Z V C Data memory 809888h SUBF *AR0-- (IR0),R5 After Instruction R5 AR0 IR0 LUF LV UF N Z V C 05 1D00 0000 3.9250e+01 80 9808 80 0 0 0 0 0 0 0 Before Instruction 07 33C0 0000 1.79750000e+02 80 9888 80 0 0 0 0 0 0 0 70C8000 1.4050e+02 809888h 70C8000 1.4050e+02 Assembly Language Instructions 13-231 SUBF3 Subtract Floating-Point Value, 3-Operand Syntax Operation Operands SUBF3 src2, src1, dst src1 - src2 dst src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 register (Rn2, 0 n2 7) register (Rn2, 0 n2 7) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) dst register (Rn, 0 n 7) Opcode 31 0 0 1 24 23 0 0 1 1 0 1 T dst 16 15 src1 8 7 src2 0 Description The difference between the src1 and src2 operands is loaded into the dst register. The src1, src2, and dst operands are assumed to be floating-point numbers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-232 Subtract Floating-Point Value, 3-Operand SUBF3 Example 1 SUBF3 R4 AR0 AR1 IR0 LUF LV UF N Z V C Data memory 809888h 809851h *AR0-- (IR0),*AR1,R4 After Instruction R4 AR0 AR1 IR0 LUF LV UF N Z V C 05 1D00 0000 80 9808 80 9851 80 0 0 0 0 0 0 0 3.9250e+01 Before Instruction 00 0000 0000 80 9888 80 9851 80 0 0 0 0 0 0 0 70C8000 1.4050e+02 733C000 1.79750e+02 809888h 809851h 70C8000 733C000 1.4050e+02 1.79750e+02 Example 2 R0 R6 R7 LUF LV UF N Z V C SUBF3 R7,R0,R6 After Instruction R0 R6 R7 LUF LV UF N Z V C 03 4C20 0000 1.27578125e+01 05 B7C8 0000 -5.00546875e+01 05 7B40 0000 6.281250e+01 0 0 0 0 1 0 0 Before Instruction 03 4C20 0000 1.27578125e+01 00 0000 0000 05 7B40 0000 6.281250e+01 0 0 0 0 0 0 0 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-233 SUBF3||STF Parallel SUBF3 and STF Syntax || Operation Operands SUBF3 src1, src2, dst1 STF src3, dst2 src2 - src1 dst1 || src3 dst2 src1 src2 dst1 src3 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 src2 dst1 src3 dst2 Opcode 31 1 1 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) 24 23 1 0 1 0 1 dst1 src1 16 15 src3 dst2 8 7 src2 0 Description A floating-point subtraction and a floating-point store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STF) reads from a register and the operation being performed in parallel (SUBF3) writes to the same register, STF accepts the contents of the register as input before it is modified by the SUBF3. If src3 and dst1 point to the same location, src3 is read before the write to dst1. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. Mode Bit 13-234 OVM Parallel SUBF3 and STF SUBF3||STF Example || R0 R1 R7 AR4 AR5 IR0 IR1 LUF LV UF N Z V C Data memory 8098B0h 809860h SUBF3 STF 00 0000 0000 R1,*-AR4(IR1),R0 R7,*+AR5(IR0) After Instruction R0 R1 R7 AR4 AR5 IR0 IR1 LUF LV UF N Z V C 06 1B60 0000 05 7B40 0000 07 33C0 0000 80 98B8 80 9850 10 8 0 0 0 0 0 0 0 7.768750e+01 6.28125e+01 1.79750e+02 Before Instruction 05 7B40 0000 6.28125e+01 07 33C0 0000 1.79750e+02 80 98B8 80 9850 10 8 0 0 0 0 0 0 0 70C8000 1.4050e+02 0 8098B0h 809860h 70C8000 733C000 1.4050e+02 1.79750e+02 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-235 SUBI Subtract Integer Syntax Operation Operands SUBI src, dst dst - src dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 27) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 27) Opcode 31 0 0 0 24 23 1 1 0 0 0 0 G dst 16 15 8 7 src 0 Description Cycles Status Bits The difference between the dst operand and the src operand is loaded into the dst register. The dst and src operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. Mode Bit Example OVM SUBI 220,R7 Before Instruction R7 LUF LV UF N Z V C 00 0000 0226 0 0 0 0 0 0 0 550 R7 LUF LV UF N Z V C After Instruction 00 0000 014A 0 0 0 0 0 0 0 330 13-236 Subtract Integer, 3-Operand SUBI3 Syntax Operation Operands SUBI3 src2, src1, dst src1 - src2 dst src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 register (Rn2, 0 n2 27) register (Rn2, 0 n2 27) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) dst register (Rn, 0 n 27) Opcode 31 0 0 1 24 23 0 0 1 1 1 0 T dst 16 15 src1 8 7 src2 0 Description The difference between the src1 operand and the src2 operand is loaded into the dst register. The src1, src2, and dst operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-237 SUBI3 Subtract Integer, 3-Operand Example 1 SUBI3 R0 R2 R7 LUF LV UF N Z V C R7,R2,R0 Before Instruction 00 0000 0000 00 0000 0866 00 0000 0834 0 0 0 0 0 0 0 2150 2100 R0 R2 R7 LUF LV UF N Z V C After Instruction 00 0000 0032 00 0000 0866 00 0000 0834 0 0 0 1 0 0 0 50 2150 2100 Example 2 SUBI3 *-AR2(1),R4,R3 Before Instruction R3 R4 AR2 LUF LV UF N Z V C Data memory 80985Dh 0DC 220 80985Dh 0DC 220 00 0000 0000 00 0000 0226 80 985E 0 0 0 0 0 0 0 550 R3 R4 AR2 LUF LV UF N Z V C After Instruction 00 0000 014A 00 0000 0226 80 985E 0 0 0 0 0 0 0 330 550 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-238 Parallel SUBI3 and STI SUBI3||STI Syntax || Operation Operands SUBI3 src1, src2, dst1 STI src3, dst2 src2 - src1 dst1 || src3 dst2 src1 src2 dst1 src3 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 src2 dst1 src3 dst2 Opcode 31 1 1 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) 24 23 1 0 1 1 0 dst1 src1 16 15 src3 dst2 8 7 src2 0 Description An integer subtraction and an integer store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. This means that if one of the parallel operations (STI) reads from a register and the operation being performed in parallel (SUBI3) writes to the same register, STI accepts the contents of the register as input before it is modified by the SUBI3. If src3 and dst1 point to the same location, src3 is read before the write to dst1. Cycles Status Bits 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. Assembly Language Instructions 13-239 Mode Bit OVM SUBI3||STI Parallel SUBI3 and STI Example || R1 R3 R7 AR2 AR7 IR0 LUF LV UF N Z V C Data memory 80983Fh 80983Ch 0DC 0 220 80983Fh 80983Ch 0DC 35 220 53 SUBI3 STI Before Instruction 00 0000 0000 00 0000 0035 00 0000 0014 80 982F 80 983B 10 0 0 0 0 0 0 0 R7,*+AR2(IR0),R1 R3,*++AR7 After Instruction R1 53 20 R3 R7 AR2 AR7 IR0 LUF LV UF N Z V C 00 0000 00C8 00 0000 0035 00 0000 0014 80 982F 80 983C 10 0 0 0 0 0 0 0 200 53 20 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-240 Subtract Reverse Integer With Borrow SUBRB Syntax Operation Operands SUBRB src, dst src - dst - C dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 27) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 27) Opcode 31 0 0 0 24 23 1 1 0 0 0 1 G dst 16 15 87 src 0 Description Cycles Status Bits The difference of the src, dst, and C operands is loaded into the dst register. The dst and src operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. Mode Bit Example OVM SUBRB R4,R6 Before Instruction R4 R6 LUF LV UF N Z V C 00 0000 03CB 00 0000 0258 0 0 0 0 0 0 1 971 600 R4 R6 LUF LV UF N Z V C After Instruction 00 0000 03CB 00 0000 0172 0 0 0 0 0 0 0 971 370 Assembly Language Instructions 13-241 SUBRF Subtract Reverse Floating-Point Value Syntax Operation Operands SUBRF src, dst src - dst dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 7) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 7) Opcode 31 0 0 0 24 23 1 1 0 0 1 0 G dst 16 15 8 7 src 0 Description The difference between the src operand and the dst operand is loaded into the dst register. The dst and src operands are assumed to be floating-point numbers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C 1 if a floating-point underflow occurs; unchanged otherwise 1 if a floating-point overflow occurs; unchanged otherwise 1 if a floating-point underflow occurs; 0 otherwise 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if a floating-point overflow occurs; 0 otherwise Unaffected Operation is not affected by OVM bit value. After Instruction R5 DP LUF LV UF N Z V C 06 69E0 0000 080 0 0 0 0 0 0 0 1.16937500e+02 Cycles Status Bits Mode Bit Example R5 DP LUF LV UF N Z V C Data memory 809905h OVM SUBRF @9905h,R5 Before Instruction 05 7B40 0000 6.281250e+01 080 0 0 0 0 0 0 0 733C000 1.79750e+02 809905h 733C000 1.79750e+02 13-242 Subtract Reverse Integer SUBRI Syntax Operation Operands SUBRI src, dst src - dst dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 27) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 27) Opcode 31 0 0 0 24 23 1 1 0 0 1 1 G dst 16 15 8 7 src 0 Description Cycles Status Bits The difference between the src operand and the dst operand is loaded into the dst register. The dst and src operands are assumed to be signed integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected 1 if an integer overflow occurs; unchanged otherwise 0 1 if a negative result is generated; 0 otherwise 1 if a 0 result is generated; 0 otherwise 1 if an integer overflow occurs; 0 otherwise 1 if a borrow occurs; 0 otherwise Operation is affected by OVM bit value. Before Instruction R3 AR5 IR0 LUF LV UF N Z V C Data memory 809900h 226 550 809900h 226 550 00 0000 00DC 80 9900 8 0 0 0 0 0 0 0 220 R3 AR5 IR0 LUF LV UF N Z V C After Instruction 00 0000 014A 80 9908 8 0 0 0 0 0 0 0 330 Mode Bit Example OVM SUBRI *AR5++(IR0),R3 Assembly Language Instructions 13-243 SWI Software Interrupt Syntax Operation Operands Opcode 31 24 23 16 15 8 7 0 SWI Performs an emulation interrupt None 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Description Cycles Status Bits The SWI instruction performs an emulator interrupt. This is a reserved instruction and should not be used in normal programming. 4 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit 13-244 Trap Conditionally TRAPcond Syntax Operation TRAPcond N 0 ST(GIE) If cond is true: Next PC *++SP, Trap vector N PC. Else: Set ST(GIE) to original state. Continue. Operands Opcode N (0 N 31) 31 24 23 cond 16 15 8 7 N + 20h 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Description Interrupts are disabled globally when 0 is written to ST(GIE). If the condition is true, the contents of the PC are pushed onto the system stack, and the PC is loaded with the contents of the specified trap vector (N). If the condition is not true, ST(GIE) is set to its value before the TRAPcond instruction changes it. The 'C3x provides 20 condition codes that can be used with this instruction (see Table 13-12 on page 13-30 for a list of condition mnemonics, condition codes, and flags). Condition flags are set on a previous instruction only when the destination register is one of the extended-precision registers (R7-R0) or when one of the compare instructions (CMPF, CMPF3, CMPI, CMPI3, TSTB, or TSTB3) is executed. Cycles Status Bits 5 LUF LV UF N Z V C OVM Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected Operation is not affected by OVM bit value. Mode Bit Assembly Language Instructions 13-245 TRAPcond Example Trap Conditionally TRAPZ PC SP ST LUF LV UF N Z V C Data memory Trap V.16 16 Before Instruction 0123 809870 0 0 0 0 0 0 0 0 PC SP ST LUF LV UF N Z V C After Instruction 0010 809871 0 0 0 0 0 0 0 0 10 809871h 124 13-246 Test Bit Fields TSTB Syntax Operation Operands TSTB src, dst dst AND src src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 27) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 27) Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 1 1 0 1 0 0 Description The bitwise-logical AND of the dst and src operands is formed, but the result is not loaded in any register. This allows for nondestructive compares. The dst and src operands are assumed to be unsigned integers. 1 These condition flags are modified for all destination registers (R27 -R0). LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-247 TSTB Test Bit Fields Example TSTB *-AR4(1),R5 Before Instruction R5 AR4 LUF LV UF N Z V C Data memory 8099C4h 767 1895 8099C4h 767 1895 00 0000 0898 80 99C5 0 0 0 0 0 0 0 2200 R5 AR4 LUF LV UF N Z V C After Instruction 00 0000 0898 80 99C5 0 0 0 0 1 0 0 2200 13-248 Test Bit Fields, 3-Operand TSTB3 Syntax Operation Operands TSTB3 src2, src1 src1 AND src2 src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 Opcode 31 0 0 1 24 23 0 0 1 1 1 1 T 16 15 0 0 0 0 0 src1 8 7 src2 0 register (Rn2, 0 n2 27) register (Rn2, 0 n2 127) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) Description The bitwise-logical AND between the src1 and src2 operands is formed but is not loaded into any register. This allows for nondestructive compares. The src1 and src2 operands are assumed to be unsigned integers. Although this instruction has only two operands, it is designated as a 3-operand instruction because operands are specified in the 3-operand format. 1 These condition flags are modified for all destination registers (R27 -R0). LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM Assembly Language Instructions 13-249 TSTB3 Test Bit Fields, 3-Operand Example 1 TSTB3 AR0 AR5 IR0 LUF LV UF N Z V C Data memory 809885h 80992Dh *AR5-- (IR0),*+AR0(1) After Instruction AR0 AR5 IR0 LUF LV UF N Z V C 80 992C 80 9805 80 0 0 0 0 1 0 0 80 992C 80 9885 80 0 0 0 0 0 0 0 Before Instruction 898 767 2200 1895 809885h 80992Dh 898 767 2200 1895 Example 2 TSTB3 R4 AR6 IR0 LUF LV UF N Z V C Data memory 8099F8h R4,*AR6-- (IR0) Before Instruction 00 0000 FBC4 80 99F8 8 0 0 0 0 0 0 0 R4 AR6 IR0 LUF LV UF N Z V C After Instruction 00 0000 FBC4 80 99F0 8 0 0 0 0 0 0 0 1568 8099F8h 1568 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. 13-250 Bitwise-Exclusive OR XOR Syntax Operation Operands XOR src, dst dst XOR src dst src general addressing modes (G): 00 01 10 11 register (Rn, 0 n 27) direct indirect (disp = 0-255, IR0, IR1) immediate dst register (Rn, 0 n 27) Opcode 31 24 23 G dst 16 15 8 7 src 0 0 0 0 1 1 0 1 0 1 Description Cycles Status Bits The bitwise-exclusive OR of the src and dst operands is loaded into the dst register. The dst and src operands are assumed to be unsigned integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Mode Bit Example OVM XOR R1,R2 Before Instruction R1 R2 LUF LV UF N Z V C 00 000F FA32 00 000F F5C1 0 0 0 0 0 0 0 R1 R2 LUF LV UF N Z V C After Instruction 00 000F F412 00 0000 0FF3 0 0 0 0 0 0 0 Assembly Language Instructions 13-251 XOR3 Bitwise-Exclusive OR, 3-Operand Syntax Operation Operands XOR3 src2, src1, dst src1 XOR src2 dst src1 3-operand addressing modes (T): 00 01 10 11 register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) register (Rn1, 0 n1 27) indirect (disp = 0, 1, IR0, IR1) src2 3-operand addressing modes (T): 00 01 10 11 register (Rn2, 0 n2 27) register (Rn2, 0 n2 27) indirect (disp = 0, 1, IR0, IR1) indirect (disp = 0, 1, IR0, IR1) dst register (Rn, 0 n 27) Opcode 31 0 0 1 24 23 0 1 0 0 0 0 T dst 16 15 src1 8 7 src2 0 Description The bitwise-exclusive OR between the src1 and src2 operands is loaded into the dst register. The src1, src2, and dst operands are assumed to be unsigned integers. 1 These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. Cycles Status Bits Mode Bit OVM 13-252 Bitwise-Exclusive OR, 3-Operand XOR3 Example 1 XOR3 *AR3++(IR0),R7,R4 Before Instruction R4 R7 AR3 IR0 LUF LV UF N Z V C Data memory 809800h 5AC3 809800h 5AC3 00 0000 0000 00 0000 FFFF 80 9800 10 0 0 0 0 0 0 0 R4 R7 AR3 IR0 LUF LV UF N Z V C After Instruction 00 0000 A53C 00 0000 FFFF 80 9810 10 0 0 0 0 0 0 0 Example 2 XOR3 R1 R5 AR1 LUF LV UF N Z V C Data memory 809825h R5,*-AR1(1),R1 Before Instruction 00 0000 0000 00 000F FA32 80 9826 0 0 0 0 0 0 0 R1 R5 AR1 LUF LV UF N Z V C After Instruction 00 0000 0F33 00 000F FA32 80 9826 0 0 0 0 0 0 0 0FF5C1 809825h 0FF5C1 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-253 XOR3||STI Parallel XOR3 and STI Syntax || Operation XOR3 STI src2, src1, dst1 src3, dst2 src1 XOR src2 dst1 || src3 dst2 src1 src2 dst1 src3 dst2 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) Operands This instruction's operands have been augmented in the following devices: - 'C31 silicon revision 6.0 or greater - 'C32 silicon revision 2.0 or greater - 'VC33 src1 src2 dst1 src3 dst2 Opcode 31 1 1 register (Rn1, 0 n1 7) indirect (disp = 0, 1, IR0, IR1) or any CPU register register (Rn2, 0 n2 7) register (Rn3, 0 n3 7) indirect (disp = 0, 1, IR0, IR1) 24 23 1 0 1 1 1 dst src1 16 15 src3 dst2 8 7 src2 0 Description A bitwise-exclusive XOR and an integer store are performed in parallel. All registers are read at the beginning and loaded at the end of the execute cycle. If one of the parallel operations (STI) reads from a register and the operation being performed in parallel (XOR3) writes to the same register, STI accepts as input the contents of the register before it is modified by the XOR3. If src2 and dst2 point to the same location, src2 is read before the write to dst2. Cycles 1 13-254 Parallel XOR3 and STI XOR3||STI Status Bits These condition flags are modified only if the destination register is R7 -R0. LUF LV UF N Z V C Unaffected Unaffected 0 MSB of the output 1 if a 0 output is generated; 0 otherwise 0 Unaffected Operation is not affected by OVM bit value. XOR3 STI Before Instruction R3 R6 AR1 AR2 IR0 LUF LV UF N Z V C Data memory 80987Eh 8098ACh 85 0 80987Eh 8098ACh 85 0DC 220 00 0000 0085 00 0000 00DC 80 987E 80 98B4 8 0 0 0 0 0 0 0 220 R3 R6 AR1 AR2 IR0 LUF LV UF N Z V C Mode Bit Example OVM || *AR1++,R3,R3 R6,*-AR2(IR0) After Instruction 00 0000 0000 00 0000 00DC 80 987F 80 98B4 8 0 0 0 0 0 0 0 220 Note: Cycle Count See subsection 8.5.2, Data Loads and Stores, on page 8-24 for the effects of operand ordering on the cycle count. Assembly Language Instructions 13-255 13-256 Appendix A Appendix A Instruction Opcodes The opcode fields for all TMS320C3x instructions are shown in Table A-1. Bits in the table marked with a hyphen are defined in the individual instruction descriptions (see Chapter 13, Assembly Language Instructions). Table A-1, along with the instruction descriptions, fully defines the instruction words. The opcodes are listed in numerical order. Note that an undefined operation may occur if an illegal opcode is executed. (An Illegal opcode can only be generated by the misuse of the TMS320 floating-point software tools, by an error in the ROM code, or by a defective RAM.) A-1 Instruction Opcodes Table A-1. TMS320C3x Instruction Opcodes Instruction ABSF ABSI ADDC ADDF ADDI AND ANDN ASH CMPF CMPI FIX FLOAT IDLE IDLE2 LDE LDF LDFI LDI LDII LDM LDP LSH LOPOWER MAXSPEED MPYF 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 27 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 26 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 25 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 1 24 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 1 1 0 0 1 0 1 0 0 0 23 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 0 1 1 1 0 The opcode is the same for standard and delayed instructions. A-2 Instruction Opcodes Table A-1. TMS320C3x Instruction Opcodes (Continued) Instruction MPYI NEGB NEGF NEGI NOP NORM NOT POP POPF PUSH PUSHF OR RND ROL ROLC ROR RORC RPTS STF STFI STI STII SIGI SUBB SUBC SUBF SUBI 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 28 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 27 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 26 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 25 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 24 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 23 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 The opcode is the same for standard and delayed instructions. Instruction Opcodes A-3 Instruction Opcodes Table A-1. TMS320C3x Instruction Opcodes (Continued) Instruction SUBRB SUBRF SUBRI TSTB XOR IACK ADDC3 ADDF3 ADDI3 AND3 ANDN3 ASH3 CMPF3 CMPI3 LSH3 MPYF3 MPYI3 OR3 SUBB3 SUBF3 SUB13 TSTB3 XOR3 LDFcond LDIcond BR(D) CALL 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 29 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 28 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 27 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 - - 0 0 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 - - 0 0 25 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 - - 0 1 24 0 1 1 0 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 - - - - 23 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 - - - - The opcode is the same for standard and delayed instructions. A-4 Instruction Opcodes Table A-1. TMS320C3x Instruction Opcodes (Continued) Instruction RPTB SWI Bcond(D) DBcond(D) CALLcond TRAPcond RETIcond RETScond MPYF3||ADDF3 31 0 0 0 0 0 0 0 0 1 1 1 1 MPYF3||SUBF3 1 1 1 1 MPYI3||ADDI3 1 1 1 1 MPYI3||SUBI3 1 1 1 1 STF||STF STI||STI LDF||LDF LDI||LDI ABSF||STF 1 1 1 1 1 30 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 29 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 28 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 27 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 26 1 1 0 1 0 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 25 0 1 - - - 0 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 24 - - - - - - 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 - - - - - 23 - - - - - - 0 1 - - - - - - - - - - - - - - - - - - - - - The opcode is the same for standard and delayed instructions. Instruction Opcodes A-5 Instruction Opcodes Table A-1. TMS320C3x Instruction Opcodes (Continued) Instruction ABSI||STI ADDF3||STF ADDI3||STI AND3||STI ASH3||STI FIX||STI FLOAT||STF LDF||STF LDI||STI LSH3||STI MPYF3||STF MPYI3||STI NEGF||STF NEGI||STI NOT||STI OR3||STI SUBF3||STF SUBI3||STI XOR3||STI Reserved for reset, traps, and interrupts 31 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 29 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 28 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 27 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 26 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 25 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 24 - - - - - - - - - - - - - - - - - - - 1 23 - - - - - - - - - - - - - - - - - - - 1 The opcode is the same for standard and delayed instructions. A-6 Appendix B Appendix A TMS320C31/VC33 Boot Loader Source Code This appendix contains the source code for the 'C31/VC33 boot loader. Note: VC33 The TMS320VC33 is logically and functionally a superset of the TMS320C31 making nearly all literature and documentation for the TMS320C31 applica- ble. However, the electrical characteristics are different and are covered in detail in the TMS320VC33 data sheet (literature number SPRS087). B-1 TMS320C31 Boot Loader Source Code ************************************************************************ * C31BOOT - TMS320C31 BOOT LOADER PROGRAM * (C) COPYRIGHT TEXAS INSTRUMENTS INC., 1990 * * NOTE: 1. AFTER DEVICE RESET, THE PROGRAM IS SET TO WAIT FOR * THE EXTERNAL INTERRUPTS. THE FUNCTION SELECTION OF * THE EXTERNAL INTERRUPTS IS AS FOLLOWS: * --------------------------------------------------- * INTERRUPT PIN | FUNCTION * ---------------|----------------------------------- * 0 | EPROM boot loader from 1000H * ---------------|----------------------------------- * 1 | EPROM boot loader from 400000H * ---------------|----------------------------------- * 2 | EPROM boot loader from FFF000H * ---------------|----------------------------------- * 3 | Serial port 0 boot loader * --------------------------------------------------- * * 2. THE EPROM BOOT LOADER LOADS WORD, HALFWORD, OR BYTE* WIDE PROGRAMS TO SPECIFIED LOCATIONS. THE * 8 LSBs OF FIRST MEMORY SPECIFY THE MEMORY WIDTH OF * THE EPROM. IF THE HALFWORD OR BYTE-WIDE PROGRAM IS * SELECTED, THE LSBs ARE LOADED FIRST, FOLLOWED BY THE MSBs. * THE FOLLOWING WORD CONTAINS THE CONTROL WORD FOR * THE LOCAL MEMORY REGISTER. THE PROGRAM BLOCKS FOLLOW. * THE FIRST TWO WORDS OF EACH PROGRAM BLOCK CONTAIN * THE BLOCK SIZE AND MEMORY ADDRESS TO BE LOADED INTO. * WHEN THE ZERO BLOCK SIZE IS READ, THE PROGRAM BLOCK * LOADING IS TERMINATED. THE PC WILL BRANCH TO THE * STARTING ADDRESS OF THE FIRST PROGRAM BLOCK. * * 3. IF SERIAL PORT 0 IS SELECTED FOR BOOT LOADING, THE * PROCESSOR WILL WAIT FOR THE INTERRUPT FROM THE * RECEIVE SERIAL PORT 0 AND PERFORM THE DOWNLOAD. * AS WITH THE EPROM LOADER, PROGRAMS CAN BE LOADED * INTO DIFFERENT MEMORY BLOCKS. THE FIRST TWO WORDS OF EACH * PROGRAM BLOCK CONTAIN THE BLOCK SIZE AND MEMORY ADDRESS * TO BE LOADED INTO. WHEN THE ZERO BLOCK SIZE IS READ, * PROGRAM BLOCK LOADING IS TERMINATED. IN OTHER WORDS, * IN ORDER TO TERMINATE THE PROGRAM BLOCK LOADING, * A ZERO HAS TO BE ADDED AT THE END OF THE PROGRAM BLOCK. * AFTER THE BOOT LOADING IS COMPLETED, THE PC WILL BRANCH * TO THE STARTING ADDRESS OF THE FIRST PROGRAM BLOCK. * ************************************************************************ B-2 TMS320C31 Boot Loader Source Code reset int0 int1 int2 int3 xint0 rint0 tint0 tint1 dint .global check .sect "vectors" .word check .word 809FC1h .word 809FC2h .word 809FC3h .word 809FC4h .word 809FC5h .word 809FC6h .word 809FC7h .word 809FC8h .word 809FC9h .word 809FCAh .word 809FCBh .word 809FCCh .word 809FCDh .word 809FCEh .word 809FCFh .word 809FD0h .word 809FD1h .word 809FD2h .word 809FD3h .word 809FD4h .word 809FD5h .word 809FD6h .word 809FD7h .word 809FD8h .word 809FD9h .word 809FDAh .word 809FDBh .word 809FDCh .word 809FDDh .word 809FDEh .word 809FDFh *************************************************************************** trap0 .word trap1 .word trap2 .word trap3 .word trap4 .word trap5 .word trap6 .word trap7 .word trap8 .word trap9 .word trap10 .word 809FE0h 809FE1h 809FE2h 809FE3h 809FE4h 809FE5h 809FE6h 809FE7h 809FE8h 809FE9h 809FEAh TMS320C31 Boot Loader Source Code B-3 TMS320C31 Boot Loader Source Code trap11 .word trap12 .word trap13 .word trap14 .word trap15 .word trap16 .word trap17 .word trap18 .word trap19 .word trap20 .word trap21 .word trap22 .word trap23 .word trap24 .word trap25 .word trap26 .word trap27 .word .word .word .word .word 809FEBh 809FECh 809FEDh 809FEEh 809FEFh 809FF0h 809FF1h 809FF2h 809FF3h 809FF4h 809FF5h 809FF6h 809FF7h 809FF8h 809FF9h 809FFAh 809FFBh 809FFCh 809FFDh 809FFEh 809FFFh *************************************************************************** .space 5 check: LDI LSH LDI LSH LDI TSTB BNZ LDI TSTB BNZ LDI TSTB BNZ LDI TSTB BZ eprom_load LSH LDI LDI LSH BN 4040h,AR0 9,AR0 404Ch,SP 9,SP 0,R0 8,IF serial 8,AR1 1,IF eprom_load 2000h,AR1 2,IF eprom_load 7FF8h,AR1 4,IF intloop 9,AR1 *AR1++(1),R1 sub_w,AR3 26,R1 load0 ; ; ; ; ; load peripheral mem. map start addr. 808000h initialize stack pointer to ram0 addr. 809800h set start address flag off intloop ; test for ext int3 ; on int3 go to serial ; load 001000h / 2^9 -> AR1 ; test for int0 ; branch to eprom_load if int0 = 1 ; load 400000h / 2^9 -> AR1 ; test for int1 ; branch to eprom_load if int1 = 1 ; load FFF000h / 2^9 -> AR1 ; test for int2 ; if no intX go to intloop ; eprom address = AR1 * 2^9 ; load eprom mem. width ; ; ; ; ; full-word size subroutine address -> AR3 test bit 5 of mem. width word if '1' start PGM loading (32 bits width) B-4 TMS320C31 Boot Loader Source Code NOP LDI LSH BN *AR1++(1) sub_h,AR3 1,R1 load0 ; ; ; ; ; ; jump last half word from mem. word half word size subroutine address -> AR3 test bit 4 of mem. width word if '1' start PGM loading (16 bits width) LDI ADDI load0 CALLU STI load2 CALLU LDI CMPI BZ SUBI CALLU LDI LDI LDIZ LDI SUBI sub_b,AR3 2,AR1 AR3 R1,*+AR0(64h) AR3 R1,RC 0,RC AR2 1,RC AR3 R1,AR4 R0,R0 R1,AR2 -1,R0 1,AR3 CALLUAR3 ; byte size subroutine address -> AR3 ; jump last 2 bytes from mem. word ; load new word ; according to mem. width ; set primary bus control ; ; ; ; load new word according to mem. width set block size for repeat loop if 0 block size start PGM ; block size -1 ; ; ; ; ; ; ; ; ; ; ; ; ; load new word according to mem. width set destination address test start address loaded flag load start address if flag off set start & dest. address flag on sub address with loop load new word according to mem. width set dest. address flag off sub address without loop jump to load a new block when loop completed LDI ADDI BR 1,R0 1,AR3 load2 .space 1 serial LDI LDI STI LDI LSH STI BR sub_s,AR3 111h,R1 R1,*+AR0(43h) 0A30h,R2 16,R2 R2,*+AR0(40h) load2 ; ; ; ; ; ; ; ; serial words subroutine address -> AR3 R1 = 0000111h set CLKR,DR,FSR as serial port pins R2 = A300000h set serial port global ctrl. register jump to load 1st block .space 29 loop_s sub_s RPTB TSTB BZ AND load_s 20h,IF sub_s 0FDFh,IF ; PGM load loop ; wait for receive buffer full ; reset interrupt flag TMS320C31 Boot Loader Source Code B-5 TMS320C31 Boot Loader Source Code load_s end_s LDI LDI BNN STI RETSU *+AR0(4Ch),R1 R0,R0 end_s R1,*AR4++(1) ; test load address flag ; store new word to dest. address ; return from subroutine .space 22 loop_h sub_h RPTB LDI AND LDI LSH OR LDI BNN STI RETSU load_h *AR1++(1),R1 0FFFFh,R1 *AR1++(1),R2 16,R2 R2,R1 R0,R0 end_h R1,*AR4++(1) ; PGM load loop ; load LSB half word ; load MSB half word ; R1 = a new 32-bit word ; test load address flag ; store new word to dest. address ; return from subroutine load_h end_h .space 26 loop_w sub_w RPTB LDI LDI BNN STI RETSU load_w *AR1++(1),R1 R0,R0 end_w R1,*AR4++(1) ; PGM load loop ; read a new 32-bit word ; test load address flag ; store new word to dest. address ; return from subroutine load_w end_w .space 14 loop_b sub_b RPTB LDI AND LDI AND LSH OR LDI AND LSH OR LDI OR LDI BNN STI RETSU .space 1 .end load_b *AR1++(1),R1 0FFh,R1 *AR1++(1),R2 0FFh,R2 8,R2 R2,R1 *AR1++(1),R2 0FFh,R2 16,R2 R2,R1 *AR1++(1),R2 LSH 24,R2 R2,R1 R0,R0 end_b R1,*AR4++(1) ; PGM load loop ; load 1st byte ( LSB ) ; load 2nd byte ; load 3rd byte ; load 4th byte ( MSB ) ; R1 = a new 32-bit word ; test load address flag ; store new word to dest. address ; return from subroutine load_b end_b B-6 Appendix C Appendix A TMS320C32 Boot Loader Source Code This appendix includes a description of the 'C32 boot loader sequence of events and a listing of its source code. Topic C.1 C.2 Page Boot-Loader Source Code Description . . . . . . . . . . . . . . . . . . . . . . . . . . C-2 Boot-Loader Source Code Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-4 C-1 Boot-Loader Source Code Description C.1 Boot-Loader Source Code Description Figure C-1 shows the boot loader program flow chart. The boot loader program starts by initializing three registers: AR7, SP, and IR0. These registers hold the peripheral bus memory map register base address, the timer counter register (used as a stack), and a flag that indicates the first block, respectively. Then, the program checks for serial port boot load or memory boot load mode by processing the bit fields set in the interrupt flag register (IF). For a serial port boot load, the program initializes the serial port for 32-bit fixed-burst-mode reads with an externally generated serial port clock and FSR. For a memory boot load, AR3 is set to the boot source address, AR2 points to the boot source strobe control register, and R2 contains the value that is stored in this strobe control register. The boot loader also sets the bit field I/ OXF0 of the I/O flag register (IOF) if the handshake mode was selected. Then the boot loader reads the first word of the boot source program. This 32-bit word indicates the boot memory width and the boot load program stores this value in R5. AR0 points to the read_mc routine that performs this read. After reading the memory width word, the boot loader reads IOSTRB, STRB0, and STRB1 control register values of the source program. These values are temporarily saved in the DMA source address register, DMA destination address register, and DMA transfer counter registers, respectively. Then, the program reads the block size with the read_mc routine. If the block size is 0, the boot loader restores the values of IOSTRB, STRB0, and STRB1 previously saved and branches to the destination address of the first block loaded and begins program execution. If the block size is not 0, the boot loader stores the block size in the BK register. This is used as a counter in a repeat block (RPTB) to transfer all the data or program in that block. For each block, the boot loader reads the destination address and the destination strobe control word. The program stores the destination address in the AR5 register. The destination strobe control word includes the destination strobe identification, the contents of the destination strobe control register (includes memory width and data size). The boot loader extracts this information from the destination control word and stores the destination strobe-control register memory-mapped address in the AR4 register, the contents of the destination strobe control register in the R4 register, and the source data size in the R3 register. The boot loader sets the AR1 register to the appropriate read routine read_s0 for serial port boot load and read_mb for memory boot load. The read routine uses these registers to control the transfer of a block of data or program. C-2 Boot-Loader Source Code Description Figure C-1. Boot-Loader Flow Chart Start Initialize registers: AR7, SP, IR0 Yes Serial boot? No Process interrupts INT0, INT1, INT2 Process memory width word Read and store strobe values Boot source address: AR3 Boot strobe pointer: AR2 Boot strobe value: R2 Handshake mode: IOF Transfer one block of data or program Interrupt flag IF Serial initialize serial global control register Memory width: R5 Memory control word read routine: AR0 Read block size Block size RC Yes Block size=0? No Restore strobe values previously saved Read destination address Destination address: AR3 Start program execution Destination strobe pointer: AR4 Read destination strobe Destination strobe value: R4 Destination data size: R3 Select read routine Memory block read routine: AR1 Memory width: R5 TMS320C32 Boot Loader Source Code C-3 Boot-Loader Source Code Listing C.2 Boot-Loader Source Code Listing ********************************************************************************** * C32BOOT - TMS320C32 BOOT LOADER PROGRAM (143 words) March-96 * (C) COPYRIGHT TEXAS INSTRUMENTS INCORPORATED, 1994 v.27 *================================================================================* * * NOTE: * * 1. Following device reset, the program waits for an external interrupt. * The interrupt type determines the initial address from which the boot * loader will start loading the boot table to the destination memory: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * C-4 INTERRUPT PIN INT0 INT1 INT2 INT3 INT0 and INT3 INT1 and INT3 INT2 and INT3 BOOT TABLE START ADDRESS 1000h 810000h 900000h 80804Ch 1000h 810000h 900000h (STRB0) (IOSTRB) (STRB1) (sport0 Rx) ASYNC ASYNC ASYNC BOOT SOURCE EPROM EPROM EPROM SERIAL EPROM,XF0/XF1 EPROM,XF0/XF1 EPROM,XF0/XF1 (STRB0) (IOSTRB) (STRB1) If INT3 is asserted together with (INT2 or INT1 or INT0) following reset, that indicates that the boot table is to be read asynchronously from EPROM using pins XF0 and XF1 for handshaking. The handshaking protocol assumes that the data ready signal generated by the host arrives through pin XF1. The data acknowledge signal is output from the C32 on pin XF0.Both signals are active low. The C32 will continuously toggle the IACK signal while waiting for the host to assert data ready signal (pin XF1). 2. The boot operation involves transfer of one or more source blocks from the boot media to the destination memory. The block structure of the boot table serves the purpose of distributing the source data/program among different memory spaces. Each block is preceded by several 32-bit control words de scribing the block contents to the boot loader program. 3. When loading from serial port, the boot loader reads the source data/program and writes it to the destination memory. There is only one way to read the serial port. When loading from EPROM, however, there are 4 ways to read and assemble the source contents, depending on the width of boot memory and the size of the program/data being transferred. Because there is a possibility that reads and writes can span the same STRB space the boot loader loads the appropriate STRB control registers before each read and write. 4. If the boot source is EPROM whose physical width is less than 32 bits, the physical interface of the EPROM device(s) to the processor should be the same as that of the 32-bit interface. (This involves a specific connection to C32's strobe and address signals). The reason for such arrangement is Boot-Loader Source Code Listing * that to function properly, the boot loader program always expects 32-bit * data from 32-bit wide memory during the boot load operation. Valid boot * EPROM widths are : 1, 2, 4, 8, 16 and 32 bits. * * 5. A single source block cannot cross STRB boundaries. For example, its * destination cannot overlap STRB0 space and IOSTRB space. Additionally, all * of the destination addresses of a single source block should reside in * physical memory of the same width. It is also not permitted to mix prg and * data in the same source block. * * 6. The boot loader stops boot operation when it finds 0 in the block size * control word. Therefore, each boot table should always end with a 0, * prompting the boot loader to branch to the first address of the first block * and start program execution from that location. * *================================================================================* * C32 boot loader program register assignments, and altered mem locations *================================================================================* * * AR7 - peripheral memory map IOF - XF0 (handshake O) * AR0 - read cntrl data subr pointer IOF - XF1 (handshake I) * AR1 - read block data/prg subr pointer * * R2 - read STRB value R4 - write STRB value * AR2 - read STRB pointer AR4 - write STRB pointer * AR3 - read data/prg pointer AR5 - write data/prg pointer * * read --> R1 --> write * * IR0 - EXEC start flag stack - 808024h - TIM0 cnt reg * IR1 - EXEC start address 808028h - TIM0 per reg * IOSTRB - 808004h - DMA0 dst reg * R3 - data SIZE STRB0 - 808006h - DMA0 dst reg * R5 - mem WIDTH STRB1 - 808008h - DMA0 cnt reg * * R6 - memory read value AR6,R7,R0,BK - scratch registers * *================================================================================* reset .word .space start 44h ; reset vector ; program starts @45h *================================================================================* * Init registers : 808000h --> AR7, 808023h --> SP, -1 --> IR0 *================================================================================* start LDI LSH LDI OR LDI 4040h,AR7 9,AR7 23h,SP AR7,SP -1,IR0 ; ; ; ; ; load peripheral memory map base address = 808000h initialize stack pointer to 808023h (timer counter - 1) reset exec start addr flag *================================================================================* TMS320C32 Boot Loader Source Code C-5 Boot-Loader Source Code Listing * Test for INT3 and, if set exclusively, proceed with serial boot load. Else, * load AR3 with 1000h if INT0, 810000h if INT1 900000h if INT2. Also load , * appropriate boot strobe pointer --> AR2 and force the boot strobe value to * reflect 32bit memory width. If (INT0 or INT1 or INT2) and INT3, turn on the * handshake mode. *================================================================================* wait1 LDI IF,R0 AND 0Fh,R0 ; clean CMPI 8,R0 ; test for INT3 BEQ serial ;*******; serial boot load mode LDI AR7,AR2 ADDI TSTB LDINZ BNZ ADDI TSTB LDINZ BNZ ADDI TSTB LDINZ BZ exit3 TSTB BZ TSTB LDI LDI LSH OR STI LSH 60h,AR2 ; 808060h (IOSTRB) 2,R0 ; test for INT1 4080h,AR3 ; 810000h / 2**9 exit3 ;*******; 4,AR2 1,R0 8,AR3 exit3 ; 808064h (STRB0) ; test for INT0 ; 001000h / 2**9 ;*******; --> AR2 --> AR2 4,AR2 ; 808068h (STRB1) 4,R0 ; test for INT2 4800h,AR3 ; 900000h / 2**9 wait1 ;*******; 8,R0 exit2 80h,IOF 6,IOF 0Fh,R2 16,R2 *AR2,R2 R2,*AR2 9,AR3 ;*; ;*; ;*; ;*; test#1 test#2 enable test#1 --> AR2 - INT3 asserted - INXF1 low (not used) handshake mode if passed exit2 ; force boot data size to 32 ; force boot mem width to 32 ; boot mem start addr --> AR3 * xx000001 - 1 bit *================================================== xx000010 - 2 bit * Process MEMORY WIDTH control word (32 bits long) xx000100 - 4 bit *================================================== xx001000 - 8 bit * xx010000 - 16 bit * xx100000 - 32 bit LDI read_mc,AR0 ; use memory to read cntrl words ; read_mc --> AR0 LDI 1,R5 ; mem width = 1 (init) LDI 32,AR6 ; mem reads = 32 (init) CALLU read_m ; read memory once (1st read) loop2 TSTB BNZ LSH LSH LSH BU 1,R6 label4 -1,R6 -1,AR6 1,R5 loop2 ; look at next bit ; decr mem reads ; incr mem width --> ;*******; R5 C-6 Boot-Loader Source Code Listing label4 label5 SUBI CMPI BN CALLU DBU 2,AR6 0,AR6 ; set flags strobes ;*******; total # of mem reads = 32/R5 read_m ; read memory once AR6,label5 ;****; *================================================================================* * Read and save IOSTRB, STRB0 & STRB1 (to be loaded at end of boot load) *================================================================================* strobes CALLU STI CALLU STI CALLU STI AR0 R1,*+AR7(4) AR0 R1,*+AR7(6) AR0 R1,*+AR7(8) ; IOSTRB ; STRB0 ; STRB1 --> --> --> (DMA src) (DMA dst) (DMA cnt) *================================================================================ * Process block size (# of bytes, half-words, or words after STRB cntrl) *================================================================================* block CALLU LDI BNZ LDI STI LDI STI LDI STI BU label2 LDI SUBI AR0 R1,R1 label2 ; read boot memory cntrl word ; is this the last block ? ;*******; no, go around (DMA src) restore IOSTRB (DMA dst) restore STRB0 (DMA cnt) restore STRB1 branch to start of program *+AR7(4),R0 ; R0,*+AR7(60h) ; *+AR7(6),R0 ; R0,*+AR7(64h) ; *+AR7(8),R0 ; R0,*+AR7(68h) ; IR1 ;*******; R1,RC 1,RC ; setup transfer loop ; RC - 1 --> RC *================================================================================* * Process block destination address, save start address of first block *================================================================================* CALLU LDI CMPI LDINZ LDINZ AR0 R1,AR5 0,IR0 AR5,IR1 0,IR0 ; ; ; ; ; read boot memory cntrl word set dest addr --> AR5 look at EXEC start addr flag if -1, EXEC start addr --> IR1 set EXEC start addr flag *================================================================================* * (For internal destination, this word should be 0 or 60h. The first case will * result in 0 --> DMA cntrl reg, in second case 0 --> IOSTRB reg). * Process block destination strobe control (sss...sss 0110 xx00) *======================================== strb value ==== 00 - IOSTRB * 01 - STRB0 TMS320C32 Boot Loader Source Code C-7 Boot-Loader Source Code Listing CALLU LDI AND OR3 LSH LDI LSH AND TSTB LDIZ AR0 R1,R4 6Ch,R1 AR7,R1,AR4 -8,R4 R4,R3 -16,R3 3,R3 0Ch,R1 3,R3 ; 10 - STRB1 ; dest mem strb pntr --> AR4 ; dest memory strobe --> R4 ; dest data size ; (IOSTRB case) --> R3 *================================================================================* * Look at R5 and choose serial or memory read for block data/program *================================================================================* CMPI LDIEQ LDINE 0,R5 read_s0,AR1 read_mb,AR1 ; read serial port0 ; read memory *================================================================================* * Transfer one block of data or program *================================================================================* RPTB CALLU STI NOP STI BU loop4 AR1 R4,*AR4 R1,*AR5++ block loop4 ; ; ; ; ;*******; read data/prg set write strobe pipeline write data/prg!!!!!!!!!! process next block *================================================================================* * Load R5 with 0, load read_s0 to AR0 and initialize serial port_0 *================================================================================* serial LDI LDI LDI LDI LDI STI LDI LSH STI BU read_s0,AR0 0,R5 0,R AR7,AR2 111h,R0 R0,*+AR7(43h) 0A30h,R7 16,R7 R7,*+AR7(40h) strobes ; use serial to read cntrl words ; memory WIDTH = serial ; dummy ; dummy ; 0000111h --> R0 ; set CLKR,DR,FSR as serial ; port pins ; A300000h --> R7 ; set serial global cntrl reg ;*******; process first block *================================================================================* * Read a single value from serial or boot memory. The number of * memory reads depends on mem WIDTH and data SIZE. R1 returns the * read value. (Serial sim: NOP --> BZ read_s0 & LDI @4000H,R1 --> LDI * *+AR7(4Ch),R1) *================================================================================* C-8 Boot-Loader Source Code Listing read_s0 TSTB 20h,IF ; look at RINT0 flag BZ read_s0 ; wait for receive buffer full AND 0FDFh,IF ; reset interrupt flag LDI *+AR7(4Ch),R1 ; read data --> R1 RETSU *-------------------------------------------------------------------- read_mc LDI 3,R3 ; data size = 32, 3 --> R3 read_mb LDI LSH SUBI LDI ADDI LSH LDI CMPI BEQ LSH LSH BU SUBI LDI LDI ADDI CALLU SUBI AND3 LSH OR ADDI DBU RETSU 1,BK R5,BK 1,BK R3,AR6 1,AR6 3,AR6 R5,R0 1,R0 exit1 -1,R0 -1,AR6 loop3 1,AR6 0,R0 0,R1 3,SP read_m 3,SP R6,BK,R7 R0,R7 R7,R1 R5,R0 AR6,loop1 ; 00000001 ; 00000100 ; 000000FF ; 0 - ; 1 - ; 11 - (ex: mem width=8) = mask --> BK EXPAND DATA --> AR6 SIZE 1 000 10 000 100 000 loop3 ; DATA SIZE ; --------- - 1 ; MEM WIDTH ;*******; --> AR6 exit1 loop1 ; init shift value ; init accumulator ; 808027h --> SP ; read memory once --> R6 ; 808024h --> SP ; apply mask ; shift ; accumulate --> R1 ; increment shift value ;*****; decrement #of chunks --> AR6 *================================================================================* * Perform a single memory read from the source boot table. Handshake enabled if * IOXF0 bit of IOF reg is set, disabled when reset. IACK will pulse continuously * if handshake enabled and data not ready (to achieve zero-glue interface when * connecting to a C40 comm-port) *================================================================================* read_m TSTB 2,IOF ; handshake mode enabled ? STI R2,*AR2 ; set read strobe !!!!!!!!!!!!! BNZ loop5 ; yes, jump over LDI *AR3++,R6 ; no, just read memory & return RETSU *------------------------------------------------------------ (C40) loop5 IACK *AR7 ;*; intrnl dummy read pulses IACK TSTB 80h,IOF ;*; wait for data ready BNZ loop5 ;*; (XF1 low from host) LDI *AR3++,R6 ;*; read memory once --> R6 TMS320C32 Boot Loader Source Code C-9 Boot-Loader Source Code Listing LDI 2,IOF ;*; assert data acknowledge ;*; (XF0 low to host) ;*; wait for data not ready ;*; (XF1 high from host) ;*; deassert data acknowledge ;*; (XF0 high to host) loop6 TSTB BZ LDI RETSU 80h,IOF loop6 6,IOF *================================================================================* C-10 Appendix D Appendix A Glossary A A0-A23: External address pins for data/program memory or I/O devices. These pins are on the primary bus. address: The location of program code or data stored in memory. addressing mode: The method by which an instruction interprets its operands to acquire the data it needs. ALU: Arithmetic logic unit. The part of the CPU that performs arithmetic and logic operations. analog-to-digital (A/D) converter: A converter with internal sample-andhold circuitry used to translate an analog signal to a digital signal. ARAU: Auxiliary-register arithmetic unit. A 32-bit ALU used to calculate indirect addresses using the auxiliary registers as inputs and outputs. arithmetic logic unit (ALU): The part of the CPU that performs arithmetic and logic operations. auxiliary registers (ARn): A set of registers used primarily in address generation. auxiliary-register arithmetic unit (ARAU): Auxiliary-register arithmetic unit. A 32-bit ALU used to calculate indirect addresses using the auxiliary registers as inputs and outputs. B bit-reversed addressing: Accessing data from memory, registers, and the instruction word by reversing several bits of an address in order to speed processing of algorithms, such as Fourier transforms. D-1 Glossary BK: Block-size register. A 32-bit register used by the ARAU in circular addressing to specify the data block size. boot loader: An on-chip code that loads and executes programs received from a host processor through standard memory devices (including EPROM), with and without handshake, or through the serial port to RAM at power up. C carry bit: A bit in the status register (ST) used by the ALU for extended arithmetic operations and accumulator shifts and rotates. The carry bit can be tested by conditional instructions. circular addressing: Accessing data from memory, registers, and the instruction word by using an auxiliary register to cycle through a range of addresses to create a circular buffer in memory. context save/restore: A save/restore of system status (status registers, accumulator, product register, temporary register, hardware stack, and auxiliary registers, etc.) when the device enters/exits a subroutine such as an interrupt service routine. CPU: Central processing unit. The unit that coordinates the functions of a processor. CPU cycle: The time it takes the CPU to go through one logic phase (during which internal values are changed) and one latch phase (during which the values are held constant). ICPU interrupt flag register (IF): A register that contains CPU, serial ports, timer, and DMA interrupt flags. cycle: See CPU cycle. D D0-D31: External data-bus pins that transfer data between the processor and external data/program memory or I/O devices. See also LD0-LD31. data-address generation logic: Circuitry that generates the addresses for data-memory reads and writes. This circuitry can generate one address per machine cycle. See also program address generation logic. data-page pointer: A 32-bit register used as the 8 most significant bits (MSBs) in addresses generated using direct addressing. D-2 Glossary data size: The number of bits (8, 16, or 32) used to represent a particular number. decode phase: The phase of the pipeline in which the instruction is decoded (identified). DMA coprocessor: A peripheral that transfers the contents of memory locations independently of the processor (except for initialization). DMA controller: See DMA coprocessor. DP: See data-page pointer. dual-access RAM: Memory that can be accessed twice in a single clock cycle. For example, code that can read from and write to a RAM in one clock cycle. E external interrupt: A hardware interrupt triggered by a pin. extended-precision floating-point format: A 40-bit representation of a floating-point number with a 32-bit mantissa and an 8-bit exponent. extended-precision register: A 40-bit register used primarily for extendedprecision floating-point calculations. Floating-point operations use bits 39-0 of an extended-precision register. Integer operations, however, use only bits 31-0. F FIFO buffer: First-in, first-out buffer. A portion of memory in which data is stored and then retrieved in the same order in which it was stored. Thus, the first word stored in this buffer is retrieved first. H hardware interrupt: An interrupt triggered through physical connections with on-chip peripherals or external devices. hit: A condition in which, when the processor fetches an instruction, the instruction is available in the cache. Glossary D-3 Glossary I IACK: Interrupt acknowledge signal. An output signal indicating that an interrupt has been received and that the program counter is fetching the interrupt vector that will force the processor into an interrupt service routine. IE: See internal interrupt enable register. I/O flag (IOF) register: Controls the function (general-purpose I/O or interrupt) of the external pins. It also contains timer/DMA interrupt flags. index registers: Two 32-bit registers (IR0 and IR1) that are used by the ARAU for indexing an address. internal interrupt: A hardware interrupt caused by an on-chip peripheral. internal interrupt enable register: A register (in the CPU register file) that determines whether the CPU or DMA responds to interrupts from external interrupt pins, the serial ports, the timers, and the DMA coprocessor. interrupt: A signal sent to the CPU that (when not masked) forces the CPU into an ISR. This signal can be triggered by an external device, an onchip peripheral, or an instruction (TRAP, for example). interrupt acknowledge (IACK): A signal indicating that an interrupt has been received and that the program counter is fetching the interrupt vector location. interrupt-trap table pointer (ITTP): A bit field in the status register that indicates the starting location (base address) of the interrupt-trap vector table. The base address is formed by left-shifting the value of the ITTP bit field by 8 bits. ISR: Interrupt service routine. A module of code that is executed in response to a hardware or software interrupt. ITTP: See interrupt-trap table pointer. L LSB: Least significant bit. The lowest-order bit in a word. D-4 Glossary M machine cycle: See CPU cycle. mantissa: A component of a floating-point number consisting of a fraction and a sign bit. The mantissa represents a normalized fraction whose binary point is shifted by the exponent. maskable interrupt: A hardware interrupt that can be enabled or disabled through software. memory-mapped register: One of the on-chip registers that point to addresses in memory. Some memory-mapped registers point to data memory, and somepoint to input/output memory. memory width: The number of bits that can be stored in a single external memory address. MFLOPS: Millions of floating point operations per second. A measure of floating-point processor speed that counts of the number of floating-point operations made per second. Also called megaflops. microcomputer mode: A mode in which the on-chip ROM (boot loader) is enabled. This mode is selected via the MP/MCBL pin. microprocessor mode: A mode in which the on-chip ROM is disabled. This mode is selected via the MP/MCBL pin. See also MP/MC pin. MIPS: Million instructions per second. miss: A condition in which, when the processor fetches an instruction, it is not available in the cache. MSB: Most significant bit. The highest-order bit in a word. multiplier: A device that generates the product of two numbers. N NMI: Nonmaskable interrupt. A hardware interrupt that uses the same logic as the maskable interrupts but cannot be masked. Glossary D-5 Glossary O overflow flag (OV) bit: A status bit that indicates whether or not an arithmetic operation has exceeded the capacity of the corresponding register. P PC: Program counter. A register that contains the address of the next instruction to be fetched. peripheral bus: A bus that is used by the CPU to communicate to the DMA coprocessor, communication ports, and timers. pipeline: A method of executing instructions in an assembly-line fashion. R RC: See repeat counter register. read/write (R/W) pin: A memory-control signal that indicates the direction of transfer when communicating to an external device. register file: A bank of registers. repeat-counter (RC) register: A 32-bit register in the CPU register file that specifies the number of times to repeat a block of code when performing a block repeat. repeat mode: A zero-overhead method for repeating the execution of a block of code. Using repeat modes allows time-critical sections of code to be executed in the shortest possible time. reset: A means to bring the CPU to a known state by setting the registers and control bits to predetermined values and signaling execution to fetch the reset vector. reset pin: A signal that causes the device to reset. R/W: See read/write pin. D-6 Glossary S short floating-point format: A 16-bit representation of a floating point number with a 12-bit mantissa and a 4-bit exponent. short floating-point format for external 16-bit data: A 16-bit representation of a floating point number with an 8-bit mantissa and an 8-bit exponent. short integer format: A 2s-complement,16-bit format for integer data. short unsigned-integer format: A 16-bit unsigned format for integer data. sign-extend: sign bit. The process of filling the high-order bits of a number with the single-precision floating-point format: A 32-bit representation of a floating-point number with a 24-bit mantissa and an 8-bit exponent. single-precision integer format: A 2s-complement 32-bit format for integer data. single-precision unsigned-integer format: A 32-bit unsigned format for integer data. software interrupt: An interrupt caused by the execution of a TRAP instruction. ST: See status register. stack: A block of memory reserved for storing and retrieving data on a first-in last-out basis. It is usually used for storing return addresses and for preserving register values. status register: A register in the CPU register file that contains global information relating to the current state of the CPU. T timer: A programmable peripheral that generates pulses for timed events. timer-period register: A 32-bit memory-mapped register that specifies the period for the on-chip timer. Glossary D-7 Glossary W wait state: A period of time that the CPU must wait for external program, data, or I/O memory to respond when it reads from or writes to that external memory. The CPU waits one extra cycle for every wait state. wait-state generator: A program that can be modified to generate a limited number of wait states for a given off-chip memory space (lower program, upper program, data, or I/O). X XA0-XA13: External address pins for data/program memory or I/O devices. These pins are on the expansion bus of the 'C30. See also A0-A23. XD0-XD31: External data bus pins that transfer data between the processor and external data/program memory or I/O devices of the 'C30. See also D0-D31. Z zero fill: The process of filling the low- or high-order bits with 0s when loading a number into a larger field. D-8 Index Index 16-bit-wide configured memory, TMS320C31/VC33 11-10 2-operand instruction 13-3 8-25 2-17, 13-2413-25 2-operand instruction word add floating-point value instruction (ADDF) 3-operand instruction 13-53 integer (ADDI) 13-57 3-operand instruction 13-58 13-51 3-operand addressing modes 3-operand instruction 13-4 add, integer 13-58 arithmetic shift 13-73 bitwise-exclusive OR 13-250 bitwise-logical ANDN 13-69 OR 13-190 compare floating-point value 13-90 integer 13-93 logical shift 13-138 multiply floating-point value 13-147 integer 13-161 subtract floating-point value 13-230 integer 13-235 with borrow 13-224 with carry instruction (ADDC) 3-operand instruction 13-49 13-48 test bit fields 13-247 8-25 3-operand instruction word 32-bit-wide configured memory, TMS320C31/VC33 11-10 A A/D converter, definition A0-A30, definition D-1 D-1 absolute value of floating-point instruction (ABSF) 13-41 integer instruction (ABSI) 13-44 address, definition D-1 address pins, external D-8 addressing 6-16-32 modes 3-operand 2-17, 13-2413-25 branch 2-17 definition D-1 general 2-17, 13-2013-23 groups 13-2013-27 parallel 2-17, 13-2513-26 register 6-36-29 types 6-2 bit-reversed 6-266-27 circular 6-216-25 direct 6-46-29 immediate 6-186-29 indirect 6-56-29 PC-relative 6-196-20 ALU. See arithmetic logic unit applications, general listing 1-7 AR read of 8-8 write to 8-7 architectural block diagram TMS320C30 2-3 TMS320C31/VC33 2-4 TMS320C32 2-5 architecture 2-2 arithmetic, shift instruction (ASH) 13-71 arithmetic logic unit (ALU) 2-8 Index-1 Index arithmetic logic unit (ALU), definition D-1 13-38 assembler syntax expression, example assembly language instructions (continued) unconditionally delayed (BRD) 13-84 standard (BR) 13-83 assembly language, instruction set 2-operand instructions 13-3 3-operand instructions 13-4 interlocked operations instructions 13-513-6 load and store instructions 13-2 low-power control instructions 13-5 program control instructions 13-413-5 assembly language instructions 3-operand instruction add 13-113-37 floating-point value 13-5313-54 integer with carry 13-4913-50 arithmetic shift 13-7313-75 bitwise-exclusive OR 13-25013-251 bitwise-logical AND 13-6313-64 AND with complement 13-6913-70 OR 13-19013-191 compare floating-point value 13-9013-91 integer 13-9313-94 logical shift multiply 13-13813-140 floating-point value 13-14713-148 integer 13-16113-162 subtract floating-point value 13-23013-231 integer 13-23513-236 with borrow 13-22413-225 call, subroutine (CALL) 13-85 conditionally (CALLcond) 13-8613-87 categories 2-operand 13-3 3-operand 13-4 interlocked operation 13-513-6 load and store 13-2 low-power control 13-5 program control 13-413-5 compare floating-point value (CMPF) 13-8813-89 integer (CMPI) 13-92 decrement and branch, conditionally delayed instruction (DBcondD) 13-9713-98 standaard instruction (DBcond) 13-9513-96 divide clock by 16 (LOPOWER) 13-135 example instruction 13-3813-40 floating-point to integer conversion (FIX) 13-9913-100 idle until interrupt (IDLE) 13-109 integer to floating-point conversion (FLOAT) 13-10313-104 interrupt, acknowledge (IACK) 13-10713-108 load data-page pointer (LDP) 13-134 floating-point exponent (LDE) 13-11213-113 mantissa (LDM) 13-133 value (LDF) 13-114 conditionally (LDFcond) 13-11513-116 interlocked (LDFI) 13-11713-118 test bit fields 13-24713-248 absolute value of floating-point (ABSF) 13-41 integer (ABSI) 13-4413-45 add floating-point value (ADDF) 13-5113-52 integer (ADDI) 13-57 3-operand instruction 13-5813-59 integer (LDI) 13-12313-124 conditionally (LDIcond) 13-12513-126 interlocked (LDII) 13-12713-128 integer with carry (ADDC) 13-48 arithmetic shift (ASH) 13-7113-72 bitwise-exclusive OR (XOR) 13-249 bitwise-logical AND 13-62 with complement (ANDN) 13-6713-68 complement (NOT) 13-18413-185 OR 13-18813-189 branch conditionally delayed (BcondD) 13-8113-82 standard (Bcond) 13-7913-80 logical shift (LSH) 13-13613-137 low-power idle (IDLE2) 13-11013-111 multiply floating-point value (MPYF) 13-146 integer (MPYI) 13-15913-160 negate floating-point value (NEGF) 13-17413-175 integer (NEGI) 13-178 negative integer with borrow (NEGB) 13-173 no operation (NOP) 13-181 Index-2 Index assembly language instructions (continued) normalize (NORM) 13-18213-183 parallel instructions ABSF and STF 13-42 ABSI and STI 13-46 ADDF3 and STF 13-55 ADDI3 and STI 13-6013-61 AND3 and STI 13-6513-66 ASH3 and STI 13-7613-78 FIX and STI 13-10113-102 FLOAT and STF 13-10513-106 LDF and LDF 13-11913-120 LDF and STF 13-12113-122 LDI and LDI 13-12913-130 LDI and STI 13-13113-132 LSH3 and STI 13-14113-144 MPYF3 and ADDF3 13-14913-152 MPYF3 and STF 13-15313-154 MPYF3 and SUBF3 13-15513-158 MPYI3 and ADDI3 13-16313-166 MPYI3 and STI 13-16713-168 MPYI3 and SUBI3 13-16913-172 NEGF and STF 13-176 NEGI and STI 13-17913-180 NOT and STI 13-18613-187 OR3 and STI 13-19213-193 STF and STF 13-21713-218 STI and STI 13-22113-222 SUBF3 and STF 13-23213-233 SUBI3 and STI 13-23713-238 XOR3 and STI 13-25213-254 POP floating-point value (POPF) 13-195 integer instruction 13-194 PUSH floating-point value (PUSHF) 13-197 integer 13-196 register syntax 13-36 repeat block (RPTB) 13-20913-210 single instruction (RPTS) 13-21113-212 restore clock to regular speed (MAXSPEED) 13-145 return from interrupt conditionally (RETIcond) 13-19813-199 from subroutine conditionally (RETScond) 13-20013-201 assembly language instructions (continued) rotate left (ROL) 13-204 assembly language instructions (continued) left through carry (ROLC) 13-20513-206 right (ROR) 13-207 right through carry (RORC) 13-208 round floating-point value (RND) 13-20213-203 signal, interlocked (SIGI) 13-213 software interrupt (SWI) 13-242 store floating-point value (STF) 13-214 interlocked (STFI) 13-21513-216 integer (STI) 13-219 interlocked (STII) 13-220 subtract floating-point value (SUBF) integer 13-22813-229 (SUBI) 13-234 conditionally (SUBC) 13-22613-227 with borrow (SUBB) 13-223 reverse floating-point value (SUBRF) 13-240 integer (SUBRI) 13-241 with borrow (SUBRB) 13-239 symbols used to define instructions 13-3313-37 test bit fields (TSTB) 13-24513-246 trap conditionally (TRAPcond) 13-24313-244 auxiliary (AR7-AR0) registers auxiliary register ALUs 2-8 arithmetic unit (ARAU) definition D-1 definition D-1 3-4 6-5 B bank switching example 9-14, 10-18 programmable 9-129-14 bit-reversed, addressing 6-266-27 definition D-1 FFT algorithms 6-266-27 bitwise-exclusive OR instruction (XOR) 13-249 Index-3 Index bitwise-logical AND 13-62 3-operand 13-63 with complement (ANDN) 13-67 complement instruction (NOT) 13-184 OR instruction 13-188 block diagram, TMS320C3x 1-3 repeat-mode control bits 7-3 nested block repeats 7-8 operation 7-37-4 RC register value 7-7 registers (RC, RE, RS) 7-2 restrictions 7-67-7 RPTB instruction 7-47-5 RPTS instruction 7-5 size (BK) register 3-4 transfer completion 12-51 block-repeat (RS, RE) registers 3-17 boot loader code description C-2 code listing C-4 definition D-2 flowchart C-3 hardware interface, TMS320C32 11-23 interrupt and trap vector mapping 11-11 memory 11-19 precautions 11-13 serial-port loading 11-11 TMS320C31/VC33 11-211-13 data stream 11-7 description 11-2 external memory loading 11-9 memory load flowchart 11-5 mode selection 11-2 mode selection flowchart 11-3 sequence 11-4 serial port load flowchart 11-6 TMS320C32 11-1411-24 data stream 11-20 description 11-14 external memory interface 11-23 mode selection 11-14 mode selection flowchart 11-17 sequence 11-15 serial port load flowchart 11-18 Index-4 branch addressing modes 2-17 conditionally delayed instruction (BcondD) 13-81 standard instruction (Bcond) 13-79 conflicts 8-4 delayed 7-97-10 execution 7-10 incorrect use of 7-9 incorrectly placed 7-7, 7-10 incorrectly placed 7-6 unconditionally delayed instruction (BRD) 13-84 standard instruction (BR) 13-83 bus cycles 10-39 IOSTRB 10-42 STRB0 10-39 STRB1 10-39 operation external 2-19 internal 2-18 timing 10-39 buses data 2-18 DMA 2-18 program 2-18 busy-waiting loop, example 7-16 byte-wide configured memory, TMS320C31/VC33 11-9 C cache control bits cache clear bit (CC) 4-22 cache enable bit (CE) 4-22 cache freeze bit (CF) 4-22 hit 4-21 instruction 2-16, 4-19 algorithm 4-214-22 memory 2-13 architecture 4-19 miss 4-21 segment 4-21 subsegment 4-21 call, subroutine conditionally instruction (CALLcond) 13-86 7-11, Index instruction (CALL) 7-11, 13-85 response timing 7-12 carry bit, definition carry flag 13-29 D-2 central processing unit. See CPU circular addressing 6-216-25 algorithm 6-23 buffer 6-216-25 definition D-2 FIR filters 6-24 operation 6-23 CLKX pins 12-22 clock mode timer interrupt 12-13 timer pulse generator 12-712-9 clock periods, minor 8-24 13-88 compare floating-point value instruction (CMPF) integer instruction (CMPI) 13-92 comparison, feature set condition codes and flags 2-27 13-1, 13-30, 13-31 interrupt DMA interaction 7-40 latency 7-35 CPU (continued) processing, block diagram 7-34 processing cycle 7-33 primary registers 2-9 register file 3-2 registers 3-13-20 auxiliary (AR7-AR0) 2-10 3-4 block size (BK) 2-11, 3-4 block-repeat (RS, RE) 3-17 data-page pointer (DP) 2-10, 3-4 extended-precision (R7-R0) 2-10, 3-3 I/O flag (IOF) 2-11, 3-16 index (IR1, IR0) 2-10, 3-4 interrupt flag (IF) 2-11, 3-11, 7-32 bits defined 3-13 condition flag floating-point underflow 13-29 latched floating-point underflow 13-29 latched overflow 13-29 negative 13-29 overflow 13-29 zero 13-29 conditional delayed branches compare instructions 7-9 extended-precision registers context save/restore, definition control register 12-51 9-2 interrupt-enable (IE) 2-11, 3-9, 7-32 list of 3-2 program-counter (PC) 2-18, 3-18 repeat end-address (RE) 2-11, 3-17, 7-2 repeat start-address (RS) 2-11, 3-17, 7-2 repeat-counter (RC) 2-11, 3-17, 7-2 reserved bits and compatibility 3-19 status (ST) 2-11, 3-5, 7-32, 13-29 system-stack pointer (SP) 2-11, 3-4 transfer, with serial-port transmit polling 12-4312-44 D D0-D31, definition D-2 data, buses 2-18 data formats 5-15-48 floating-point addition and subtraction 5-325-36 conversion to integer 5-415-42 floating-point formats 5-45-13 conversion between formats 5-125-15 extended-precision 5-85-9 short 5-55-6 single-precision 5-75-8 integer 5-2 single-precision 5-25-3 unsigned 5-3 integer to floating-point conversion 5-43 normalization using NORM instruction 5-375-38 rounding with RND instruction 5-395-40 7-9 D-2 control registers, external interface expansion bus 9-99-15 primary bus 9-79-8 conversion floating-point to integer 5-415-42 integer to floating-point 5-43 counter register (timer) CPU arbitration 12-63 block diagram 2-7 cycle, definition D-2 definition D-2 general 2-6 12-3, 12-7 Index-5 Index unsigned-integer formats, single-precision 5-35-5 data memory, TMS320C32 2-20 data-rate timing operation fixed 12-36 burst mode 12-36 continuous mode 12-36 variable 12-39 burst mode 12-35 continuous mode 12-40 data-page pointer (DP) 2-10, 3-4 data-receive register (DRR) 12-28 serial port 12-2812-29 data-transfer operation, handshake 11-20 data-transmit register (DXR) 12-28, 12-32, 12-36, 12-37 data-address generation logic, definition D-2 data-page pointer (DP), definition D-2 DBR instruction 8-8 decode phase, definition D-3 decrement and branch conditionally delayed instruction (DBcondD) 13-97 standard instruction (DBcond) 13-95 instruction (DBR) 8-8 delayed branch 7-97-10 correct device operation 7-50 example 8-6 incorrectly placed 7-7 dequeue (stacks) 6-29, 6-31 destination-address register 12-51 direct addressing 6-46-29 direct memory access (DMA) 2-24 disabled interrupts by branch 7-9 displacements indirect addressing 6-5 PC-relative addressing 6-19 divide clock by 16 instruction (LOPOWER) 13-135 DMA architecture 2-24 block moves 12-48 buses 2-18 controller 2-18, 2-24, 12-4812-68 2-channel, TMS320C32 12-49 address generation 12-57 arbitration 12-63 basic configuration 12-51 Index-6 basic operation 12-50 block diagram 2-25 channel synchronization 12-6512-67 DMA (continued) functional description 12-48 global-control register 12-53 internal priority schemes for 'C32 12-62 interrupts 12-64 priorities 12-62 register 12-51 transfer-counter register 12-58 coprocessor, definition D-3 destination register 12-6712-68 destination/source address register 12-5712-59 Initialization/reconfiguration 12-73 interrupt, CPU interaction 7-40 interrupt-enable register 12-5912-62 interrupts 7-38 control bits 7-38 processing, block diagram 7-39, 7-40 memory transfer 12-6712-68 single DMA timing 12-68 PRI and CPU/DMA arbitration rules for 'C32 12-64 registers, initialization 12-50 setup and use examples 12-7412-80 source register 12-6712-68 start 12-50 timing expansion bus destination 12-72 on-chip destination 12-69 primary bus destination 12-70 12-71 transfer-counter register 12-5812-59 word transfers 12-50 dual-access RAM, definition D-3 DX pins 12-22 E event counters 12-2 example instruction 13-3813-40 execute only 8-12 parallel store followed by single read 8-14 single store followed by two reads 8-13 expansion bus 9-2 control register 9-99-15 bits described 9-9 functional timing of operations 9-15 I/O cycles 9-219-36 Index interface, signals 9-5 programmable wait states 9-109-11, 10-1510-16 extended-precision (R7-R0) registers 3-3 definition D-3 floating-point format, definition D-3 external buses (expansion, primary) 2-19 interface control registers 9-2 memory map 9-6 timing, expansion bus I/O cycles 9-219-36 timing, primary bus cycles 9-159-20 interrupt 7-26, 7-36 buses (expansion, primary) 2-21 definition D-3 interlocked-instruction signaling 2-21 memory interface 9-19-38 configurations 10-7 control registers 10-7 features 10-2 overview 10-3 timing 9-159-38 reset signal 7-21 external bus operation external interface control registers 9-2 expansion bus 9-99-15 primary bus 9-79-8 external interface timing expansion-bus I/O cycles 9-219-36 primary-bus cycles 9-159-20 external memory interface timing, expansion bus 9-159-38 programmable bank switching 9-129-14 wait states 9-109-11, 10-1510-16 F FFT algorithms, using bit-reversed addressing to implement 6-26 FIFO buffer, definition D-3 FIR filters, implementation using circular addressing 6-24 FIX instruction 5-41 flowchart 5-42 fixed data-rate timing operation 12-36 burst-mode timing 12-36 continuous-mode timing 12-36 fixed priority, for 'C32 12-62 flag carry 13-29 condition floating-point underflow 13-29 latched floating-point underflow 13-29 latched overflow 13-29 negative 13-29 overflow 13-29 zero 13-29 FLOAT instruction, flowchart 5-43 floating-point addition, flowchart 5-33 multiplication examples 5-295-31 flowchart 5-28 operation 5-15-48 to integer conversion instruction (FIX) 13-99 underflow condition flag 13-29 values fractional 5-11 negative 5-11 positive 5-10 floating-point format 5-45-13 2s-complement, converting IEEE format to 5-15 addition and subtraction 5-325-36 examples 5-345-36 conversion between formats 5-125-13 TMS320C3x to IEEE 5-22 to IEEE standard 754, 5-14 to integer 5-415-42 converting integer to 5-43 determining decimal equivalent 5-9 extended-precision 5-85-9 normalization 5-375-38 rounding value 5-395-40 multiplication 5-26 short, for external 16-bit data, TMS320C32 5-6 single-precision 5-75-8 frame sync 12-37, 12-38 FSX pins 12-22 G general addressing modes 13-2013-23 global memory, sharing 7-17 by multiple processors 7-13 Index-7 Index global-control register DMA 12-5312-59 serial port 12-15, 12-1712-21 timer 12-3, 12-412-6 indirect addressing (continued) with preinde 6-136-15 instruction 2-operand 13-3 3-operand 13-4 cache 4-19 algorithm 4-21 TMS320C32 2-16 CALL 7-11 CALLcond 7-11 DBR 8-8 FIX 5-41 FLOAT 5-43 IACK 7-35 IDLE2 7-49 interlocked operations 13-513-6 ISR 7-35 LDFI 7-14 LDII 7-14 load and store 13-2 low-power control operations 13-5 LOWPOWER 7-51 NOP 7-45 NORM 5-37 POP ST 7-41 program control 13-413-5 PUSH ST 7-41 RETIcond 7-12, 7-48 RETScond 7-11 RND 5-39 RPTB 7-2, 7-4 RPTS 7-2, 7-5 SIGI 7-14 STFI 7-14 STII 7-14 TRAPcond 7-11 instruction register (IR) instruction register (IR) 2-18 3-18 H handshake 11-20 hardware interrupt, definition D-3 hit, definition D-3 hold cycles 9-37 hold everything 8-15 busy external port 8-16 conditional calls and traps 8-18 multicycle data reads 8-17 I I/O flag (IOF) register 3-16 bits defined 3-16 CPU register file 3-16 definition D-4 I/O flags, external 2-21 IACK instruction 7-35 IACK signal, definition D-4 idle until interrupt instruction (IDLE) 13-109 IDLE2 interrupt response timing 7-51 power-down mode 7-497-51 timing 7-50 IEEE format, converting floating-point format to 5-21 IIOF flag register (IIF), definition D-2 immediate addressing 6-186-29 inactive bus states 10-51 index registers (IR1, IR0) 3-4 definition D-4 indirect addressing 6-56-29 3-operand addressing mode 13-25 ARAUs 6-5 auxiliary register 6-5 parallel addressing mode 13-26 with postdisplacement 6-11 with postinde 6-156-18 with predisplacement 6-96-11 Index-8 instruction set 13-3813-172 example instruction 13-3813-40 summary, table 13-10 integer format 5-2 short integer 5-2 sign-extended 5-2 single-precision 5-2 unsigned 5-3 integer to floating-point conversion instruction (FLOAT) 13-103 using the FLOAT instruction 5-43 Index interface enhanced memory, TMS320C32 expansion bus 2-19 primary bus 2-19 2-19 interlocked instructions 2-21 operations 7-137-20 busy-waiting loop 7-15 external flag pins (XF0, XF1) 7-13 instructions 13-513-6 instructions used in 7-13 LDFI and LDII instructions 7-14 loads and stores 7-13 multiprocessor counter manipulation STFI and STII instructions 7-14 internal bus operation 2-18 buses 2-8 clock 12-10 interrupt 7-26 definitions D-4 enable register, definition 7-16 D-4 interrupt 7-267-37 acknowledge, instruction (IACK) 13-107 acknowledge signal, definition D-4 considerations TMS320C30 7-447-47 TMS320C3x 7-417-43 control bits 7-32 interrupt enable register (IE) 7-32 interrupt flag register (IF) 7-32 status register (ST) 7-32 CPU/DMA interaction 7-40 definition D-4 DMA 7-38, 12-64 edge-triggered 12-64 external 2-21, 7-36 flag register (IF), behavior 7-32 initialization 7-47 latency (CPU) 7-357-36 locations 3-15 logic, functional diagram 7-37 prioritization 7-31 processing 7-337-35 block diagram 7-34, 7-39 serial port 12-34 receive timer 12-34 transmit timer 12-34 interrupt (continued) service routine (ISR) 7-35, 7-50 instruction 7-35 timer 12-2, 12-13 vector table TMS320C30 and TMS320C31/VC33 7-267-28 TMS320C32 7-297-30 interrupt and trap branch instructions, TMS320C31/VC33, microcomputer mode 4-17 vector locations, TMS320C32 4-18, 7-30 interrupt service routine (ISR), definition D-4 interrupt-enable (IE) register bits defined 3-10 CPU register file 3-9 interrupt-trap table pointer (ITTP) 3-14 definition D-4 interrupts, level-triggered 12-64 IOSTRB bus cycles 10-42 control register 10-9 signal 9-3, 9-15 ISR. See interrupt service routine (ISR) L LA0-LA30, definition D-8 latched floating-point underflow condition flag 13-29 overflow condition flag 13-29 LD0-LD31, definition D-8 LDFI instruction 7-14 LDII instruction 7-14 load data-page pointer instruction (LDP) 13-134 floating-point exponent instruction (LDE) 13-112 mantissa instruction (LDM) 13-133 value (LDF) 13-114 conditionally instruction (LDFcond) 13-115 interlocked instruction (LDFI) 13-117 integer conditionally instruction (LDIcond) 13-125 instruction (LDI) 13-123 interlocked instruction (LDII) 13-127 load and store instructions 13-2 Index-9 Index logical shift instruction (LSH) LOPOWER 7-517-52 timing 7-52 13-136 TMS320C31/VC33 4-11 memory (continued) TMS320C32 4-12 low-power control instructions 13-5 idle instruction (IDLE2) 13-110 LRU cache update LSB, definition D-4 4-19 M mantissa, definition MAXSPEED, timing D-5 D-5 7-52 maskable interrupt, definition memory 4-2 accesses 2-operand instructions 8-25 3-operand instructions 8-25 data access 8-22 data loads and stores 8-24 internal clock 8-24 pipeline 8-24 program fetch 8-22, 8-24 timing 8-24 two data accesses 8-23 addressing modes 2-17 cache 2-13 configured, TMS320C31/VC33, byte-wide conflicts 8-4, 8-9, 8-22 execute only 8-12 hold everything 8-15 program fetch incomplete 8-11 program wait 8-9 data, TMS320C32 2-20 DMA memory transfer 12-6712-68 enhanced interface, TMS320C32 2-19 general organization 2-13 global, sharing 7-17 by multiple processors 7-13 interface 16-bit wide 10-26 32-bit wide 10-20 8-bit wide 10-32, 10-38 control registers 9-7 signals 9-3 maps peripheral bus TMS320C30 4-9 11-9 TMS320C30 4-2, 4-4 TMS320C31/VC33 4-6 microcomputer mode TMS320C30 4-3 TMS320C31/VC33 4-5 TMS320C32 4-7 microprocessor mode TMS320C30 4-2 TMS320C31/VC33 4-5 TMS320C32 4-7 organization, block diagram TMS320C30 2-14 TMS320C31/VC33 2-15 TMS320C32 2-16 parallel multiplies and adds 8-30 stores 8-29 pipeline conflicts 8-8 program, TMS320C32 2-19 timing 8-24 TMS320C31/VC33, configured 16-bit-wide 11-10 32-bit-wide 11-10 widths 16-bit with 16-bit data type size 10-28 16-bit with 32-bit data type size 10-30 16-bit with 8-bit data type size 10-26 32-bit with 16-bit data type size 10-22 32-bit with 32-bit data type size 10-24 32-bit with 8-bit data type size 10-20 8-bit with 16-bit data type size 10-34 8-bit with 32-bit data type size 10-35 8-bit with 8-bit data type size 10-32 memory-mapped register, definition MFLOPS, definition D-5 D-5 D-5 microcomputer mode, definition microprocessor mode, definition MIPS, definition miss, definition D-5 D-5 D-5 modes, boot loader flowchart TMS320C31/VC33 11-3 TMS320C32 11-17 mode selection TMS320C31/VC33 11-2 TMS320C32 11-14 Index-10 Index MSB, definition D-5 MSTRB signal 9-3, 9-15 multiple processors, sharing global memory 7-13 multiplication, floating-point, examples 5-295-31 multiplier definition D-5 floating-point/integer 2-8 multiply floating-point value instruction (MPYF) 13-146 integer instruction (MPYI) 13-159 or CPU operation with a parallel store, instruction word format 8-29 multiprocessor counter manipulation, example 7-16 support, through interlocked operations 7-13 parallel Instructions ADDI3 and STI 13-6013-61 FIX and STI 13-10113-102 parallel instructions ABSF and STF 13-4213-43 ABSI and STI 13-4613-47 ADDF3 and STF 13-5513-56 ASH3 and STI 13-7613-78 FLOAT and STF 13-10513-106 LDF and LDF 13-11913-120 LDF and STF 13-121 LDI and LDI 13-12913-130 LDI and STI 13-13113-132 LSH3 and STI 13-14113-144 MPYF3 and ADDF3 13-14913-152 MPYF3 and STF 13-15313-154 MPYF3 and SUBF3 13-15513-158 MPYI3 and ADDI3 13-16313-166 MPYI3 and STI 13-16713-168 MPYI3 and SUBI3 13-16913-172 NEGF and STF 13-17613-177 NEGI and STI 13-17913-180 NOT and STI 13-18613-187 OR3 and STI 13-19213-193 STF and STF 13-21713-218 STI and STI 13-22113-222 SUBF3 and STF 13-23213-233 SUBI3 and STI 13-23713-238 XOR3 and STI 13-25213-254 PC-relative addressing period register (timer) 6-196-20 12-3, 12-7 N negate floating-point value instruction (NEGF) 13-174 integer instruction (NEGI) 13-178 negative condition flag 13-29 integer with borrow instruction (NEGB) 13-173 nested block repeats 7-8 no operation instruction (NOP) 13-181 normalization, floating-point value 5-375-38 normalize instruction (NORM) 13-182 flowchart 5-38 using 5-375-38 O output value formats 13-28 overflow 5-41 condition flag 13-29 flag (OV) bit, definition D-6 peripheral bus definition D-6 memory-mapped registers TMS320C30 4-10 TMS320C31/VC33 4-11 TMS320C32 4-13 P parallel addressing modes 2-17, 13-2513-26 instruction set summary table 13-1713-19 multiplies and adds, instruction word format 8-30 peripherals on DMA controller 12-4812-68 serial port 12-1512-47 timers 12-2 register diagram 2-22 serial ports 2-23 timers 2-23 modules, block diagram 2-22 Index-11 Index peripherals 12-112-68 DMA controller 12-4812-68 CPU/DMA interrupt enable register 12-5912-62 destination- and source-address registers 12-5712-59 global-control register 12-5312-59 Initialization/reconfiguration 12-73 memory transfer timing 12-6712-68 programming examples 12-7412-80 transfer-counter register 12-5812-59 general architecture 2-22 serial ports 12-1512-47 data-transmit register 12-28 data-receive register 12-2812-29 FSR/DR/CLKR port control register 12-2312-24 FSX/DX/CLKX port control register 12-2212-23 functional operation 12-3512-41 global-control register 12-1712-21 initialization/reconfiguration 12-41 interrupt sources 12-34 operation configurations 12-2912-31 receive/transmit timer control register 12-2512-27 receive/transmit timer counter register 12-27 receive/transmit timer period register 12-28 timing 12-3112-34 TMS320C3x interface examples 12-4112-48 timers 12-212-14 global-control register 12-412-6 initialization/reconfiguration 12-1312-17 interrupts 12-13 operation modes 12-1012-12 period and counter registers 12-7 pulse generation 12-712-9 pin operation, states at reset 7-21 pipeline conflicts 8-4 branch 8-4 memory 8-8, 8-9 register 8-6 resolving (memory) 8-22 decode unit 8-2 definition D-6 execute unit 8-2 fetch unit 8-2 memory accesses 8-24 Index-12 pipeline (continued) operation 7-42 introduction 8-1 read unit 8-2 structure 8-2 major units 8-2 POP floating-point value instruction (POPF) integer instruction 13-194 power-management modes IDLE2 7-497-51 7-497-52 13-195 primary bus 9-2 bus cycles 9-159-20 control register 9-79-8 bits described 9-7 BNKCMP and bank size 9-12, 10-17 full speed accesses 9-15 functional timing of operations 9-15 interface, signals 9-4 programmable bank switching 9-13, 10-18 wait states 9-109-11, 10-1510-16 program buses 2-18 control, instructions 13-413-5 counter, definition D-6 fetch incomplete 8-11 multicycle program memory fetches 8-12 flow control 7-17-52 calls, traps, and returns 7-117-12 delayed branches 7-97-10 interlocked operations 7-137-20 interrupt vector table, TMS320C32 7-297-30 interrupts 7-267-37 control bits 7-32 CPU interrupt latency 7-357-36 CPU/DMA interaction 7-40 prioritization 7-31 processing 7-337-35 TMS320C30 considerations 7-447-47 TMS320C3x considerations 7-417-43 vector table 7-267-28 power-management mode repeat modes 7-27-8 7-497-52 nested block repeats 7-87-15 RC register value after repeat mode 7-7 repeat-mode control bits 7-3 repeat-mode operation 7-37-4 restrictions 7-67-7 Index program (continued) RPTB instruction 7-47-5 RPTS instruction 7-57-6 reset operation 7-217-25 TMS320LC31/VC33 power management mode IDLE2 7-497-51 LOPOWER 7-517-52 memory 2-19 wait due to multicycle access 8-11 until CPU data access completes program-counter (PC) register programmable bank switching 9-129-14 wait states 9-109-11, 10-1510-16 pulse mode timer interrupt 12-13 timer pulse generator 12-712-9 registers buses 2-18 CPU 2-9 auxiliary (AR7-AR0) 2-10, 3-4 block size (BK) 2-11, 3-4 block-repeat (RS, RE) 3-17 data-page pointer (DP) 2-10, 3-4 extended-precision (R7-R0) 2-10, 3-3 condition flags 13-39 8-10 2-18, 3-18 extended-precision registers (R7-R0) I/O flag (IOF) 2-11, 3-16 index (IR1, IR0) 2-10, 3-4 interrupt flag (IF) 2-11, 3-11 7-9 asynchronous accesses 7-45 interrupt-trap table pointer (ITTP) bit 3-14 PUSH floating-point value instruction (PUSHF) integer instruction 13-196 13-197 Q queue (stacks) 6-29, 6-31 R RAM. See memory RC register value, after repeat mode completes 7-7 read/write (R/W) pin, definition receive shift register (RSR) D-6 12-28 interrupt-enable (IE) 2-11, 3-9, 12-5912-62 repeat end-address (RE) 7-2 repeat start-address (RS) 7-2 repeat-counter (RC) 2-11, 3-17, 7-2 status (ST) 2-11, 3-5, 13-29 system-stack pointer (SP) 2-11, 3-4, 6-29 DMA destination and source address 12-5712-59 global-control register 12-5312-59 transfer-counter register 12-5812-59 DMA channel control 7-38 instruction (IR) 2-12, 3-18 interrupt-enable (IE) 7-38 memory map, external memory interface 10-7 IOSTRB control 10-9 STRB0 10-8 STRB1 control 10-8 peripherals receive/transmit timer control 12-25 serial port 12-1512-47 FSR/DR/CLKR 12-23 FSX/DX/CLKX 12-22 global-control 12-1712-21 timer 12-3 counter 12-7 global-control 12-4 period 12-7 receive/transmit timer control register (serial port) 12-2512-27 counter register (serial port) 12-27 period register (serial port) 12-28 register addressing 6-36-29 conflicts 8-4 file CPU 2-9 definition D-6 pipeline conflicts 8-6 program-counter (PC) 2-12, 2-18, 3-18 repeat mode operation 7-37-4 reserved bits and compatibility 3-19 repeat block instruction (RPTB) 13-209 See also RPTB instruction single instruction (RPTS) 13-211 See also RPTS instruction Index-13 Index repeat end-address (RE) register repeat mode, definition D-6 repeat modes 7-27-8 control algorithm 7-4 control bits 7-3 maximum number of repeats nested block repeats 7-8 operation 7-37-4 RC register value 7-7 restrictions 7-67-7 RPTB instruction 7-47-5 RPTS instruction 7-5 repeat start-address (RS) register repeat-counter (RC) register definition D-6 reset 4-14 definition D-6 operation 7-217-25 performed 7-25 pin states 7-21 reset and interrupt vector priorities reset pin, definition D-6 3-17, 7-2 7-3 3-17, 7-2 3-17, 7-2 from subroutine conditionally instruction (RETScond) 7-11 RND instruction 5-39 flowchart 5-40 ROM. See memory rotate left instruction (ROL) 13-204 left through carry (ROLC) 13-205 right instruction (ROR) 13-207 right through carry instruction (RORC) 13-208 rotating priority, for 'C32 12-63 round floating-point value instruction (RND) 13-202 rounding of floating-point value 5-395-40 RPTB instruction 7-47-5 nesting 7-8 pipeline conflict in 7-7 to flush pipeline 8-5 RPTS instruction 7-57-6 to flush pipeline 8-5 7-31 S segment start address (SSA) 4-19 semaphores, using in critical sections 7-17 serial port 12-1512-47 block diagram 12-16 clock 12-15, 12-31 configurations 12-2912-31 timer 12-42 timing 12-3112-34 continuous transmit and receive mode 12-33 CPU transfer with transmit polling 12-4312-44 data-receive register 12-2812-29 data-transmit register 12-28 fixed data-rate timing 12-36 burst mode 12-36 continuous mode 12-36 frame sync 12-37, 12-38 functional operation 12-3512-41 global-control register 12-15, 12-1712-21 handshake mode 12-19, 12-3312-35, 12-42, 12-43 direct connect 12-34 initialization reconfiguration 12-4112-47 interface examples handshake mode example 12-4212-43 serial A/C interface example 12-45 serial A/D and DIA interface example 12-4612-48 reset, interrupt, and trap vector, locations, microprocessor mode, TMS320C31/VC33 4-16 reset/interrupt,/trap vector, locations, microprocessor mode, TMS320C30 and TMS320C31/VC33 7-27 reset/interrupt/trap vector locations microcomputer boot mode, TMS320C31/VC33 7-28 microprocessor mode, TMS320C30 4-15 map microcomputer mode 4-14 microcomputer/boot-loader mode 4-14 microprocessor and microcomputer/boot-loader mode 4-14 microprocessor mode 4-14 restore clock to regular speed instruction (MAXSPEED) 13-145 RETIcond instruction 7-48 return from interrupt conditionally instruction (RETIcond) 7-12, 13-198 from subroutine 7-11 from subroutine conditionally (RETScond) 13-200 Index-14 Index interrupt sources 12-34 serial port (continued) loading 11-11 memory mapped locations for 12-17 operation configurations 12-2912-31 port control register FSR/DR/CLKR 12-2312-24 FSX/DX/CLKX 12-2212-23 receive/transmit timer control register 12-2512-27 counter register 12-27 period register 12-28 registers 12-15, 12-47 timing 12-3112-34 short floating-point format, definition D-7 integer format 5-2 definition D-7 unsigned integer format, definition D-7 SIGI instruction 7-14 timing diagram for 7-15 signal, interlocked instruction (SIGI) sign-extend, definition D-7 13-213 STII instruction 7-14 store floating-point value (STF) 13-214 interlocked (STFI) 13-215 integer instruction (STI) 13-219 interlocked (STII) 13-220 STRB signal 9-3, 9-15 STRB0 control register 10-8 STRB1 control register 10-8 subtract floating-point value instruction (SUBF) 13-228 integer (SUBI) 13-234 conditionally instruction (SUBC) 13-226 with borrow instruction (SUBB) 13-223 reverse floating-point value instruction (SUBRF) 13-240 integer (SUBRI) 13-241 with borrow instruction (SUBRB) 13-239 single-precision floating-point format, definition D-7 integer format 5-2 definition D-7 unsigned integer format, definition D-7 software interrupt definition D-7 instruction (SWI) 13-242 source-address register 12-51 stack 6-306-31 building 6-30 definition D-7 implementation of high-to-low memory implementation of low-to-high memory management 6-296-32 pointer 6-29 standard branch 7-9 example 8-5 status (ST) register 3-5, 13-29 CPU register file 3-5 definition D-7 global interrupt enable (GIE) bit 'C30 interrupt considerations 7-44 'C3x interrupt considerations 7-41 STFI instruction 7-14 synchronization, DMA channels 12-65 synchronize two processors, example 7-19 system management 6-296-32 system-stack pointer (SP) register 3-4, 6-29 T test bit fields instruction (TSTB) 13-245 timer 2-23, 12-212-14 block diagram 12-2 control register 12-13 receive/transmit 12-2512-27 counter 12-2 counter register 12-3, 12-7 receive/transmit 12-27 definition D-7 global-control register 12-3, 12-412-6 I/O port configurations 12-10 initialization/reconfiguration 12-1312-17 interrupts 12-13 operation modes 12-1012-12 output generation examples 12-9 period register 12-3, 12-7 receive/transmit 12-28 pulse generation 12-712-9 registers 12-47 6-30 6-31 Index-15 Index timing figure 12-8 D-7 timer-period register, definition timing external interface expansion bus I/O cycles 9-219-36 primary bus cycles 9-159-20 external memory interface 9-159-38 TMS320C30 architecture, block diagram 2-3 DMA controller 12-49 arbitration 12-63 external memory interface 9-19-38 interrupt vector table 7-26 memory maps 4-4 memory organization, block diagram 2-14 serial ports 12-15 timers 12-2 TMS320C31/VC33 architecture, block diagram 2-4 boot loader 11-2 DMA controller 12-49 arbitration 12-63 external memory interface 9-19-38 interrupt and trap memory maps 11-12 interrupt vector table 7-26 memory maps 4-5, 4-6 memory organization, block diagram 2-15 serial ports 12-15 timers 12-2 TMS320C32 architecture, block diagram 2-5 boot loader 11-14 data memory 2-20 data types and sizes 2-20 DMA controller 12-49 arbitration 12-63 external memory interface 2-19, 10-110-52 interrupt vector table 7-29 memory, external widths 2-20 memory organization, block diagram 2-16 program memory 2-19 serial ports 12-15 short floating-point format 5-4, 5-6 timers 12-2 trap vector locations 7-30 TMS320C3x device differences 2-27 devices 1-2 compared 1-5 Index-16 DSPs, introduction 1-1 functional block diagram 1-3 TMS320C3x (continued) key specifications 1-3 serial port interface examples 12-4112-48 TMS320LC31/VC33, power management mode, LOPOWER 7-517-52 transfer-counter register 12-51 trap 7-117-12 conditionally instruction (TRAPcond) 7-11, 13-243 flow, block diagram 7-47 initialization 7-47 interrupt considerations, 'C30 7-447-46 operation 7-47 vector locations 3-15 traps 4-14 two parallel stores, instruction word format 8-29 U unsigned-integer format 5-3 single-precision 5-3 V variable data-rate timing operation burst mode 12-35 continuous mode 12-40 12-39 W wait state definition D-8 generation 9-11 programmable 9-109-11, 10-1510-16 wait-state generator, definition D-8 X XF0, XF1 signals 2-21 Z zero condition flag 13-29 zero fill, definition D-8 zero wait-state 9-15 Index zero-logic interconnect of devices zero-overhead looping 7-2 7-18 Index-17

Textbooks related to the document above:

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Duquesne - BUS - 281
PROBABILITY RULES Case 1: An aerospace company has submitted bids on two separate federal government defense contracts, A and B. The company feels that it has a 50% chance of winning contract A and a 40% chance of winning contract B. Furthermore, it
Sveriges lantbruksuniversitet - ENSC - 305
Janus TechnologiesA Wireless Gateway Device for the SolarMax Charge ControllerTeam 9Adam Ciapponi Matthew Giassa Dan Hilbich Robert SzolomickiWhy: Project Motivation Team member noticed room for improvement during his coop at Analytic System S
UCSC - CMPE - 240
UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE 240: INTRODUCTION TO LINEAR DYNAMICAL SYSTEMSProblem Set 4 Due on 19-Oct-20061. Modifying measurements to satisfy known conservation laws. A vector y R n contains
UCSC - CMPE - 240
UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE 240: INTRODUCTION TO LINEAR DYNAMICAL SYSTEMSProblem Set 3 Due on 12-Oct-20061. Derivative with vector variable. Let y(x) be a real-valued (scalar) function that ta
UCSC - CMPE - 240
UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE 240: INTRODUCTION TO LINEAR DYNAMICAL SYSTEMSProblem Set 1 Due on 28-Sept-20061. A simple power control algorithm for a wireless network. First some background. We
UCSC - CMPE - 240
UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE 240: INTRODUCTION TO LINEAR DYNAMICAL SYSTEMSProblem Set 5 0 - 0 Due on 02-Nov-20061. Harmonic oscillator. The system x = x is called a harmonic oscillator.(a)
LSU - OLD - 1202
Chemistry 1202, Section 7 Spring 2008 Exam 1 1. What is the kinetic energy of a 450 kg motorcycle traveling at 90 km/hr? a) b) c) d) e) 2. 215 kJ 141 kJ 39 kJ 607 kJ 98 kJConsider the first law of thermodynamics for the following five systems: I II
Duquesne - BUS - 284
Let's make the test part &quot;out of 13&quot; rather than 14, and the HW part &quot;out of 3&quot; rather than 4. Order of SSNs is not alphabetical. SSN . 15 . 204 . 28 . 172 . 176 . 163 . 189 . 162 . 185 . 169 . 171 . 198 . 174 . 160 . 177 . 205 . 22 . 180 . 21 . 12 .
UCSC - CMPS - 164
Quake EngineTHE QUAKE ENGINE IS OLD (relatively) Made in 1996 to power the game of the same name. id's follow up to the immensely popular &quot;DOOM&quot; Made the transition from DOOM's psuedo3D (2.5D?) to levels and models actually rendered in 3D with p
UCSC - CMPS - 080
Syllabus: Introduction to UnixCMPS/LING 080GInstructor: Teaching Asst.: Official Text: Alternative: Optional: Ereserves:Syllabus: Introduction to UnixApr. 4, 2008Allen Van Gelder, 355 Engr. II, 459-4611, avg@cs ucsc edu Office Hours: Mon., W
Sveriges lantbruksuniversitet - GEOG - 213
Dietrich and Perron, 2006
Cal Poly - STAT - 252
Stat 252Topics emphasized on the exam:Sample Mini ExamReinChapter 14 linear regression The linear model Slope and Intercept Find in Minitab output Derive from correlation coefficient, means and SDs Interpret Residual Analysis Inference for th
Cal Poly - STAT - 252
Stat 252Regression II (Chapter 14) Activity 14: House Prices (continued) Use the RealEstate.MTW data file which has the price (in thousands of dollars) and size (in square feet) of houses sold in the Bakersfield, California area for one week in Apri
UCSC - CMPE - 080
Disability Models in the Western WorldPeggy Church, Director Disability Resource CenterFour Western Models Deviant-Pre Industrial Times Medical-Industrial Era (Capitalism) Transitional-Civil Rights Era Equity/Social Justice-21st CenturyProg
UCSC - CMPS - 130
Quiz 1 will cover: NFA NFA -&gt; DFA DFA subsumes regular alphabet language string definiton of dfa definition of nfa
Columbia - EE - 4710
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: hw1.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -t
UCSC - AMS - 274
AMS 274 - Generalized Linear Models Winter 20081. DefinitionsExponential dispersion family of distributionsCentral to the development of generalized linear models (glms) is the exponential dispersion family of distributions as it defines the rand
UCSC - AMS - 274
AMS 274 - Generalized Linear Models Spring 20051. DefinitionsExponential dispersion family of distributionsCentral to the development of generalized linear models (glms) is the exponential dispersion family of distributions as it defines the rand
Columbia - EE - 4710
%!PS-Adobe-2.0 %Creator: dvipsk 5.86 p1.5d Copyright 1996-2001 ASCII Corp.(www-ptex@ascii.co.jp) %based on dvipsk 5.86 Copyright 1999 Radical Eye Software (www.radicaleye.com) %Title: hw3.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %Do
Columbia - EE - 4710
%!PS-Adobe-2.0 %Creator: dvipsk 5.86 p1.5d Copyright 1996-2001 ASCII Corp.(www-ptex@ascii.co.jp) %based on dvipsk 5.86 Copyright 1999 Radical Eye Software (www.radicaleye.com) %Title: hw8.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %Do
MD University College - CMIT - 391
CMIT 391Name:_Partitions, filesystems, mountingOn each of the three Linuxes: paste the (specific) output:Fedora:/proc/partitionsls -l of the device files of those partitions.df's output about them.mount's output about them.Their en
Columbia - EE - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: syllabus.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -osyllabus.ps sy
Columbia - EE - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: survey.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -osurvey.ps survey
Columbia - EE - 6761
EE E6761 - Computer Communication NetworksSurveyProfessor Dan Rubenstein Fall 2000This survey is also available on-line at:http:/www.cs.columbia.edu/~danr/EE6761/intro/6761-survey.(ps|txt)Please put your answers onto this form, and
Columbia - EE - 6761
Electrical Engineering E6761 Computer Communication NetworksProfessor Dan Rubenstein Tues 4:106:40, Mudd 545 Call # 67650 Course URL: http:/www.cs.columbia.edu/~danr/EE67611Today Course Overview / Structure / Handouts Intro Socket Programming
Columbia - EE - 6761
%!PSAdobe3.0 %Title: Microsoft PowerPoint intro %Creator: PSCRIPT.DRV Version 4.0 %CreationDate: 09/05/00 14:41:53 %BoundingBox: 13 13 599 779 %Pages: (atend) %PageOrder: Special %Requirements: %DocumentNeededFonts: (atend) %DocumentSuppl
Columbia - EE - 6761
S t Program ing ocke m What is a socke t? Using socke ts r Type (Protocols) s r Associate functions d rS s tylerWewill look at using socke in C ts r For Java, se C e hapte 2.6-2.8 (optional) r: ts ptually quitesim ilar Note Java socke areconce
Columbia - EE - 6761
%!PSAdobe3.0 %Title: Microsoft PowerPoint sockets %Creator: PSCRIPT.DRV Version 4.0 %CreationDate: 09/05/00 14:40:06 %BoundingBox: 13 13 599 779 %Pages: (atend) %PageOrder: Special %Requirements: %DocumentNeededFonts: (atend) %DocumentSup
Columbia - HW - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: hw0.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -ohw0.ps hw0 %DVIPSPa
Columbia - PA - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: pa1.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -opa1.ps pa1 %DVIPSPa
Columbia - WEEK - 6761
%!PSAdobe3.0 %Title: Microsoft PowerPoint 2dnsaddrhware %Creator: PSCRIPT.DRV Version 4.0 %CreationDate: 09/18/00 14:02:18 %BoundingBox: 13 13 599 779 %Pages: (atend) %PageOrder: Special %Requirements: %DocumentNeededFonts: (atend) %Docum
Columbia - HW - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: soln0.dvi %Pages: 4 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -osoln0.ps soln0 %D
Columbia - HW - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: soln1.dvi %Pages: 5 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -osoln1.ps soln1 %D
Columbia - WEEK - 6761
Columbia - WEEK - 6761
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: penalty.dvi %Pages: 16 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: Times-Roman Times-Bold Times-Italic Helvetica %DocumentPaperSizes: A4 %EndComm
Columbia - WEEK - 6761
A Binary Feedback Scheme for Congestion Avoidance in Computer NetworksK. K. RAMAKRISHNAN and RAJ JAIN Digital Equipment CorporationWe propose a scheme for congestion auoidunce in networks using a connectionless protocol at the network layer. The s
Columbia - WEEK - 6761
%!PS-Adobe-3.0 %BoundingBox: 54 72 558 720 %Creator: Mozilla (NetScape) HTML-&gt;PS %DocumentData: Clean7Bit %Orientation: Portrait %Pages: 17 %PageOrder: Ascend %Title: Whitepaper: A Fast Switched Backplane for a Gigabit Switched Router %EndComments %B
Columbia - WEEK - 6761
%!PS-Adobe-1.0 %Creator: okeeffe.Berkeley.EDU:sklower (Keith &amp;,444E,9587,8630990) %Title: stdin (ditroff) %CreationDate: Wed Jul 24 10:45:29 1991 %EndComments % @(#)psdit.pro 1.6 11/6/90 % lib/psdit.pro - prolog for psdit (ditroff) files % Copyright
Columbia - WEEK - 6761
344IEEWACM TRANSACTIONSON NEJ'WORJONG, VOL. 1, NO. 3, JUNE 1993A Generalized Processor Sharing Approach to Flow Control in Integrated Services Networks: The Single-Node CaseAbhay K. Parekh, Member, IEEE, and Robert G. Gallager, Fellow, IEEEr
Columbia - WEEK - 6761
Scalable High Speed IP Routing LookupsMarcel Waldvogely, George Varghesez, Jon Turnerz, Bernhard PlattneryyComputer zComputerEngineering and Networks Laboratory ETH Z rich, Switzerland u fwaldvogel,plattnerg@tik.ee.ethz.chand Communications Res
Columbia - WEEK - 6761
%!PSAdobe3.0 %Title: Microsoft PowerPoint 5rtrqueue %Creator: PSCRIPT.DRV Version 4.0 %CreationDate: 10/05/00 12:08:42 %BoundingBox: 13 13 599 779 %Pages: (atend) %PageOrder: Special %Requirements: %DocumentNeededFonts: (atend) %DocumentS
Columbia - WEEK - 6761
%!PSAdobe3.0 %Title: Microsoft PowerPoint 5rtrqueue %Creator: PSCRIPT.DRV Version 4.0 %CreationDate: 10/05/00 12:09:07 %BoundingBox: 13 13 599 779 %Pages: (atend) %PageOrder: Special %Requirements: %DocumentNeededFonts: (atend) %DocumentS
Columbia - HW - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: hw2.dvi %Pages: 4 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -ohw2.ps hw2 %DVIPSPa
Columbia - HW - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: soln2.dvi %Pages: 8 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -osoln2.ps soln2 %D
Columbia - WEEK - 6761
%!PSAdobe3.0 %Title: Microsoft PowerPoint 6routing %Creator: PSCRIPT.DRV Version 4.0 %CreationDate: 10/10/00 11:18:49 %BoundingBox: 13 13 599 779 %Pages: (atend) %PageOrder: Special %Requirements: %DocumentNeededFonts: (atend) %DocumentSu
Columbia - WEEK - 6761
%!PSAdobe3.0 %Title: Microsoft PowerPoint 6routing %Creator: PSCRIPT.DRV Version 4.0 %CreationDate: 10/10/00 11:19:39 %BoundingBox: 13 13 599 779 %Pages: (atend) %PageOrder: Special %Requirements: %DocumentNeededFonts: (atend) %DocumentSu
Columbia - WEEK - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: sample.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -osample.ps sample
Columbia - PA - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: pa3.dvi %Pages: 4 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -opa3.ps pa3 %DVIPSPa
Columbia - WEEK - 6761
%!PS-Adobe-2.0 %Creator: dvips 5.518 Copyright 1986, 1993 Radical Eye Software %Title: info94.dvi %CreationDate: Wed Mar 16 13:37:06 1994 %Pages: 9 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSCommandLine: dvips info94 %DVIPSSource
Columbia - WEEK - 6761
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: tcp-friendly.dvi %Pages: 18 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Times-Bold Times-Italic Courier %DocumentPaperSizes: Letter %
Columbia - WEEK - 6761
%!PS-Adobe-2.0 %Creator: dvipsk 5.526a Copyright 1986, 1993 Radical Eye Software %Title: ton.dvi %Pages: 22 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSCommandLine: dvips ton -o %DVIPSParameters: dpi=300, comments removed %DVIPSSo
Columbia - WEEK - 6761
%!PSAdobe3.0 %Title: Microsoft PowerPoint 8realtime %Creator: PSCRIPT.DRV Version 4.0 %CreationDate: 10/31/00 13:23:13 %BoundingBox: 13 13 599 779 %Pages: (atend) %PageOrder: Special %Requirements: %DocumentNeededFonts: (atend) %DocumentS
Columbia - WEEK - 6761
%!PSAdobe3.0 %Title: Microsoft PowerPoint 8realtime %Creator: PSCRIPT.DRV Version 4.0 %CreationDate: 10/31/00 13:23:30 %BoundingBox: 13 13 599 779 %Pages: (atend) %PageOrder: Special %Requirements: %DocumentNeededFonts: (atend) %DocumentS
Columbia - HW - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: hw3.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -ohw3.ps hw3 %DVIPSPa
Columbia - HW - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: soln3.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -tletter -osoln3.ps soln3 %D
Columbia - WEEK - 6761
Network Working Group S. ShenkerRequest for Comments: 2212 XeroxCategory: Standards Track C. Partridge
Columbia - WEEK - 6761
%!PS-Adobe-2.0 %Creator: dvips 5.514 Copyright 1986, 1993 Radical Eye Software %Title: rsvp.dvi %CreationDate: Fri Jul 16 09:52:32 1993 %Pages: 22 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSCommandLine: dvips rsvp.dvi %DVIPSSourc
Columbia - WEEK - 6761
Network Working Group S. BlakeRequest for Comments: 2475 Torrent Networking TechnologiesCategory: Informational D. Black
Columbia - WEEK - 6761
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: infocom.dvi %Pages: 10 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Helvetica Times-Italic Times-Bold Courier %EndComments %DVIPSWebPage: (
Columbia - WEEK - 6761
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: sigcomm98.dvi %Pages: 13 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSCommandLine: dvips sigcomm98.dvi -o %DVIPSParameters: dpi=300, compressed
Columbia - WEEK - 6761
%!PS-Adobe-3.0 %BoundingBox: 54 72 558 720 %Creator: Mozilla (NetScape) HTML-&gt;PS %DocumentData: Clean7Bit %Orientation: Portrait %Pages: 11 %PageOrder: Ascend %Title: rfc2105 - Cisco Systems' Tag Switching Architecture Overview %EndComments %BeginPro