How to Create DSP Algorithm Package with RidgeRun SDK

From RidgeRun Developer Connection

(Difference between revisions)
Jump to:navigation, search
m (package.xs)
(8 intermediate revisions not shown)
Line 1: Line 1:
=Introduction=
=Introduction=
This document will be an easy way to create a new DSP algorithm based on TMS320 DSP processor.  
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.  
+
It will target these algorithms and assists the reader for making his 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 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.  
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.  
Line 31: Line 31:
=Making a basic package  xDAIS & xDM compliant =
=Making a basic package  xDAIS & xDM compliant =
-
Those steps shown below has to be followed to complete a memcpy DSP algorithm.
+
Those steps shown above 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.
+
If you desire to add new features , new functions, and others refer to previous section links for more details.
==Adding the wizard support to DVSDK makefile==
==Adding the wizard support to DVSDK makefile==
Line 118: Line 118:
= Create the CE-Consumable Codec Package  =
= 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.  
+
After creating the xDM algorithm and Codec Package Structure, 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 '''MYCODEX.xdc''' declares the xDM class we are trying to implement and the algorithm function table.  
Line 138: Line 138:
=== MODULE.xdc  ===
=== MODULE.xdc  ===
-
Modify the file MODULE.xdc and add the code highlighted  as shown below:  
+
Modify the file MODULE.xdc and add the code  shown below:  
<pre>metaonly module MYCODEX
<pre>metaonly module MYCODEX
inherits ti.sdo.ce.universal.IUNIVERSAL  
inherits ti.sdo.ce.universal.IUNIVERSAL  
Line 144: Line 144:
{
{
   readonly config ti.sdo.codecs.mycodec.MYCODEC.Module alg = ti.sdo.codecs.mycodec.MYCODEC;
   readonly config ti.sdo.codecs.mycodec.MYCODEC.Module alg = ti.sdo.codecs.mycodec.MYCODEC;
-
   '''override readonly config String ialgFxns = "MYCODEC_TI_MYCODEC";'''
+
   override readonly config String ialgFxns = "MYCODEC_TI_MYCODEC";
}  
}  
-
</pre>  
+
</pre>
 +
 
=== package.xdc  ===
=== package.xdc  ===
Line 266: Line 267:
{
{
-
template = "ti/sdo/codecs/audio_effect/link.xdt";
+
template = "ti/sdo/codecs/mycodec/link.xdt";
}
}
Line 275: Line 276:
</pre>  
</pre>  
-
<br>  
+
<br>
=== link.xdt  ===
=== link.xdt  ===
Line 285: Line 286:
{
{
 +
  % if (this.MYCODEC.dataSection)  {
 +
    .const:.string &gt; `this.MYCODEC.dataSection`
-
% if (this.MYCODEC.dataSection)
+
  %}
-
{ .const:.string &gt; `this.AUDIO_EFFECT.dataSection`
+
  % if (this.MYCODEC.codeSection) {
-
%}
+
  .text:_algorithm &gt; `this.MYCODEC.codeSection`
-
% if (this.MYCODEC.codeSection)
+
  .text:algProcess:_MYCODEC_VENDOR_process &gt; `this.MYCODEC.codeSection`
-
{
+
  .text:algInit:_MYCODEC_VENDOR_initObj &gt; `this.MYCODEC.codeSection`
-
.text:_algorithm &gt; `this.MYCODEC.codeSection`
+
  .text:algAlloc:_MYCODEC_VENDOR_alloc &gt; `this.AMYCODEC.codeSection`
-
.text:algProcess:_MYCODEC_VENDOR_process &gt; `this.MYCODEC.codeSection`
+
  .text:algFree:_MYCODEC_VENDOR_free &gt; `this.MYCODEC.codeSection`
-
.text:algInit:_MYCODEC_VENDOR_initObj &gt; `this.MYCODEC.codeSection`
+
  .text:algControl:_MYCODEC_VENDOR_control &gt; `this.MYCODEC.codeSection`
-
.text:algAlloc:_MYCODEC_VENDOR_alloc &gt; `this.AMYCODEC.codeSection`
+
%}
-
 
+
-
.text:algFree:_MYCODEC_VENDOR_free &gt; `this.MYCODEC.codeSection`
+
-
 
+
-
.text:algControl:_MYCODEC_VENDOR_control &gt; `this.MYCODEC.codeSection`
+
-
 
+
-
%}
+
}
}
Line 314: Line 311:
<br> Usually the codec should be integrated with the codec server that comes with the dvsdk out-of-the-box.  
<br> Usually the codec should be integrated with the codec server that comes with the dvsdk out-of-the-box.  
-
<br>  
+
<br>
= Codec server integration  =
= Codec server integration  =
Line 365: Line 362:
Add you codec to the validate function at file  
Add you codec to the validate function at file  
-
<pre>$(DEVDIR)/proprietary/&lt;DVSDK&gt;/&lt;CODEC_SERVER&gt;/packages/ti/sdo/server/cs/package.xs
+
<pre>
 +
$(DEVDIR)/proprietary/&lt;DVSDK&gt;/&lt;CODEC_SERVER&gt;/packages/ti/sdo/server/cs/package.xs
</pre>  
</pre>  
-
<br>
 
-
 
<br> Validate your new codec with the code shown below:  
<br> Validate your new codec with the code shown below:  
 +
<pre>
 +
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 20:25, 28 June 2010

Contents

Introduction

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 for making his 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

References

For details, see the following documents:

Requirements for the GencodecPkg Wizard

Making a basic package xDAIS & xDM compliant

Those steps shown above has to be followed to complete a memcpy DSP algorithm. If you desire to add new features , new functions, 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:

gencodecpkg: 
    $(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

CodecEngineGenCodecPkgWizard-moc01.png

  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

CodecEngineGenCodecPkgWizard-moc02.png

  1. Fill the spaces according with the name of your new package.
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, 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.

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

MODULE.xdc

Modify the file MODULE.xdc and add the code  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";
} 

package.xdc

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

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

Pkg.attrs.exportAll = true; 


Root Codec Directory

MYCODEC.xdc

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";

}


package.bld

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.xs

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/mycodec/link.xdt";

}

return (template);

}


link.xdt

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.


SECTIONS

{
  % if (this.MYCODEC.dataSection)  {
    .const:.string > `this.MYCODEC.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

 $(DEVDIR)/proprietary/<DVSDK>/<CODEC_SERVER>/packages/ti/sdo/server/cs/package.xs


Validate your new codec with the code shown below:

function validate() {

...

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

 Compile the codec server

Navigation
Toolbox