2 -- VHDL Entity ipbus_v2_lib.UDP_if.symbol and
3 -- VHDL Entity ipbus_v2_lib.rxblock.symbol
4 -- Dave Sankey Sep 2012
7 USE ieee.std_logic_1164.
all;
8 USE ieee.numeric_std.
all;
12 -- Number of address bits to select RX or TX buffer
13 -- Number of RX and TX buffers is 2**BUFWIDTH
16 -- Numer of address bits to select internal buffer
17 -- Number of internal buffers is 2**INTERNALWIDTH
20 -- Number of address bits within each buffer
21 -- Size of each buffer is 2**ADDRWIDTH
24 -- UDP port for IPbus traffic in this instance
25 IPBUSPORT: (15 DOWNTO 0) := x"C351";
27 -- Flag whether this instance ignores everything except IPBus traffic
36 IP_addr: IN (31 DOWNTO 0);
37 MAC_addr: IN (47 DOWNTO 0);
40 mac_rx_data: IN (7 DOWNTO 0);
47 raddr: IN (11 DOWNTO 0);
48 waddr: IN (11 DOWNTO 0);
49 wdata: IN (31 DOWNTO 0);
52 mac_tx_data: OUT (7 DOWNTO 0);
56 My_IP_addr: OUT (31 DOWNTO 0);
58 rdata: OUT (31 DOWNTO 0);
59 rxpacket_ignored: OUT ;
67 SIGNAL addra: (12 DOWNTO 0);
68 SIGNAL addrb: (12 DOWNTO 0);
71 SIGNAL dia: (7 DOWNTO 0);
73 SIGNAL dob: (7 DOWNTO 0);
74 SIGNAL int_data: (7 DOWNTO 0);
76 SIGNAL outbyte: (7 DOWNTO 0);
77 SIGNAL payload_addr: (12 DOWNTO 0);
78 SIGNAL payload_data: (7 DOWNTO 0);
79 SIGNAL payload_send: ;
85 SIGNAL rxram_end_addr: (12 DOWNTO 0);
87 SIGNAL udpaddrb: (12 DOWNTO 0);
88 SIGNAL udpdob: (7 DOWNTO 0);
93 SIGNAL My_IP_addr_sig: (31 DOWNTO 0);
94 SIGNAL pkt_drop_rarp: ;
95 SIGNAL rarp_addr: (12 DOWNTO 0);
96 SIGNAL rarp_data: (7 DOWNTO 0);
97 SIGNAL rarp_end_addr: (12 DOWNTO 0);
102 SIGNAL arp_addr: (12 DOWNTO 0);
103 SIGNAL arp_data: (7 DOWNTO 0);
104 SIGNAL arp_end_addr: (12 DOWNTO 0);
109 SIGNAL clr_sum_payload: ;
110 SIGNAL clr_sum_ping: ;
112 SIGNAL do_sum_payload: ;
113 SIGNAL do_sum_ping: ;
114 SIGNAL rx_int_data: (7 DOWNTO 0);
115 SIGNAL int_data_payload: (7 DOWNTO 0);
116 SIGNAL int_data_ping: (7 DOWNTO 0);
117 SIGNAL rx_int_valid: ;
118 SIGNAL int_valid_payload: ;
119 SIGNAL int_valid_ping: ;
120 SIGNAL rx_outbyte: (7 DOWNTO 0);
121 SIGNAL ping_addr: (12 DOWNTO 0);
122 SIGNAL ping_data: (7 DOWNTO 0);
123 SIGNAL ping_end_addr: (12 DOWNTO 0);
126 SIGNAL status_block: (127 downto 0);
127 SIGNAL status_request: ;
128 SIGNAL status_data: (7 downto 0);
129 SIGNAL status_addr: (12 downto 0);
131 SIGNAL status_end_addr: (12 downto 0);
132 SIGNAL status_send: ;
133 SIGNAL pkt_drop_arp: ;
134 SIGNAL pkt_drop_payload: ;
135 SIGNAL pkt_drop_ping: ;
136 SIGNAL pkt_drop_resend: ;
137 SIGNAL pkt_drop_status: ;
138 signal last_rx_last: ;
141 signal mac_tx_last_sig, mac_tx_error_sig: ;
143 signal ipbus_in_hdr, ipbus_out_hdr: (31 downto 0);
144 signal pkt_broadcast, ipbus_out_valid: ;
145 signal rxram_dropped_sig, rxpayload_dropped_sig: ;
146 signal pkt_drop_ipbus, pkt_drop_reliable, pkt_byteswap: ;
147 signal next_pkt_id: (15 downto 0);
-- Next expected packet ID
150 signal rst_ipb_125: ;
152 SIGNAL rxram_write_buf, rxram_send_buf: (INTERNALWIDTH - 1 downto 0);
153 SIGNAL rxram_sent, internal_busy, rxram_req_send, rxram_send_x: ;
154 SIGNAL rxram_end_addr_x: (12 downto 0);
155 SIGNAL rxram_addra, rxram_addrb: (INTERNALWIDTH + ADDRWIDTH - 1 downto 0);
157 SIGNAL rx_read_buffer, rx_read_buffer_125: (BUFWIDTH - 1 downto 0);
158 SIGNAL rx_write_buffer, tx_read_buffer: (BUFWIDTH - 1 downto 0);
159 SIGNAL tx_write_buffer, tx_write_buffer_125, resend_buf: (BUFWIDTH - 1 downto 0);
160 SIGNAL rx_full_addra, tx_full_addrb: (BUFWIDTH + ADDRWIDTH - 1 downto 0);
161 SIGNAL rx_full_addrb, tx_full_addra: (BUFWIDTH + ADDRWIDTH - 3 downto 0);
162 signal pkt_resend, pkt_rcvd, rx_ram_busy, rx_req_send_125, udpram_sent: ;
163 signal busy_125, enable_125, rarp_125, rx_ram_sent, tx_ram_written: ;
164 signal rxreq_not_found: ;
165 signal resend_pkt_id: (15 downto 0);
166 signal clean_buf: (2**BUFWIDTH - 1 downto 0);
170 rxpacket_dropped <= rxram_dropped_sig or rxpayload_dropped_sig or rxreq_not_found;
171 rxpacket_ignored <= my_rx_last and pkt_drop_arp and pkt_drop_ping and
172 pkt_drop_payload and pkt_drop_rarp and pkt_drop_resend and pkt_drop_status;
174 mac_tx_last <= mac_tx_last_sig;
177 rx_do_sum <= do_sum_ping or do_sum_payload;
178 rx_clr_sum <= clr_sum_ping or clr_sum_payload;
179 rx_int_valid <= int_valid_ping or int_valid_payload;
180 rx_int_data <= int_data_payload when int_valid_payload = '1' else int_data_ping;
182 rxram_addra <= rxram_write_buf & addra(ADDRWIDTH - 1 downto 0);
183 rxram_addrb <= rxram_send_buf & addrb(ADDRWIDTH - 1 downto 0);
185 rx_full_addra <= rx_write_buffer & payload_addr(ADDRWIDTH - 1 downto 0);
186 rx_full_addrb <= rx_read_buffer & raddr(ADDRWIDTH - 3 downto 0);
188 tx_full_addra <= tx_write_buffer & waddr(ADDRWIDTH - 3 downto 0);
189 tx_full_addrb <= tx_read_buffer & udpaddrb(ADDRWIDTH - 1 downto 0);
191 -- force rx_last to match documentation!
192 rx_last_kludge:
process(mac_clk)
194 if rising_edge(mac_clk) then
195 last_rx_last <= mac_rx_last
196 -- pragma translate_off
198 -- pragma translate_on
203 my_rx_last <= mac_rx_last and not last_rx_last;
205 My_IP_addr <= My_IP_addr_sig;
207 -- Instance port mappings.
211 rst_macclk => rst_macclk,
212 rx_reset => rx_reset,
213 enable_125 => enable_125,
214 rarp_125 => rarp_125,
216 mac_rx_data => mac_rx_data,
217 mac_rx_error => mac_rx_error,
218 mac_rx_last => my_rx_last,
219 mac_rx_valid => mac_rx_valid,
220 pkt_drop_rarp => pkt_drop_rarp,
221 My_IP_addr => My_IP_addr_sig,
222 rarp_mode => rarp_mode
227 rst_macclk => rst_macclk,
228 enable_125 => enable_125,
229 MAC_addr => MAC_addr,
230 rarp_mode => rarp_mode,
231 rarp_addr => rarp_addr,
232 rarp_data => rarp_data,
233 rarp_end_addr => rarp_end_addr,
234 rarp_send => rarp_send,
240 rx_reset => rx_reset,
241 mac_rx_data => mac_rx_data,
242 mac_rx_valid => mac_rx_valid,
243 mac_rx_last => my_rx_last,
244 mac_rx_error => mac_rx_error,
245 pkt_drop_arp => pkt_drop_arp,
246 MAC_addr => MAC_addr,
247 My_IP_addr => My_IP_addr_sig,
248 arp_data => arp_data,
249 arp_addr => arp_addr,
251 arp_end_addr => arp_end_addr,
257 rx_reset => rx_reset,
258 mac_rx_data => mac_rx_data,
259 mac_rx_valid => mac_rx_valid,
260 mac_rx_last => my_rx_last,
261 mac_rx_error => mac_rx_error,
262 pkt_drop_payload => pkt_drop_payload,
263 pkt_byteswap => pkt_byteswap,
264 outbyte => rx_outbyte,
265 payload_data => payload_data,
266 payload_addr => payload_addr,
267 payload_we => payload_we,
268 payload_send => payload_send,
269 do_sum_payload => do_sum_payload,
270 clr_sum_payload => clr_sum_payload,
271 int_data_payload => int_data_payload,
272 int_valid_payload => int_valid_payload,
274 ipbus_in_hdr => ipbus_in_hdr
279 rx_reset => rx_reset,
280 mac_rx_data => mac_rx_data,
281 mac_rx_valid => mac_rx_valid,
282 mac_rx_last => my_rx_last,
283 mac_rx_error => mac_rx_error,
284 pkt_drop_ping => pkt_drop_ping,
285 outbyte => rx_outbyte,
286 ping_data => ping_data,
287 ping_addr => ping_addr,
289 ping_end_addr => ping_end_addr,
290 ping_send => ping_send,
291 do_sum_ping => do_sum_ping,
292 clr_sum_ping => clr_sum_ping,
293 int_data_ping => int_data_ping,
294 int_valid_ping => int_valid_ping
299 rx_reset => rx_reset,
300 mac_rx_data => mac_rx_data,
301 mac_rx_error => mac_rx_error,
302 mac_rx_last => my_rx_last,
303 mac_rx_valid => mac_rx_valid,
304 pkt_drop_resend => pkt_drop_resend,
305 pkt_resend => pkt_resend,
306 resend_pkt_id => resend_pkt_id
311 rx_reset => rx_reset,
312 mac_rx_data => mac_rx_data,
313 mac_rx_valid => mac_rx_valid,
314 mac_rx_last => my_rx_last,
315 mac_rx_error => mac_rx_error,
316 pkt_drop_status => pkt_drop_status,
317 status_block => status_block,
318 status_request => status_request ,
319 status_data => status_data,
320 status_addr => status_addr,
321 status_we => status_we,
322 status_end_addr => status_end_addr,
323 status_send => status_send
327 BUFWIDTH => BUFWIDTH,
328 ADDRWIDTH => ADDRWIDTH
332 rst_macclk => rst_macclk,
333 rst_ipb_125 => rst_ipb_125,
334 rx_reset => rx_reset,
335 ipbus_in_hdr => ipbus_in_hdr,
336 ipbus_out_hdr => ipbus_out_hdr,
337 ipbus_out_valid => ipbus_out_valid,
338 mac_rx_error => mac_rx_error,
339 mac_rx_last => my_rx_last,
340 mac_tx_error => mac_tx_error_sig,
341 mac_tx_last => mac_tx_last_sig,
342 pkt_broadcast => pkt_broadcast,
343 pkt_drop_arp => pkt_drop_arp,
344 pkt_drop_ipbus => pkt_drop_ipbus ,
345 pkt_drop_payload => pkt_drop_payload,
346 pkt_drop_ping => pkt_drop_ping,
347 pkt_drop_rarp => pkt_drop_rarp,
348 pkt_drop_reliable => pkt_drop_reliable,
349 pkt_drop_resend => pkt_drop_resend,
350 pkt_drop_status => pkt_drop_status,
351 pkt_rcvd => pkt_rcvd,
352 req_not_found => rxreq_not_found,
353 rx_ram_sent => rx_ram_sent,
354 rx_req_send_125 => rx_req_send_125,
355 rxpayload_dropped => rxpayload_dropped_sig,
356 rxram_dropped => rxram_dropped_sig,
357 status_request => status_request ,
358 tx_ram_written => tx_ram_written ,
359 udpram_send => udpram_send,
360 next_pkt_id => next_pkt_id,
361 status_block => status_block
367 clr_sum => rx_clr_sum,
368 mac_rx_data => mac_rx_data,
369 mac_rx_valid => mac_rx_valid,
370 int_data => rx_int_data,
371 int_valid => rx_int_valid,
374 outbyte => rx_outbyte
379 rst_macclk => rst_macclk,
380 mac_rx_last => my_rx_last,
381 mac_rx_valid => mac_rx_valid,
386 IPBUSPORT => IPBUSPORT,
387 SECONDARYPORT => SECONDARYPORT
391 rx_reset => rx_reset,
392 enable_125 => enable_125,
393 mac_rx_data => mac_rx_data,
394 mac_rx_valid => mac_rx_valid,
395 MAC_addr => MAC_addr,
396 My_IP_addr => My_IP_addr_sig,
397 next_pkt_id => next_pkt_id,
398 pkt_broadcast => pkt_broadcast,
399 pkt_byteswap => pkt_byteswap,
400 pkt_drop_arp => pkt_drop_arp,
401 pkt_drop_ipbus => pkt_drop_ipbus ,
402 pkt_drop_payload => pkt_drop_payload,
403 pkt_drop_ping => pkt_drop_ping,
404 pkt_drop_rarp => pkt_drop_rarp,
405 pkt_drop_reliable => pkt_drop_reliable,
406 pkt_drop_resend => pkt_drop_resend,
407 pkt_drop_status => pkt_drop_status
412 rx_reset => rx_reset,
413 rarp_mode => rarp_mode,
414 rarp_addr => rarp_addr,
415 rarp_data => rarp_data,
416 rarp_end_addr => rarp_end_addr,
417 rarp_send => rarp_send,
419 pkt_drop_arp => pkt_drop_arp,
420 arp_data => arp_data,
421 arp_addr => arp_addr,
423 arp_end_addr => arp_end_addr,
424 arp_send => arp_send,
425 pkt_drop_ping => pkt_drop_ping,
426 ping_data => ping_data,
427 ping_addr => ping_addr,
429 ping_end_addr => ping_end_addr,
430 ping_send => ping_send,
431 pkt_drop_status => pkt_drop_status,
432 status_data => status_data,
433 status_addr => status_addr,
434 status_we => status_we,
435 status_end_addr => status_end_addr,
436 status_send => status_send,
437 mac_rx_valid => mac_rx_valid,
438 rxram_busy => internal_busy,
442 rxram_end_addr => rxram_end_addr,
443 rxram_send => rxram_send,
444 rxram_dropped => rxram_dropped_sig
448 BUFWIDTH => INTERNALWIDTH,
449 ADDRWIDTH => ADDRWIDTH
455 addra => rxram_addra,
456 addrb => rxram_addrb,
462 BUFWIDTH => INTERNALWIDTH
466 rst_macclk => rst_macclk,
467 written => rxram_send,
471 resend_buf =>
(Others => '0'
),
472 busy => internal_busy,
473 write_buf => rxram_write_buf,
474 req_send => rxram_req_send,
475 send_buf => rxram_send_buf,
480 BUFWIDTH => INTERNALWIDTH
484 rst_macclk => rst_macclk,
485 rxram_end_addr => rxram_end_addr ,
486 rxram_send => rxram_send,
487 rxram_write_buf => rxram_write_buf,
488 rxram_req_send => rxram_req_send ,
489 rxram_send_buf => rxram_send_buf ,
490 rxram_busy => rxram_busy,
491 rxram_end_addr_x => rxram_end_addr_x,
492 rxram_send_x => rxram_send_x,
493 rxram_sent => rxram_sent
497 BUFWIDTH => BUFWIDTH,
498 ADDRWIDTH => ADDRWIDTH
504 rx_addra => rx_full_addra,
505 rx_addrb => rx_full_addrb,
506 rx_dia => payload_data,
515 rst_macclk => rst_macclk,
520 resend_buf =>
(Others => '0'
),
522 write_buf => rx_write_buffer,
523 req_send => rx_req_send_125,
524 send_buf => rx_read_buffer_125,
529 BUFWIDTH => BUFWIDTH,
530 ADDRWIDTH => ADDRWIDTH
536 tx_addra => tx_full_addra,
537 tx_addrb => tx_full_addrb,
547 rst_macclk => rst_macclk,
548 written => tx_ram_written,
551 req_resend => req_resend,
552 resend_buf => resend_buf,
554 write_buf => tx_write_buffer_125,
555 req_send => udpram_send,
556 send_buf => tx_read_buffer,
557 clean_buf => clean_buf
564 mac_rx_data => udpdob ,
565 mac_rx_valid => udpram_busy,
566 int_data => int_data,
567 int_valid => int_valid,
568 run_byte_sum => int_valid,
575 rx_reset => rx_reset,
576 payload_send => payload_send,
577 payload_we => payload_we,
578 rx_ram_busy => rx_ram_busy,
579 pkt_rcvd => pkt_rcvd,
581 rxpayload_dropped => rxpayload_dropped_sig
586 rst_macclk => rst_macclk,
587 rxram_end_addr => rxram_end_addr_x,
588 rxram_send => rxram_send_x,
589 rxram_busy => rxram_busy,
592 udpram_send => udpram_send,
593 udpram_busy => udpram_busy,
594 udpaddrb => udpaddrb,
598 int_data => int_data,
599 int_valid => int_valid,
602 mac_tx_data => mac_tx_data,
603 mac_tx_valid => mac_tx_valid,
604 mac_tx_last => mac_tx_last_sig,
605 mac_tx_error => mac_tx_error_sig,
606 mac_tx_ready => mac_tx_ready,
607 ipbus_out_hdr => ipbus_out_hdr,
608 ipbus_out_valid => ipbus_out_valid
616 rst_macclk => rst_macclk,
617 pkt_resend => pkt_resend,
618 resend_pkt_id => resend_pkt_id,
619 ipbus_out_hdr => ipbus_out_hdr,
620 ipbus_out_valid => ipbus_out_valid,
621 tx_read_buffer => tx_read_buffer ,
622 udpram_busy => udpram_busy,
623 clean_buf => clean_buf,
624 req_not_found => rxreq_not_found,
625 req_resend => req_resend,
626 resend_buf => resend_buf,
627 udpram_sent => udpram_sent
635 rst_macclk => rst_macclk,
636 busy_125 => busy_125,
637 rx_read_buffer_125 => rx_read_buffer_125,
638 rx_req_send_125 => rx_req_send_125,
639 tx_write_buffer_125 => tx_write_buffer_125,
640 enable_125 => enable_125,
641 rarp_125 => rarp_125,
642 rst_ipb_125 => rst_ipb_125,
643 rx_ram_sent => rx_ram_sent,
644 tx_ram_written => tx_ram_written ,
650 pkt_done_read => pkt_done_read,
651 pkt_done_write => pkt_done_write,
656 rx_read_buffer => rx_read_buffer ,
657 tx_write_buffer => tx_write_buffer