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

📄 uart_fifo.v

📁 一个UART的FPGA core
💻 V
字号:
`timescale 1ns/100psmodule UART_FIFO ( clk,rst,data_in,data_out,                    // Control signals	               push,                                           // push strobe, active high	               pop,                                            // pop strobe, active high	 				   EF,AE,AF,FF                                     // status signals	             );input clk,rst;input push,pop;input	[7:0] data_in;output	[7:0] data_out;output	EF,AE,AF,FF;reg	[3:0] top;reg	[3:0] bottom;reg	[3:0] count;wire [3:0] top_plus_1 = top + 1;//PUR PUR_INST(.PUR(1'b1));//GSR GSR_INST(.GSR(1'b1));dpram16x8 u0(.WrAddress( top_plus_1 ),             .Data( data_in ),		 .WrClock( clk ),		 .WE( push ),              .WrClockEn( push ),		 .RdAddress( bottom ),		  .RdClock( clk ),		   .RdClockEn( pop ),		  .Reset( rst ),              .Q( data_out ));             always @(posedge clk or posedge rst) // synchronous FIFObegin	if (rst)  	begin		        top	<= 0 ;		        bottom <= 1 ;		        count <=  0;	            end	else        begin	            case ({push, pop})		        2'b10 :  if(!FF)                                 begin				         top  <=  top_plus_1;				         count <= count + 1;			             end		        2'b01 :  if(!EF)                                 begin				         bottom <= bottom + 1;				         count <= count - 1;			             end		        2'b11 :  begin				         bottom <= bottom + 1;				         top <= top_plus_1;		                 end                 default ;		        endcase	            endend   // always/////////////////////////////////////FLAG generator////////////////////////////////assign FF = count[3] & count[2] & count[1] & count[0] ;assign AF = count[3] & count[2] ;assign AE = ~count[3] & ~count[2] ;assign EF = ~count[3] & ~count[2] & ~count[1] & ~count[0] ;/////////////////////////////////////////////////////////////////////////////////////////////////endmodule

⌨️ 快捷键说明

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