Sep 2

EDK works with Sysgen 不指定

RickySu , 13:08 , 技术经验 , 评论(0) , 引用(0) , 阅读(248) , Via 本站原创 | |
[2008.08.04]
同时使用EDK和Sysgen,有两种流程:
1、在Sysgen中做hw co-sim;
2、用Sysgen生成pcore然后手动添加到EDK工程中。

参考文档:
- Sysgen User Guide --> Hardware/Software Co-Design --> Design with Embedded Processors and Microcontrollers
- API Documents (在生成PCORE的src目录中)

数据交互方法:
- From/To Registers
- From/To FIFO
- Shared Memory

使用Shared Memory时,记得TestBench中的Shared Memory要设置成 "owned and initialized elsewhere",否则等于两处地方都放置了同样名字的Shared Memory,会产生冲突。

API使用方法
参考API文档,下面有例子。基本流程是:

引用
    xc_iface_t *iface;  //初始化interface

    xc_from_reg_t *fromreg_gray;  //初始化register
    xc_to_reg_t *toreg_red, *toreg_green, *toreg_blue; //初始化register
    xc_shram_t *shram; //初始化shared memory
    xc_to_fifo_t *tofifo; //初始化fifo

    // initialize the software driver
    xc_create(&iface, &RGB2GRAY_PLBW_ConfigTable[0]);

    // obtain the memory locations
    xc_get_shmem(iface, "result",  (void **) &fromreg_gray);  //Register 中间引号中的字符串是Sysgen中起的名字
    xc_get_shmem(iface, "red",   (void **) &toreg_red);
    xc_get_shmem(iface, "green", (void **) &toreg_green);
    xc_get_shmem(iface, "blue",  (void **) &toreg_blue);
    xc_get_shmem(iface, "cap_ram0", (void **) &shram);  //Shared Memory
    xc_get_shmem(iface, "fifo", (void **) &tofifo);  //Shared Memory

    //写Shared Memory
      for (i=0;i<10;i++) {
    xc_write(iface, xc_get_addr(shram->addr, i), (const unsigned) i+60);
  }

    //写Register
    xc_write(iface, toreg_red->din, 2);

    //读 Register
    xc_read(iface, fromreg_result->dout, &result);


[2008.09.02]
以上的方法是使用了一个ConfigurationTable。因为Overhead比较大,所以Performance比较低。
另一种直接的读写方法是使用指针。
每块Share Memory的起始地址都可以在xparameters.h中找到。知道了起始地址,使用指针可以很方便得对内容进行读写。
引用
In the following code snippet, users can read data from a "From Register" shared memory named "FROMREG1" and write it to a "To Register" shared memory named "TOREG1":
volatile unsigned value;
unsigned *fromreg_plb_data;
unsigned *toreg_plb_data;

// get the absolute shared memory addresses from "xparameters.h"
fromreg_plb_data = XPAR_SG_PLBIFACE_0_MEMMAP_FROMREG1;
toreg_plb_data = XPAR_SG_PLBIFACE_0_MEMMAP_TOREG1;

// read data from shared memory "FROMREG1"
value = *fromreg_plb_data;
// write data to shared memory "TOREG1"
*toreg_plb_data = value;
Tags: ,
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]