news 2026/6/8 6:24:12

HLS用于应用加速

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
HLS用于应用加速


一、why FPGA
1.FPGA可以自定义数据类型
2.FPGA可以自定义数据路径,dataflow or pipeline
3.有效的memory访问,可以random access,FIFO,stack
4.parallelism并行化没有限制

二、FPGA开发趋于简单化
1.可以使用c/c++/system c,opencl,python来开发FPGA
2.tenssorflow

三、HLS代码结构
1.top-level函数定义
2.interface接口定义
3.dataflow the processing
4.internal streaming variable变量声明
5.synchronize to start of frame帧同步开始
6.covert from axi stream to xf::Mat

四、HLS让FPGA开发变得简单

五、并行化
并行化有两种
1.data-level parallesim
2.task-level parallelism
3.Instruction(operator) level parallelsim
在HLS设计中需要考虑的data-level和task-level的并行化,
不需要考虑指令或者操作的并行化,指令和操作的并行化是HLS帮我们做了。

六、CPU和FPGA
1.cpu使用得地址空间都是虚拟的地址空间
2.FPGA使用的地址空间都是physical address space

七、组合逻辑 + 时序逻辑模型设计

1.单个组合逻辑+时序逻辑设计模型


void comb_sequential_top
(
ap_uint<32> in1,
ap_uint<32> in2,
ap_uint<32> *out
){
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS INTERFACE ap_none port=in1
#pragma HLS INTERFACE ap_none port=in2
#pragma HLS INTERFACE ap_none port=out
static int L;//flip-flop

*out = in1 * L;//read current-L
L = in2 + L;//assign next-L
}

2.多个组合逻辑+时序逻辑模型

void sub1_func(
ap_uint<32> in1,
ap_uint<32> in2,
ap_uint<32> *out
){
#pragma HLS INLINE off
static int L;//flip-flop

*out = in1 * L;//read current-L
L = in2 + L;//assign next-L
}

void sub2_func(
ap_uint<32> in1,
ap_uint<32> in2,
ap_uint<32> *out
){
#pragma HLS INLINE off
static int L;//flip-flop

*out = in1 * L;//read current-L
L = in2 + L;//assign next-L
}


void comb_sequential_top
(
ap_uint<32> in1,
ap_uint<32> *out
){
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS INTERFACE ap_none port=in1
#pragma HLS INTERFACE ap_none port=out

ap_uint<32> tmp1;
ap_uint<32> tmp2;

sub1_func(in1,tmp2,&tmp1);

sub2_func(tmp1,tmp1,&tmp2);

*out = tmp2;

}

上述这个代码综合设计,发现综合的rtl代码,并没有实现两次组合逻辑+时序逻辑模块,为什么??

template<int N>
void sub1_func(
ap_uint<32> in1,
ap_uint<32> in2,
ap_uint<32> *out
){
#pragma HLS INLINE off
static int L;//flip-flop

*out = in1 * L;//read current-L
L = in2 + L;//assign next-L
}

template<int N>
void sub2_func(
ap_uint<32> in1,
ap_uint<32> in2,
ap_uint<32> *out
){
#pragma HLS INLINE off
static int L;//flip-flop

*out = in1 * L;//read current-L
L = in2 + L;//assign next-L
}


void comb_sequential_top
(
ap_uint<32> in1,
ap_uint<32> *out
){
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS INTERFACE ap_none port=in1
#pragma HLS INTERFACE ap_none port=out

ap_uint<32> tmp1;
ap_uint<32> tmp2;

sub1_func<1>(in1,tmp2,&tmp1);

sub1_func<2>(tmp1,tmp1,&tmp2);

*out = tmp2;

}
使用模板函数好像实现的功能也不太对!!!

这个后续专门对这块设计进行说明!!!

3.two-module

void comb_sequential_top
(
ap_uint<32> in1,
ap_uint<32> *out
){
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS INTERFACE ap_none port=in1
#pragma HLS INTERFACE ap_none port=out

ap_uint<32> tmp1;
ap_uint<32> tmp2;

sub1_func(in1,in1,&tmp1);

sub1_func(tmp1,tmp1,&tmp2);

*out = tmp2;

}

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/7 8:08:59

Open-AutoGLM共享机制深度解析:5大核心策略提升团队AI开发效率

第一章&#xff1a;Open-AutoGLM共享机制的核心价值Open-AutoGLM 的共享机制重新定义了大模型协作开发的边界&#xff0c;其核心价值在于促进知识、算力与模型能力的高效流通。该机制通过去中心化的贡献评估体系&#xff0c;确保每位参与者的输出——无论是训练数据、微调权重还…

作者头像 李华
网站建设 2026/6/8 9:21:33

Open-AutoGLM团队共享方案全曝光(仅限内部流出版本)

第一章&#xff1a;Open-AutoGLM团队共享方案概述Open-AutoGLM 是一个面向自动化代码生成与团队协作的开源框架&#xff0c;旨在通过大语言模型能力提升开发效率。该方案支持多成员协同编辑、版本控制集成与智能补全建议&#xff0c;适用于中大型软件开发团队在统一语义理解基础…

作者头像 李华
网站建设 2026/6/9 5:07:45

Excalidraw图形元数据管理

Excalidraw图形元数据管理 在远程协作和敏捷开发成为常态的今天&#xff0c;团队对可视化工具的需求早已超越“画图”本身。一张架构草图不仅要能快速表达想法&#xff0c;还应具备可追溯、可交互、可被机器理解的能力。传统绘图软件往往过于沉重或封闭&#xff0c;而Excalidra…

作者头像 李华
网站建设 2026/6/8 4:24:59

Excalidraw与Typst结合:学术绘图新组合

Excalidraw与Typst结合&#xff1a;学术绘图新组合 在撰写技术文档、论文或系统设计说明书时&#xff0c;你是否曾为一张架构图反复调整数小时&#xff1f;是否因为团队成员无法协同编辑TikZ代码而延误交付&#xff1f;又或者&#xff0c;看着LaTeX生成的规整图表&#xff0c;总…

作者头像 李华