⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcon.v

📁 开发板原理图 需要做开发板的可以参考参考
💻 V
字号:
module 	TCON (
				X,
				Y,
				NCLK,
				rstn,
				Display_mode,
				Hsyn,
				Vsyn,
				Red,
				Green,
				Blue,
				DENB,
							
				ClkCnt,
				HsynCnt
			  );
						

input 	[11:0]	X;
input 	[11:0]	Y;
input			NCLK;
input			rstn;
input 	[1:0]	Display_mode;

output	reg 	Hsyn;
output	reg 	Vsyn;
output	reg 	DENB;
output	[7:0]	Red;
output	[7:0]	Green;
output	[7:0]	Blue;

parameter ONE_HSYN_LINE =	1055;	//  unit : NCLK
parameter ONE_VSYN_LINE = 	524;	//  unit : VSYN
parameter Hsync_Blank = 215;
parameter Hsync_Front_Porch = 40;
parameter Vertical_Back_Porch = 35;
parameter Vertical_Front_Porch = 10;


output reg	[10:0]	ClkCnt;
output reg	[10:0]	HsynCnt;

reg	[7:0]	Red_1;
reg [7:0]	Green_1;
reg [7:0]	Blue_1;
reg [7:0]	GrayCnt;
reg	[7:0]	Tmp_DATA;	
reg	[1:0]   Display_Mode;

wire	[7:0]	Red;
wire	[7:0]	Green;
wire	[7:0]	Blue;
wire	[10:0]	RealH_Line;
wire	[10:0]	RealH_Dot;
wire 	[7:0] 	Red_2;  
wire 	[7:0] 	Green_2;
wire	[7:0] 	Blue_2;
wire	[1:0]	mSEL;

/////////////////////// touch panel timing ////////////////

//  Description Clock Counter  //
always@(negedge NCLK or negedge rstn)
begin
	if (!rstn)
	  begin
		ClkCnt 	<= 0;
		Hsyn   	<= 1;
	  end
	else if (ClkCnt == ONE_HSYN_LINE)
	  begin
		Hsyn 	<= 0;
		ClkCnt	<= 0;
	  end	
	else
	  begin
		ClkCnt  <= ClkCnt + 1;
		Hsyn   	<= 1;
	  end
end

//  Description Horizontal Line Counter  //
always@(posedge Hsyn or negedge rstn)
begin
	if (!rstn)
	  begin
		HsynCnt <= 0;
		Vsyn 	<= 1;
	  end
	else if (HsynCnt == ONE_VSYN_LINE)
	  begin
		HsynCnt <= 0;
		Vsyn 	<= 0;
	  end
	else
	  begin
		HsynCnt <= HsynCnt + 1;
		Vsyn 	<= 1;
	  end
end

// Data Enable Signal  //
always@(negedge NCLK or negedge rstn)
 begin
	if (!rstn)
		DENB <= 0;
	else if (!Vsyn)
		DENB <= 0;		
	else if ( (ClkCnt > Hsync_Blank) && (ClkCnt < (ONE_HSYN_LINE+1)) )   //(ClkCnt > 215) && (ClkCnt < 1056)
		DENB <= 1;
	else	
		DENB <= 0;
end


//	Horizontal Display Line number  // 
assign RealH_Line = ( HsynCnt < Vertical_Back_Porch )? 0 :  //HsynCnt < 35	
					( HsynCnt - (Vertical_Back_Porch-1) );  //HsynCnt - (34)

//  Display Dot number  //
assign RealH_Dot  = ( ClkCnt < (Hsync_Blank + 1 )  )? 0 :  //ClkCnt < 216
					( ClkCnt - Hsync_Blank );			   //ClkCnt - 215	

////////////////// touch panel display pattern control /////////////////////

assign	mSEL		=	(HsynCnt<200)					?	2'b01	:
						(HsynCnt>=200	&& HsynCnt<360)	?	2'b10	:
														    2'b00	;
assign Red_2    =GrayCnt; 
assign Green_2  =GrayCnt;
assign Blue_2   =GrayCnt;

// color pattern //
always@(negedge NCLK or negedge rstn)
begin
	if (!rstn)
		Tmp_DATA	<=	8'h00;
	else if((ClkCnt > 215)&&(ClkCnt < 1016)) 
	begin
		if(mSEL==1)
		begin
			Tmp_DATA <= Tmp_DATA + 2;		
			Red_1 <= Tmp_DATA;
			Green_1 <= 0;
			Blue_1 <= 0;
		end	
		else if (mSEL==2)
		begin
			Tmp_DATA <= Tmp_DATA + 2;
			Red_1 <= 0;
			Green_1 <= Tmp_DATA;
			Blue_1 <= 0;
		end	
		else if (mSEL==0)
		begin
			Tmp_DATA <= Tmp_DATA + 2;
			Red_1 <= 0;
			Green_1 <= 0;
			Blue_1 <= Tmp_DATA;
		end	
	end	
	else
		Tmp_DATA<=	8'h00;	
end	

// Graylevel pattern //

always@(negedge NCLK or negedge rstn)
begin
	if (!rstn)
		GrayCnt <= 0;
	else if((ClkCnt > Hsync_Blank) && (ClkCnt < (ONE_HSYN_LINE+1))) //(ClkCnt > 215) && (ClkCnt < 1056)
		GrayCnt <= GrayCnt + 1;	
	else
		GrayCnt <= 0;		
end	


assign Red    = (Display_mode == 2'b11)?  8'hff:  
				(Display_mode == 2'b10)?  8'h7f: 
			    (Display_mode == 2'b01)?  Red_2:
				  						  Red_1; 

assign Green  = (Display_mode == 2'b11)?  8'hff:
			    (Display_mode == 2'b10)?  8'h7f:
				(Display_mode == 2'b01)?  Green_2:
				  				          Green_1;
				
assign Blue   = (Display_mode == 2'b11)?  8'hff:
			    (Display_mode == 2'b10)?  8'h7f:
				(Display_mode == 2'b01)?  Blue_2:
				  				          Blue_1;


endmodule







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -