⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lumchr_mgr.c

📁 这是韩国EQUATOR公司提供的DEMO程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/**
*** Copyright (c) 2001 Equator Technologies, Inc.
**/

#include <eti/ds.h>
#include <mm.h>
#include <eti/vlx.h>
#include "swap_table.h"

#include "vlumchr_vlx.h" // this picks up the VLX binary labels so we don't have
                         // have to lookup labels at runtime

//-------------------------------------------

#define SEQ_LEADONES

//
// Macros, constants, and structs
//
#define BLOCKSIZE                   64
#define NUMBYTES_BUFFER_IN          BLOCKSIZE   // type char
#define NUMBYTES_BUFFER_OUT         2*BLOCKSIZE // type short
#define NUMBYTES_VLMEM_DATA_BUFFER  2*BLOCKSIZE  // type short

#define S_PASS       0
#define S_FAIL_SEMA  1
#define S_FAIL_DATA  2
#define S_FAIL_OTHER 3

#define SEMA_TIMEOUT_CYCLES  100000

//
// GLOBAL DECLARATIONS
//
void InitData(unsigned char *);
void InitDsReqPath(
	DS_PATH_INFO 	*dsPathRequest, 
	BOOL 		isSrcIO, 
	BOOL 		isDstIO, 
	SINT32 		bufferSize, 
	SINT32 		srcSize, 
	SINT32 		dstSize
);

extern unsigned char swap_table[256];

//-------------------------------------------
//-------------------------------------------
//
// MAIN
//
//-------------------------------------------
//-------------------------------------------
main()  // main begin
{

    //-------------------------------------------
    // DECLARATIONS
    //-------------------------------------------

    unsigned char    BufferIn[2*BLOCKSIZE];
    unsigned char    BufferTmp[2*BLOCKSIZE];
    unsigned short   BufferOut[2*BLOCKSIZE];
    volatile_noncached unsigned short*  pVlDataBuffer;
    volatile unsigned short*  pVlSemaStop;
    volatile_noncached unsigned short* pVlStatusGb;
    unsigned long  getBitsOffset;

    int i=0; 
    int j=0; 
    int succeeded=S_PASS;

    //
    // DS Declarations
    //

    //
    // BufferIn->DS->GB(IO)
    //
    DS_PATH_INFO    PathW2GBi_InputStream, req_PathW2GBi_InputStream;
    DS_DESCRIPTOR   dsSrc_PathW2GBi_InputStream;
    unsigned short  InputStream_width  = NUMBYTES_BUFFER_IN;  // size of item is 1 byte
    unsigned short  InputStream_count  = 1; // xfer BLOCKSIZE number of data items
    unsigned short  InputStream_stride = 0; 

    //
    // GB(IO)->DS->BufferTmp
    //
    DS_PATH_INFO    PathGBo2W_OutputStream, req_PathGBo2W_OutputStream;
    DS_DESCRIPTOR   dsDst_PathGBo2W_OutputStream;
    unsigned short  OutputStream_width  = NUMBYTES_BUFFER_IN;  // Same as InputStream, size of item is 1 byte
    unsigned short  OutputStream_count  = 1; // xfer BLOCKSIZE number of data items
    unsigned short  OutputStream_stride = 0; 

    //
    // Vlmem->DS->BufferOut
    //
    DS_PATH_INFO    PathV2W_OutputXfer, req_PathV2W_OutputXfer;
    DS_DESCRIPTOR   dsSrc_PathV2W_OutputXfer; // DS descriptor for src
    DS_DESCRIPTOR   dsDst_PathV2W_OutputXfer; // DS descriptor for dst
    unsigned short  OutputXfer_width  = NUMBYTES_BUFFER_OUT;  // size of item is 1 byte
    unsigned short  OutputXfer_count  = 1; // xfer BLOCKSIZE number of data items
    unsigned short  OutputXfer_stride = 0; 

    SCODE status = 15; 

    unsigned short  getBitsData, gbCtrl;
    unsigned short  bufInIndex, bufOutIndex;
    unsigned short* pCM1 = (unsigned short *)VlxLookupCM1(); // Pointer to VLx Mem xxx

    extern VLX_BIN vlumchr;
    PVLX_BIN       vlxBin = &vlumchr;

    //-------------------------------------------
    // CODE
    //-------------------------------------------

    printf("\nBegin main()...\n");

   #ifdef _CONFIG_VLX_C
    kprintf("VLX C configuration...\n");
    pVlDataBuffer = (volatile_noncached unsigned short*)(pCM1 + VLXLAB_vlumchr__lumchr_data);
    pVlSemaStop   = (volatile unsigned short*)(pCM1 + VLXLAB_vlumchr__sema);
    pVlStatusGb   = (volatile_noncached unsigned short*)(pCM1 + VLXLAB_vlumchr__status );
   #else
    kprintf("VLX ASM configuration...\n");
    pVlDataBuffer = (volatile unsigned short*)(pCM1 + VLXLAB_vlumchr_D0_DATA);
    pVlSemaStop   = (volatile unsigned short*)(pCM1 + VLXLAB_vlumchr_D0_SEMA_STOP);
   #endif // _CONFIG_VLX_C

    printf("\nCheck pointers to vlmem...\n");
    printf("pCM1          = 0x%08x\n", pCM1 );
    printf("pVlDataBuffer = 0x%08x\n", pVlDataBuffer );
    printf("pVlSemaStop   = 0x%08x\n", pVlSemaStop );

    //
    // Initialize Buffers
    //
    InitData(BufferIn);
    for (i=0;i<2*BLOCKSIZE;i++) {
	BufferOut[i] = 0;
	BufferTmp[i] = 0;
    }
    //for (i=0;i<4;i++) printf("BufferIn[%d] = 0x%x\n", i, BufferIn[i] );

    //
    // Generate Stream on VLx
    //
    // Start Simple : 
    //   ~ First, send the coeffs to Vlx via GB (and DS)
    //   ~ Have the Vlx store them in Vlmem
    //   ~ Then have the Vlx send them back to core via GB (and DS)
    //   ~ Actually, first just try to get it to the Vlx...
    //
    InitDsReqPath(
        &req_PathW2GBi_InputStream // DS_PATH_INFO 
        ,FALSE // isSrcIO 
        ,TRUE  // isDstIO 
        ,64    // DS bufferSize in bytes
        ,64    // srcChunkSize in bytes
        ,0     // dstChunkSize in bytes
    ); 

    InitDsReqPath(
        &req_PathGBo2W_OutputStream // DS_PATH_INFO 
        ,TRUE   // isSrcIO 
        ,FALSE  // isDstIO 
        ,64     // DS bufferSize in bytes
        ,0      // srcChunkSize in bytes
        ,64     // dstChunkSize in bytes
    ); 

    InitDsReqPath(
        &req_PathV2W_OutputXfer // DS_PATH_INFO 
        ,FALSE  // isSrcIO 
        ,FALSE  // isDstIO 
        ,64     // DS bufferSize in bytes
        ,64     // srcChunkSize in bytes
        ,64     // dstChunkSize in bytes
    ); 

    //--------------------------------------------------------------------
    //
    // DS Descriptors
    //
    //--------------------------------------------------------------------

    //
    // PATH : PathW2GBi_InputStream
    //

    // DS Descriptor : SRC dsSrc_PathW2GBi_InputStream
    DsDescSetGenericFmt1(
         &dsSrc_PathW2GBi_InputStream          // the_descriptor
        ,&dsSrc_PathW2GBi_InputStream          // the_next_descriptor
        ,DS_DESC_HALT | DS_DESC_DATA_ACCESS_CA // options
        ,(char*)BufferIn                       // target addr
        ,InputStream_width                     // width
        ,InputStream_count                     // count
        ,InputStream_stride                    // stride
    );

    //
    // PATH : PathGBo2W_OutputStream
    //

    // DS Descriptor : DST dsDst_PathGBo2W_OutputStream
    DsDescSetGenericFmt1(
         &dsDst_PathGBo2W_OutputStream         // the_descriptor
        ,&dsDst_PathGBo2W_OutputStream         // the_next_descriptor
        ,DS_DESC_DATA_ACCESS_CA                // options
        ,(char*)BufferTmp                      // target addr
        ,OutputStream_width                    // width
        ,OutputStream_count                    // count
        ,OutputStream_stride                   // stride
    );

    //
    // PATH : PathV2W_OutputXfer (Vlmem to Core Memory via DS)
    //

    // DS Descriptor : SRC dsSrc_PathV2W_OutputXfer
    DsDescSetGenericFmt1(
         &dsSrc_PathV2W_OutputXfer             // the_descriptor
        ,&dsSrc_PathV2W_OutputXfer             // the_next_descriptor
        ,DS_DESC_HALT | DS_DESC_DATA_ACCESS_NC // options
        ,(char*)pVlDataBuffer                  // target addr
        ,OutputXfer_width                      // width
        ,OutputXfer_count                      // count
        ,OutputXfer_stride                     // stride
    );
    // DS Descriptor : DST dsDst_PathV2W_OutputXfer
    DsDescSetGenericFmt1(
         &dsDst_PathV2W_OutputXfer             // the_descriptor
        ,&dsDst_PathV2W_OutputXfer             // the_next_descriptor
        ,DS_DESC_DATA_ACCESS_CA                // options
        ,(char*)BufferOut                      // target addr
        ,OutputXfer_width                      // width
        ,OutputXfer_count                      // count
        ,OutputXfer_stride                     // stride
    );

    //
    // Open DS Path(s)
    //

    status = DsOpenPath(&req_PathW2GBi_InputStream, &PathW2GBi_InputStream);
    if ( status != S_OK ) printf("ERROR : S_ERROR returned for status of DsOpenPath()...\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -