Skip to content Skip to navigation

OpenStax_CNX

You are here: Home » Content » Assembly Implementation of FIR Filters on TI TMS320C62x

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

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

What is in a lens?

Lens makers point to 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 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.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • Rice Digital Scholarship

    This module is included in aLens by: Digital Scholarship at Rice UniversityAs a part of collection: "Finite Impulse Response"

    Click the "Rice Digital Scholarship" link to see all content affiliated with them.

Recently Viewed

This feature requires Javascript to be enabled.
 

Assembly Implementation of FIR Filters on TI TMS320C62x

Module by: Hyeokho Choi. E-mail the author

Summary: This module is the exercise to implement FIR filtering in TI TMS320C62x assembly.

Implementation of FIR filters in assembly

Storing filter coefficients

Rather than defining the filter coefficients in your main assembly program file, it is usually more convenient to store them in a separate file. By defining the coefficients in a separate assembly (for example, coeff.asm) file, you can load the coefficients at a desired memory location at the run time, although it is not essential for the current simple FIR filtering lab.

The assembly file containing the filter coefficients can be written as follows:


	    
	    .def    _coef
	    .sect   "coeffs"

	    _coef: 
	    .short  0ff9bh
	    .short  0ff06h
	    .short  0feffh
	    .short  0ff93h
	    .short  070h
	    .short  0117h
	    .short  0120h
	    .short  07bh
	    
	  

Each coefficient must be converted to the Q-15 format and defined by each .short assembly directive. For your convenience, I wrote a short MATLAB script save_coef.m that converts the filter coefficients stored as a MATLAB vector to Q-15 format and then writes to a file exactly in the above format. (You can download save_coef.m from the course web page.) The section coeffs should be defined in the link command file so that the coefficients are to be loaded at the correct memory location.

You can simply include the coeff.asm using the .include directive at the beginning of your main assembly program.

Exercise 1

Make coefficient files for each of the filters you designed in the previous exercise.

Solution

Assembly implementation

Based on the codec input and output program you have written in the previous labs, you can now implement a real-time FIR filtering algorithm.

Exercise 2

Write an assembly routine that implements the FIR filter by modifying the inner product program you have written in Lab 3. Combine the FIR filtering routine with the interrupt-based codec input-output code you wrote in the previous lab. Your code should perform FIR filtering on the input samples and output the filtered result to the codec. Both the left and right channels should be filtered. To write the designed MATLAB vector of filter coefficients as a .asm file, use the provided save_coef.m matlab function. First implement the length-40 lowpass filter with 10kHz cutoff designed using the remez.m.

Solution

Implementation using circular addressing modes

As you might already have noticed, a lot of cycles are wasted in FIR filtering while maintaining the buffer to see if you reached the end of buffer and update the address pointers properly. To avoid this unnecessary buffer maintenance, the TI DSP processors have a special addressing mode, called circular addressing. Using circular addressing, you can define a block of memory as a circular buffer. As you increase (or decrease) the pointer register pointing to the buffer index beyond the buffer limit, it automatically points to the other end of the buffer, implementing a circle of data array. Instead of moving the data samples themselves, you can move the pointer which specifies the beginning of the buffer, as each new sample is processed. You don't need to check if you reached the end of buffer because the address pointer returns to the beginning of the buffer immediately after reaching the end.

Of the 32 registers on the C6x, 8 of them can perform circular addressing. These registers are A4 through A7 and B4 through B7. Since circular addressing is not default, each of these registers must be specified as circular using the AMR (Address Mode Register) register. The lower 16 bits of the AMR are used to select the mode for each of the 8 registers. The upper 10 bits (6 are reserved) are used to set the length of the circular buffer. Buffer size is determined by 2N+1 2 N 1 bytes, where NN is the value appearing in the block size fields of the AMR register. The top address of the buffer needs to be aligned with proper physical memory block address using the .align assembler directive.

Exercise 3

First read TMS320C62x/C67x CPU and Instruction Set Reference Guide to learn how to define circular buffers. Modify your FIR filtering assembly code to use circular addressing modes. After optimizing your code as much as you can, count the number of required clock cycles for each FIR filter output computation. Compare the number with the code written without circular addressing.

Solution

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

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

| A lens I own (?)

Definition of a lens

Lenses

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

What is in a lens?

Lens makers point to 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 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