当前位置:网站首页>Vitis HLS build project and generate IP core (vivado HLS)
Vitis HLS build project and generate IP core (vivado HLS)
2022-04-21 16:55:00 【A piece of chicken dregs with vegetables】
Preface
Vitis HLS, You can use it , use C and C++ Create and encapsulate a IP nucleus , from Vivado 2021 The version of started built-in , Used in substitution Vivado HLS, Because it's too new , There are few online tutorials (2020 Version or Vivado HLS), So this series of articles , Used to record how to use Vitis HLS.
Use Vitis HLS When developing , It's best not to use C Language , It is C++, meanwhile , Use some of the things mentioned in the old tutorial "ap_cint.h" The header file will report an error , For this, please refer to the following “ error 1”. So all the code in this article will use C++.
New project
Building engineering
After opening the software , Build a new project .

Set the project directory and project name .

All the way next, It asks us to add two files , Let's skip here . To the select device column .

What I use here is xc7z020clg400-2.

Click on ok, And then click finish, It's the development interface .

Edit source
In limine , We focus on the window in the upper left corner .

stay Source One column , Let's create two new source files .

Create a new one in the project directory “src” Folder is used to store code files . I'm gonna make a new one here h Header file and a cpp file . Because of the use of C++, The file name suffix is cpp.

After the new building is completed , The window will show .

Here are the codes of two files .
- led_twinkle.h
#include <ap_int.h>
void led_twinkle(ap_int<1> *led);
- led_twinkle.cpp
#include "led_twinkle.h"
#define DELAY_TIME 50000000
#define DELAY_TIME_HALF 25000000 //optimize
//50000000
void led_twinkle(ap_int<1> *led){
int i;
for(i = 0;i < DELAY_TIME;i++){
if(i < DELAY_TIME_HALF)
*led=0;
else
*led=1;
}
}
Be careful : There are errors in the code in all the screenshots below , Please run the code listed above
Set port
stay led_twinkle.cpp Under the document , Focus on the window in the upper right corner .

Add an instruction to a function .

Follow the picture below to set . Be careful , If it is set to ap_ctrl_none, stay C/RTL An error will be reported during simulation , See error for details 4( You can skip it, of course C/RTL Simulation ).

Also add an instruction to the output port .

similarly , Set as shown in the figure below , Set to ap_none Will play a warning , See error for details 4( You can also ignore , Set to ap_none).

When it's set up , The relevant code will be automatically added to the source code , It is not recommended to add , It's best to use software to automatically generate .

Add tests
stay “Test Bench” in , Create a new source file , be called led_twinkle_test.cpp.

Source code is as follows .
- led_twinkle_test.cpp
#include "led_twinkle.h"
ap_int<1> led_1;
int main(){
led_twinkle(&led_1);
printf("Run successfully!");
return 0;
}
Then you need to set the top-level function .

Select the function just set .

Verification test
To generate correctly IP nucleus , The following four tests must pass .

C Language simulation
function C Language simulation .

In addition to its own grammatical errors, it will report errors , If I use theta C Written language , Instead of C++, Errors will also be reported here , See the mistake 1.printf Code results , It will show here , and C The language console is the same , Output some test information written by yourself .

C Language synthesis
function C Language synthesis .

If the latest patch is not installed , An error may be reported here , See the mistake 2. And if the port setting is wrong , There will be errors 4. After the simulation, the interface information and other related information will be .

C/RTL Simulation
function C/RTL Simulation .

Follow the following settings .

After that, the result will appear . If you set the function to ap_ctrl_none, Will report a mistake , See error for details 4( You can skip it, of course C/RTL Simulation ).

export RTL
Run export RTL.

The default can be , You don't need to set the output directory .

You will be prompted that the export was successful .

IP The kernel is generated in the default directory .

final result
Generated IP Nuclear can be in Vivado Shows . Verification and testing will be put into the next article .

If the function and port are set separately "ap_ctrl_none" and "ap_none", It's like this . Verify in the next article IP The core article will use the IP nucleus .

Error collection
error 1
unexpected top argument type: type of the parameter is C language Arbitray-precesion type
I've been looking for answers for a long time , Problems found , yes <ap_cint.h> Error in this header file . from Vitis 2021 Start (Vivado 2021), The official clearly no longer supports this header file , It is also recommended to use C++ Development . This header file is still used in the code of many old tutorials , They use C Language .

Official instructions and solutions :
The solution is to reference <ap_cint.h> Change it to <ap_int.h>, At the same time, the relevant data types need to be modified .

error 2
clang compile failed: child process exited abnormally
In fact, it has been prompted here , The relevant header file could not be found , But the header file is clearly included in the project .

It's actually because of the use of include When , The difference between double quotation marks and angle brackets . In this error , Incorrect use of double quotation marks to refer to .

Change to double quotation marks .

error 3
Failed to generate IP
This report is wrong . No specific information is given in the console , In fact, just install the latest patch . Refer to the link below .
Export IP Invalid Argument / Revision Number Overflow Issue (Y2K22)
Unzip the downloaded patch into the software directory , Hold down Shift Key and then press the right mouse button , Open console .

Input README The code given in .

Running results . Patch installed successfully , Just restart the software .

error 4
A warning
WARNING: [RTGEN 206-101] Port 'led' with mode 'ap_none' may require an associated data valid signal to correctly communicate with other blocks or a test bench; automatic C/RTL co-simulation may not be able to verify such a port.
There is an error
ERROR: [COSIM 212-4] *** C/RTL co-simulation finished: FAIL ***
A similar error occurred , It's all because of the port setting error . In many old tutorials , When it comes to setting the function to "ap_ctrl_none", And the port is set to "ap_none", But this brings uncertainty . The correct way is to set it to "ap_ctrl_hs" as well as "ap_hs", So that we don't make a mistake , The results are the same .

But set the function to "ap_ctrl_hs", That is, a two-way protocol , Will introduce a lot of IO mouth . Use "ap_ctrl_none" It's OK, too , Just need to skip C/RTL Simulation .
版权声明
本文为[A piece of chicken dregs with vegetables]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211646273786.html
边栏推荐
- 优炫数据库中标北京市应急管理部消防产品合格评定中心项目
- Sqli labs 23-25a breakthrough experience and ideas
- PPS website XSS vulnerability
- L2-040 哲哲打游戏 (25 分) 模拟
- Are you sure you don't want to see it yet? Managing your code base in this way is both convenient and worry free
- 多核和多CPU編程——任務調度
- k线图及单个k线图形态分析
- 解读论文记录 指出经典的RMS证明过程小错误的一个论文的解读
- 域内信息查询工具AdFind
- Programmation Multi - noyaux et multi - processeurs - programmation des tâches
猜你喜欢

FastReport Business Graphics .NET

.NET宝藏API之:IHostedService,后台任务执行

Sort the exercises after class

【观察】让能源行业“大象起舞”,中国系统以硬核实力构筑数字底座

Spark SQL底层执行流程详解

2018-8-10-win10-uwp- exit the program

巴比特副总裁马千里:元宇宙时代NPC崛起,数字身份协议或成为入口级产品丨2022元宇宙云峰会

824. 山羊拉丁文

直播带货、送外卖、做货运,航空公司靠副业“回血”

4.25 unlock openharmony technology day! The annual event is about to open!
随机推荐
云安全日报220421:思科虚拟化基础设施管理器软件发现权限提升漏洞,需要尽快升级
Netease XSS
Mina中的Scan State
从源码角度分析创建线程池究竟有哪些方式
域内信息查询工具AdFind
巴比特副总裁马千里:元宇宙时代NPC崛起,数字身份协议或成为入口级产品丨2022元宇宙云峰会
Download the chrome plug-in and install it into the browser
29. 有 1、2、3、4 个数字,能组成多少个互不相同且无重复数字的三位数
R语言数据导出(数据保存、导出、持久化到本地指定目录文件)、使用xlsx包的write.xlsx函数将dataframe导出为excel文件xls格式、而非xlsx格式
Multilingual communication foundation 04 grpc and protobuf
k线图及单个k线图形态分析
IO view command
如果这题都不会面试官还会继续问我 JVM 嘛:如何判断对象是否可回收
Sohu white society cross site vulnerability
js 毫秒转天时分秒
Program design TIANTI race l2-007 family real estate (it's too against the sky. I always look at the solution of the problem, resulting in forgetting the problem and looking up how to write the collec
MySQL queries whether a field contains Chinese characters
Program design TIANTI race l3-29 restore file (DFS is over, leaving the original spectrum)
C语言-细说函数与结构体
Use of Arthas tunnel