【DM642】ICELL Interface—Cells as Algorithm Containers

ICELL Interface—Cells as Algorithm Containers:

DSP的算法标准(XDAIS)为算法提供了一个标准的接口.这样我们就可以使用第三方的算法.For technical detailson the TMS320 DSP Algorithm Standard, see TMS320 DSP AlgorithmStandard Rules and Guidelines (SPRU352) and the TMS320 DSPAlgorithm Standard API Reference (SPRU360).

RF5的应用程序使用了相对多的算法和通道,为了简化算法的融合,RF5使用"cell".一个"cell"是一个XDAIS算法的封装.一个RF5通道可以包含多个细胞,因此多个算法.在通道结构的核心是细胞的概念.算法的运行时函数可以不同.一个细胞是一个标准的算法封装.对每一个算法实例,就会有一个细胞对象.通道不直接和算法接口,而是同细胞接口,结果调用算法接口.RF5提供细胞接口ICELL.他的结构被接口定义,而没有ICELL模块函数调用.

ICELL接口类似于IALG接口规范.也就是,这个接口的结构在头文件中定义.必须有一个结构来使用.对ICELL和IALG来说,最主要的区别是算法提供者被要求使用IALG接口.而,算法设计者一般为每个算法使用ICELL接口来为某个特别地应用定制.

应用必须创建如下的结构为每一个算法:

  • ICELL_Fxns类型的结构和它的函数.这个结构为算法的执行函数提供了一个一致的接口,它的名字
    和参数不是标准的.这个结构在RF_DIRincludeicell.h中定义:
    typedef struct ICELL_Fxns {
        Bool(*cellClose )(ICELL_Handle handle);
        Int(*cellControl)(ICELL_Handle handle, IALG_Cmd cmd, IALG_Status*status);
        Bool(*cellExecute)(ICELL_Handle handle, Arg arg);
        Bool(*cellOpen )(ICELL_Handle handle);
    } ICELL_Fxns;

    例如:RF_DIRapps f5cellsvolcellVol.h和cellVol.c文件使用了ICELL_Fxns结构和它的函数为VOL算法.
    Int VOL_cellControl( ICELL_Handle handle, IVOL_Cmd cmd, IVOL_Status*status);
    Bool VOL_cellExecute( ICELL_Handle handle, Arg arg );

    ICELL_Fxns VOL_CELLFXNS = {
        NULL,
       VOL_cellControl,
       VOL_cellExecute,
        NULL
    };
    cellClose,cellControl,cellOpen并不一定需要.cellExecute是必须的.cellExecute在线程的主循环中被调用了很多次.cellControl可以被偶尔调用来调整控制信息.cellClose,cellOpen是在调用CHAN_open()和CHAN_close()时被使用的.即:在细胞被创建和销毁的时候创建的.
    这些函数一般使用算法提供的IALG执行和AlGRF模块来激活或不激活算法.
    Bool VOL_cellExecute( ICELL_Handle handle, Arg arg )
    {
        IVOL_Fxns*volFxns = (IVOL_Fxns *)handle->algFxns;
        IVOL_HandlevolHandle = (IVOL_Handle)handle->algHandle;
        // activateinstance object
       ALGRF_activate( handle->algHandle );
       volFxns->amplify( volHandle,
        (XDAS_Int16*)handle->inputIcc[0]->buffer,
        (XDAS_Int16*)handle->outputIcc[0]->buffer );
        //deactivate instance object
       ALGRF_deactivate( handle->algHandle );
        return (TRUE );
    }

  • ICELL_Obj对象:
    这个结构体定义了一个细胞的特征.这个结构体在RF_DIRincludeicell.h中定义.我们也可以修改这个结构体.
    typedef struct ICELL_Obj {
        Intsize;                
        Stringname;             
        ICELL_Fxns*cellFxns;    
        PtrcellEnv;             
        IALG_Fxns*algFxns;      
        IALG_Params*algParams;  
        IALG_HandlealgHandle;   
        UnsscrBucketIndex;      
        ICC_Handle*inputIcc;    
        UnsinputIccCnt;         
        ICC_Handle*outputIcc;   
        UnsoutputIccCnt;        
    } ICELL_Obj;

    这个结构体帮助创建ICELL,IALG,ICC和SSCR模块之间的关系.ICELL_Obj结构体中的一些需要我们注意:
    --size和name:大下是:sizeof(ICELL_Obj).name是:算法使用的字符串.
    --cellFxns:这个元素指向了前面描述的ICELL_Fxns.
    --cellEnv:这个是用户自己定义的.每一个细胞都有自己的cellEnv指针,这个可以被用来保持细胞特性指针.每一个细胞可以有不同的结构定义.例如:如果一个算法有相互包含的函数,如,apply1和apply2,cellExecute结构可以决定哪一个函数来执行,这个是基于cellEnv结构体中的一个域,而且这个域是调用函数的线程可以写的.另外一个对cellEnv结构体的使用是存储DMA句柄(被细胞使用).在cellOpen函数中,DMA通道可以被分配并存储在cellEnv结构体中.然后,cellExecute函数可以使用这个DMA句柄.
    --  algFxns, algParams, and algHandle. Theseelements have types defined by the IALG interface that is part ofthe XDAIS specification.
    --  scrBucketIndex. Generally, all cells inchannels executed by tasks at the same priority level should havethe same scrBucketIndex. This element is used by the SSCR module,which is described in Section 7.5, SSCR Module—Shared ScratchMemory, page 54.
    --  inputIcc andoutputIcc:这些元素调用CHAN_regCell()是填充的.这个信息被ICC模块使用.whichis  described in Section 7.4,ICC Module—Inter-CellCommunication, page 52.

  • For example, theRF_DIRapps f5 hreadsprocess hrProcess.c file creates an arrayof elements of type ICELL_Obj for all the cells in the application,which you should modify to integrate your algorithms. The followingportion shows the declaration of the first cell.

  • 【DM642】ICELL <wbr>Interface—Cells <wbr>as <wbr>Algorithm <wbr>Containers

原文地址:https://www.cnblogs.com/eaglediao/p/7136519.html