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

📄 cursor_right.v

📁 ALTERA的DE2平台VGA接口应用
💻 V
字号:
module Cursor
(
    SW,//rst:SW[17]; 
    CLOCK_50,
	KEY,
	
	VGA_R,VGA_G,VGA_B,
	VGA_CLK,
	VGA_BLANK,
    VGA_HS, 
    VGA_VS, 
	VGA_SYNC
  ); 
input [17:0] SW; 
input CLOCK_50;
input [3:0] KEY; 
 
output [9:0] VGA_R,VGA_G,VGA_B;
output VGA_CLK;
output VGA_BLANK;
output reg VGA_HS; 
output reg VGA_VS;
output VGA_SYNC;  

reg [9:0] CountH; 
reg [9:0] CountV;
reg [9:0] R_Val,G_Val,B_Val;
reg [9:0] X,Y;

assign VGA_R = R_Val;
assign VGA_G = G_Val;
assign VGA_B = B_Val;
assign VGA_CLK = CLOCK_50;
assign VGA_SYNC = 1'b0;
assign VGA_BLANK = VGA_HS & VGA_VS;

parameter CycH = 120;
parameter TotalH = 1040;
parameter FrontH = 120 + 61;
parameter BackH = 53;
parameter LengthX = 806;

parameter CycV = 6;
parameter TotalV = 666;
parameter FrontV = 6 + 21;
parameter BackV = 35;
parameter LengthY = 604;

parameter Wide = 16;




initial
begin
	X = 100;
	Y = 100;
end

always @(posedge  CLOCK_50)
begin
	///////////////////////
	if ((CountH >= (X+FrontH)) & (CountH < (X+FrontH+Wide)) & (CountV >= (Y+FrontV)) & (CountV < (Y+FrontV+Wide)))
	begin
		R_Val <= 10'h000;
		G_Val <= 10'h000;
		B_Val <= 10'h000;
	end
	else
	begin
		R_Val <= 10'h3FF;
		G_Val <= 10'h3FF;
		B_Val <= 10'h3FF;
	end
end

always @ (posedge KEY[0])
begin
	if (X <= (LengthX-Wide))
		X <= X + Wide;
	else
		X <= 0;
end

always @(posedge  CLOCK_50 or negedge SW[17])
begin
	if(!SW[17])
	begin
		CountH <= 0;
		VGA_HS <= 0;
	end
	else
	begin
		if(CountH < TotalH)
			CountH <= CountH + 1;
		else
			CountH <= 0;
		
		if(CountH < CycH)
			VGA_HS <= 0;
		else
			VGA_HS <= 1;
	end
end

always @(posedge  CLOCK_50 or negedge SW[17])
begin
	if(!SW[17])
	begin
		CountV <= 0;
		VGA_VS <= 0;
	end
	else
	begin
		if(CountH == 0)
		begin
			if (CountV < TotalV)
				CountV <= CountV + 1;
			else
				CountV <= 0;
			
			if (CountV < CycV)
				VGA_VS <= 0;
			else
				VGA_VS <= 1;
		end
	end
end
endmodule

⌨️ 快捷键说明

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