|
修改VGA驱动逻辑模块vga.v。
使之显示红绿蓝三色彩条。屏幕三等分,从上至下依次显示红、绿、蓝。
修改vga.v(显示彩条)文件如下。
module vga(clk, rst_n, rgb8, hsync, vsync);
input clk, rst_n;
output [7:0] rgb8;
output hsync, vsync;
reg [31:0] hcnt, vcnt;
wire hflag, vflag;
///// 800*600*60 40.0MHz = 1056(128+88+800+40) * 628(4+23+600+1) * 60Hz
parameter ha = 128,
hb = 88,
hc = 800,
hd = 40,
he = 1056;
parameter va = 4,
vb = 23,
vc = 600,
vd = 1,
ve = 628;
localparam hab = ha + hb,
hac = ha + hb + hc;
localparam vab = va + vb,
vac = va + vb + vc;
always @ (posedge clk or negedge rst_n)
begin
if (!rst_n)
begin
hcnt <= 0;
vcnt <= 0;
end
else
begin
if ((vcnt == ve - 1) && (hcnt == he - 1))
begin
hcnt <= 0;
vcnt <= 0;
end
else
begin
if (hcnt == he - 1)
begin
hcnt <= 0;
vcnt <= vcnt + 1;
end
else
hcnt <= hcnt + 1;
end
end
end
assign hsync = (hcnt < ha) ? 1'b0 : 1'b1;
assign vsync = (vcnt < va) ? 1'b0 : 1'b1;
assign hflag = ((hcnt >= hab) && (hcnt < hac)) ? 1'b1 : 1'b0;
assign vflag = ((vcnt >= vab) && (vcnt < vac)) ? 1'b1 : 1'b0;
wire [7:0] block;
// assign block = 8'b111_000_00;
assign block = (vcnt-vab<200) ? 8'b111_000_00 : (vcnt-vab<400) ? 8'b000_111_00 : 8'b000_000_11;
assign rgb8 = (hflag && vflag) ? block : 8'b000_000_00;
endmodule
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?我要注册
x
|