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

相关推荐
LabVIEW开发1 天前
LabVIEW与FPGA超声探伤
fpga开发·labview·labview功能
cycf1 天前
FPGA设计中的数据存储
fpga开发
FPGA之旅2 天前
FPGA从零到一实现FOC(一)之PWM模块设计
fpga开发·dubbo
XMAIPC_Robot2 天前
基于ARM+FPGA的光栅尺精密位移加速度测试解决方案
arm开发·人工智能·fpga开发·自动化·边缘计算
cycf2 天前
状态机的设计
fpga开发
szxinmai主板定制专家2 天前
【精密测量】基于ARM+FPGA的多路光栅信号采集方案
服务器·arm开发·人工智能·嵌入式硬件·fpga开发
千宇宙航3 天前
闲庭信步使用SV搭建图像测试平台:第三十二课——系列结篇语
fpga开发
千宇宙航3 天前
闲庭信步使用SV搭建图像测试平台:第三十一课——基于神经网络的手写数字识别
图像处理·人工智能·深度学习·神经网络·计算机视觉·fpga开发
小眼睛FPGA3 天前
【RK3568+PG2L50H开发板实验例程】FPGA部分/紫光同创 IP core 的使用及添加
科技·嵌入式硬件·ai·fpga开发·gpu算力
forgeda4 天前
如何将FPGA设计验证效率提升1000倍以上(2)
fpga开发·前沿技术·在线调试·硬件断点·时钟断点·事件断点