时钟用的是33.333Mhz, 50M锁相环倍频分频得到,
大概每隔1秒显示横条,竖条,方块,青色,蓝色,绿色,红色等;
代码经过本人几天调试终于完成,这个驱动板的电路原理图在ouravr上发过,大家有兴趣可以找找,我懒得上传了。
`timescale 1ns / 1ps
//-----------------------------------------------------------------------------
module AT070TN92(CLK,DCLK,
HS,VS,
MODE,
DE,
LR,UD,
KEY,
LCDR,LCDG,LCDB,
DITHB,BLPWM,RESET);
input CLK;
input KEY;
output DCLK;
output HS;
output VS;
output MODE;
output DE;
output LR;
output UD;
output RESET;
output DITHB;
output BLPWM;
output [7:0] LCDR;
output [7:0] LCDG;
output [7:0] LCDB;
// Horizontal Signals:
parameter
thpw = 11'd8, //HS Pulse Width,1-40 DCLK
thb = 11'd46, //HS Blanking 46 DCLK = HS Pulse Width + HS Back Porch
thd = 11'd800, //Horizontal Display Area,800 DCLK
thfp = 11'd210, //HS Front Porch,16-210-354 DCLK
th = (thb+thd+thfp), //One Horizontal Line = HS Blanking (thb) + Horizontal Display Area (thd) + HS Front Porch (thfp)
// Vertical Signals:
tvpw = 11'd3, //Vs Pulse Width 1-20 TH
tvb = 11'd23, //Vs Blanking 23 TH = Vs Pulse Width + VS Back Porch
tvd = 11'd480, //Vertical Dsiplay Area 480 TH
tvfp = 11'd22, //Vs Front Porch 7-22-147 TH
tv = (tvb+tvd+tvfp); //Vs Blanking (tvb) + Vertical Dsiplay Area (tvd) + Vs Front Porch (tvfp
wire HS;
wire VS;
//reg [7:0] LCDR;
//reg [7:0] LCDG;
//reg [7:0] LCDB;
wire [7:0] LCDR;
wire [7:0] LCDG;
wire [7:0] LCDB;
reg [9:0] BL_CNT = 0;
reg HS_R = 1;
reg VS_R = 1;
reg [10:0] hcount = th-1;
reg [10:0] vcount = tv-1;
reg videoh = 0;
reg videov = 0;
wire videon = 0;
reg [9:0] column = 10'b0;
reg [8:0] row = 9'b0;
reg [23:0] v_data;
reg [23:0] h_data;
reg [2:0] dismode =3'b0;
reg [31:0] data;
reg [24:0] switchsync;
assign DITHB = 0;
assign RESET = 1;
assign DCLK = CLK;
assign BLPWM = (BL_CNT >=200)? 1'b1 : 1'b0;
assign HS = HS_R;
assign VS = VS_R;
assign DE = 0;
assign MODE = 0;
assign UD = 0;
assign LR = 1;
assign videon = videoh && videov ;
assign LCDR = data[31:16] ;
assign LCDG = data[15:8] ;
assign LCDB = data[7:0] ;
//TFT LCD LED PW
always @(posedge CLK)
begin
if(BL_CNT < 700)
BL_CNT <= BL_CNT + 1'b1;
else
BL_CNT <= 1'b0;
end
//TFT hcount, vcount siganl
always @(posedge CLK)
begin
if(hcount==(th-1'b1))
begin
hcount <= 1'b0;
if(vcount==(tv-1'b1))
vcount <= 1'b0;
else
vcount <= vcount+ 1'b1;
end
else
hcount <= hcount+1'b1;
end
//videoh signal
always @(hcount)
begin
if( (hcount>=46) && (hcount<=846) )
videoh <= 1'b1;
else
videoh <= 1'b0;
end
//videov signal
always @(vcount)
begin
if( (vcount>=23) && (vcount<=503) )
videov <= 1'b1;
else
videov <= 1'b0;
end
always @(posedge CLK)
begin
if(videon==1'b1)
begin
column <= column+10'b1;
row <= row+9'b1;
end
else
begin
column <= 10'b0;
row <= 9'b0;
end
end
// hsync , vsync
always @(posedge CLK)
begin
HS_R <= ( hcount >= thpw);
VS_R <= ( vcount >= tvpw);
end
always @(posedge CLK)
begin
if( hcount <=146)
begin
h_data <={8'd0,8'd0,8'd0} ;
end
else if ( hcount <=246 )
begin
h_data <={8'd0,8'd0,8'd255} ;
end
else if (hcount <=346)
begin
h_data <={8'd0,8'd255,8'd0} ;
end
else if ( hcount <=446 )
begin
h_data <={8'd0,8'd255,8'd255} ;
end
else if ( hcount <=546)
begin
h_data <={8'd255,8'd0,8'd0} ;
end
else if (hcount <=646 )
begin
h_data <={8'd255,8'd0,8'd255} ;
end
else if (hcount <=746)
begin
h_data <={8'd255,8'd255,8'd0} ;
end
else
begin
h_data <={8'd255,8'd255,8'd255} ;
end
end
always @(posedge CLK)
begin
if(vcount<=83)
begin
v_data <={8'd0,8'd0,8'd0} ;
end
else if(vcount<=143)
begin
v_data <={8'd0,8'd0,8'd255} ;
end
else if(vcount<=203)
begin
v_data <={8'd0,8'd255,8'd0} ;
end
else if(vcount<=263)
begin
v_data <={8'd0,8'd255,8'd255} ;
end
else if(vcount<=323)
begin
v_data <={8'd255,8'd0,8'd0} ;
end
else if(vcount<=383)
begin
v_data <={8'd255,8'd0,8'd255} ;
end
else if(vcount<=443)
begin
v_data <={8'd255,8'd255,8'd0} ;
end
else
begin
v_data <={8'd255,8'd255,8'd255} ;
end
end
// key vaule inc
//always @(posedge KEY)
//begin
// dismode <= dismode+1'b1;
//end
//
always @(posedge CLK)
begin
switchsync <= switchsync + 1'b1;
end
//
always @(posedge switchsync[24])
begin
dismode <= dismode+3'b1;
end
always @(posedge CLK)
begin
case(dismode)
3'd0: data <= h_data;
3'd1: data <= v_data;
3'd2: data <= (v_data ^ h_data);
3'd3: data <= (v_data ~^ h_data);
3'd4: data <= {8'd0,8'd255,8'd255};
3'd5: data <= {8'd0,8'd0,8'd255};
3'd6: data <= {8'd0,8'd255,8'd0};
3'd7: data <= {8'd255,8'd0,8'd0};
3'd7: data <= {8'd255,8'd255,8'd0};
endcase
end
endmodule
用户1830132 2015-3-12 13:55
用户1324799 2013-8-6 16:42
用户1651448 2013-8-5 13:39
用户525326 2009-11-19 11:29
用户1353831 2009-11-5 10:41
用户187751 2009-4-8 19:46
用户506238 2009-2-11 10:42
用户151646 2008-10-13 20:45
用户170041 2008-9-13 20:31
用户170041 2008-9-13 20:30