1 ----------------------------------------------------------------------------------
5 -- Create Date: 11:
02:
29 01/25/2013
7 -- Module Name: ddr_wportA - Behavioral
16 -- Revision 0.
01 -
File Created
17 -- Additional Comments:
19 ----------------------------------------------------------------------------------
21 use IEEE.STD_LOGIC_1164.
ALL;
22 use IEEE.STD_LOGIC_ARITH.
ALL;
23 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
24 use IEEE.std_logic_misc.
all;
27 -- Uncomment the following library declaration if using
28 -- arithmetic functions with or values
29 --use IEEE.NUMERIC_STD.ALL;
31 -- Uncomment the following library declaration if instantiating
32 -- any Xilinx primitives in this code.
34 use UNISIM.VComponents.
all;
36 use UNIMACRO.vcomponents.
all;
45 test : in (1 downto 0);
-- memory test
46 test_block_sent : in ;
-- indicating test writing progress. One pulse every 256 32-bit words
48 test_status : out (63 downto 0);
49 -- each TCP segment sent will have dest IP address (32-bit), TCP port(2x16-bit), SEQ number(32-bit), length(16 ), stamp(
16 ), control bits(
6)
50 -- and memory starting address of the segment payload data(24-bit)
51 -- for alignment purposes, each entry occupies 32 bytes
of memory space (
256 bits)
52 TCP_dout : out (31 downto 0);
-- TCP data are written in unit of 32-bit words
53 TCP_dout_type : out (2 downto 0);
-- TCP data destination
54 TCP_addr : in (28 downto 0);
-- 28-26 encoded request source 25-0 address in 64 word
55 TCP_length : in (10 downto 0);
-- in 64 word, actual length -
1
56 TCP_dout_valid : out ;
64 ipb_addr : in (31 downto 0);
65 ipb_rdata : out (31 downto 0);
67 page_addr : in (9 downto 0);
-- monitored event memory window
68 cs_out : out (511 downto 0);
69 -- ddr3 user interface
70 app_rqst : out ;
-- request to output data
71 app_ack : in ;
-- permission to output data
74 app_rd_data_valid : in ;
75 app_rd_data : in (255 downto 0);
76 app_addr : out (27 downto 0) := (others => '0'));
-- in unit of 32bit word, 27 is not used
103 di :
IN (
5 downto 0);
105 wa :
IN (
4 downto 0);
106 ra :
IN (
4 downto 0);
107 do :
OUT (
5 downto 0)
110 signal TCPqueue_we : := '0';
111 signal ipb_start_addr : (26 downto 0) := (others => '0');
112 signal ipbReadSyncRegs : (3 downto 0) := (others => '0');
113 signal ipbRead : := '0';
114 signal ipbRead_q : := '0';
115 signal ipb_ack_i : := '0';
116 signal ipb_rqst : := '0';
117 signal ipb_raddr : (23 downto 0) := (others => '0');
118 signal ipb_seq : (1 downto 0) := (others => '0');
119 signal ipb_rqst_cnt : (1 downto 0) := (others => '0');
120 signal ipb_rqst_inqueue : (1 downto 0) := (others => '0');
121 signal ipb_rqstSyncRegs : (3 downto 0) := (others => '0');
122 signal queue_we : := '0';
123 signal queue_ceReg : := '0';
124 signal queue_do_vld : := '0';
125 signal TCP_addr1and0 : (1 downto 0) := (others => '0');
126 signal queue_di : (29 downto 0) := (others => '0');
127 signal queue_do : (29 downto 0) := (others => '0');
128 signal queue_wa : (4 downto 0) := (others => '0');
129 signal queue_ra : (4 downto 0) := (others => '0');
130 signal queue_wap : (3 downto 0) := (others => '0');
131 signal queue_wa0SyncRegs : (2 downto 0) := (others => '0');
132 signal queue_wa1SyncRegs : (2 downto 0) := (others => '0');
133 signal queue_wa2SyncRegs : (2 downto 0) := (others => '0');
134 signal queue_wa3SyncRegs : (2 downto 0) := (others => '0');
135 signal Oqueue_di : (12 downto 0) := (others => '0');
136 signal Oqueue_dop : (12 downto 0) := (others => '0');
137 signal Oqueue_do : (12 downto 0) := (others => '0');
138 signal Oqueue_a : (3 downto 0) := (others => '1');
139 signal Oqueue_re : := '0';
140 signal Oqueue_do_vld : := '0';
141 signal test_wc : (3 downto 0) := (others => '0');
142 signal lfsr: (31 downto 0) := (others => '0');
143 signal testErr : := '0';
144 signal testCntr: (30 downto 0) := (others => '0');
145 signal app_rqst_i : := '0';
146 signal app_ren : := '0';
147 signal last_word : := '0';
148 signal s_demux : (2 downto 0) := (others => '0');
149 signal data_demux : (31 downto 0) := (others => '0');
150 signal lengthCntr : (7 downto 0) := (others => '0');
151 signal rd_cnt : (4 downto 0) := (others => '0');
152 signal app_addr_i : (27 downto 0) := (others => '0');
153 signal fifo_en : := '0';
154 signal fifo_rst : := '0';
155 signal buf_empty : (3 downto 0) := (others => '0');
156 signal buf_we : := '0';
157 signal buf_re : := '0';
158 signal buf_di : (255 downto 0) := (others => '0');
159 signal buf_do : (255 downto 0) := (others => '0');
160 signal TCPqueue_do_vld : := '0';
161 signal TCP_rrqst : := '0';
162 signal TCP_raddr : (23 downto 0) := (others => '0');
163 signal TCP_raddr_end : (10 downto 0) := (others => '0');
164 signal TCP_rlengthp : (6 downto 0) := (others => '0');
165 signal TCP_rlength : (7 downto 0) := (others => '0');
166 signal TCPqueue_di : (39 downto 0) := (others => '0');
167 signal TCPqueue_dop : (39 downto 0) := (others => '0');
168 signal TCPqueue_do : (39 downto 0) := (others => '0');
169 signal TCPqueue_a : (3 downto 0) := (others => '1');
170 signal Last_TCP_addr : (10 downto 0) := (others => '0');
171 signal first_test_read : := '1';
172 signal sel_TCP : := '0';
173 signal rd_ipb : := '0';
174 signal ipbus_rbuf_wa : (4 downto 0) := (others => '0');
175 signal ipbus_rbuf_ra : (4 downto 0) := (others => '0');
176 signal ipbus_rbuf_di : (257 downto 0) := (others => '0');
177 signal ipbus_rbuf_do : (257 downto 0) := (others => '0');
178 signal ipbus_rbuf_wa2SyncRegs : (2 downto 0) := (others => '0');
179 signal ipbus_rbuf_wa1SyncRegs : (2 downto 0) := (others => '0');
180 signal ipbus_rbuf_wa0SyncRegs : (2 downto 0) := (others => '0');
181 signal ipbus_rbuf_wap : (2 downto 0) := (others => '0');
182 signal ipb_rdata_i : (31 downto 0) := (others => '0');
183 signal rd_queue_o : (2 downto 0) := (others => '0');
184 signal rd_queue_q : (2 downto 0) := (others => '0');
185 signal rd_queue_wa : (5 downto 0) := (others => '0');
186 signal rd_queue_ra : (5 downto 0) := (others => '0');
187 signal rd_queue_q_vld : := '0';
188 signal WRCOUNT : array4x9;
189 signal RDCOUNT : array4x9;
190 signal TCP_dout_valid_i : := '0';
191 signal TCP_lastword_i : := '0';
197 ina :
IN (
135 downto 0);
198 inb :
IN (
135 downto 0)
205 Din :
IN (
303 downto 0)
208 COMPONENT chipscope1b
209 generic (USER2 : := false);
212 Din :
IN (
303 downto 0)
215 signal chk_SEQ : := '0';
216 signal bad_SEQ : := '0';
217 signal NXT_SEQ : (15 downto 0) := (others => '0');
218 signal ina : (135 downto 0) := (others => '0');
219 signal inb : (135 downto 0) := (others => '0');
220 signal cs_in : (303 downto 0) := (others => '0');
222 cs_out(165) <= app_rdy;
223 cs_out(164) <= app_ack;
224 cs_out(163) <= app_rqst_i;
225 cs_out(162 downto 159) <= queue_wap(3 downto 0);
226 cs_out(158 downto 155) <= queue_ra(3 downto 0);
227 cs_out(154 downto 149) <= cs_in(247 downto 242);
228 cs_out(148 downto 105) <= cs_in(166 downto 123);
229 cs_out(104 downto 0) <= cs_in(104 downto 0);
230 --i_chipscope1b: chipscope1b PORT MAP(
234 cs_in(297) <= Oqueue_do_vld;
235 cs_in(296) <= buf_empty(0);
236 cs_in(295 downto 292) <= Oqueue_do(12 downto 9);
237 cs_in(291) <= Oqueue_re;
238 cs_in(290) <= TCP_rrqst;
239 --cs_in(289) <= TCP_addr(
29);
240 cs_in(288) <= bad_SEQ;
244 cs_in(280) <= TCP_lastword_i;
245 --cs_in( downto ) <= ;
246 --cs_in( downto ) <= ;
247 cs_in(279 downto 251) <= TCP_addr(28 downto 0);
248 cs_in(250 downto 247) <= buf_empty;
249 cs_in(246) <= queue_we;
250 cs_in(245) <= Oqueue_re;
251 cs_in(244) <= Oqueue_do_vld;
252 cs_in(242) <= buf_re;
253 cs_in(241) <= TCP_rrqst;
254 cs_in(240 downto 239) <= TCP_addr1and0;
255 cs_in(238 downto 228) <= Last_TCP_addr;
256 cs_in(227 downto 220) <= TCP_rlength;
257 cs_in(219 downto 213) <= TCP_rlengthp;
258 cs_in(201 downto 191) <= TCP_raddr_end;
259 cs_in(190 downto 167) <= TCP_raddr;
260 cs_in(166 downto 163) <= TCPqueue_a;
261 cs_in(162 downto 123) <= TCPqueue_do;
262 --cs_in(114 downto 105) <= TCP_length;
263 cs_in(104 downto 73) <= data_demux;
264 cs_in(72 downto 70) <= s_demux;
265 cs_in(69 downto 62) <= lengthCntr;
266 cs_in(61 downto 58) <= Oqueue_a;
267 cs_in(57 downto 45) <= Oqueue_do;
268 cs_in(44 downto 32) <= Oqueue_di;
269 cs_in(31) <= TCP_dout_valid_i;
270 cs_in(30) <= TCPqueue_we;
271 cs_in(29) <= TCPqueue_do_vld;
272 cs_in(28 downto 0) <= queue_di(28 downto 0);
273 test_pause <= test_wc(3) or testErr;
274 ipb_rdata <= ipb_rdata_i;
275 ipb_ack <= ipb_ack_i;
276 app_rqst <= '0' when app_rqst_i = '0' or (last_word = '1' and app_ren = '1') else '1';
278 app_ren <= app_ack and app_rdy;
279 TCP_ack <= TCPqueue_we;
280 --test_status(5 downto 0) <= rd_queue_ra;
281 --test_status(11 downto 6) <= rd_queue_wa;
282 --test_status(12) <= rd_queue_q_vld;
283 --test_status(13) <= queue_do_vld;
284 --test_status(14) <= Oqueue_do_vld;
285 --test_status(18 downto 15) <= Oqueue_a;
286 --test_status(22 downto 19) <= queue_wa(
3 downto 0);
287 --test_status(26 downto 23) <= queue_ra(
3 downto 0);
288 --test_status(30 downto 27) <= TCPqueue_a;
289 --test_status(40 downto 31) <= Oqueue_do(
9 downto 0);
290 --test_status(48 downto 41) <= lengthCntr;
291 --test_status(51 downto 49) <= s_demux;
292 test_status(31 downto 0) <= testErr & testCntr;
293 --test_status(32) <= '0';
294 --test_status(33) <= first_test_read;
295 --test_status(40 downto 34) <= (
others => '0');
296 --test_status(46 downto 41) <= rd_queue_ra;
297 --test_status(52 downto 47) <= rd_queue_wa;
298 --test_status(55 downto 53) <= ipbus_rbuf_ra(
2 downto 0);
299 --test_status(58 downto 56) <= ipbus_rbuf_wap;
300 --test_status(62 downto 59) <= test_wc;
301 test_status(63 downto 32) <= (others => '0');
302 app_addr <= app_addr_i;
303 TCP_dout <= data_demux;
304 TCP_dout_valid <= TCP_dout_valid_i;
305 TCP_lastword <= TCP_lastword_i;
306 ipb_ack_i <= '0' when ipbRead = '0' or ipbus_rbuf_wap = ipbus_rbuf_ra(2 downto 0) else ipb_strobe;
309 if(ipb_clk'event and ipb_clk = '1')then
312 elsif((ipbRead = '1' and ipbRead_q = '0') or (first_test_read = '1' and test_wc(2) = '1'))then
314 elsif((ipbus_rbuf_ra(2 downto 0) = "001" or ipbus_rbuf_ra(2 downto 0) = "111") and ipb_addr(2 downto 0) = "000" and ipb_ack_i = '1' and test(0) = '0')then
316 elsif((ipbus_rbuf_ra(2 downto 0) = "001" or ipbus_rbuf_ra(2 downto 0) = "111") and testCntr(2 downto 0) = "001")then
321 if(test(0) = '0')then
322 first_test_read <= '1';
323 elsif(ipb_rqst = '1')then
324 first_test_read <= '0';
326 if(reset = '1' or test(0) = '0')then
327 test_wc <= (others => '0');
328 elsif(test_block_sent = '1' and ipb_rqst = '0')then
329 test_wc <= test_wc + 1;
330 elsif(test_block_sent = '0' and ipb_rqst = '1')then
331 test_wc <= test_wc - 1;
333 if(reset = '0' and test(0) = '0' and ipb_strobe = '1' and ipb_write = '0' and (ipb_addr(27) = '1' or ipb_addr(17) = '1'))then
338 ipbRead_q <= ipbRead;
339 if(ipbRead = '0')then
340 if(ipb_addr(27) = '1')then
341 ipb_start_addr <= ipb_addr(26 downto 0);
342 elsif(ipb_addr(17) = '1')then
343 ipb_start_addr <= page_addr & ipb_addr(16 downto 0);
346 if(ipbRead = '0' and test(0) = '0')then
347 ipbus_rbuf_ra <= (others => '0');
348 elsif((ipb_ack_i = '1' and ipb_addr(2 downto 0) = "111") or testCntr(2 downto 0) = "111")then
349 case ipbus_rbuf_ra(2 downto 0) is
350 when "000" => ipbus_rbuf_ra(2 downto 0) <= "001";
351 when "001" => ipbus_rbuf_ra(2 downto 0) <= "011";
352 when "011" => ipbus_rbuf_ra(2 downto 0) <= "010";
353 when "010" => ipbus_rbuf_ra(2 downto 0) <= "110";
354 when "110" => ipbus_rbuf_ra(2 downto 0) <= "111";
355 when "111" => ipbus_rbuf_ra(2 downto 0) <= "101";
356 when "101" => ipbus_rbuf_ra(2 downto 0) <= "100";
357 when others => ipbus_rbuf_ra(2 downto 0) <= "000";
360 if(ipbRead = '0' and test(0) = '0')then
361 ipbus_rbuf_wa2SyncRegs <= "000";
362 ipbus_rbuf_wa1SyncRegs <= "000";
363 ipbus_rbuf_wa0SyncRegs <= "000";
364 ipbus_rbuf_wap <= "000";
366 ipbus_rbuf_wa2SyncRegs <= ipbus_rbuf_wa2SyncRegs(1 downto 0) & ipbus_rbuf_wa(2);
367 ipbus_rbuf_wa1SyncRegs <= ipbus_rbuf_wa1SyncRegs(1 downto 0) & ipbus_rbuf_wa(1);
368 ipbus_rbuf_wa0SyncRegs <= ipbus_rbuf_wa0SyncRegs(1 downto 0) & ipbus_rbuf_wa(0);
369 ipbus_rbuf_wap(2) <= ipbus_rbuf_wa2SyncRegs(2);
370 ipbus_rbuf_wap(1) <= ipbus_rbuf_wa1SyncRegs(2);
371 ipbus_rbuf_wap(0) <= ipbus_rbuf_wa0SyncRegs(2);
373 if(reset = '1' or test(0) = '0')then
375 testCntr <= (others => '0');
376 elsif(ipbus_rbuf_wap /= ipbus_rbuf_ra(2 downto 0))then
377 if(lfsr /= ipb_rdata_i)then
380 if(testErr = '0')then
381 testCntr <= testCntr + 1;
384 if(test(0) = '0')then
385 lfsr <= (others => '0');
386 elsif(ipbus_rbuf_wap /= ipbus_rbuf_ra(2 downto 0))then
387 if(test(1) = '0')then
388 lfsr <= lfsr(30 downto 0) & not(lfsr(31) xor lfsr(21) xor lfsr(1) xor lfsr(0));
395 process(ipb_addr,ipbus_rbuf_do,testCntr)
396 variable s : (2 downto 0);
398 if(test(0) = '0')then
399 s := ipb_addr(2 downto 0);
401 s := testCntr(2 downto 0);
404 when "000" => ipb_rdata_i <= ipbus_rbuf_do(31 downto 0);
405 when "001" => ipb_rdata_i <= ipbus_rbuf_do(63 downto 32);
406 when "010" => ipb_rdata_i <= ipbus_rbuf_do(95 downto 64);
407 when "011" => ipb_rdata_i <= ipbus_rbuf_do(127 downto 96);
408 when "100" => ipb_rdata_i <= ipbus_rbuf_do(159 downto 128);
409 when "101" => ipb_rdata_i <= ipbus_rbuf_do(191 downto 160);
410 when "110" => ipb_rdata_i <= ipbus_rbuf_do(223 downto 192);
411 when others => ipb_rdata_i <= ipbus_rbuf_do(255 downto 224);
414 g_TCPqueue: for i in 0 to 39 generate
417 Q => TCPqueue_dop
(i
),
-- SRL data output
418 A0 => TCPqueue_a
(0),
-- Select[0] input
419 A1 => TCPqueue_a
(1),
-- Select[1] input
420 A2 => TCPqueue_a
(2),
-- Select[2] input
421 A3 => TCPqueue_a
(3),
-- Select[3] input
422 CE => TCPqueue_we,
-- Clock enable input
423 CLK => sysclk,
-- Clock input
424 D => TCPqueue_di
(i
) -- SRL data input
427 g_Oqueue: for i in 0 to 12 generate
430 Q => Oqueue_dop
(i
),
-- SRL data output
431 A0 => Oqueue_a
(0),
-- Select[0] input
432 A1 => Oqueue_a
(1),
-- Select[1] input
433 A2 => Oqueue_a
(2),
-- Select[2] input
434 A3 => Oqueue_a
(3),
-- Select[3] input
435 CE => queue_we,
-- Clock enable input
436 CLK => sysclk,
-- Clock input
437 D => Oqueue_di
(i
) -- SRL data input
440 g_queue : for i in 0 to 4 generate
445 di => queue_di
(i*6+5
downto i*6
),
449 ceReg => queue_ceReg,
450 do => queue_do
(i*6+5
downto i*6
)
453 queue_ceReg <= '1' when queue_do_vld = '0' or (last_word = '1' and app_ren = '1' and sel_TCP = '1') else '0';
454 TCP_rlengthp <= TCP_rlength(6 downto 0) + "0000011";
455 TCPqueue_di <= Last_TCP_addr & TCP_addr(28 downto 0);
457 variable dif : (7 downto 0);
459 dif := (Oqueue_do(8 downto 2) & '0') - lengthCntr;
460 if(sysclk'event and sysclk = '1')then
461 if(resetSys = '1' or run = '0' or TCPqueue_we = '1')then
463 elsif(TCP_rqst = '1')then
466 Last_TCP_addr <= TCP_addr(10 downto 0) + TCP_length;
467 if(resetSys = '1')then
468 TCPqueue_a <= (others => '1');
469 elsif(TCPqueue_we = '1' and (and_reduce(TCPqueue_a) = '1' or TCPqueue_do_vld = '1'))then
470 TCPqueue_a <= TCPqueue_a + 1;
471 elsif(TCPqueue_we = '0' and and_reduce(TCPqueue_a) = '0' and TCPqueue_do_vld = '0')then
472 TCPqueue_a <= TCPqueue_a - 1;
474 if(resetSys = '1' or (queue_we = '1' and Oqueue_di(9) = '1'))then
475 TCPqueue_do_vld <= '0';
476 elsif(and_reduce(TCPqueue_a) = '0')then
477 TCPqueue_do_vld <= '1';
479 if(TCPqueue_do_vld = '0')then
480 TCPqueue_do <= TCPqueue_dop;
482 if(resetSys = '1')then
484 elsif(queue_we = '1' and Oqueue_di(9) = '1')then
486 elsif(TCPqueue_do_vld = '1')then
489 if(TCP_rrqst = '0')then
490 TCP_addr1and0 <= TCPqueue_do(1 downto 0);
491 TCP_raddr <= TCPqueue_do(25 downto 2);
-- in unit of 256 word
492 TCP_raddr_end(10 downto 7) <= TCPqueue_do(39 downto 36) - 1;
493 TCP_raddr_end(6 downto 0) <= TCPqueue_do(35 downto 29);
494 if(TCPqueue_do(10 downto 7) = TCPqueue_do(39 downto 36))then
495 TCP_rlength(7) <= '1';
496 TCP_rlength(6 downto 0) <= TCPqueue_do(35 downto 29) - TCPqueue_do(6 downto 0) + 1;
498 TCP_rlength(7) <= '0';
499 TCP_rlength(6 downto 0) <= "0000000" - TCPqueue_do(6 downto 0);
501 Oqueue_di(12 downto 10) <= TCPqueue_do(28 downto 26);
502 elsif(queue_we = '1')then
503 TCP_addr1and0 <= "00";
504 TCP_raddr(23 downto 5) <= TCP_raddr(23 downto 5) + 1;
505 TCP_raddr(4 downto 0) <= (others => '0');
506 if(TCP_raddr(8 downto 5) = TCP_raddr_end(10 downto 7))then
507 TCP_rlength(7) <= '1';
508 TCP_rlength(6 downto 0) <= (TCP_raddr_end(6 downto 0) + 1);
510 TCP_rlength <= (others => '0');
513 if(resetSys = '1' or buf_empty(0) = '1' or Oqueue_do_vld = '0' or Oqueue_re = '1' or (lengthCntr = x"01" and s_demux(2 downto 1) < Oqueue_do(1 downto 0)))then
514 TCP_dout_valid_i <= '0';
516 TCP_dout_valid_i <= '1';
519 when "000" => data_demux <= buf_do(31 downto 0);
520 when "001" => data_demux <= buf_do(63 downto 32);
521 when "010" => data_demux <= buf_do(95 downto 64);
522 when "011" => data_demux <= buf_do(127 downto 96);
523 when "100" => data_demux <= buf_do(159 downto 128);
524 when "101" => data_demux <= buf_do(191 downto 160);
525 when "110" => data_demux <= buf_do(223 downto 192);
526 when others => data_demux <= buf_do(255 downto 224);
528 if(resetSys = '1' or (Oqueue_do(9) = '1' and Oqueue_re = '1'))then
530 elsif(Oqueue_do(12) = '0' and s_demux = "001")then
533 if(Oqueue_do(12) = '0' and s_demux(1 downto 0) = "10")then
534 NXT_SEQ <= data_demux(15 downto 0);
536 if(chk_SEQ = '1' and Oqueue_do(12) = '0' and s_demux(1 downto 0) = "01" and NXT_SEQ /= data_demux(31 downto 16))then
541 TCP_dout_type <= Oqueue_do(12 downto 10);
542 if(buf_empty(0) = '1' or Oqueue_re = '1')then
545 s_demux <= s_demux + 1;
547 if(resetSys = '1' or queue_we = '1')then
549 elsif(TCP_rrqst = '1' and Oqueue_a(3 downto 2) /= "01")then
554 queue_di(23 downto 0) <= TCP_raddr;
555 queue_di(28 downto 24) <= TCP_rlengthp(6 downto 2);
-- length in 256-bit words
556 Oqueue_di(1 downto 0) <= TCP_addr1and0;
557 Oqueue_di(8 downto 2) <= TCP_rlength(6 downto 0);
-- length in 64-bit words
558 Oqueue_di(9) <= TCP_rlength(7);
559 if(resetSys = '1')then
560 Oqueue_do_vld <= '0';
561 elsif(Oqueue_a /= x"f")then
562 Oqueue_do_vld <= '1';
563 elsif(Oqueue_re = '1')then
564 Oqueue_do_vld <= '0';
566 if(Oqueue_do_vld = '0' or Oqueue_re = '1')then
567 Oqueue_do <= Oqueue_dop;
569 if(resetSys = '1' or Oqueue_re = '1' or (lengthCntr = x"01" and s_demux(2 downto 1) < Oqueue_do(1 downto 0)))then
571 elsif(buf_empty(0) = '0')then
572 lengthCntr <= lengthCntr + 1;
574 if(resetSys = '1')then
576 TCP_lastword_i <= '0';
577 elsif(lengthCntr = (Oqueue_do(8 downto 2) & '0') and buf_empty(0) = '0')then
579 TCP_lastword_i <= Oqueue_do(9);
582 TCP_lastword_i <= '0';
584 if(resetSys = '1')then
585 Oqueue_a <= (others => '1');
586 elsif(queue_we = '1' and (Oqueue_a = x"f" or (Oqueue_do_vld = '1' and Oqueue_re = '0')))then
587 Oqueue_a <= Oqueue_a + 1;
588 elsif(queue_we = '0' and Oqueue_a /= x"f" and (Oqueue_do_vld = '0' or Oqueue_re = '1'))then
589 Oqueue_a <= Oqueue_a - 1;
591 if(resetSys = '1')then
592 queue_wa <= (others => '0');
593 elsif(queue_we = '1')then
594 queue_wa(1) <= queue_wa(0);
595 queue_wa(0) <= not queue_wa(1);
596 if(queue_wa(1 downto 0) = "10")then
597 queue_wa(3 downto 2) <= queue_wa(3 downto 2) + 1;
600 if(resetSys = '1' or fifo_en = '0' or buf_re = '1')then
602 elsif(s_demux = "110" or (lengthCntr = (Oqueue_do(8 downto 2) & '0') and Oqueue_do(9) = '1'))then
609 if(memclk'event and memclk = '1')then
610 if(resetMem = '1')then
612 elsif(queue_wap /= queue_ra(3 downto 0))then
614 elsif(last_word = '1' and app_ren = '1' and sel_TCP = '1')then
617 if(resetMem = '1')then
618 queue_ra <= (others => '0');
619 elsif(queue_wap /= queue_ra(3 downto 0) and (queue_do_vld = '0' or (last_word = '1' and app_ren = '1' and sel_TCP = '1')))then
620 queue_ra(1) <= queue_ra(0);
621 queue_ra(0) <= not queue_ra(1);
622 if(queue_ra(1 downto 0) = "10")then
623 queue_ra(3 downto 2) <= queue_ra(3 downto 2) + 1;
626 if(resetMem = '1')then
627 queue_wa0SyncRegs <= (others => '0');
628 queue_wa1SyncRegs <= (others => '0');
629 queue_wap <= (others => '0');
631 queue_wa0SyncRegs <= queue_wa0SyncRegs(1 downto 0) & queue_wa(0);
632 queue_wa1SyncRegs <= queue_wa1SyncRegs(1 downto 0) & queue_wa(1);
633 queue_wap(0) <= queue_wa0SyncRegs(2);
634 queue_wap(1) <= queue_wa1SyncRegs(2);
635 if(queue_wap(1) = '1' and queue_wa1SyncRegs(2) = '0')then
636 queue_wap(3 downto 2) <= queue_wap(3 downto 2) + 1;
639 if(resetMem = '1' or (last_word = '1' and app_ren = '1'))then
641 elsif(queue_do_vld = '1' or or_reduce(ipb_rqst_cnt) = '1')then
644 if(app_rqst_i = '0')then
645 if(queue_do_vld = '1' and queue_do(28 downto 24) = "00001")then
650 elsif(app_ren = '1')then
651 if(rd_cnt = "00010")then
657 if(app_rqst_i = '0')then
658 if(or_reduce(ipb_rqst_cnt) = '1')then
659 app_addr_i <= '0' & ipb_raddr & "000";
662 elsif(queue_do_vld = '1')then
663 app_addr_i <= '0' & queue_do(23 downto 0) & "000";
664 rd_cnt <= queue_do(28 downto 24);
-- rd_cnt is number of read in unit of 256 word(equivalent
to eight 32-bit word)
667 elsif(app_ren = '1')then
668 app_addr_i(24 downto 3) <= app_addr_i(24 downto 3) + 1;
-- should never carry to app_addr_i(25), must wrap around
669 rd_cnt <= rd_cnt - 1;
676 fifo_rst => fifo_rst,
679 g_rbuf : for i in 0 to 3 generate
680 i_rbuf : FIFO_DUALCLOCK_MACRO
682 DEVICE =>
"7SERIES",
-- Target Device: "VIRTEX5",
"VIRTEX6",
"7SERIES"
683 ALMOST_FULL_OFFSET => X"0080",
-- Sets almost full threshold
684 ALMOST_EMPTY_OFFSET => X"0080",
-- Sets the almost empty threshold
685 DATA_WIDTH =>
64,
-- Valid values are 1-72 (37-72 only valid when FIFO_SIZE="36Kb")
686 FIFO_SIZE =>
"36Kb",
-- Target BRAM, "18Kb" or "36Kb"
687 FIRST_WORD_FALL_THROUGH => TRUE
) -- Sets the FIFO FWFT to TRUE or FALSE
689 ALMOSTEMPTY =>
open,
-- 1-bit output almost empty
690 ALMOSTFULL =>
open,
-- 1-bit output almost full
691 DO => buf_do
(i*64+63
downto i*64
),
-- Output data, width defined by DATA_WIDTH parameter
692 EMPTY => buf_empty
(i
),
-- 1-bit output empty
693 FULL =>
open,
-- 1-bit output full
694 RDCOUNT => RDCOUNT
(i
),
-- Output read count, width determined by FIFO depth
695 RDERR =>
open,
-- 1-bit output read error
696 WRCOUNT => WRCOUNT
(i
),
-- Output write count, width determined by FIFO depth
697 WRERR =>
open,
-- 1-bit output write error
698 DI => buf_di
(i*64+63
downto i*64
),
-- Input data, width defined by DATA_WIDTH parameter
699 RDCLK => sysclk,
-- 1-bit input read clock
700 RDEN => buf_re,
-- 1-bit input read enable
701 RST => fifo_rst,
-- 1-bit input reset
702 WRCLK => memclk,
-- 1-bit input write clock
703 WREN => buf_we
-- 1-bit input write enable
706 buf_di <= app_rd_data;
707 buf_we <= '1' when app_rd_data_valid = '1' and fifo_en = '1' and rd_queue_q(2) = '1' else '0';
708 g_ipbus_rbuf : for i in 0 to 42 generate
711 di => ipbus_rbuf_di
(i*6+5
downto i*6
),
712 we => app_rd_data_valid,
715 do => ipbus_rbuf_do
(i*6+5
downto i*6
)
718 ipbus_rbuf_di(255 downto 0) <= app_rd_data;
719 process(memclk,ipbRead,test)
721 if(ipbRead = '0' and test(0) = '0')then
722 ipbus_rbuf_wa(2 downto 0) <= (others => '0');
723 ipb_rqstSyncRegs <= (others => '0');
724 ipb_rqst_cnt <= (others => '0');
725 elsif(memclk'event and memclk = '1')then
726 if(app_rd_data_valid = '1' and ipb_seq = rd_queue_q(1 downto 0) and rd_queue_q_vld = '1' and rd_queue_q(2) = '0')then
727 case ipbus_rbuf_wa(2 downto 0) is
728 when "000" => ipbus_rbuf_wa(2 downto 0) <= "001";
729 when "001" => ipbus_rbuf_wa(2 downto 0) <= "011";
730 when "011" => ipbus_rbuf_wa(2 downto 0) <= "010";
731 when "010" => ipbus_rbuf_wa(2 downto 0) <= "110";
732 when "110" => ipbus_rbuf_wa(2 downto 0) <= "111";
733 when "111" => ipbus_rbuf_wa(2 downto 0) <= "101";
734 when "101" => ipbus_rbuf_wa(2 downto 0) <= "100";
735 when others => ipbus_rbuf_wa(2 downto 0) <= "000";
738 ipb_rqstSyncRegs <= ipb_rqstSyncRegs(2 downto 0) & ipb_rqst;
739 if(ipb_rqstSyncRegs(3 downto 2) = "10" and (app_rqst_i = '1' or or_reduce(ipb_rqst_cnt) = '0'))then
740 ipb_rqst_cnt <= ipb_rqst_cnt + 1;
741 elsif(ipb_rqstSyncRegs(3 downto 2) /= "10" and app_rqst_i = '0' and or_reduce(ipb_rqst_cnt) = '1')then
742 ipb_rqst_cnt <= ipb_rqst_cnt - 1;
746 ipbus_rbuf_wa(4) <= rd_queue_q(2);
749 if(memclk'event and memclk = '1')then
750 ipbReadSyncRegs <= ipbReadSyncRegs(2 downto 0) & ipbRead;
751 if(ipbReadSyncRegs(3 downto 2) = "10")then -- ipb_seq is used to eject stalemate read data
752 ipb_seq <= ipb_seq + 1;
754 if(resetMem = '1')then
755 ipb_raddr <= (others => '0');
756 elsif(ipbReadSyncRegs(3 downto 2) = "01")then
757 ipb_raddr <= ipb_start_addr(26 downto 3);
758 elsif(sel_TCP = '0' and app_ren = '1')then
759 ipb_raddr <= ipb_raddr + 1;
761 if(resetMem = '1')then
762 rd_queue_wa <= (others => '0');
763 elsif(app_ren = '1')then
764 rd_queue_wa <= rd_queue_wa + 1;
766 if(resetMem = '1')then
767 rd_queue_ra <= (others => '0');
768 elsif(rd_queue_wa /= rd_queue_ra and (app_rd_data_valid = '1' or rd_queue_q_vld = '0'))then
769 rd_queue_ra <= rd_queue_ra + 1;
771 if(resetMem = '1')then
772 rd_queue_q_vld <= '0';
773 elsif(rd_queue_wa /= rd_queue_ra)then
774 rd_queue_q_vld <= '1';
775 elsif(app_rd_data_valid = '1')then
776 rd_queue_q_vld <= '0';
778 if(app_rd_data_valid = '1' or rd_queue_q_vld = '0')then
779 rd_queue_q <= rd_queue_o;
785 DOA => rd_queue_o
(0),
-- Read port A 1-bit output
786 DOB => rd_queue_o
(1),
-- Read port B 1-bit output
787 DOC => rd_queue_o
(2),
-- Read port C 1-bit output
788 DOD =>
open,
-- Read/Write port D 1-bit output
789 ADDRA => rd_queue_ra,
-- Read port A 6-bit address input
790 ADDRB => rd_queue_ra,
-- Read port B 6-bit address input
791 ADDRC => rd_queue_ra,
-- Read port C 6-bit address input
792 ADDRD => rd_queue_wa,
-- Read/Write port D 6-bit address input
793 DIA => ipb_seq
(0),
-- RAM 1-bit data write input addressed by ADDRD,
794 -- read addressed by ADDRA
795 DIB => ipb_seq
(1),
-- RAM 1-bit data write input addressed by ADDRD,
796 -- read addressed by ADDRB
797 DIC => sel_TCP,
-- RAM 1-bit data write input addressed by ADDRD,
798 -- read addressed by ADDRC
799 DID => '0',
-- RAM 1-bit data write input addressed by ADDRD,
800 -- read addressed by ADDRD
801 WCLK => memclk ,
-- Write clock input
802 WE => app_ren
-- Write enable input