HLS编程环境入门搭建liunx下环境
2021/5/22 22:25:39
本文主要是介绍HLS编程环境入门搭建liunx下环境,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
文章目录
- 一、安装liunx版vivado
- 安装前准备
- 安装过程中
- 添加权限和安装下载驱动
- 二、PetaLinux安装
- 安装依赖库
- 安装 Petalinux
- 三、hello_world--灯闪烁
一、安装liunx版vivado
须知
- 安装Vivado下载文件达20G
- liunx虚拟机环境磁盘需要100G左右
安装前准备
由于我的liunx磁盘过小,所以我对磁盘进行了扩充。链接:VMware虚拟机 Linux系统 Ubuntu 16.04 硬盘/磁盘扩容(超详细图文详解!亲测有效!)。
- 将windows中的安装文件放到liunx的共享文件。
这里是我在window中下载了xilinx安装文件压缩包
- 解压文件。
sudo tar xvzf /mnt/hgfs/ubuntshare/Vivado_SDK_2018.3_1207_2324.tar.gz
- 到解压文件中,运行安装文件。
sudo ./xsetup
安装过程中
-
实验使用当前版本,不需要更新到最新版本,点contiune。
-
三个同意,点击 Next。
-
选择 Vivado HL Design Edition,点击 Next。
-
勾选需要用到工具,点击 Next。
-
继续next。
-
进入安装过程中,想到windows漫长的安装,可以喝杯咖啡了。
-
完成安装,将license放到文件中。
-
软件注册成功
添加权限和安装下载驱动
- 添加权限
sudo chmod -R 777 /tools/Xilinx sudo chmod -R 777 ~/.Xilinx/
- 安装下载器驱动
直接cd到驱动目录,会出错,建议一个一个慢慢进。
cd /tools/Xilinx/Vivado/2018.3/data/xicom /cable_drivers/lin64/install_script/install_drivers sudo ./install_drivers
- 写入环境变量方便使用
sudo gedit .bashrc 在该文件末端,添加: source /tools/Xilinx/Vivado/2018.3/settings64.sh
二、PetaLinux安装
PetaLinux 是一个嵌入式 Linux 系统开发工具包,用于 XilinxFPGA 片上系统
的定制、建立、测试和部署嵌入式 Linux 系统。
安装依赖库
- 安装依赖库
sudo -s sudo apt-get install gcc git make net-tools libncurses5-dev tftpd zlib1g-dev libssl-dev flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib build-essential libsdl1.2-dev libglib2.0-dev zlib1g:i386 screen pax gzip gawk
- 安装tftp Server。
apt-get install tftpd-hpa
- 启动tft Serve,查看状态。
service tftpd-hpa restart service tftpd-hpa status
- 校验 tftp。
ps ax | grep tftpd
安装 Petalinux
- 安装准备
这里的<your_user_name>填写你的用户名
sudo –s mkdir –p /opt/pkg/petalinux/2018.3 chown <your_user_name> /opt/pkg/ chown <your_user_name> /opt/pkg/petalinux/ chown <your_user_name> /opt/pkg/petalinux/2018.3/ chgrp <your_user_name> /opt/pkg/ chgrp <your_user_name> /opt/pkg/petalinux/ chgrp <your_user_name> /opt/pkg/petalinux/2018.3/ exit
- 为安装包添加运行权限。
sudo chmod +x petalinux-v2018.3-final-installer.run
- 安装程序。
./petalinux-v2018.3-final-installer.run /opt/pkg/petalinux/2018.3/
-
同意三连。
-
验证安装正确性。
source /opt/pkg/petalinux/2018.3/settings.sh echo $PETALINUX
三、hello_world–灯闪烁
- 启动vivado hls,使用以下命令。
注意:先写入bash,
source /tools/Xilinx/Vivado/2018.3/settings64.sh
vivado_hls
- 创建文件,设置目录及文件名。
- 选择器件,根据实际情况。
- 在source右键,新建led.cpp文件。
内容为:
#include "led.h" void flash_led(led_t *led_o , led_t led_i){ #pragma HLS INTERFACE ap_vld port=led_i #pragma HLS INTERFACE ap_ovld port=led_o #pragma HLS INTERFACE ap_vld port=led_i #pragma HLS INTERFACE ap_ovld port=led_o cnt_t i; for(i=0;i<CNT_MAX;i++){ if(i==FLASH_FLAG){ *led_o = ~led_i; } } }
- 新建led.h文件。内容:
#ifndef _SHIFT_LED_H_ #define _SHIFT_LED_H_ #include "ap_int.h" #define CNT_MAX 100000000 //#define CNT_MAX 100 #define FLASH_FLAG CNT_MAX-2 // typedef int led_t; // typedef int cnt_t; typedef ap_int<1> led_t; typedef ap_int<32> cnt_t; void flash_led(led_t *led_o , led_t led_i); #endif
- 添加C仿真文件,右键test Bench新建文件。
内容:
#include "led.h" void flash_led(led_t *led_o , led_t led_i){ #pragma HLS INTERFACE ap_vld port=led_i #pragma HLS INTERFACE ap_ovld port=led_o cnt_t i; for(i=0;i<CNT_MAX;i++) { if(i==FLASH_FLAG) { *led_o = ~led_i; } } }
-
设置信号 led_o 进行约束 led_i 进行约束。
-
进行仿真之前,我们首先选中我们要仿真的顶层函数,点击 project 选择
project seethings选择 synthesisbrowser选择 flash_led 作为顶层函数。
-
然后点击 project Run C simulation,进行仿真。
-
接下来,进行 C 综合,编译器会将 C++代码映射到 RTL 电路,点击 Solution Run C Synthesis Active Solution。等待一段时间后,编译器会提示综合后的结果。
-
接下来,我们进行 C/RTL 联合仿真,来验证映射出来的 RTL 电路是否正确。
-
仿真错误,有待解决。
- ww
ERROR: [COSIM 212-104] Cannot find Mentor Graphics ModelSim. Make sure it is accessible through the PATH variable. command 'ap_source' returned error code while executing "source E:/XilinxHls/hls_led_test/solution1/cosim.tcl" invoked from within "hls::main E:/XilinxHls/hls_led_test/solution1/cosim.tcl" ("uplevel" body line 1) invoked from within "uplevel 1 hls::main {*}$args" (procedure "hls_proc" line 5) invoked from within "hls_proc $argv" hls_led_test:solution1 2021年5月22日 下午9:39:17
错误为 :仿真软件在path找不到。
这篇关于HLS编程环境入门搭建liunx下环境的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)