vga_tgen.v

来自「用来实现VGA发生时序」· Verilog 代码 · 共 97 行

V
97
字号
/////////////////////////////////////////////////////////////////////

`include "timescale.v"
//synopsys translate_on

module VGA(
	clk, clk_ena, rst,
//	Thsync, Thgdel, Thgate, Thlen, Tvsync, Tvgdel, Tvgate, Tvlen,
//	eol, eof, csync, blank,
	enab, hsync, vsync, vgate,vaddr
	);

	// inputs & outputs
	input clk;
	input clk_ena;
	input rst;
/*
	// horizontal timing settings inputs
	input [ 7:0] Thsync; // horizontal sync pule width (in pixels)
	input [ 7:0] Thgdel; // horizontal gate delay
	input [15:0] Thgate; // horizontal gate (number of visible pixels per line)
	input [15:0] Thlen;  // horizontal length (number of pixels per line)

	// vertical timing settings inputs
	input [ 7:0] Tvsync; // vertical sync pule width (in pixels)
	input [ 7:0] Tvgdel; // vertical gate delay
	input [15:0] Tvgate; // vertical gate (number of visible pixels per line)
	input [15:0] Tvlen;  // vertical length (number of pixels per line)
*/
	// outputs
	/*
	output eol;  // end of line
	output eof;  // end of frame
	output csync; // composite sync
	output blank; // blank signal
	*/
	output enab; // vertical AND horizontal gate (logical AND function)

	output hsync; // horizontal sync pulse
	output vsync; // vertical sync pulse
	output vgate; // vertical gate
	output [18:0] vaddr;
	//
	// variable declarations
	//
	wire Hgate, Vgate;
	wire Hdone;

	//
	// module body
	//

	// hookup horizontal timing generator
	vga_vtim #(2,2,10,25) hor_gen(
		.clk(clk),
		.ena(clk_ena),
		.rst(rst),
	//	.Tsync(Thsync),
	//	.Tgdel(Thgdel),
	//	.Tgate(Thgate),
	//	.Tlen(Thlen),
		.Sync(hsync),
		.Gate(Hgate),
		.Done(Hdone)
	);


	// hookup vertical timing generator
	wire vclk_ena = Hdone & clk_ena;
    
	vga_vtim #(2,2,10,22) ver_gen(
		.clk(clk),
		.ena(vclk_ena),
		.rst(rst),
	//	.Tsync(Tvsync),
	//	.Tgdel(Tvgdel),
	//	.Tgate(Tvgate),
	//	.Tlen(Tvlen),
		.Sync(vsync),
		.Gate(Vgate),
		.Done(eof)
	);
	vga_vaddr vramaddr_gen(
		.clk(clk),
		.rst(rst),
		.Hgate(Hgate),
		.Vgate(Vgate),
		.vaddr(vaddr)
	);
	// assign outputs
//	assign eol  = Hdone;
	assign vgate = Vgate;
	assign enab = Hgate & Vgate;
//	assign csync = hsync | vsync;
//	assign blank = ~gate;
endmodule

⌨️ 快捷键说明

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