|
本帖最后由 lcytms 于 2017-2-14 11:27 编辑
先从VGA驱动逻辑模块vga.v做起吧!
新建工程文件夹vga。
新建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 rgb8 = (hflag && vflag) ? block : 8'b000_000_00;
endmodule
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?我要注册
x
|