名称:VGA显示彩色条纹Basys3开发板verilog代码(代码在文末下载)
软件:VIVADO
语言:Verilog
代码功能:
编写 VGA 驱动, 使用 FPGA 开发板驱动 VGA 显示器显示十色等宽彩条,VGA 显示模式为 640x480@60。
FPGA代码Verilog/VHDL代码资源下载:www.hdlcode.com
本代码已在Basys3开发板验证,开发板如下,其他开发板可以修改管脚适配:
工程文件
程序文件
RTL图
程序编译
管脚分配
部分代码展示:
//彩色条纹控制模块 module?imageGenerator?( inputi_clk, input[10:0]i_x, input[9:0]i_y, output[3:0]o_blue, output[3:0]o_green, output[3:0]o_red ); localparam?display_x?=?640; localparam?display_y?=?480; reg?[3:0]?blue=?4'h0; reg?[3:0]?red=?4'h0; reg?[3:0]?green=?4'h0; //将3种颜色进行排列组合 always?@(posedge?i_clk?)?begin if?(i_x?<?display_x/8)?begin//白色--1/8 blue??<=?4'h0;//蓝色 green?<=?4'h0;//绿色 red?<=?4'h0;//红色 end?else?if?(?display_x/8?<=?i_x?&&?i_x?<=?display_x/4?)begin//?1/8~2/8 blue??<=?4'h0; ????????green???<=?4'h0; ????????red?????<=?4'hf; end?else?if?(?display_x/4?<=?i_x?&&?i_x?<=?3*display_x/8?)begin//?2/8~3/8 ????????blue????<=?4'h0; ????????green???<=?4'hf; ????????red?????<=?4'h0; end?else?if?(?3*display_x/8?<=?i_x?&&?i_x?<=?display_x/2?)begin//?3/8~4/8 ????????blue????<=?4'h0; ????????green???<=?4'hf; ????????red?????<=?4'hf; end?else?if?(?display_x/2?<=?i_x?&&?i_x?<=?5*display_x/8?)begin//?4/8~5/8 ????????blue????<=?4'hf; ????????green???<=?4'h0; ????????red?????<=?4'h0; end?else?if?(?5*display_x/8?<=?i_x?&&?i_x?<=?6*display_x/8?)begin//?5/8~6/8 ????????blue????<=?4'hf; ????????green???<=?4'h0; ????????red?????<=?4'hf; end?else?if?(?6*display_x/8?<=?i_x?&&?i_x?<=?7*display_x/8)begin//?6/8~7/8 blue??<=?4'hf; green?<=?4'hf; red?<=?4'h0; end?else?begin//?7/8~8/8 blue??<=?4'hf; green?<=?4'hf; red?<=?4'hf; end end assign?o_blue=?blue; assign?o_red=?red; assign?o_green=?green; endmodule
点击链接获取代码文件:http://www.hdlcode.com/index.php?m=home&c=View&a=index&aid=289
阅读全文
969