├── README.md ├── SD Test ├── readme └── sd_test.c └── hls快速部署教程.pdf /README.md: -------------------------------------------------------------------------------- 1 | # HLStoFPGA 2 | ZCU104, Vitis 2019/2020, Tutorial 3 | 4 | 5 | 本教程旨在记录从```hls```到```ZCU104```的快速部署的流程,其中包含了简单的步骤解释,适合有相关基础的同学。 6 | 由于目的是快速验证,因此最后的硬件部署并不基于linux系统,而是基于**裸机+SD card**的形式进行快速硬件验证。 7 | 若想从更深入了解,可以参考Xuan Wang写的[教程](https://github.com/WangXuan95/ZedBoard_Tutorial)。后续会补充hls+petalinux或者Pynq的教程。 8 | 9 | 10 | # 目录 11 | hls+ vivado + vitis sdk -zcu104为例 1 12 | - 一、 HLS部分 13 | - 1.1 C Simulation 14 | - 1.2 C Synthesis 15 | - 1.3 Co-Simulation 16 | - 1.4 Export RTL 17 | - 二、 Vivado部分 18 | - 2.1 创建工程 19 | - 2.2 创建Block Design 20 | - 2.3 添加HLS IP核心 21 | - 2.2 添加PS及配置 22 | - 2.3 添加AXI桥 23 | - 2.4 Address Assign & Valide Design 24 | - 2.3 综合以及实现 25 | - 2.4 导出硬件 26 | - 三、 Vitis部分 27 | - 3.1 创建platform 工程 28 | - 3.2 创建application工程 29 | - 3.3 编写测试程序(ps + sd卡读写测试) 30 | - 3.4 Program FPGA 31 | -------------------------------------------------------------------------------- /SD Test/readme: -------------------------------------------------------------------------------- 1 | 这里仅仅进行SD卡读写测试,仅包含了zynqMP上的PS,和PL逻辑无关 2 | -------------------------------------------------------------------------------- /SD Test/sd_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main.c 3 | * 4 | * Created on: 2016年8月20日 5 | * Author: hsp 6 | * 本文件实现SD写入一段字符串,然后从其中读出并打印到串口。 7 | * 8 | */ 9 | 10 | #include 11 | #include "platform.h" 12 | //#include "xparameters.h" 13 | 14 | #include "xil_printf.h" 15 | #include "ff.h" 16 | //#include "xdevcfg.h" 17 | 18 | static FATFS fatfs; 19 | 20 | int SD_Init() 21 | { 22 | FRESULT rc; 23 | 24 | rc = f_mount(&fatfs,"",0); 25 | if(rc) 26 | { 27 | xil_printf("ERROR : f_mount returned %d\r\n",rc); 28 | return 0; 29 | } 30 | return 1; 31 | } 32 | 33 | int SD_Transfer_read(char *FileName,u32 DestinationAddress,u32 ByteLength) 34 | { 35 | FIL fil; 36 | FRESULT rc; 37 | UINT br; 38 | 39 | rc = f_open(&fil,FileName,FA_READ); 40 | if(rc) 41 | { 42 | xil_printf("ERROR : f_open returned %d\r\n",rc); 43 | return 0; 44 | } 45 | rc = f_lseek(&fil, 0); 46 | if(rc) 47 | { 48 | xil_printf("ERROR : f_lseek returned %d\r\n",rc); 49 | return 0; 50 | } 51 | rc = f_read(&fil, (void*)DestinationAddress,ByteLength,&br); 52 | if(rc) 53 | { 54 | xil_printf("ERROR : f_read returned %d\r\n",rc); 55 | return 0; 56 | } 57 | rc = f_close(&fil); 58 | if(rc) 59 | { 60 | xil_printf(" ERROR : f_close returned %d\r\n", rc); 61 | return 0; 62 | } 63 | return 1; 64 | } 65 | 66 | int SD_Transfer_write(char *FileName,u32 SourceAddress,u32 ByteLength) 67 | { 68 | FIL fil; 69 | FRESULT rc; 70 | UINT bw; 71 | 72 | rc = f_open(&fil,FileName,FA_CREATE_ALWAYS | FA_WRITE); 73 | if(rc) 74 | { 75 | xil_printf("ERROR : f_open returned %d\r\n",rc); 76 | return 0; 77 | } 78 | rc = f_lseek(&fil, 0); 79 | if(rc) 80 | { 81 | xil_printf("ERROR : f_lseek returned %d\r\n",rc); 82 | return 0; 83 | } 84 | rc = f_write(&fil,(void*) SourceAddress,ByteLength,&bw); 85 | if(rc) 86 | { 87 | xil_printf("ERROR : f_write returned %d\r\n", rc); 88 | return 0; 89 | } 90 | rc = f_close(&fil); 91 | if(rc){ 92 | xil_printf("ERROR : f_close returned %d\r\n",rc); 93 | return 0; 94 | } 95 | return 1; 96 | } 97 | 98 | #define FILE "test.txt" 99 | 100 | int main() 101 | { 102 | init_platform(); 103 | 104 | const char src_str[] = "hsp test sd card write and read!"; 105 | u32 len = strlen(src_str); 106 | 107 | SD_Init(); 108 | SD_Transfer_write(FILE,(u32)src_str,(len+1));//当直接指定len时没有写出,需要指定较大的长度才会写出,原因未知 109 | 110 | char dest_str[33];//len<=33 111 | SD_Init(); 112 | SD_Transfer_read(FILE,(u32)dest_str,(len+1)); 113 | 114 | xil_printf("%s\r\n",dest_str); 115 | print("SD write and read over!\r\n"); 116 | 117 | cleanup_platform(); 118 | return 0; 119 | } 120 | 121 | -------------------------------------------------------------------------------- /hls快速部署教程.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reconfigurable-Computing/HLStoFPGA/964f177ef1a2e78dae4e84516bffff4dfb00600d/hls快速部署教程.pdf --------------------------------------------------------------------------------