当前位置:网站首页>HLS实验一--乘法器
HLS实验一--乘法器
2022-07-26 02:22:00 【J-JMF】
前言
本次实验使用了两种方法,分别是直接调用组件和以流水线的方式调用组件。
流水线使用到的函数
1.排队函数
ihc_hls_enqueue(void *retptr, void *funcptr,/*function arguments*/)
参数:
retptr:返回值
funcptr:将要调用的HLS component
这个函数对HLS组件的一次调用进行排队。返回值存储在第一个实参中,该实参应该是指向返回类型的指针。在调用ihc_hls_component_run_all()之前,组件不会运行。
2.没有返回类型的排队函数
ihc_hls_enqueue_noret(void* funcptr,/*function arguments*/)
参数:
funcptr:将要调用的HLS component
这个函数对HLS组件的一次调用进行排队。当HLS组件的返回类型为void时,应该使用这个函数。在调用ihc_hls_component_run_all()之前,组件不会运行。
3.开启组件函数
ihc_hls_component_run_all(void* funcptr)
参数:
funcptr:将要调用的HLS component
这个函数接受一个指向HLS组件函数的指针。组件的所有排队调用在运行时将被推入,当组件能够接受新的调用时,HDL模拟器就能以最快的速度运行。
参考文章
https://blog.csdn.net/qq_42585108/article/details/120614492
一、直接调用组件
#include<HLS/stdio.h>
#include<HLS/hls.h>
#include<assert.h>
#include<stdlib.h>
component int multiplication(int a,int b) {
return a * b;
}
int main() {
srand(0);
int i, x[10] = {
0 }, y[10] = {
0}, z[10] = {
0 };
for (i = 0; i < 10; i++) {
x[i]= rand() % 10;
y[i]= rand() % 10;
z[i]= multiplication(x[i], y[i]);
printf("%d = %d * %d \n", z[i],x[i],y[i]); //打印查看是否正确
assert(z[i] == x[i] * y[i]); //调用断言函数
}
return 0;
}
1.生成hls环境
2.使用i++ -march=x86-64 multiplication.c -v查看C语言是否编写正确。并运行生成的a.exe。
3.使用i++ -march=CycloneV multiplication.c -v -ghdl进行hls上的编写
4.运行生成的a.exe文件并运行vsim a.prj/verification/vsim.wlf进行仿真

二、使用流水线的方法
#include<HLS/stdio.h>
#include<HLS/hls.h>
#include<assert.h>
#include<stdlib.h>
component int multiplication(int a,int b) {
return a * b;
}
int main() {
srand(0);
int i, x[10] = {
0 }, y[10] = {
0}, z[10] = {
0 };
for (i = 0; i < 10; i++) {
x[i]= rand() % 10;
y[i]= rand() % 10;
// z[i]= add(x[i], y[i]);
// printf("%d = %d + %d \n", z[i],x[i],y[i]);
ihc_hls_enqueue(&z[i], &add, x[i], y[i]);
//ihc_hls_enqueue_noret(&add, x, y);
//assert(z[i] == x[i] + y[i]);
}
ihc_hls_component_run_all(add);
return 0;
}
前面三步与上面的一样,我们直接来看仿真

三、两种模式的对比
1.仿真
通过两者的仿真可以清楚的看到,我们在直接调用组件的时候启动了10次组件,而在使用流水线时,就只调用了1次组件。这大大节约了我们的硬件资源。
2.报告
报告地址:a.prj/reports/report.html

通过报告可以明显的看到,第一种方法并没有排队的组件,而第二种方法就有10个。
边栏推荐
- prometheus+blackbox-exporter+grafana 监控服务器端口及url地址
- [pyqt5 packaged as exe]
- I.MX6UL核心模块使用连载-触摸屏校准 (九)
- 1. Mx6ul core module uses serial can and buzzer test (XI)
- SQL how to return all data when the input query condition is empty
- Primary key b+ tree, secondary index b+ tree and corresponding query process analysis
- EAM系统能帮助企业做什么?
- 【红队】ATT&CK - 利用BITS服务实现持久化
- (CVPR 2019) GSPN: Generative Shape Proposal Network for 3D Instance Segmentation in Point Cloud
- (Dynamic Programming Series) sword finger offer 48. the longest substring without repeated characters
猜你喜欢

Niuke net question brushing training (I)

TCP three handshakes and four waves

I.MX6UL核心模块使用连载-RS485测试 (十)

1. Mx6ul core module serial WiFi test (VIII)

1. Mx6ul core module serial USB interface test (VI)

Yum install MySQL FAQ

Prometheus + process exporter + grafana monitor the resource usage of the process

增删改查业务的快速上手

I.MX6UL核心模块使用连载-nand flash读写测试 (三)

These practical security browser plug-ins improve your efficiency
随机推荐
LeetCode302场周赛第三题--裁剪数字后查询第 K 小的数字
prometheus+blackbox-exporter+grafana 监控服务器端口及url地址
Overview of pytoch's API
[纯理论] YOLO v4: Optimal Speed and Accuracy of Object Detection
Postman报Json序列化错误
【PyQt5打包为exe】
I.MX6UL核心模块使用连载-TF卡读写测试 (五)
必会面试题:1.浅拷贝和深拷贝_深拷贝
2022-07-17
[C language brush leetcode] 1462. curriculum IV (m)
What is JSX?
TCP三次握手四次挥手
[C language brush leetcode] 735. Planetary collision (m)
Ti AM335X工控模块使用beaglebone(bbb)的Debian系统
Monitoring of debezium synchronization debezium
How to install opengauss manually (non om mode)
obsidian移动端PC段同步
Bitmap这个“内存刺客”你要小心~
LeetCode_动态规划_中等_264.丑数 II
BigDecimal use