Skip to content

Commit 4f38c13

Browse files
committed
fifo_async: Add reset functionality for read pointer
1 parent e500d4a commit 4f38c13

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

ip/memories/fifo/fifo_async.vhd

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ entity fifo_async is
3131
read_data_valid: out std_ulogic;
3232
full: out std_ulogic;
3333
empty: out std_ulogic;
34-
words_stored: out natural range 0 to 2**FIFO_DEPTH_IN_BITS
34+
words_stored: out natural range 0 to 2**FIFO_DEPTH_IN_BITS;
35+
36+
-- Reset read pointer for data replay (keeps write pointer intact)
37+
reset_read_pointer: in std_ulogic := '0'
3538
);
3639

3740
constant FIFO_DEPTH: natural := 2**FIFO_DEPTH_IN_BITS;
@@ -97,7 +100,7 @@ begin
97100
wr_rst_busy => wr_rst_busy_unconnected,
98101
almost_full => almost_full_unconnected,
99102
wr_ack => wr_ack_unconnected,
100-
rd_en => read_enable,
103+
rd_en => read_enable and not reset_read_pointer,
101104
rd_clk => read_clk,
102105
dout => read_data,
103106
empty => empty,
@@ -241,7 +244,11 @@ begin
241244
read_pointer_binary <= (others => '0');
242245
read_pointer_gray <= (others => '0');
243246
elsif rising_edge(read_clk) then
244-
if read_enable and not empty then
247+
if reset_read_pointer then
248+
-- Reset read pointer to replay data (write pointer stays intact)
249+
read_pointer_binary <= (others => '0');
250+
read_pointer_gray <= (others => '0');
251+
elsif read_enable and not empty then
245252
read_pointer_binary <= read_pointer_binary + 1;
246253
read_pointer_gray <= binary_to_gray(read_pointer_binary + 1);
247254
end if;

0 commit comments

Comments
 (0)