AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
udp_ipaddr_block.vhd
1 -- Handles source of IP address...
2 -- Parses incoming RARP response
3 --
4 -- Dave Sankey, July 2012
5 
6 library ieee;
7 use ieee.std_logic_1164.all;
8 use ieee.numeric_std.all;
9 
11  port (
12  mac_clk: in std_logic;
13  rst_macclk: in std_logic;
14  rx_reset: in std_logic;
15  enable_125: in std_logic;
16  rarp_125: in std_logic;
17  IP_addr: in std_logic_vector(31 downto 0);
18  mac_rx_data: in std_logic_vector(7 downto 0);
19  mac_rx_error: in std_logic;
20  mac_rx_last: in std_logic;
21  mac_rx_valid: in std_logic;
22  pkt_drop_rarp: in std_logic;
23  My_IP_addr: out std_logic_vector(31 downto 0);
24  rarp_mode: out std_logic
25  );
26 end udp_ipaddr_block;
27 
28 architecture rtl of udp_ipaddr_block is
29 
30  signal IP_addr_rx_vld: std_logic;
31  signal IP_addr_rx: std_logic_vector(31 downto 0);
32 
33 begin
34 
35 IP_addr_rx_vld_block: process (mac_clk)
36  begin
37  if rising_edge(mac_clk) then
38 -- Valid RARP response received.
39  if mac_rx_last = '1' and pkt_drop_rarp = '0' and
40  mac_rx_error = '0' then
41  IP_addr_rx_vld <= '1'
42 -- pragma translate_off
43  after 4 ns
44 -- pragma translate_on
45  ;
46  else
47  IP_addr_rx_vld <= '0'
48 -- pragma translate_off
49  after 4 ns
50 -- pragma translate_on
51  ;
52  end if;
53  end if;
54  end process;
55 
56 IP_addr_rx_block: process(mac_clk)
57  variable pkt_mask: std_logic_vector(41 downto 0);
58  variable IP_addr_rx_int: std_logic_vector(31 downto 0);
59  begin
60  if rising_edge(mac_clk) then
61  if rx_reset = '1' then
62  pkt_mask := "111111" & "111111" & "11" &
63  "11" & "11" & "11" & "11" & "111111" &
64  "1111" & "111111" & "0000";
65  IP_addr_rx_int := (Others => '0');
66  elsif mac_rx_valid = '1' then
67  if pkt_drop_rarp = '1' then
68  IP_addr_rx_int := (Others => '0');
69  elsif pkt_mask(41) = '0' then
70  IP_addr_rx_int := IP_addr_rx_int(23 downto 0) & mac_rx_data;
71  end if;
72  pkt_mask := pkt_mask(40 downto 0) & '1';
73  end if;
74  IP_addr_rx <= IP_addr_rx_int
75 -- pragma translate_off
76  after 4 ns
77 -- pragma translate_on
78  ;
79  end if;
80  end process;
81 
82 My_IP_addr_block: process (mac_clk)
83  variable Got_IP_addr_rx: std_logic;
84  variable My_IP_addr_int: std_logic_vector(31 downto 0);
85  begin
86  if rising_edge(mac_clk) then
87  if rst_macclk = '1' then
88  Got_IP_addr_rx := '0';
89  My_IP_addr_int := (Others => '0');
90  elsif IP_addr_rx_vld = '1' then
91  Got_IP_addr_rx := '1';
92  My_IP_addr_int := IP_addr_rx;
93  end if;
94 -- Predefined (Non-RARP) mode...
95  if rarp_125 = '0' then
96  My_IP_addr <= IP_addr
97 -- pragma translate_off
98  after 4 ns
99 -- pragma translate_on
100  ;
101  else
102  My_IP_addr <= My_IP_addr_int
103 -- pragma translate_off
104  after 4 ns
105 -- pragma translate_on
106  ;
107  end if;
108  rarp_mode <= enable_125 and rarp_125 and not Got_IP_addr_rx
109 -- pragma translate_off
110  after 4 ns
111 -- pragma translate_on
112  ;
113  end if;
114  end process;
115 
116 end rtl;