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

相关推荐
风_峰20 小时前
Ubuntu Linux SD卡分区操作
嵌入式硬件·ubuntu·fpga开发
FPGA_Linuxer21 小时前
FPGA 40 DAC线缆和光模块带光纤实现40G UDP差异
网络协议·fpga开发·udp
风_峰1 天前
Petalinux相关配置——ZYNQ通过eMMC启动
嵌入式硬件·ubuntu·fpga开发
风_峰1 天前
【ZYNQ开发篇】Petalinux和电脑端的静态ip地址配置
网络·嵌入式硬件·tcp/ip·ubuntu·fpga开发
碎碎思1 天前
一块板子,玩转 HDMI、USB、FPGA ——聊聊开源项目 HDMI2USB-Numato-Opsis
fpga开发
ooo-p2 天前
FPGA学习篇——Verilog学习Led灯的实现
学习·fpga开发
嵌入式-老费2 天前
Zynq开发实践(FPGA之选择开发板)
fpga开发
风_峰2 天前
PuTTY软件访问ZYNQ板卡的Linux系统
linux·服务器·嵌入式硬件·fpga开发
电子凉冰2 天前
FPGA入门-状态机
fpga开发
Aczone282 天前
硬件(十)IMX6ULL 中断与时钟配置
arm开发·单片机·嵌入式硬件·fpga开发