使用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

http://www.logicbricks.com/logicBRICKS/Reference-logicBRICKS-Design/Xylon-Reference-Designs-Navigation-Page.aspx

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 Synthesis
2.Verifying
your VivadoHLS Design
3.Packaging
Vivado HLSIP for use from Vivado IP Catalog
4.Generating
Vivado HLSblock for use in System Generator for DSP
5.Generating
Vivado HLSpcore for use in Xilinx Platform Studio
6.Analyzing
your VivadoHLS design
7.Specifying
AXI4interfaces for your Vivado HLS design
8.Using
Vivado HLSC/C++/SystemC block in System Generator
9.Using
Vivado HLSC/C++/SystemC based pcores in XPS
10.Floating-Point
Designwith Vivado HLS
11.Using
Vivado HLS SWlibraries in your C, C++, SystemC code
12.Using
the Vivado HLSTcl
interface13.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 HLS
Tool XAPP1163
-Floating-Point PID Controller Design with Vivado HLS and System Generatorfor
DSP XAPP1167Accelerating
OpenCVApplications with Zynq using Vivado HLS Video Libraries



HLS入门收集(1)的更多相关文章

  1. go入门收集(转)

    go mod 使用 原文地址: https://juejin.im/post/5c8e503a6fb9a070d878184a  

  2. linux shell 入门

    本文是本人学习linux shell入门收集整理,不完全原创. 参考博文: http://www.cnblogs.com/suyang/archive/2008/05/18/1201990.html ...

  3. redis入门资源收集汇总

    redis安装:http://www.redis.io/download redis命令测试平台:http://try.redis.io/ redis桌面管理工具:http://redisdeskto ...

  4. pc/移动端(手机端)浏览器的直播rtmp hls(适合入门者快速上手)

    一.直播概述 关于直播,大概的过程是:推流端——>源站——>客户端拉流,用媒介播放 客户端所谓的拉流就是一个播放的地址url,会有多种类型的流: 视频直播服务目前支持三种直播协议,分别是R ...

  5. ELK快速入门(二)通过logstash收集日志

    ELK快速入门二-通过logstash收集日志 说明 这里的环境接着上面的ELK快速入门-基本部署文章继续下面的操作. 收集多个日志文件 1)logstash配置文件编写 [root@linux-el ...

  6. ELK快速入门(三)logstash收集日志写入redis

    ELK快速入门三-logstash收集日志写入redis 用一台服务器部署redis服务,专门用于日志缓存使用,一般用于web服务器产生大量日志的场景. 这里是使用一台专门用于部署redis ,一台专 ...

  7. ELK快速入门(四)filebeat替代logstash收集日志

    ELK快速入门四-filebeat替代logstash收集日志 filebeat简介 Filebeat是轻量级单用途的日志收集工具,用于在没有安装java的服务器上专门收集日志,可以将日志转发到log ...

  8. SpringBoot入门系列(十二)统一日志收集

    前面介绍了Spring Boot 异常处理,不清楚的朋友可以看看之前的文章:https://www.cnblogs.com/zhangweizhong/category/1657780.html. 今 ...

  9. ZED-Board从入门到精通系列(八)——Vivado HLS实现FIR滤波器

    http://www.tuicool.com/articles/eQ7nEn 最终到了HLS部分.HLS是High Level Synthesis的缩写,是一种能够将高级程序设计语言C,C++.Sys ...

随机推荐

  1. lable标签透明

    方法1: pictureBox1.Controls.Add(lable1);    //或 this.label1.Parent=pictureBox1;   lable1.BackColor=Col ...

  2. mysql 用户权限设置【转】

    在Linux下phpStudy集成开发环境中,要先进入mysql下bin目录,执行mysql ./mysql -u root -p 1.创建新用户 通过root用户登录之后创建 >> gr ...

  3. javascript delete方法

    学习delete可以参考下面两个博客,写的都很好,本文大部分参考与以下两个博客 http://www.cnblogs.com/windows7/archive/2010/03/28/1698387.h ...

  4. glctx.ClearColor 参数说明

    glctx.ClearColor 的参数信息如下: // ClearColor specifies the RGBA values used to clear color buffers. // // ...

  5. 第六届蓝桥杯B组C++试题

    1.  奖券数目 有些人很迷信数字,比如带"4"的数字,认为和"死"谐音,就觉得不吉利. 虽然这些说法纯属无稽之谈,但有时还要迎合大众的需求.某抽奖活动的奖券号 ...

  6. (转)C# WinForm获取当前路径汇总

    Winform获取应用程序的当前路径的方法集合,具体如下,值得收藏本文来源 :http://www.cnblogs.com/greatverve/archive/2011/12/15/winform- ...

  7. document.write('<script type=\"text/javascript\"><\/script>')

    document.write('<script type=\"text/javascript\"><\/script>')

  8. Loadrunner 添加windows资源没反应

    使用 LoadRunner Controller 添加Windows资源系统没有反应, 解决办法 : 1.关闭Windows 防火墙 2.若使用的不是本机 1) 首先要启动所监测机器的remote r ...

  9. linux spi驱动开发学习-----spidev.c和spi test app

    一.spidev.c文件 看一个设备驱动的方法: module_init标识的入口初始化函数spidev_init,(module_exit标识的出口函数) 设备与设备驱动匹配时候调用的probe方法 ...

  10. Android——显示单位px和dip以及sp的区别

    dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA.HVGA和QVGA 推荐使用这个,不依赖像素.d ...