(1)Visio视图:
(2)控制模块Verilog代码:
module tft_ctrl(input clk_33M ,input reset_n ,input [23:0] data_in ,output [9:0] hang ,output [9:0] lie ,output hsync ,output vsync ,output [23:0] rgb_tft ,output tft_bl ,output tft_clk ,output tft_DE );reg [10:0] hang_cnt ;reg [9:0] v_cnt ;wire data_vaild ;parameter H_SYNC = 128 ;parameter H_BACK = 88 ;parameter H_VAILD = 800 ;parameter H_FRONT = 40 ;parameter H_TOTAL = 1056 ;parameter V_SYNC = 2 ;parameter V_BACK = 33 ;parameter V_VAILD = 480 ;parameter V_FRONT = 10 ;parameter V_TOTAL = 525 ;//行计数器设计always@(posedge clk_33M or negedge reset_n)if(!reset_n)hang_cnt <= 11'd0;else if(hang_cnt == H_TOTAL - 11'd1)hang_cnt <= 11'd0;else hang_cnt <= hang_cnt + 11'd1;//场计数器设计always@(posedge clk_33M or negedge reset_n)if(!reset_n)v_cnt <= 10'd0;else if ((v_cnt == V_TOTAL - 10'd1) && (hang_cnt == H_TOTAL - 11'd1))v_cnt <= 10'd0;else if(hang_cnt == H_TOTAL - 11'd1)v_cnt <= v_cnt + 10'd1;else v_cnt <= v_cnt;//数据有效信号设计assign data_vaild = (hang_cnt >= H_SYNC + H_BACK) && (hang_cnt < H_SYNC + H_BACK + H_VAILD)&& (v_cnt >= V_SYNC + V_BACK) && (v_cnt < V_SYNC + V_BACK + V_VAILD);//行、列信号设计 assign hang = ( data_vaild ) ? (hang_cnt - H_SYNC - H_BACK + 1'd1) : 10'd0;assign lie = ( data_vaild ) ? (v_cnt - V_SYNC - V_BACK + 1'd1) : 10'd0; //行同步、场同步信号设计assign hsync = (hang_cnt >= H_SYNC);assign vsync = (v_cnt >= V_SYNC);//rgb_tft、tft_bl、tft_clk、tft_DE信号设计assign rgb_tft = (data_vaild) ? data_in : 24'd0;assign tft_bl = 1'd1;assign tft_clk = clk_33M;assign tft_DE = data_vaild;endmodule
(3)仿真代码:
`timescale 1ns / 1psmodule tft_ctrl_tb;reg clk ;
reg reset_n ;
wire [23:0] data_in ;wire locked ;
wire clk_33M ;wire [9:0] hang ;
wire [9:0] lie ;
wire hsync ;
wire vsync ;
wire [23:0] rgb_tft ;
wire tft_bl ;
wire tft_clk ;
wire tft_DE ;initial clk = 1'd1;
always #10 clk = ~clk;initial beginreset_n <= 1'd0;#15;reset_n <= 1'd1;#20_000_000;$stop;
endassign data_in = ((hang >= 10'd1) && (lie >= 10'd1)) ? 24'h111_111 : 24'd0 ;PLL_33M PLL_33M_inst
(.clk_33M (clk_33M ), .resetn (reset_n ), .locked (locked ), .clk_in1 (clk )
);tft_ctrl tft_ctrl_inst(.clk_33M (clk_33M ),.reset_n (locked ),.data_in (data_in ),.hang (hang ),.lie (lie ),.hsync (hsync ),.vsync (vsync ),.rgb_tft (rgb_tft ),.tft_bl (tft_bl ),.tft_clk (tft_clk ),.tft_DE (tft_DE )
);endmodule
(4)仿真波形:
- PLL仿真波形:
- 行计数器信号、行同步信号(我这里同步信号的设计与之前理论部分的不一样,是根据tft显示屏数据手册改的):
- 场计数器信号、场同步信号:
- 行信号、列信号:
第35列的第216个像素点是有效的第一行第一列数据。
- 数据输入信号和rgb_tft信号: