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