📄 uart_fifo.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,count // status signals );//fifo consist of dpram,xo can be set to dpram,so fifo should be write by userinput clk,rst;input push,pop;input [7:0] data_in;output [7:0] data_out;output EF,AE,AF,FF;output [3:0] count;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));dpraml_16x8 u0 (.WrAddress( top_plus_1 ), .Data( data_in ), .WrClock( clk ), .WE( push ), .WrClockEn( ), .RdAddress( bottom), .Q( data_out ) );/*dpram16x8 u0(.WrAddress( top ), .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 <= 0 ; count <= 0; end else begin case ({push, pop})//set address 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////////////////////////////////set flagassign 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 + -