|
楼主 |
发表于 2014-3-10 23:52:07
|
显示全部楼层
本帖最后由 zcy0517 于 2014-3-11 09:26 编辑
module VGA(clk,db,r,g,b,hs,vs,addr);
input clk;
input db;
output r,g,b,hs,vs;
output addr;
reg hs,vs;
reg[10:0] count_v,count_h;
reg[18:0] addr;
wire[11:0] db;
reg flag;
wire[3:0] r;
wire[3:0] g;
wire[3:0] b;
assign{r,g,b}=(flag==1?db[11:0]:0);
always @(posedge clk)
begin
if (count_h==800)
count_h<=0;
else
count_h<=count_h+1;
end
always@(posedge clk)
begin
if (count_v==525)
count_v<=0;
else
count_h<=count_v+1;
end
always@(posedge clk)
begin
if (count_h==0) hs<=0;
if (count_h==96) hs<=1;
if (count_v==0) vs<=0;
if (count_v==2) vs<=1;
if (count_v>2&&count_v<515)
begin
if (count_h>144&&count_h<784)
begin
flag<=1;
addr<=addr+1;
end
else flag<=0;
else addr<=0;
end
endmodule
end
end
这个是参考以上资料和5楼大哥的VGA电路图写的程序,ov7670 640*480 |
|