HLS入门收集(1)
使用HLS各种问题
关于求指数函数 exp(x)
在HLS中使用exp(x),也就是指数函数。不能导出RTL到EDK也就是Pcore
只能导出为VIVADO IP:相关解释:见官方论坛
http://forums.xilinx.com/t5/High-Level-Synthesis-HLS/pow-function-in-Pcore-Export/td-p/470178
解决办法只能通过通过vivado来做:http://www.xilinx.com/support/documentation/sw_manuals/xilinx2013_2/ug994-vivado-ip-subsystems.pdf
http://www.xilinx.com/support/documentation/sw_manuals/xilinx2013_2/ug902-vivado-high-level-synthesis.pdf
我的解决办法是非不入流:我用VS2010或者matlab计算相应从0到30000的指数函数结果,然后保存到文件中,之后在HLS中通过查表法去访问我需要的指数函数计算结果,这种方法是你需要提前能预测你需要的区间。这种方法从计算的角度是可以简化时间的。
其中size就是我们需要计算的区间,LUT就是一张表。
Unsupported C Constructs(HLS可综合化 )
UG902 page326
虽然HLS支持大部分C语言原型,但是有部分还是不能支持,总的来说可综合化有下面几点要求:
To be synthesized:
• The C function must contain the entire functionality ofthe design.
• None of the functionality can be performed by system calls to the operatingsystem.
不能系统调用操作系统
• The C constructs must be of a fixed or bounded size.
C的构造中必须是定长或者有边界的
• The implementation of those constructs must be unambiguous
必须是明确的构造
不支持以下操作
System Calls
不能在函数实现中调用系统函数,类似与printf、getc、time、等等,可以用宏
__SYNTHESIS__ 来处理可综合与不可综合的代码。列入以下程序
include hier_func4.h
int sumsub_func(din_t *in1, din_t *in2, dint_t *outSum, dint_t *outSub)
{
*outSum = *in1 + *in2;
*outSub = *in1 - *in2;
}
int shift_func(dint_t *in1, dint_t *in2, dout_t *outA, dout_t *outB)
{
*outA = *in1 >> 1;
*outB = *in2 >> 2;
}
void hier_func4(din_t A, din_t B, dout_t *C, dout_t *D)
{
dint_t apb, amb;
sumsub_func(&A,&B,&apb,&amb);
#ifndef __SYNTHESIS__ //通过宏来处理可综合与不可综合代码,但是在仿真的时候却是可以起作用的!!
FILE *fp1;// The following code is ignored for synthesis
char filename[255];
sprintf(filename,Out_apb_%03d.dat,apb);
fp1=fopen(filename,w);
fprintf(fp1, %d \n, apb);
fclose(fp1);
#endif
shift_func(&apb,&amb,C,D);
}
Dynamic MemoryUsage
Any system callsthat manage memory allocation within the system, for example,malloc(), alloc(),and free() are using resources
that exist in the memory of the operating systemand are created and released during run time: to be able to synthesize ahardware implementation the design must be fully self-contained, specifying allrequired resources.
Memory allocation system calls mustbe removed from the design code before synthesis.Because dynamic memoryoperations are used to define the functionality of the design,they
must betransformed into equivalent bounded representations. The following code exampleshows how a design using malloc() can be transformed into asynthesizableversion and highlights two useful coding style techniques:
HLS不支持动态内存分配,也就是不支持在程序运行时才分配内存,反之就是只支持在程序编译的时候就要确定大小的代码。
.The design doesnot use the __SYNTHESIS__ macro.
Theuser-defined macro NO_SYNTH is used to select between the synthesizable andnon-synthesizable versions. This ensures that the same
code is simulated in Cand synthesized in Vivado HLS.
.The pointers inthe original design using malloc() do not need to be rewritten towork withfixed sized elements.
Fixed sizedresources can be created and the existing pointer can simply be made to pointto the fixed sized resource. This technique
can prevent manual re-coding of theexisting design.
Transformingmalloc() to Fixed Resources(修改代替malloc函数的方法)
#include malloc_removed.h
#include <stdlib.h>
//#define NO_SYNTH
dout_t malloc_removed(din_t din[N], dsel_t width) {
#ifdef NO_SYNTH //不可综合的代码,包括malloc函数
long long *out_accum = malloc (sizeof(long long));
int* array_local = malloc (64 * sizeof(int));
#else
long long _out_accum;
long long *out_accum = &_out_accum;//指针必须指向的是定长的变量
int _array_local[64];//只支持在编译时候就定长的数组
int* array_local = &_array_local[0];
#endif
int i,j;
LOOP_SHIFT:for (i=0;i<N-1; i++) {
if (i<width)
*(array_local+i)=din[i];
else
*(array_local+i)=din[i]>>2;
}
*out_accum=0;
LOOP_ACCUM:for (j=0;j<N-1; j++) {
*out_accum += *(array_local+j);
}
return *out_accum;
}
Because thecoding changes here impact the functionality of the design, Xilinx does notrecommend using the __SYNTHESIS__ macro. Xilinx
recommends that you:
1. Add the user-defined macro NO_SYNTH to the code and modify thecode.
2. Enable macro NO_SYNTH, execute the C simulation and saves the results.
3.
Disable the macro NO_SYNTH (for example comment out, as in Example 50),execute the C simulation to verify that the results are identical.
4. Perform synthesis with the user-defined macro disabled.
XILINX推荐使用条件编译来修改可综合与不可综合的代码,这样在程序更新的时候更加方便
As withrestrictions on dynamic memory usage in C, Vivado HLS does not support (forsynthesis) C++ objects that are dynamically created
or destroyed. This includesdynamic polymorphism and dynamic virtual function calls.
不支持C++中类的动态创建与销毁,列入如下C++代码:
Unsynthesizable Code Coding Example
PointerLimitations(指针限制)
General Pointer Casting
Vivado
HLS does not support general pointer casting,but supports pointer casting between native C types. For more information onpointer casting, see Example 3-36.
Pointer Arrays(指针数组)
Vivado
HLSsupports pointer arrays for synthesis, provided that each pointer points toa scalar or an array of scalars. Arrays of pointers cannot point toadditional pointers.
支持指针数组,但是指针数组必须是指向一个定长或者标量的数组,不能用于指向另外一个指针。
Recursive Functions(递归函数)
递归函数不支持
Standard TemplateLibraries(标准的模板类)
不支持(由于含有动态内存分配)
参考:
http://shakithweblog.blogspot.com/2012/12/getting-sobel-filter-application.html
http://www.zedboard.org/content/implementing-xapp1167-application-note-example-zedboard
http://www.zedboard.org/content/accelerating-opencv-zynq-zedboard-xilinx-appnote-1167
http://www.zedboard.org/node/830
https://www.google.com.hk/#newwindow=1&q=XAPP890&safe=strict
https://www.google.com.hk/#newwindow=1&q=xapp1167++zedboard&safe=strict
VDMA driver:https://ez.analog.com/message/70323#70323
ug871是xilinx公开提供的HLS教程,包括11个例子: C
ValidationInterface SynthesisArbitrary Precision TypesDesignAnalysisDesign OptimizationRTL VerificationUsing HLS IP in IP IntegratorUsingHLS IP in a Zynq Processor DesignUsing HLS IP in System Generator forDSP ug871:http://www.xilinx.com/support/documentation/sw_manuals/xilinx2013_1/ug871-vivado-high-level-synthesi...
参考设计源代码:http://www.xilinx.com/cgi-bin/docs/rdoc?v=2013.2;t=vivado+tutorials 第三,
13个Xilinx专家讲解视频,包括讲座和演示 地址: www.xilinx.com/training/vivado 1.Getting
Started withVivado High-Level Synthesis2.Verifying
your VivadoHLS Design3.Packaging
Vivado HLSIP for use from Vivado IP Catalog4.Generating
Vivado HLSblock for use in System Generator for DSP5.Generating
Vivado HLSpcore for use in Xilinx Platform Studio6.Analyzing
your VivadoHLS design7.Specifying
AXI4interfaces for your Vivado HLS design8.Using
Vivado HLSC/C++/SystemC block in System Generator9.Using
Vivado HLSC/C++/SystemC based pcores in XPS10.Floating-Point
Designwith Vivado HLS11.Using
Vivado HLS SWlibraries in your C, C++, SystemC code12.Using
the Vivado HLSTclinterface13.LeveragingOpenCVand
High LevelSynthesis with Vivado 第四,不停更新的武林秘籍 www.xilinx.com/hls XAPP745
ProcessorControl of Vivado HLS Designs XAPP793
ImplementingMemory Structures for Video Processing in the Vivado HLS Tool XAPP599Floating
Point Design with Vivado HLS XAPP890
Zynq AllProgrammable SoC Sobel Filter Implementation Using the Vivado HLSTool XAPP1163
-Floating-Point PID Controller Design with Vivado HLS and System GeneratorforDSP XAPP1167Accelerating
OpenCVApplications with Zynq using Vivado HLS Video Libraries
HLS入门收集(1)的更多相关文章
- go入门收集(转)
go mod 使用 原文地址: https://juejin.im/post/5c8e503a6fb9a070d878184a
- linux shell 入门
本文是本人学习linux shell入门收集整理,不完全原创. 参考博文: http://www.cnblogs.com/suyang/archive/2008/05/18/1201990.html ...
- redis入门资源收集汇总
redis安装:http://www.redis.io/download redis命令测试平台:http://try.redis.io/ redis桌面管理工具:http://redisdeskto ...
- pc/移动端(手机端)浏览器的直播rtmp hls(适合入门者快速上手)
一.直播概述 关于直播,大概的过程是:推流端——>源站——>客户端拉流,用媒介播放 客户端所谓的拉流就是一个播放的地址url,会有多种类型的流: 视频直播服务目前支持三种直播协议,分别是R ...
- ELK快速入门(二)通过logstash收集日志
ELK快速入门二-通过logstash收集日志 说明 这里的环境接着上面的ELK快速入门-基本部署文章继续下面的操作. 收集多个日志文件 1)logstash配置文件编写 [root@linux-el ...
- ELK快速入门(三)logstash收集日志写入redis
ELK快速入门三-logstash收集日志写入redis 用一台服务器部署redis服务,专门用于日志缓存使用,一般用于web服务器产生大量日志的场景. 这里是使用一台专门用于部署redis ,一台专 ...
- ELK快速入门(四)filebeat替代logstash收集日志
ELK快速入门四-filebeat替代logstash收集日志 filebeat简介 Filebeat是轻量级单用途的日志收集工具,用于在没有安装java的服务器上专门收集日志,可以将日志转发到log ...
- SpringBoot入门系列(十二)统一日志收集
前面介绍了Spring Boot 异常处理,不清楚的朋友可以看看之前的文章:https://www.cnblogs.com/zhangweizhong/category/1657780.html. 今 ...
- ZED-Board从入门到精通系列(八)——Vivado HLS实现FIR滤波器
http://www.tuicool.com/articles/eQ7nEn 最终到了HLS部分.HLS是High Level Synthesis的缩写,是一种能够将高级程序设计语言C,C++.Sys ...
随机推荐
- Python进阶06 循环对象
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 这一讲的主要目的是为了大家在读Python程序的时候对循环对象有一个基本概念. 循 ...
- Jmeter+jenkins接口性能测试平台实践整理(一)
最近两周在研究jmeter+Jenkin的性能测试平台测试dubbo接口,分别尝试使用maven,ant和Shell进行构建,jmeter相关设置略. 一.Jmeter+jenkins+Shell+t ...
- FS4412系统移植
一.SD启动盘制作 1. 下载SD启动盘的工具 sdfuse_q 2. 插入SD卡,并格式化 (1)查看SD卡:sudo fdisk -l (2)格式化SD卡: sudo mkfs -t vfat / ...
- 创建一个hibernate helloword
1.下载hibernate包 http://hibernate.org/orm/ 点download下载最终版 安装hibernate插件hibernatetools 2.创建一个java工程 导入必 ...
- MongoDB 语法使用小结
MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的 他支持的数据结构非常松散,是类似json的bjson格式,因此可以存储比较复杂的数据 ...
- types.MethodType
http://stackoverflow.com/questions/972/adding-a-method-to-an-existing-object-instance 532down voteac ...
- c# list排序的三种实现方式
用了一段时间的gridview,对gridview实现的排序功能比较好奇,而且利用C#自带的排序方法只能对某一个字段进行排序,今天demo了一下,总结了三种对list排序的方法,并实现动态传递字段名对 ...
- [HDU 2602]Bone Collector ( 0-1背包水题 )
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 水题啊水题 还给我WA了好多次 因为我在j<w[i]的时候状态没有下传.. #includ ...
- MongoDB增删改查
MongoDB以文档的形式存储数据,文档是类似于JSON键值对结构的BSON格式. 许多有共性的文档就组成一个集合. 集合.文档分别对应关系型数据库的表和行记录. 进入数据库: [mongodb@lo ...
- Html5——地理定位及地图
常用的navigator.geolocation对象有以下三种方法: 获取当前地理位置:navigator.geolocation.getCurrentPosition(success_callbac ...