当前位置: 首页 > news >正文

VESA时序检测模块设计verilog实现

module fps_vs_hs_de_timing_check
#(
parameter FPS             = 60,//帧率
parameter CLK_FREQ_CNT     = 74250000,//clock:单位HZ
parameter WIDTH            = 1920,//分辨率宽
parameter HIGH             = 1080//分辨率高
)
(
input            i_clk,
input            i_rst_n,

input            i_vs,
input            i_hs,

output reg            o_fps_err,
output reg            o_row_err,
output reg            o_col_err,

output reg    [31:0]    o_check_fps,
output reg    [31:0]    o_check_high,
output reg    [31:0]    o_check_width
);


reg    vs_r;
reg hs_r;

reg[31:0] col_cnt;
reg[31:0] row_cnt;


reg       start_flag;
reg[31:0] clk_cnt;
reg[31:0] frame_cnt;

always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
vs_r <= 1'b0;
hs_r <= 1'b0;
end
else begin
vs_r <= i_vs;
hs_r <= i_hs;
end
end

always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
col_cnt <= 'd0;
end
else begin
if(i_hs)begin
col_cnt <= col_cnt + 'd1;
end
else begin
col_cnt <= 'd0;
end
end
end

always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
o_check_width <= 'd0;
end
else begin
if(~i_hs & hs_r)begin
o_check_width <= col_cnt;
end
end
end


always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
row_cnt <= 'd0;
end
else if(~i_vs & vs_r)begin
row_cnt <= 'd0;
end
else if(i_vs) begin
if((~i_hs & hs_r)begin
row_cnt <= row_cnt + 'd1;
end
end
end

always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
o_check_high <= 'd0;
end
else begin
if(~i_vs & vs_r)begin
o_check_high <= row_cnt;
end
end
end

//clk_cnt
//start_flag
//frame_cnt

always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
start_flag <= 'd0;
end
else if(~vs_r & i_vs) begin
start_flag <= 1'b1;
end
end



always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
clk_cnt <= 'd0;
end
else  begin
if(clk_cnt==CLK_FREQ_CNT-1)begin
clk_cnt <= 'd0;
end
else begin
clk_cnt <= clk_cnt + 'd1;
end
end
end

always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
frame_cnt <= 'd0;
end
else if(clk_cnt ==(CLK_FREQ_CNT-1))begin
frame_cnt <= 'd0;
end
else if(clk_cnt < (CLK_FREQ_CNT-1)) begin
if(~vs_r & i_vs)begin
frame_cnt <= frame_cnt + 1;
end

end
end

always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
o_check_fps <= 'd0;
end
else if(clk_cnt ==(CLK_FREQ_CNT-1))  begin
o_check_fps <= frame_cnt;
end
end



always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
o_col_err <= 1'b0;
end
else if(o_check_width!=WIDTH) begin
o_col_err <= 1'b1;
end
else begin
o_col_err <= 1'b0;
end
end

always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
o_row_err <= 1'b0;
end
else if(o_check_high!=HIGH) begin
o_row_err <= 1'b1;
end
else begin
o_row_err <= 1'b0;
end
end

always@(posedge i_clk or negedge i_rst_n)begin
if(i_rst_n==1'b0)begin
o_fps_err <= 1'b0;
end
else if(o_check_fps>=(FPS-2)  o_check_fps<=(FPS+2)) begin//误差范围
o_fps_err <= 1'b0;
end
else begin
o_fps_err <= 1'b1;
end
end






endmodule

http://www.xdnf.cn/news/1374877.html

相关文章:

  • Ubuntu 24 Server 如何设置无线网络
  • imx6ull-驱动开发篇45——Linux 下 SPI 驱动框架简介
  • d435i相机读取镜头内参和相对之间的外参
  • 艾体宝新闻 | 98%好评率!KnowBe4 连续5年蝉联第一,现开放免费钓鱼测试等你解锁
  • 内网应用如何实现外网访问?外地通过公网地址访问内网服务器的设置方法
  • 遗传算法:模拟自然选择的优化智慧
  • Spring Boot项目集成日志系统使用完整指南
  • 欧洲数字化养殖平台 Herdwatch 借力 Iceberg + StarRocks 提升分析能力
  • 嵌入式开发学习 C++:day01
  • 动态规划:硬币兑换(有趣)
  • LeetCode - 739. 每日温度
  • 线性回归原理推导与应用(十一):多重共线性
  • 获取服务器指标的信息
  • bin log 和 redo log有什么区别
  • Mybatis总结
  • 【如何解决Java中的ClassCastException类转换异常问题】
  • 基于Matlab结合肤色检测与卷积神经网络的人脸识别方法研究
  • 基于MATLAB/Simulink的单机带负荷仿真系统搭建
  • 分布式2PC理论
  • 使用 html2canvas + jspdf 实现页面元素下载为pdf文件
  • UE5 查找组件
  • 云原生安全架构设计与零信任实践
  • 预测模型及超参数:1.传统机器学习:SVR与KNN
  • 工业网络安全:保护制造系统和数据
  • HIVE的Window functions窗口函数【二】
  • 【Hadoop】Zookeeper、HBase、Sqoop
  • 全球位置智能软件CR10为73%,市场集中度高
  • Java中高效获取IP地域信息方案全解析:从入门到生产实践
  • jQuery版EasyUI的ComboBox(下拉列表框)问题
  • JS(面试)