1 |
2 |
danv |
--------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
3 |
danv |
-- Copyright 2020
|
4 |
2 |
danv |
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
3 |
danv |
--
|
7 |
|
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
8 |
|
|
-- you may not use this file except in compliance with the License.
|
9 |
|
|
-- You may obtain a copy of the License at
|
10 |
|
|
--
|
11 |
|
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
12 |
|
|
--
|
13 |
|
|
-- Unless required by applicable law or agreed to in writing, software
|
14 |
|
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
15 |
|
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16 |
|
|
-- See the License for the specific language governing permissions and
|
17 |
|
|
-- limitations under the License.
|
18 |
2 |
danv |
--
|
19 |
|
|
--------------------------------------------------------------------------------
|
20 |
|
|
|
21 |
|
|
-- Purpose:
|
22 |
|
|
-- The FIFO starts outputting data when the output is ready and it has been
|
23 |
|
|
-- filled with more than g_fifo_fill words. Given a fixed frame length, this
|
24 |
|
|
-- is useful when the in_val is throttled while the out_val should not be
|
25 |
|
|
-- inactive valid between out_sop to out_eop. This is necessary for frame
|
26 |
|
|
-- transport over a PHY link without separate data valid signal.
|
27 |
|
|
-- Description:
|
28 |
|
|
-- The FIFO is filled sufficiently for each input frame, as defined by the
|
29 |
|
|
-- sop and then read until the eop.
|
30 |
|
|
-- The rd_fill_32b control input is used for dynamic control of the fill
|
31 |
|
|
-- level on the read side of the FIFO. The rd_fill_32b defaults to
|
32 |
|
|
-- g_fifo_fill, so if rd_fill_32b is not connected then the fill level is
|
33 |
|
|
-- fixed to g_fifo_fill. A g_fifo_fill disables the fifo fill mechanism.
|
34 |
|
|
-- The rd_fill_32b signal must be stable in the rd_clk domain.
|
35 |
|
|
-- Remarks:
|
36 |
|
|
-- . Reuse from LOFAR rad_frame_scheduler.vhd and rad_frame_scheduler(rtl).vhd
|
37 |
|
|
-- . For g_fifo_fill=0 this dp_fifo_fill_core defaults to dp_fifo_core.
|
38 |
|
|
-- . The architecture offers two implementations via g_fifo_rl. Use 0 for show
|
39 |
|
|
-- ahead FIFO or 1 for normal FIFO. At the output of dp_fifo_fill_core the
|
40 |
|
|
-- RL=1 independent of g_fifo_rl, the g_fifo_rl only applies to the internal
|
41 |
|
|
-- FIFO. The show ahead FIFO uses the dp_latency_adapter to get to RL 0
|
42 |
|
|
-- internally. The normal FIFO is prefered, because it uses less logic. It
|
43 |
|
|
-- keeps the RL internally also at 1.
|
44 |
|
|
-- . Note that the structure of p_state is idendical in both architectures
|
45 |
|
|
-- for both g_fifo_rl=0 or 1. Hence the implementation of g_fifo_rl=1 with
|
46 |
|
|
-- dp_input_hold is an example of how to use dp_input_hold to get the same
|
47 |
|
|
-- behaviour as if the input had g_fifo_rl=0 as with the show ahead FIFO.
|
48 |
|
|
-- . To view the similarity of the p_state process for both g_fifo_rl e.g.
|
49 |
|
|
-- open the file in two editors or do repeatedly find (F3) on a text
|
50 |
|
|
-- section like 'WHEN s_fill =>' that only occurs one in each p_state.
|
51 |
|
|
-- . The next_src_out = pend_src_out when src_in.ready='1'. However it is more
|
52 |
|
|
-- clear to only use pend_src_out and explicitely write the condition on
|
53 |
|
|
-- src_in.ready in the code, because then the structure of p_state is the
|
54 |
|
|
-- same for both g_fifo_rl=0 or 1. Furthermore using pend_src_out and
|
55 |
|
|
-- src_in.ready is often more clear to comprehend then using next_src_out
|
56 |
|
|
-- directly.
|
57 |
|
|
|
58 |
4 |
danv |
LIBRARY IEEE, common_pkg_lib, dp_pkg_lib, dp_components_lib;
|
59 |
2 |
danv |
USE IEEE.std_logic_1164.ALL;
|
60 |
|
|
USE IEEE.numeric_std.ALL;
|
61 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
62 |
|
|
USE dp_pkg_lib.dp_stream_pkg.ALL;
|
63 |
4 |
danv |
--USE technology_lib.technology_select_pkg.ALL;
|
64 |
2 |
danv |
|
65 |
|
|
ENTITY dp_fifo_fill_core IS
|
66 |
|
|
GENERIC (
|
67 |
4 |
danv |
g_technology : NATURAL := 0;
|
68 |
2 |
danv |
g_use_dual_clock : BOOLEAN := FALSE;
|
69 |
|
|
g_data_w : NATURAL := 16;
|
70 |
|
|
g_bsn_w : NATURAL := 1;
|
71 |
|
|
g_empty_w : NATURAL := 1;
|
72 |
|
|
g_channel_w : NATURAL := 1;
|
73 |
|
|
g_error_w : NATURAL := 1;
|
74 |
|
|
g_use_bsn : BOOLEAN := FALSE;
|
75 |
|
|
g_use_empty : BOOLEAN := FALSE;
|
76 |
|
|
g_use_channel : BOOLEAN := FALSE;
|
77 |
|
|
g_use_error : BOOLEAN := FALSE;
|
78 |
|
|
g_use_sync : BOOLEAN := FALSE;
|
79 |
|
|
g_use_complex : BOOLEAN := FALSE; -- TRUE feeds the concatenated complex fields (im & re) through the FIFO instead of the data field.
|
80 |
|
|
g_fifo_fill : NATURAL := 0;
|
81 |
|
|
g_fifo_size : NATURAL := 256; -- (32+2) * 256 = 1 M9K, g_data_w+2 for sop and eop
|
82 |
|
|
g_fifo_af_margin : NATURAL := 4; -- Nof words below max (full) at which fifo is considered almost full
|
83 |
|
|
g_fifo_rl : NATURAL := 1 -- use RL=0 for internal show ahead FIFO, default use RL=1 for internal normal FIFO
|
84 |
|
|
);
|
85 |
|
|
PORT (
|
86 |
|
|
wr_rst : IN STD_LOGIC;
|
87 |
|
|
wr_clk : IN STD_LOGIC;
|
88 |
|
|
rd_rst : IN STD_LOGIC;
|
89 |
|
|
rd_clk : IN STD_LOGIC;
|
90 |
|
|
-- Monitor FIFO filling
|
91 |
|
|
wr_ful : OUT STD_LOGIC; -- corresponds to the carry bit of wr_usedw when FIFO is full
|
92 |
|
|
wr_usedw : OUT STD_LOGIC_VECTOR(ceil_log2(largest(g_fifo_size, g_fifo_fill + g_fifo_af_margin + 2))-1 DOWNTO 0); -- = ceil_log2(c_fifo_size)-1 DOWNTO 0
|
93 |
|
|
rd_usedw : OUT STD_LOGIC_VECTOR(ceil_log2(largest(g_fifo_size, g_fifo_fill + g_fifo_af_margin + 2))-1 DOWNTO 0); -- = ceil_log2(c_fifo_size)-1 DOWNTO 0
|
94 |
|
|
rd_emp : OUT STD_LOGIC;
|
95 |
|
|
-- MM control FIFO filling (assume 32 bit MM interface)
|
96 |
|
|
wr_usedw_32b : OUT STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0); -- = wr_usedw
|
97 |
|
|
rd_usedw_32b : OUT STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0); -- = rd_usedw
|
98 |
|
|
rd_fill_32b : IN STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0) := TO_UVEC(g_fifo_fill, c_word_w);
|
99 |
|
|
-- ST sink
|
100 |
|
|
snk_out : OUT t_dp_siso;
|
101 |
|
|
snk_in : IN t_dp_sosi;
|
102 |
|
|
-- ST source
|
103 |
|
|
src_in : IN t_dp_siso;
|
104 |
|
|
src_out : OUT t_dp_sosi
|
105 |
|
|
);
|
106 |
|
|
END dp_fifo_fill_core;
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
ARCHITECTURE rtl OF dp_fifo_fill_core IS
|
110 |
|
|
|
111 |
|
|
CONSTANT c_fifo_rl : NATURAL := sel_a_b(g_fifo_fill=0, 1, g_fifo_rl);
|
112 |
|
|
CONSTANT c_fifo_fill_margin : NATURAL := g_fifo_af_margin + 2; -- add +2 extra margin, with tb_dp_fifo_fill it follows that +1 is also enough to avoid almost full when fifo is operating near g_fifo_fill level
|
113 |
|
|
CONSTANT c_fifo_size : NATURAL := largest(g_fifo_size, g_fifo_fill + c_fifo_fill_margin);
|
114 |
|
|
CONSTANT c_fifo_size_w : NATURAL := ceil_log2(c_fifo_size); -- = wr_usedw'LENGTH = rd_usedw'LENGTH
|
115 |
|
|
|
116 |
|
|
-- The FIFO filling relies on framed data, so contrary to dp_fifo_sc the sop and eop need to be used.
|
117 |
|
|
CONSTANT c_use_ctrl : BOOLEAN := TRUE;
|
118 |
|
|
|
119 |
|
|
-- Define t_state as slv to avoid Modelsim warning "Nonresolved signal 'nxt_state' may have multiple sources". Due to that g_fifo_rl = 0 or 1 ar both supported.
|
120 |
|
|
--TYPE t_state IS (s_idle, s_fill, s_output, s_xoff);
|
121 |
|
|
CONSTANT s_idle : STD_LOGIC_VECTOR(1 DOWNTO 0) := "00";
|
122 |
|
|
CONSTANT s_fill : STD_LOGIC_VECTOR(1 DOWNTO 0) := "01";
|
123 |
|
|
CONSTANT s_output : STD_LOGIC_VECTOR(1 DOWNTO 0) := "10";
|
124 |
|
|
CONSTANT s_xoff : STD_LOGIC_VECTOR(1 DOWNTO 0) := "11";
|
125 |
|
|
|
126 |
|
|
SIGNAL state : STD_LOGIC_VECTOR(1 DOWNTO 0); -- t_state
|
127 |
|
|
SIGNAL nxt_state : STD_LOGIC_VECTOR(1 DOWNTO 0); -- t_state
|
128 |
|
|
|
129 |
|
|
SIGNAL xon_reg : STD_LOGIC;
|
130 |
|
|
SIGNAL nxt_xon_reg : STD_LOGIC;
|
131 |
|
|
|
132 |
|
|
SIGNAL rd_siso : t_dp_siso;
|
133 |
|
|
SIGNAL rd_sosi : t_dp_sosi := c_dp_sosi_rst; -- initialize default values for unused sosi fields;
|
134 |
|
|
|
135 |
|
|
SIGNAL wr_fifo_usedw : STD_LOGIC_VECTOR(c_fifo_size_w-1 DOWNTO 0); -- = wr_usedw'RANGE
|
136 |
|
|
SIGNAL rd_fifo_usedw : STD_LOGIC_VECTOR(c_fifo_size_w-1 DOWNTO 0); -- = rd_usedw'RANGE
|
137 |
|
|
SIGNAL rd_fill_ctrl : STD_LOGIC_VECTOR(c_fifo_size_w-1 DOWNTO 0); -- used to resize rd_fill_32b to actual maximum width
|
138 |
|
|
|
139 |
|
|
SIGNAL i_src_out : t_dp_sosi;
|
140 |
|
|
SIGNAL nxt_src_out : t_dp_sosi;
|
141 |
|
|
|
142 |
|
|
-- Signals for g_fifo_rl=1
|
143 |
|
|
SIGNAL hold_src_in : t_dp_siso;
|
144 |
|
|
SIGNAL pend_src_out : t_dp_sosi;
|
145 |
|
|
|
146 |
|
|
BEGIN
|
147 |
|
|
|
148 |
|
|
-- Output monitor FIFO filling
|
149 |
|
|
wr_usedw <= wr_fifo_usedw;
|
150 |
|
|
rd_usedw <= rd_fifo_usedw;
|
151 |
|
|
|
152 |
|
|
-- Control FIFO fill level
|
153 |
|
|
wr_usedw_32b <= RESIZE_UVEC(wr_fifo_usedw, c_word_w);
|
154 |
|
|
rd_usedw_32b <= RESIZE_UVEC(rd_fifo_usedw, c_word_w);
|
155 |
|
|
|
156 |
|
|
rd_fill_ctrl <= rd_fill_32b(c_fifo_size_w-1 DOWNTO 0);
|
157 |
|
|
|
158 |
|
|
gen_dp_fifo_sc : IF g_use_dual_clock=FALSE GENERATE
|
159 |
|
|
u_dp_fifo_sc : ENTITY work.dp_fifo_sc
|
160 |
|
|
GENERIC MAP (
|
161 |
|
|
g_technology => g_technology,
|
162 |
|
|
g_data_w => g_data_w,
|
163 |
|
|
g_bsn_w => g_bsn_w,
|
164 |
|
|
g_empty_w => g_empty_w,
|
165 |
|
|
g_channel_w => g_channel_w,
|
166 |
|
|
g_error_w => g_error_w,
|
167 |
|
|
g_use_bsn => g_use_bsn,
|
168 |
|
|
g_use_empty => g_use_empty,
|
169 |
|
|
g_use_channel => g_use_channel,
|
170 |
|
|
g_use_error => g_use_error,
|
171 |
|
|
g_use_sync => g_use_sync,
|
172 |
|
|
g_use_ctrl => c_use_ctrl,
|
173 |
|
|
g_use_complex => g_use_complex,
|
174 |
|
|
g_fifo_size => c_fifo_size,
|
175 |
|
|
g_fifo_af_margin => g_fifo_af_margin,
|
176 |
|
|
g_fifo_rl => c_fifo_rl
|
177 |
|
|
)
|
178 |
|
|
PORT MAP (
|
179 |
|
|
rst => rd_rst,
|
180 |
|
|
clk => rd_clk,
|
181 |
|
|
-- Monitor FIFO filling
|
182 |
|
|
wr_ful => wr_ful,
|
183 |
|
|
usedw => rd_fifo_usedw,
|
184 |
|
|
rd_emp => rd_emp,
|
185 |
|
|
-- ST sink
|
186 |
|
|
snk_out => snk_out,
|
187 |
|
|
snk_in => snk_in,
|
188 |
|
|
-- ST source
|
189 |
|
|
src_in => rd_siso, -- for RL = 0 rd_siso.ready acts as read acknowledge, for RL = 1 rd_siso.ready acts as read request
|
190 |
|
|
src_out => rd_sosi
|
191 |
|
|
);
|
192 |
|
|
|
193 |
|
|
wr_fifo_usedw <= rd_fifo_usedw;
|
194 |
|
|
END GENERATE;
|
195 |
|
|
|
196 |
|
|
gen_dp_fifo_dc : IF g_use_dual_clock=TRUE GENERATE
|
197 |
|
|
u_dp_fifo_dc : ENTITY work.dp_fifo_dc
|
198 |
|
|
GENERIC MAP (
|
199 |
|
|
g_technology => g_technology,
|
200 |
|
|
g_data_w => g_data_w,
|
201 |
|
|
g_bsn_w => g_bsn_w,
|
202 |
|
|
g_empty_w => g_empty_w,
|
203 |
|
|
g_channel_w => g_channel_w,
|
204 |
|
|
g_error_w => g_error_w,
|
205 |
|
|
g_use_bsn => g_use_bsn,
|
206 |
|
|
g_use_empty => g_use_empty,
|
207 |
|
|
g_use_channel => g_use_channel,
|
208 |
|
|
g_use_error => g_use_error,
|
209 |
|
|
g_use_sync => g_use_sync,
|
210 |
|
|
g_use_ctrl => c_use_ctrl,
|
211 |
|
|
--g_use_complex => g_use_complex,
|
212 |
|
|
g_fifo_size => c_fifo_size,
|
213 |
|
|
g_fifo_af_margin => g_fifo_af_margin,
|
214 |
|
|
g_fifo_rl => c_fifo_rl
|
215 |
|
|
)
|
216 |
|
|
PORT MAP (
|
217 |
|
|
wr_rst => wr_rst,
|
218 |
|
|
wr_clk => wr_clk,
|
219 |
|
|
rd_rst => rd_rst,
|
220 |
|
|
rd_clk => rd_clk,
|
221 |
|
|
-- Monitor FIFO filling
|
222 |
|
|
wr_ful => wr_ful,
|
223 |
|
|
wr_usedw => wr_fifo_usedw,
|
224 |
|
|
rd_usedw => rd_fifo_usedw,
|
225 |
|
|
rd_emp => rd_emp,
|
226 |
|
|
-- ST sink
|
227 |
|
|
snk_out => snk_out,
|
228 |
|
|
snk_in => snk_in,
|
229 |
|
|
-- ST source
|
230 |
|
|
src_in => rd_siso, -- for RL = 0 rd_siso.ready acts as read acknowledge, -- for RL = 1 rd_siso.ready acts as read request
|
231 |
|
|
src_out => rd_sosi
|
232 |
|
|
);
|
233 |
|
|
END GENERATE;
|
234 |
|
|
|
235 |
|
|
no_fill : IF g_fifo_fill=0 GENERATE
|
236 |
|
|
rd_siso <= src_in; -- SISO
|
237 |
|
|
src_out <= rd_sosi; -- SOSI
|
238 |
|
|
END GENERATE; -- no_fill
|
239 |
|
|
|
240 |
|
|
gen_fill : IF g_fifo_fill>0 GENERATE
|
241 |
|
|
|
242 |
|
|
src_out <= i_src_out;
|
243 |
|
|
|
244 |
|
|
p_rd_clk: PROCESS(rd_clk, rd_rst)
|
245 |
|
|
BEGIN
|
246 |
|
|
IF rd_rst='1' THEN
|
247 |
|
|
xon_reg <= '0';
|
248 |
|
|
state <= s_idle;
|
249 |
|
|
i_src_out <= c_dp_sosi_rst;
|
250 |
|
|
ELSIF rising_edge(rd_clk) THEN
|
251 |
|
|
xon_reg <= nxt_xon_reg;
|
252 |
|
|
state <= nxt_state;
|
253 |
|
|
i_src_out <= nxt_src_out;
|
254 |
|
|
END IF;
|
255 |
|
|
END PROCESS;
|
256 |
|
|
|
257 |
|
|
nxt_xon_reg <= src_in.xon; -- register xon to easy timing closure
|
258 |
|
|
|
259 |
|
|
gen_rl_0 : IF g_fifo_rl=0 GENERATE
|
260 |
|
|
p_state : PROCESS(state, rd_sosi, src_in, xon_reg, rd_fifo_usedw, rd_fill_ctrl)
|
261 |
|
|
BEGIN
|
262 |
|
|
nxt_state <= state;
|
263 |
|
|
|
264 |
|
|
rd_siso <= src_in; -- default acknowledge (RL=1) this input when output is ready
|
265 |
|
|
|
266 |
|
|
-- The output register stage increase RL=0 to 1, so it matches RL = 1 for src_in.ready
|
267 |
|
|
nxt_src_out <= rd_sosi;
|
268 |
|
|
nxt_src_out.valid <= '0'; -- default no output
|
269 |
|
|
nxt_src_out.sop <= '0';
|
270 |
|
|
nxt_src_out.eop <= '0';
|
271 |
|
|
nxt_src_out.sync <= '0';
|
272 |
|
|
|
273 |
|
|
CASE state IS
|
274 |
|
|
WHEN s_idle =>
|
275 |
|
|
IF xon_reg='0' THEN
|
276 |
|
|
nxt_state <= s_xoff;
|
277 |
|
|
ELSE
|
278 |
|
|
-- read the FIFO until the sop is pending at the output, so discard any valid data between eop and sop
|
279 |
|
|
IF rd_sosi.sop='0' THEN
|
280 |
|
|
rd_siso <= c_dp_siso_rdy; -- acknowledge (RL=0) this input independent of output ready
|
281 |
|
|
ELSE
|
282 |
|
|
rd_siso <= c_dp_siso_hold; -- stop the input, hold the rd_sosi.sop at FIFO output (RL=0)
|
283 |
|
|
nxt_state <= s_fill;
|
284 |
|
|
END IF;
|
285 |
|
|
END IF;
|
286 |
|
|
WHEN s_fill =>
|
287 |
|
|
IF xon_reg='0' THEN
|
288 |
|
|
nxt_state <= s_xoff;
|
289 |
|
|
ELSE
|
290 |
|
|
-- stop reading until the FIFO has been filled sufficiently
|
291 |
|
|
IF UNSIGNED(rd_fifo_usedw)<UNSIGNED(rd_fill_ctrl) THEN
|
292 |
|
|
rd_siso <= c_dp_siso_hold; -- stop the input, hold the pend_src_out.sop
|
293 |
|
|
ELSE
|
294 |
|
|
-- if the output is ready, then start outputting the frame
|
295 |
|
|
IF src_in.ready='1' THEN
|
296 |
|
|
nxt_src_out <= rd_sosi; -- output sop that is still at FIFO output (RL=0)
|
297 |
|
|
nxt_state <= s_output;
|
298 |
|
|
END IF;
|
299 |
|
|
END IF;
|
300 |
|
|
END IF;
|
301 |
|
|
WHEN s_output =>
|
302 |
|
|
-- if the output is ready continue outputting the frame, ignore xon_reg during this frame
|
303 |
|
|
IF src_in.ready='1' THEN
|
304 |
|
|
nxt_src_out <= rd_sosi; -- output valid
|
305 |
|
|
IF rd_sosi.eop='1' THEN
|
306 |
|
|
nxt_state <= s_idle; -- output eop, so stop reading the FIFO
|
307 |
|
|
END IF;
|
308 |
|
|
END IF;
|
309 |
|
|
WHEN OTHERS => -- s_xoff
|
310 |
|
|
-- Flush the fill FIFO when xon='0'
|
311 |
|
|
rd_siso <= c_dp_siso_flush;
|
312 |
|
|
IF xon_reg='1' THEN
|
313 |
|
|
nxt_state <= s_idle;
|
314 |
|
|
END IF;
|
315 |
|
|
END CASE;
|
316 |
|
|
|
317 |
|
|
-- Pass on frame level flow control
|
318 |
|
|
rd_siso.xon <= src_in.xon;
|
319 |
|
|
END PROCESS;
|
320 |
|
|
END GENERATE; -- gen_rl_0
|
321 |
|
|
|
322 |
|
|
gen_rl_1 : IF g_fifo_rl=1 GENERATE
|
323 |
|
|
-- Use dp_hold_input to get equivalent implementation with default RL=1 FIFO.
|
324 |
|
|
|
325 |
|
|
-- Hold the sink input for source output
|
326 |
|
|
u_snk : ENTITY dp_components_lib.dp_hold_input
|
327 |
|
|
PORT MAP (
|
328 |
|
|
rst => rd_rst,
|
329 |
|
|
clk => rd_clk,
|
330 |
|
|
-- ST sink
|
331 |
|
|
snk_out => rd_siso, -- SISO ready
|
332 |
|
|
snk_in => rd_sosi, -- SOSI
|
333 |
|
|
-- ST source
|
334 |
|
|
src_in => hold_src_in, -- SISO ready
|
335 |
|
|
next_src_out => OPEN, -- SOSI
|
336 |
|
|
pend_src_out => pend_src_out,
|
337 |
|
|
src_out_reg => i_src_out
|
338 |
|
|
);
|
339 |
|
|
|
340 |
|
|
p_state : PROCESS(state, src_in, xon_reg, pend_src_out, rd_fifo_usedw, rd_fill_ctrl)
|
341 |
|
|
BEGIN
|
342 |
|
|
nxt_state <= state;
|
343 |
|
|
|
344 |
|
|
hold_src_in <= src_in; -- default request (RL=1) new input when output is ready
|
345 |
|
|
|
346 |
|
|
-- The output register stage matches RL = 1 for src_in.ready
|
347 |
|
|
nxt_src_out <= pend_src_out;
|
348 |
|
|
nxt_src_out.valid <= '0'; -- default no output
|
349 |
|
|
nxt_src_out.sop <= '0';
|
350 |
|
|
nxt_src_out.eop <= '0';
|
351 |
|
|
nxt_src_out.sync <= '0';
|
352 |
|
|
|
353 |
|
|
CASE state IS
|
354 |
|
|
WHEN s_idle =>
|
355 |
|
|
IF xon_reg='0' THEN
|
356 |
|
|
nxt_state <= s_xoff;
|
357 |
|
|
ELSE
|
358 |
|
|
-- read the FIFO until the sop is pending at the output, so discard any valid data between eop and sop
|
359 |
|
|
IF pend_src_out.sop='0' THEN
|
360 |
|
|
hold_src_in <= c_dp_siso_rdy; -- request (RL=1) new input independent of output ready
|
361 |
|
|
ELSE
|
362 |
|
|
hold_src_in <= c_dp_siso_hold; -- stop the input, hold the pend_src_out.sop in dp_hold_input
|
363 |
|
|
nxt_state <= s_fill;
|
364 |
|
|
END IF;
|
365 |
|
|
END IF;
|
366 |
|
|
WHEN s_fill =>
|
367 |
|
|
IF xon_reg='0' THEN
|
368 |
|
|
nxt_state <= s_xoff;
|
369 |
|
|
ELSE
|
370 |
|
|
-- stop reading until the FIFO has been filled sufficiently
|
371 |
|
|
IF UNSIGNED(rd_fifo_usedw)<UNSIGNED(rd_fill_ctrl) THEN
|
372 |
|
|
hold_src_in <= c_dp_siso_hold; -- stop the input, hold the pend_src_out.sop
|
373 |
|
|
ELSE
|
374 |
|
|
-- if the output is ready, then start outputting the input frame
|
375 |
|
|
IF src_in.ready='1' THEN
|
376 |
|
|
nxt_src_out <= pend_src_out; -- output sop that is still pending in dp_hold_input
|
377 |
|
|
nxt_state <= s_output;
|
378 |
|
|
END IF;
|
379 |
|
|
END IF;
|
380 |
|
|
END IF;
|
381 |
|
|
WHEN s_output =>
|
382 |
|
|
-- if the output is ready continue outputting the input frame, ignore xon_reg during this frame
|
383 |
|
|
IF src_in.ready='1' THEN
|
384 |
|
|
nxt_src_out <= pend_src_out; -- output valid
|
385 |
|
|
IF pend_src_out.eop='1' THEN
|
386 |
|
|
nxt_state <= s_idle; -- output eop, so stop reading the FIFO
|
387 |
|
|
END IF;
|
388 |
|
|
END IF;
|
389 |
|
|
WHEN OTHERS => -- s_xon
|
390 |
|
|
-- Flush the fill FIFO when xon='0'
|
391 |
|
|
hold_src_in <= c_dp_siso_flush;
|
392 |
|
|
IF xon_reg='1' THEN
|
393 |
|
|
nxt_state <= s_idle;
|
394 |
|
|
END IF;
|
395 |
|
|
END CASE;
|
396 |
|
|
|
397 |
|
|
-- Pass on frame level flow control
|
398 |
|
|
hold_src_in.xon <= src_in.xon;
|
399 |
|
|
END PROCESS;
|
400 |
|
|
END GENERATE; -- gen_rl_1
|
401 |
|
|
|
402 |
|
|
END GENERATE; -- gen_fill
|
403 |
|
|
END rtl;
|