quocviet19501
Newbie level 6
Hi all, I'm doing a systemverilog project in designing an asynchronous FIFO.
My design is fine until I have to customize the read pointer for almost_empty reneration.
Here is my code :
In the testing section I want to make an almost_rempty signal that runs faster than rempty signal 2 clk cycles.
I have tried everything but it did not work.
can anyone siggest an idea how to modify my code.
Thank a lot.
Here is my expected waveform:
My design is fine until I have to customize the read pointer for almost_empty reneration.
Here is my code :
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 module rprt_flag #(parameter ADDRSIZE = 4) ( output logic rempty, output logic almost_rempty, output logic [ADDRSIZE-1:0] raddr, input logic [ADDRSIZE :0] g_wprt_syn, input logic rclk, rrst_n ); logic [ADDRSIZE:0] rbin; logic [ADDRSIZE:0] rprt; logic [ADDRSIZE:0] rgraynext, rbinnext; logic rempty_val; logic almost_rempty_val; always_ff @(posedge rclk or negedge rrst_n) if (!rrst_n) {rbin, rprt} <= '0; else {rbin, rprt} <= {rbinnext, rgraynext}; assign raddr = rbin[ADDRSIZE-1:0]; assign rbinnext = rbin + {{(ADDRSIZE){1'b0}}, 1'b1}; assign rgraynext = (rbinnext>>1) ^ rbinnext; assign rempty_val = (rgraynext == g_wprt_syn); ////////////////TESTING////////////////////////////////////// logic [ADDRSIZE:0] rbinnext_val; logic [ADDRSIZE:0] rgraynext_val; assign rbinnext_val = (rbin + {{(ADDRSIZE){1'b0}}, 1'b1}) -2; assign rgraynext_val = (rbinnext_val>>1) ^ rbinnext_val; assign almost_rempty_val = (rgraynext_val == g_wprt_syn); ////////////////////////////////////////////////////////////// always_ff @(posedge rclk or negedge rrst_n) if (!rrst_n) begin rempty <= 1'b1; almost_rempty <= '1; end else begin rempty <= rempty_val; almost_rempty <= almost_rempty_val; end endmodule : rprt_flag
In the testing section I want to make an almost_rempty signal that runs faster than rempty signal 2 clk cycles.
I have tried everything but it did not work.
can anyone siggest an idea how to modify my code.
Thank a lot.
Here is my expected waveform:
Last edited by a moderator: