ARINC818_FILE

module ARINC818_FILE(

input clk,

input rst_n,

input [31:0] container_cnt, // 容器计数

input [15:0] advb_frame_cnt, // advb帧计数

input advb_frame_last, // ADVB最后一帧

input [15:0] img_width, // 图像宽度

input [15:0] img_high, // 图像高度

output reg [31:0] sofi, // 首帧起始定界符

output reg [31:0] sofn, // 非首帧起始定界符

output reg [31:0] eofn, // 非最后帧结束定界符

output reg [31:0] eoft, // 最后帧结束定界符

output reg [31:0] advb_idle, // advb帧间隙字符

output reg [31:0] frame_words0_r_ctl,

output reg [31:0] frame_words0_dst_id,

output reg [31:0] frame_words1_cs_ctl,

output reg [31:0] frame_words1_src_id,

output reg [31:0] frame_words2_type,

output reg [31:0] frame_words2_f_ctl,

output reg [31:0] frame_words3_seq_id,

output reg [31:0] frame_words3_df_ctl,

output reg [31:0] frame_words3_seq_cnt,

output reg [31:0] frame_words4_OX_RX_ID,

output reg [31:0] frame_words5_parameter,

output reg [31:0] container_words0_cnt,

output reg [31:0] container_words1_id,

output reg [31:0] container_words2_time,

output reg [31:0] container_words3_time,

output reg [31:0] container_words4_fps,

output reg [31:0] container_words4_rate

);

// K28.5, D21.5, D22.2编码示例(ARINC 818协议定义的字符编码)

localparam [7:0] K28_5 = 8'hBC; // 示例码,真实协议确认

localparam [7:0] D21_5 = 8'h95;

localparam [7:0] D22_2 = 8'hB5;

localparam [31:0] SOFI_VAL = {K28_5, D21_5, D22_2, D22_2};

localparam [31:0] SOFN_VAL = {K28_5, D21_5, D21_5, D22_2};

localparam [31:0] EOFN_VAL = {K28_5, D22_2, D21_5, D21_5};

localparam [31:0] EOFT_VAL = {K28_5, D22_2, D22_2, D21_5};

localparam [31:0] ADVB_IDLE_VAL = 32'hBC95_B5B5; // 休止符

// 初始化和状态更新

always @(posedge clk or negedge rst_n) begin

if (!rst_n) begin

sofi <= SOFI_VAL;

sofn <= SOFN_VAL;

eofn <= EOFN_VAL;

eoft <= EOFT_VAL;

advb_idle <= ADVB_IDLE_VAL;

// 这里frame_words*和container_words*初始化为0或默认值

frame_words0_r_ctl <= 32'd0;

frame_words0_dst_id <= 32'd0;

frame_words1_cs_ctl <= 32'd0;

frame_words1_src_id <= 32'd0;

frame_words2_type <= 32'd0;

frame_words2_f_ctl <= 32'd0;

frame_words3_seq_id <= 32'd0;

frame_words3_df_ctl <= 32'd0;

frame_words3_seq_cnt <= 32'd0;

frame_words4_OX_RX_ID <= 32'd0;

frame_words5_parameter <= 32'd0;

container_words0_cnt <= 32'd0;

container_words1_id <= 32'd0;

container_words2_time <= 32'd0;

container_words3_time <= 32'd0;

container_words4_fps <= 32'd0;

container_words4_rate <= 32'd0;

end else begin

// 根据advb_frame_last控制使用SOFI或SOFN

sofi <= advb_frame_last ? SOFI_VAL : sofi;

sofn <= (!advb_frame_last) ? SOFN_VAL : sofn;

eofn <= (!advb_frame_last) ? EOFN_VAL : eofn;

eoft <= advb_frame_last ? EOFT_VAL : eoft;

// 赋值frame_words,示例根据计数器简单赋值,可根据协议详细填写

frame_words0_r_ctl <= {16'd0, advb_frame_cnt}; // 示例:下16位为帧计数

frame_words0_dst_id <= 32'h0000_0001; // 目的ID示例

frame_words1_cs_ctl <= 32'h0000_0000; // 控制字段示例

frame_words1_src_id <= 32'h0000_0002; // 源ID示例

frame_words2_type <= 32'h0000_0001; // 帧类型示例

frame_words2_f_ctl <= 32'h0000_0000; // 帧控制示例

frame_words3_seq_id <= 32'h0000_0000; // 序列ID示例

frame_words3_df_ctl <= 32'h0000_0000; // DF控制示例

frame_words3_seq_cnt <= {16'd0, advb_frame_cnt}; // 序列计数示例

frame_words4_OX_RX_ID <= 32'h0000_0000; // OX/RX示例

frame_words5_parameter <= {img_width, img_high}; // 图片分辨率打包示例

// 容器相关信息直接赋值

container_words0_cnt <= container_cnt;

container_words1_id <= 32'h0000_0001; // 容器ID示例

container_words2_time <= 32'd0; // 时间戳示例

container_words3_time <= 32'd0; // 时间戳示例

container_words4_fps <= 32'd60; // 帧率示例

container_words4_rate <= 32'd1000; // 码率示例

end

end

endmodule

相关推荐
9527华安17 小时前
Xilinx系列FPGA纯逻辑实现HDMI2.0视频收发,基于GTY高速接口,支持4K@60Hz分辨率,提供7套工程源码和技术支持
fpga开发·高速接口·gty·hdmi2.0·4k
GateWorld17 小时前
《从零掌握MIPI CSI-2: 协议精解与FPGA摄像头开发实战》-- 实战基于CSI2 Rx 构建高性能摄像头输入系统
fpga开发·mipi csi2
hahaha60162 天前
模拟信号三极管等效模型
fpga开发
Ronin-Lotus3 天前
嵌入式硬件篇---常见电平标准
嵌入式硬件·fpga开发·常见的电平标准
燎原星火*3 天前
杜勇书籍摘抄
fpga开发
hahaha60163 天前
低温对FPGA的核心影响
fpga开发
FF-Studio3 天前
【DSP笔记 · 第5章】数字滤波器的蓝图:从数学公式到硬件实现的艺术
笔记·fpga开发·自动化·音视频·音频·信号处理
JINX的诅咒3 天前
FPGA多通道卷积加速器:从零构建手写识别的硬件引擎
嵌入式硬件·fpga开发·cnn·开源
tiantianuser3 天前
RDMA简介7之RoCE v2可靠传输
服务器·fpga开发·verilog·xilinx·rdma·可编程逻辑
FF-Studio3 天前
万物皆数:构建数字信号处理的数学基石
算法·数学建模·fpga开发·自动化·音视频·信号处理·dsp开发