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 ...
 
随机推荐
- js实现的新闻列表垂直滚动实现详解
			
js实现的新闻列表垂直滚动实现详解:新闻列表垂直滚动效果在大量的网站都有应用,有点自然是不言而喻的,首先由于网页的空间有限,使用滚动代码可以使用最小的空间提供更多的信息量,还有让网页有了动态的效果,更 ...
 - C语言位运算符及作用:与、或、异或、取反、左移和右移
			
一.& 按位与 如果两个相应的二进制位都为1,则该位的结果值为1,否则为0应用:(1)清零 若想对一个存储单元清零,即使其全部二进制位为0,只要找一个二进制数,其中各个位符合一下条件:原来的数 ...
 - channelartlist标签调用实例
			
channelartlist标签,大家都知道在DedeCMS的系统中,我们可以用这个标签进行循环子栏目及其栏目的文档数据,这也是DedeCMS系统中,唯一一个支持标签嵌套的调用标签,以DedeV5.6 ...
 - 将access数据库导入mysql
			
一般地,直接在mysql端,导入时选择access文件就行:但是若access数据库版本太老,导入mysql时会出错: 这时,就需要借助access 2003,对原始数据进行转换为2003版本数据,即 ...
 - LeetCode 125. Valid Palindrome
			
这个题目只要注意大小写问题即可解决,而且我们只关注的是字母和数值 Given a string, determine if it is a palindrome, considering only a ...
 - [HDU 5074] Hatsune Miku (动态规划)
			
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5074 题目大意是给你m个note,n个数,得分是v[a[i]][a[i+1]]的总和,如果说a[i]是 ...
 - 【转】find命令
			
Linux中find常见用法示例·find path -option [ -print ] [ -exec -ok command ] {} \;find命令的参数: pathname: find命令 ...
 - win7设置防火墙允许Ping与telnet
			
Ping: 打开控制面板 >> 系统安全 >> windows防火墙 >> 高级设置 >> 入站规则
 - 03-position和anchorPoint
			
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
 - [系统] 安装Ubuntu 双系统 - 失败
			
因为工作原因, 所以需要装ubuntu系统. 在网络上查了一下, 一般都是使用U盘安装. 但是由于手头上既没有U盘又没有光盘,只能用硬盘安装了. 查一下, 使用wubi安装方式从硬盘安装, 非常方便. ...