一、h文件设计
#ifndef FRAME_TOP_H_
#define FRAME_TOP_H_
//#include "ap_int.h"
#include "hls_stream.h"
#include "ap_axi_sdata.h"
// 定义带边带信号的 AXI4-Stream 数据类型
// 数据宽度 24 位(RGB888),用户自定义宽度为 1(用于 TUSER),其余保留为 0
//typedef ap_axiu<24, 1, 0, 0> axis_pkt_t;//综合工具不支持
//需要修改为
typedef ap_axiu<24, 1, 1, 1> axis_pkt_t;//综合工具不支持
// 像素数据类型(与 AXI4-Stream 数据位宽一致)
typedef ap_uint<24> pixel_t;
// 视频时序参数(以 1920x1080 @ 60Hz 为例,可根据实际修改)
#define H_ACTIVE 1920
#define H_FRONT 88
#define H_SYNC 44
#define H_BACK 148
#define H_TOTAL (H_ACTIVE + H_FRONT + H_SYNC + H_BACK)
#define V_ACTIVE 1080
#define V_FRONT 4
#define V_SYNC 5
#define V_BACK 36
#define V_TOTAL (V_ACTIVE + V_FRONT + V_SYNC + V_BACK)
// 顶层函数声明
void axi_stream_to_video(
hls::stream<axis_pkt_t> &input_stream, // AXI4-Stream 输入(含 TUSER, TLAST)
pixel_t &out_data, // 输出像素数据
ap_uint<1> &vsync, // 场同步输出
ap_uint<1> &hsync, // 行同步输出
ap_uint<1> &de // 数据有效输出
);
#endif // AXI_TO_VIDEO_H_
二、核心代码设计
#include "frame_top.h"
void axi_stream_to_video(
hls::stream<axis_pkt_t> &input_stream,
pixel_t &out_data,
ap_uint<1> &vsync,
ap_uint<1> &hsync,
ap_uint<1> &de