ug871 Lab4

实验平台

        Vitis HLS 2021.2

        Windows 10

实验内容

        什么是块级I/O协议和如何去使用它们。

实验步骤

Step 1:创建和打开工程

  1. 在Lab4文件夹下,创建run_hls.tcl
    1. # 重置和创建工程
      open_project -reset adders_prj
      
      # 添加源文件
      add_files src/adders.cpp
      add_files src/adders.hpp
      # 添加测试文件
      add_files -tb src/adders_test.cpp
      # 设置顶层函数
      set_top adders
      
      # 创建解决方案
      open_solution -reset solution1
      
      # 设置使用芯片
      set_part {xc7z020-clg400-2}
      # 这是时钟频率
      create_clock -period 10 -name default
      
      # 源码仿真
      csim_design
      
      退出HLS
      exit
      
  2. 创建src文件夹
    1. 在src文件夹下创建adders.cpp、adders.hpp、adders_test.cpp三个文件
    2. /*******adders.hpp******/
      #ifndef ADDERS_H_
      #define ADDERS_H_
       
      int adders(int in1, int in2, int in3);
      
      #endif
      
      /*******adders.cpp******/
      #include "adders.hpp"
      
      int adders(int in1, int in2, int in3) {
      #pragma HLS INTERFACE ap_ctrl_none port=return
      
      // Prevent IO protocols on all input ports
      #pragma HLS INTERFACE ap_none port=in3
      #pragma HLS INTERFACE ap_none port=in2
      #pragma HLS INTERFACE ap_none port=in1
      
      	int sum;
      	sum = in1 + in2 + in3;
      	return sum;
      }
      
      /*******adders_test.cpp******/
      #include <stdio.h>
      #include "adders.hpp"
       
      int main()
      {
      	int inA, inB, inC;
      	int sum;
      	int refOut[5] = {60, 90, 120, 150, 180};
      	int pass;
      	int i;
      
      	inA = 10;
      	inB = 20;
      	inC = 30;
      
      	for (i=0; i<5; i++)
      	{
      		sum = adders(inA, inB, inC);
      		fprintf(stdout, "  %d+%d+%d=%d \n", inA, inB, inC, sum);
      		if (sum == refOut[i])
      			pass = 1;
      		else 
      			pass = 0;
      		inA=inA+10;
      		inB=inB+10;
      		inC=inC+10;
      	}
      
      	if (pass)
      	{
      		fprintf(stdout, "----------Pass!------------\n");
      		return 0;
      	}
      	else
      	{
      		fprintf(stderr, "----------Fail!------------\n");
      		return 1;
      	}
      }
      

  3. 使用HLS打开Project

Step 2:创建和审查默认I/O协议

  1. 点击Run C Synthesis
  2. 删除#pragma HLS INTERFACE ap_ctrl_none port=return
  3. 再点击Run C Synthesis

相关推荐

  1. ug871 Lab4

    2023-12-20 11:42:01       71 阅读
  2. Codeforces Round 817 (Div. 4)

    2023-12-20 11:42:01       38 阅读
  3. Optional lab: Linear Regression using Scikit-LearnⅡ

    2023-12-20 11:42:01       72 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-20 11:42:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-20 11:42:01       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-20 11:42:01       82 阅读
  4. Python语言-面向对象

    2023-12-20 11:42:01       91 阅读

热门阅读

  1. QT6.3学习技巧,快速入门

    2023-12-20 11:42:01       62 阅读
  2. 测试TensorFlow/PyTorch的GPU版本是否启用

    2023-12-20 11:42:01       75 阅读
  3. Jenkins在window下配置Android打包配置

    2023-12-20 11:42:01       58 阅读
  4. 云安装nginx

    2023-12-20 11:42:01       54 阅读
  5. uniapp request.js封装例子

    2023-12-20 11:42:01       51 阅读
  6. UI Grounding 学习笔记

    2023-12-20 11:42:01       60 阅读
  7. 6.如何做项目技术选型

    2023-12-20 11:42:01       56 阅读
  8. CentOS 8.2 安装 nginx-1.18.0

    2023-12-20 11:42:01       64 阅读
  9. rpc和消息队列区别

    2023-12-20 11:42:01       51 阅读
  10. js对象转换为excel,excel转换为js对象

    2023-12-20 11:42:01       64 阅读