手把手教你在FPGA实例上运行“Hello World”
:
{
"FpgaImageId": "afi-046ead8eb3a0e3112",
"FpgaImageGlobalId": "agfi-06fdb0f3cea076195"
}
其中”FpgaImageId”是本区域唯一的image ID,”FpgaImageGlobalId”是全球唯一的image ID,后面我们加载FPGA image时要使用过的是全球唯一的”FpgaImageGlobalId”,以agfi开头。
开始构建FPGA image后需要等待一段时间,你可以查看你指定的保存日志的S3桶以了解进展。
如果你在日志目录里看到有个新目录产生,里面有个叫State的文件中出现{State=available} 字样就表明构建成功了。接着就可以加载你的FPGA image了。
在加载新的FPGA image之前记得先清除现有image:
sudo fpga-clear-local-image -S 0
接着通过以下命令加载FPGA image:
sudo fpga-load-local-image -S 0 -I agfi-06fdb0f3cea076195
如之前描述的,这里-S参数用于指定image slot,-I参数用于指定FPGA image的镜像ID,注意是全球唯一,以agfi开头的镜像ID。
为了检查FPGA image是否加载成功,可以使用fpga-describe-local-image命令,执行输出的样例如下:
$ sudo fpga-describe-local-image -S 0 -R -H
Type FpgaImageSlot FpgaImageId StatusName StatusCode ErrorName ErrorCode ShVersion
AFI 0 agfi-06fdb0f3cea076195 loaded 0 ok 0 0x04151701
Type FpgaImageSlot VendorId DeviceId DBDF
AFIDEVICE 0 0x1d0f 0xf000 0000:00:1d.0
其中可以看到镜像ID为agfi-06fdb0f3cea076195的状态是loaded,就是加载成功了。
最后我们就需要运行宿主机上的软件端来测试了,进入cd $CL_DIR/software/runtime/目录,这里有个写好的c的代码用于测试,运行以下命令编译软件测试端:
$ cd $CL_DIR/software/runtime/
$ make all
编译成功后通过./test_hello_world命令执行,以下是执行结果:
$ sudo ./test_hello_world
AFI PCI Vendor ID: 0x1d0f, Device ID 0xf000
===== Starting with peek_poke_example =====
register: 0xdeadbeef
Resulting value matched expected value 0xdeadbeef. It worked!
Developers are encourged to modify the Virtual DIP Switch by calling the linux shell
command to demonstrate how AWS FPGA Virtual DIP switches can be used to change a CustomLogic functionality:
$ fpga-set-virtual-dip-switch -S (slot-id) -D (16 digit setting)
In this example, setting a virtual DIP switch to zero clears the corresponding LED, even if the peek-poke example would set it to 1.
For instance:
# fpga-set-virtual-dip-switch -S 0 -D 1111111111111111
# fpga-get-virtual-led -S 0
FPGA slot id 0 have the following Virtual LED:
1010-1101-1101-1110
# fpga-set-virtual-dip-switch -S 0 -D 0000000000000000
# fpga-get-virtual-led -S 0
FPGA slot id 0 have the following Virtual LED:
0000-0000-0000-0000
这个样例有两部分,一部分是peek_poke部分,就是寄存器的读写。样例为了说明FPGA寄存器的功能是否起作用,将输入的比特位做了交换。
如./test_hello_world.c中的代码所描述的:
uint32_t value = 0xefbeadde;
uint32_t expected = 0xdeadbeef;
/* read it back and print it out; you should expect the byte order to be
* reversed (That's what th
- 在采用FPGA设计DSP系统中仿真的重要性 (06-21)
- 基于 DSP Builder的FIR滤波器的设计与实现(06-21)
- 基于FPGA的快速并行FFT及其在空间太阳望远镜图像锁定系统中的应用(06-21)
- 3DES算法的FPGA高速实现(06-21)
- 用FPGA实现FFT算法(06-21)
- FPGA的DSP性能揭秘(06-16)