10 use IEEE.STD_LOGIC_1164.
ALL;
11 USE IEEE.NUMERIC_STD.
ALL;
49 signal write_ptr, read_ptr: unsigned(BUFWIDTH-1 downto 0);
50 signal fifo_filled_sig, fifo_empty_sig, running_sig, packet_ready_sig: STD_LOGIC;
51 signal packet_change_sig: STD_LOGIC_VECTOR(1 downto 0);
58 fifo_proc :
process (
clk)
59 type FIFO_Memory
is array(0 to 2**BUFWIDTH - 1) of STD_LOGIC_VECTOR(DATA_WIDTH downto 0);
60 variable Memory : FIFO_Memory;
61 variable DataOut: STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
62 variable last, packet_up, packet_down, error : STD_LOGIC;
63 variable Head, Tail : natural range 0 to 2**BUFWIDTH - 1;
64 variable Watchdog : unsigned(BUFWIDTH downto 0);
65 variable Fatal, Running : STD_LOGIC;
66 variable packet_change: STD_LOGIC_VECTOR(1 downto 0);
68 if rising_edge(clk) then
74 Watchdog := (Others => '0');
78 if ((out_ready = '1') and (Running = '1')) then
95 Watchdog := Watchdog + 1;
111 Watchdog := (Others => '0');
117 if (fifo_filled_sig = '1') or (packet_ready_sig = '1') then
121 If Running = '1' then
123 If (fifo_empty_sig = '1') or (Watchdog(BUFWIDTH) = '1') then
127 DataOut := (Others => '0');
132 DataOut := Memory(Tail)(DATA_WIDTH-1 downto 0);
137 DataOut := (Others => '0');
142 if (Fatal = '1') then
143 packet_change := "11";
144 elsif (packet_up = packet_down) then
145 packet_change := "00";
147 packet_change := packet_up & packet_down;
150 write_ptr <= to_unsigned(Head, BUFWIDTH)
155 read_ptr <= to_unsigned(Tail, BUFWIDTH)
160 running_sig <= Running
180 packet_change_sig <= packet_change
187 end process fifo_proc;
189 packet_count_proc :
process(
clk)
190 variable npacket: unsigned(BUFWIDTH-1 downto 0);
191 constant zeros
: unsigned(BUFWIDTH-1 downto 0) := (Others => '0');
192 variable packet_ready: std_logic;
194 if rising_edge(clk) then
196 npacket := (Others => '0');
198 Case packet_change_sig is
200 npacket := (Others => '0');
202 npacket := npacket + 1;
204 if (npacket /= zeros) then
205 npacket := npacket - 1;
211 if (npacket /= zeros) and (running_sig = '0') then
216 packet_ready_sig <= packet_ready
222 end process packet_count_proc;
224 fill_level_proc :
process(
clk)
225 variable FillLevel, Head, Tail: unsigned(BUFWIDTH downto 0);
226 variable Empty: std_logic;
228 if rising_edge(clk) then
230 FillLevel := (Others => '0');
233 if (write_ptr = read_ptr) then
238 Head := "1" & write_ptr;
239 Tail := "0" & read_ptr;
240 FillLevel := Head - Tail;
242 fifo_filled_sig <= FillLevel(BUFWIDTH-1)
247 fifo_empty_sig <= Empty
253 end process fill_level_proc;
Optimised RAM-based single clock packet FIFO.
Optimised RAM-based single clock packet FIFO.
out out_data STD_LOGIC_VECTOR( DATA_WIDTH- 1 downto 0)
AXI stream output.
in in_data STD_LOGIC_VECTOR( DATA_WIDTH- 1 downto 0)
AXI stream input.
out in_pause STD_LOGIC
AXI stream input pause request.
out out_error STD_LOGIC
AXI stream output error (asserted on last)
in rst_clk STD_LOGIC
Synchronous reset.
DATA_WIDTH positive := 64
Width of data for RAM.
out out_valid STD_LOGIC
AXI stream output valid.
in in_last STD_LOGIC
AXI stream input last.
in in_valid STD_LOGIC
AXI stream input valid.
in out_ready STD_LOGIC
AXI stream output ready.
out out_last STD_LOGIC
AXI stream output last.
BUFWIDTH positive := 4
Width of address bus for buffer, i.e. array (0 to 2**BUFWIDTH - 1)