网站建设岗位将来有什么发展,wordpress安装方式,国外建设工程网站,有ip地址如何做网站一、方块移动原理 二、实验任务 使用FPGA开发板上的HDMI接口在显示器上显示一个不停移动的方块#xff0c;要求方块移动到边界处时能够改变移动方向。显示分辨率为800*480#xff0c;刷新速率为90hz。#xff08;480p分辨率为800*480#xff0c;像素时钟频率Vga_clk 800x4…一、方块移动原理 二、实验任务 使用FPGA开发板上的HDMI接口在显示器上显示一个不停移动的方块要求方块移动到边界处时能够改变移动方向。显示分辨率为800*480刷新速率为90hz。480p分辨率为800*480像素时钟频率Vga_clk 800x480x90 33264000 ≈33.3Mhz误差忽略不计
三、程序设计
1、video_display框图: timescale 1ns / 1psmodule video_display(input pixel_clk ,//驱动时钟input sys_rst_n ,//复位信号 input [10:0] pixel_xpos ,//像素点横坐标input [10:0] pixel_ypos ,//像素点纵坐标output reg [23:0] pixel_data //像素点数据);parameter H_DISP 11d800 ; //分辨率 行
parameter V_DISP 11d480 ; //分辨率 列
parameter DIV_CNT 22d750000 ; //分辨率计数器localparam SIDE_W 11d40 ; //屏幕边框宽度
localparam BLOCK_W 11d20 ; //方块宽度
localparam BLUE 24h0000ff ; //屏幕边框颜色 蓝色
localparam WHITE 24hffffff ; //背景颜色 白色
localparam BLACK 24h000000 ; //方块颜色 黑色reg [10:0] block_x SIDE_W ; //方块左上角横坐标
reg [10:0] block_y SIDE_W ; //方块左上角纵坐标
reg [21:0] div_cnt ; //时钟分频计数器
reg h_direct ; //方块水平位移方向 1右移 0左移
reg v_direct ; //方块竖直位移方向 1向下 0向上 wire move_en ; //方块移动使能信号 频率100hzassign move_en (div_cnt DIV_CNT - 1d1) ? 1d1 : 1d0;//时钟计数器,实现时钟分频
always (posedge pixel_clk or negedge sys_rst_n ) beginif (!sys_rst_n) begindiv_cnt 22d0; end else beginif (div_cnt DIV_CNT - 1d1) begin div_cnt div_cnt 1d1;end else begindiv_cnt 22d0; //技术到10ms清零endend
end//当方块移动到边界时改变移动方向always (posedge pixel_clk or negedge sys_rst_n) beginif (!sys_rst_n) beginh_direct 1b1; //方块初始水平向右移动v_direct 1b1; //方块初始竖直向下移动end else beginif (block_x SIDE_W 1b1) begin //到达左边界水平向右h_direct 1b1;end else begin //到达有边界水平向左 if(block_x H_DISP - SIDE_W - BLOCK_W 1d1)beginh_direct 1b0; endelse beginh_direct h_direct;endendif (block_y SIDE_W 1b1) begin //到达上边界竖直向下v_direct 1b1;end else begin //到达下边界竖直向上if(block_y V_DISP - SIDE_W - BLOCK_W 1b1)begin v_direct 1b0; endelse beginv_direct v_direct;endend endend//根据方块移动方向改变横纵坐标
always (posedge pixel_clk or negedge sys_rst_n ) beginif (!sys_rst_n) begin block_x SIDE_W 1b1; //方块初始位置横坐标block_y SIDE_W 1b1; //方块初始位置纵坐标end else if(move_en 1b1)beginif (h_direct 1b1) beginblock_x block_x 1b1; //方块向右移动end else beginblock_x block_x -1b1; //方块向左移动endif (v_direct 1b1) beginblock_y block_y 1b1; //方块向下移动 end else beginblock_y block_y -1b1; //方块向上移动endendelse beginblock_x block_x;block_y block_y;end
end//对区域给出颜色数据
always (posedge pixel_clk or negedge sys_rst_n ) beginif (!sys_rst_n) beginpixel_data BLACK;end else beginif ((pixel_xpos SIDE_W) || (pixel_xpos H_DISP - SIDE_W) || (pixel_ypos SIDE_W) || (pixel_ypos V_DISP - SIDE_W)) beginpixel_data BLUE;end else beginif ((pixel_xpos block_x -1b1) (pixel_xpos block_x BLOCK_W - 1b1) (pixel_ypos block_y) (pixel_ypos block_y BLOCK_W - 1b1)) beginpixel_data BLACK;end else beginpixel_data WHITE;endend end
endendmodule其他部分完全延用上一章代码
HDMI彩条显示——FPGA学习笔记12-CSDN博客
2、整体代码框架 3、bug更正
上一章中该部分表述错误 实际应为800*480*90 34560000约等于33.3Mhz
四、仿真分析 五、下载验证 六、总结