Skip to content Skip to navigation

Connexions

You are here: Home » Content » Implementation of Q-15 arithmetic on TI TMS320C62x

Navigation

Recently Viewed

This feature requires Javascript to be enabled.

Implementation of Q-15 arithmetic on TI TMS320C62x

Module by: Hyeokho Choi. E-mail the author

User rating (How does the rating system work?)
Ratings

Ratings allow you to judge the quality of modules. If other users have ranked the module then its average rating is displayed below. Ratings are calculated on a scale from one star (Poor) to five stars (Excellent).

How to rate a module

Hover over the star that corresponds to the rating you wish to assign. Click on the star to add your rating. Your rating should be based on the quality of the content. You must have an account and be logged in to rate content.

:
(0 ratings)

Summary: This explains how to implenet Q-15 multiplication on TMS320C62x CPU.

Implementation of Q-15 multiplication on TMS320C62x

Assembly language implementation

When A0 and A1 contain two 16-bit numbers in the Q-15 format, we can perform the multiplications using MPY followed by a right shift.


	    
	    MPY	.M1	A0,A1,A2
	    NOP
	    SHR	.S1	A2,15,A2	;lower 16 bit contains result
	    ;in Q-15 format
	    
	  

Rather than throwing away the 15 LSBs of the multiplication result by shifting, you can round up the result by adding 0x4000 before shifting.


	    
	    MPY	.M1	A0,A1,A2
	    NOP
	    ADDK	.S1	4000h,A6
	    SHR	.S1	A2,15,A2	;lower 16 bit contains result
	    ;in Q-15 format
	    
	  

C language implementation

Let's suppose we have two 16-bit numbers in Q-15 format, stored in variable x and y as follows:


	    
	    short x = 0x0011;     /*   0.000518799 in decimal */
	    short y = 0xfe12;     /*  -0.015075684 in decimal */
	    short z;              /* variable to store x*y */ 
	    
	  

The product of x and y can be computed and stored in Q-15 format as follows:


	    
	    z = (x * y) >> 15;
	    
	  

The result of x*y is a 32-bit word with 2 sign bits. Right shifting it by 15 bits ignores the last 15 bits, and storing the shifted result in z that is a short variable (16 bit) removes the extended sign bit by taking only lower 16 bits.

Content actions

Give Feedback:

E-mail the module author | Rate module ( How does the rating system work?)

Rating system

Ratings

Ratings allow you to judge the quality of modules. If other users have ranked the module then its average rating is displayed below. Ratings are calculated on a scale from one star (Poor) to five stars (Excellent).

How to rate a module

Hover over the star that corresponds to the rating you wish to assign. Click on the star to add your rating. Your rating should be based on the quality of the content. You must have an account and be logged in to rate content.

(0 ratings)

Download:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.

| A lens (?)

Definition of a lens

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks