Difference between revisions of "How to Create DSP Algorithm Package with RidgeRun SDK"

From RidgeRun Developer Connection
Jump to: navigation, search
Line 367: Line 367:
<br> Validate your new codec with the code shown below:  
<br> Validate your new codec with the code shown below:  
function validate() {
<br> &lt;prefunction validate() {
validate_one_codec( "ti.sdo.codecs.mycodec", "MYCODEC" ); } &lt;/pre&gt;
validate_one_codec( "ti.sdo.codecs.mycodec", "MYCODEC" ); } </pre>
'''&nbsp;Compile the codec server'''
'''&nbsp;Compile the codec server'''

Revision as of 06:31, 7 June 2010


This document will be an easy way to create a new DSP algorithm based on TMS320 DSP processor. It will target these algorithms and assists the reader with making the algorithms compliant with the TMS320 DSP algorithm standard which is part of TI's eXpressDSP technology initiative. The document proposes a simple approach to running xDAIS or iUniversal algorithms with a Codec Engine (CE) application based on TI's technology and RidgeRun SDK. The wizard is responsible for creating an xDAIS algorithm (iUniversal), and providing the necessary packaging to enable these algorithms to be consumed and configured by Codec Engine.

We assume readers have a basic understanding of the elements in a Codec Engine application, including VISA APIs, xDM, servers, and codecs


For details, see the following documents:

  • TMS320 DSP Algorithm Standard Rules and Guidelines SPRU352E
  • TMS320 DSP Algorithm Standard API Reference SPRU360E
  • TMS320 DSP Algorithm Standard Developer’s Guide SPRU424C
  • Codec Engine Algorithm Creator User’s Guide SPRUED6C
  • Based on the Codec Engine GenCodecPkg Wizard GenCodecPkg
  • The most important care-abouts in a typical Codec Engine configuration Codec Engine configuration en breve

Requirements for the GencodecPkg Wizard

  • Engine 2.25 or later
    • CE 2.25.02 improves the GUI interface
  • XDAIS 6.25 or later
  • XDAIS 6.25.02 improves the code templates
  • XDCtools 3.16 or later

Making a basic package xDAIS & xDM compliant

Those steps shown below has to be followed to complete a memcpy DSP algorithm. If you desire to add new features , new funtions, and others refer to previous section links for more details.

Adding the wizard support to DVSDK makefile

The GenCodecPkg wizard generates the files and packaging required for integrating an algorithm into Codec Engine. Assuming your using a RR SDK you have a complete integration with a TI DVSDK release, then you likely have already defined paths to all your tools in the Rules.make.

Those generated Codec Packages can be integrated into a Server and the document will explain the way to append the new codec into TI's Codec Server.

Checking your DVSKD Makefile Support

$ cd $(DEVDIR)/propietary/dvsdk*
$ gedit Makefile

On the Makefile check if the gencodecpkg macro is activated if it's already added, please ignore next step.

Inside the Makefile from the DVSDK

$ cd $(DEVDIR)/propietary/dvsdk*
$ gedit Makefile

Append the following rule:

    $(XDC)/xs --xdcpath="$(CE_INSTALL_DIR)/packages; \
    $(XDAIS_INSTALL_DIR)/packages" ti.sdo.ce.wizards.gencodecpkg

Make sure you use a tab instead spaces.

Running the wizard

From your DVSDK directory you can invoke gencodecpkg with the following command:

 $ cd $(DEVDIR)/proprietary/dvsdk_* 
 $ make gencodecpkg

At the first Screen


  1. Choose the 3rd option, I want to create an algorithm from scratch
  2. Point to the xDAIS directory
  3. Point to the root of the compiler installation: CGTOOLS
  4. Click on next

At the Second Screen


  1. Fill the spaces according with the name of your new package.
  • Keep the capital letters on the names. as it's shown on the table placed below
Module eg: MYCODEC
Vendor eg: RIDGERUN
Interface eg: IMYCODEC
Package_name eg: ti.sdo.codecs.mycodec
BaseInterface eg: IUNIVERSAL.
Target eg: ti.targets.C64P
OutputDir eg: $(DVSDK)/csomapl138/packages
  1. Click Finish to generate the starter files.

Create the CE-Consumable Codec Package

After creating the xDM algorithm and Codec Package Structure, we then made an extra package called ti.sdo.codecs.codecs.*.ce (where * is the codec eg: mycodec) that declares static properties relevant to the Codec Engine.

  • The file MYCODEX.xdc declares the xDM class we are trying to implement and the algorithm function table.
  • The file MYCODEC.xs provides the getStackSize() function, which is used when building an application for the Codec Engine to declare the combined amount of stack usage for the algorithm.
  • Inside the ti.sdo.codecs.codecs.mycodec.ce directory create the files package.xdc and package.bld

Creating ce directory

Go to the codec path and create the ce directory

$ cd (...) cs1omap/packages/ti/sdo/codecs/mycodec
$ mkdir ce

Move the MODULE.xdc and the MODULE.xs to "ce" directory

$ mv MYCODEC.xdc ce/ 
$ mv MYCODEC.xs ce/

Modifing the files


Modify the file MODULE.xdc and add the code highlighted  as shown below:

metaonly module MYCODEX
inherits ti.sdo.ce.universal.IUNIVERSAL 

   readonly config ti.sdo.codecs.mycodec.MYCODEC.Module alg = ti.sdo.codecs.mycodec.MYCODEC;
   '''override readonly config String ialgFxns = "MYCODEC_TI_MYCODEC";'''


It declares the name of the package and the module it contains.

Furthermore, it uses the “requires” statement to specify its dependency on the algorithm and adapter package.

Hence when the server package is configured to use this CE-consumable package, it picks up the correct libraries from the packages it requires.

The package.xdc file is the package definition file, which defines your Codec Server’s name and its dependencies.

The package name must reflect the directory structure under the ti codecs.

requires ti.sdo.ce.universal; 
requires ti.sdo.codecs.mycodec;

/* ======== package.xdc ======== 

* Provides MYCODEC interface adapter for 
* ti.sdo.codecs.mycodec codec.

package ti.sdo.codecs.mycodec.ce [1, 0, 0] 
      module MYCODEC; 


/* ======== package.bld ======== */

Pkg.attrs.exportAll = true; 

Root Codec Directory


At the root directory of the codec , create a file named MYCODEC.xdc

/* ======== MYCODEC========*/

metaonly module MYCODEC {

/* ======== watermark ======== */

config Bool watermark = false;

/* ======== Code Section ======== */

config String codeSection="DDR2";

/* ======== Uninitialized Data Section ======== */

config String udataSection="DDR2";

/* ======== Initialized Data Section ======== */

config String dataSection="DDR2";



File located at the root codec directory where the sources of your algorithm has to be added. Describes the steps required to build and release the package.

Contains JavaScript instructions for building any libraries, object files, or executables that are part of the package, and specifications of what goes into a release package.

Additionally, any source and header files needed to build the artifacts and any pre-built files to be included in a release package must be included in the package directory.

The source or header files used in the package build process are not included in a release package, unless you explicitly add them using

if you desire to add new sources modify the code eg : 

var SRCS = ["mycodec.c", "algorithm.c"];

Where mycodec. is the IUNIVERSAL interface and the algorihtm.c is the where you DSP algo will be located.

For example, by adding the following line to package.bld, all files in the src and include directories and the file readme.txt are released:

Pkg.otherFiles = [ 'src', /* the whole src subdirectory */

                  'include', /* the whole include subdirectory */

                  'readme.txt', ];

In order to include a library, legacy.lib, which was built outside the package using a legacy build system, you can copy the library into the package directory and include it in Pkg.otherFiles in the package.bld file.

Pkg.otherFiles = [ 'legacy.lib', 'readme.txt', ]; 


Package properties that can vary across platforms and configurations. The getLibs() function returns the library name that the package exports. The XDC build system calls this special function—whenever an XDC application "uses" a package—to link against the package library matching the program's configuration.

The exported library does not have to be built using the housing package's build script. It can be built with any legacy build system and placed into the package. The string "64P" is a code for DSP target binaries. (ARM target binaries have a different code, "MVArm9".)

If you are building an ARM application and this codec package gets consumed, the condition above is false and the getLibs() return an empty library name—which is what you want when you don't provide any libraries for the ARM.

In the file package.xs at the root directory of the codec append the code shown below (This code is used by the linker):

/* * ======== getSects ======== */

function getSects()

{ var template = null;

if (Program.build.target.isa == "64P")


template = "ti/sdo/codecs/audio_effect/link.xdt";


return (template);



Create a file named link.xdt at the root directory of codec and modify this file, Change MYCODEC by your codec name Change VENDOR by your vendor name.



% if (this.MYCODEC.dataSection)

{ .const:.string > `this.AUDIO_EFFECT.dataSection`


% if (this.MYCODEC.codeSection)


.text:_algorithm > `this.MYCODEC.codeSection`

.text:algProcess:_MYCODEC_VENDOR_process > `this.MYCODEC.codeSection`

.text:algInit:_MYCODEC_VENDOR_initObj > `this.MYCODEC.codeSection`

.text:algAlloc:_MYCODEC_VENDOR_alloc > `this.AMYCODEC.codeSection`

.text:algFree:_MYCODEC_VENDOR_free > `this.MYCODEC.codeSection`

.text:algControl:_MYCODEC_VENDOR_control > `this.MYCODEC.codeSection`



Usually the codec should be integrated with the codec server that comes with the dvsdk out-of-the-box.

Codec server integration

There are two options here, one of them is to add your codec to the current codec server provided by the dvsdk or you can create a new codec server.

Adding the codec to the current codec server provided by the dvsdk:

Add the codec

Modify the file at

For adding your codec as follows:

var MYCODEC = xdc.useModule('ti.sdo.codecs.mycodec.ce.MYCODEC');

// Module Config

MYCODEC.alg.watermark = false;

MYCODEC.alg.codeSection = "DDR2";

MYCODEC.alg.dataSection = "DDR2";

MYCODEC.alg.udataSection = "DDR2";

 Array of algorithms

Then you should add your algorithm to the array of algorithms:

Server.algs = [


{name: "mycodec", mod: MYCODEC, threadAttrs:

{ stackMemId: 0, priority: Server.MINPRI + 1},

groupId : 2, }, ];

 Validate the codec

Add you codec to the validate function at file


Validate your new codec with the code shown below:

function validate() {


validate_one_codec( "ti.sdo.codecs.mycodec", "MYCODEC" ); } 

 Compile the codec server