Skip to content

Commit b0c132d

Browse files
nsl_amba/stream_fifo:fix on reset, mix async/sync logic.
1 parent baa800b commit b0c132d

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

lib/nsl_amba/stream_fifo/axi4_stream_fifo.vhd

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ begin
9393
out_available_o <= to_integer(out_available);
9494
in_free_o <= to_integer(in_free);
9595

96-
packet_counter_proc: process(reset_n_i, clock_i) is
96+
packet_counter_proc: process(clock_i, reset_n_i) is
9797
variable out_v : master_t;
9898
variable inc, dec: boolean;
9999
begin
100-
if rising_edge(clock_i(0)) then
100+
if reset_n_i = '0' then
101+
pkt_counter <= (others => '0');
102+
elsif rising_edge(clock_i(0)) then
101103
out_v := vector_unpack(config_c, fifo_elements_c, out_data_s);
102104
inc := is_valid(config_c, in_i) and is_last(config_c, in_i);
103105
dec := out_data_valid_s = '1' and is_last(config_c, out_v) and is_ready(config_c, out_i);
@@ -107,10 +109,6 @@ begin
107109
pkt_counter <= pkt_counter - 1;
108110
end if;
109111
end if;
110-
111-
if reset_n_i = '0' then
112-
pkt_counter <= (others => '0');
113-
end if;
114112
end process;
115113
out_pkt_available <= to_integer(pkt_counter);
116114
end generate;

0 commit comments

Comments
 (0)