本人菜鸟一枚,刚学
FPGA,在做VGA显示程序的时候总是不出颜 {MOD},但是屏幕被点亮了,只是显示不出颜 {MOD},已经调了好几天了,是在没辙啊,求大神的帮助,谢谢了!
这是我的程序,程序是从网上找的然后自己作了些修改:640×480@60
module displayVGA( rst_n,
clk,
r,
g,
b,
hsync,
vsync,
valid,
x_cnt,
y_cnt
);
input rst_n ;
input clk ;
output hsync ;
output vsync ;
output valid ;
output [10:0] x_cnt ;
output [10:0] y_cnt ;
output[7:0] r;
output[7:0] g;
output[7:0] b;
reg hsync ;
reg vsync ;
reg valid ;
reg [9:0] x_cnt ;
reg [9:0] y_cnt ;
reg clk_vga;
assign r=valid?8'hff:0;
assign g=valid?8'hff:0;
assign b=valid?8'hff:0;
always @ ( posedge clk or negedge rst_n )
if ( !rst_n )
clk_vga<=0;
else
clk_vga<=~clk_vga;
always @ ( posedge clk_vga or negedge rst_n )
if ( !rst_n )
x_cnt <= 10'd0;
else if ( x_cnt ==11'd799 )
x_cnt <= 10'd0;
else
x_cnt <= x_cnt + 1'b1;
always @ ( posedge clk_vga or negedge rst_n )
if ( !rst_n )
y_cnt <= 10'd0;
else if ( y_cnt == 11'd524 )
y_cnt <= 10'd0;
else if ( x_cnt == 11'd799 )
y_cnt <= y_cnt + 1'b1;
always @ ( posedge clk_vga or negedge rst_n )
begin
if ( !rst_n )
begin
hsync <= 1'b1;
end
else
begin
if(x_cnt==0)
hsync <= 0;
else if(x_cnt==11'd96)
hsync <= 1;
end
end
always @ ( posedge clk_vga or negedge rst_n )
begin
if ( !rst_n )
begin
vsync <= 1'b1;
end
else
begin
if(x_cnt==0)
vsync <= 0;
else if(x_cnt==11'd2)
vsync <= 1;
end
end
always @ ( posedge clk_vga or negedge rst_n )
if ( !rst_n )
valid <= 1'b0;
else
valid <= ( ( x_cnt > 11'd144 ) && ( x_cnt < 11'd784) &&
( y_cnt > 11'd35) && ( y_cnt < 11'd515) );
endmodule
一周热门 更多>