-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathudp_build_resend.vhd
72 lines (66 loc) · 1.82 KB
/
udp_build_resend.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-- Builds request for UDP resend...
--
-- Dave Sankey, July 2012
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity udp_build_resend is
port (
mac_clk: in std_logic;
rx_reset: in std_logic;
mac_rx_data: in std_logic_vector(7 downto 0);
mac_rx_error: in std_logic;
mac_rx_last: in std_logic;
mac_rx_valid: in std_logic;
pkt_drop_resend: in std_logic;
pkt_resend: out std_logic;
resend_pkt_id: out std_logic_vector(15 downto 0)
);
end udp_build_resend;
architecture rtl of udp_build_resend is
begin
send_packet: process (mac_clk)
begin
if rising_edge(mac_clk) then
if mac_rx_last = '1' and pkt_drop_resend = '0' and
mac_rx_error = '0' then
pkt_resend <= '1'
-- pragma translate_off
after 4 ns
-- pragma translate_on
;
else
pkt_resend <= '0'
-- pragma translate_off
after 4 ns
-- pragma translate_on
;
end if;
end if;
end process;
resend_pkt_id_block: process(mac_clk)
variable pkt_mask: std_logic_vector(44 downto 0);
variable resend_pkt_id_int: std_logic_vector(15 downto 0);
begin
if rising_edge(mac_clk) then
if rx_reset = '1' then
pkt_mask := "111111" & "111111" & "11" &
"11" & "11" & "11" & "11" & "1" & "1" & "11" &
"1111" & "1111" & "11" & "11" & "11" & "11" & "100";
resend_pkt_id_int := (Others => '0');
elsif mac_rx_valid = '1' then
if pkt_drop_resend = '1' then
resend_pkt_id_int := (Others => '0');
elsif pkt_mask(44) = '0' then
resend_pkt_id_int := resend_pkt_id_int(7 downto 0) & mac_rx_data;
end if;
pkt_mask := pkt_mask(43 downto 0) & '1';
end if;
resend_pkt_id <= resend_pkt_id_int
-- pragma translate_off
after 4 ns
-- pragma translate_on
;
end if;
end process;
end rtl;