AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
udp_rxram_mux.vhd
1 -- Multiplex into transport dual-port RAM/interface
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_rxram_mux is
10  port (
11  mac_clk: in std_logic;
12  rx_reset: in std_logic;
13 --
14  rarp_mode: in std_logic;
15  rarp_addr: in std_logic_vector(12 downto 0);
16  rarp_data: in std_logic_vector(7 downto 0);
17  rarp_end_addr: in std_logic_vector(12 downto 0);
18  rarp_send: in std_logic;
19  rarp_we: in std_logic;
20 --
21  pkt_drop_arp: in std_logic;
22  arp_data: in std_logic_vector(7 downto 0);
23  arp_addr: in std_logic_vector(12 downto 0);
24  arp_we: in std_logic;
25  arp_end_addr: in std_logic_vector(12 downto 0);
26  arp_send: in std_logic;
27 --
28  pkt_drop_ping: in std_logic;
29  ping_data: in std_logic_vector(7 downto 0);
30  ping_addr: in std_logic_vector(12 downto 0);
31  ping_we: in std_logic;
32  ping_end_addr: in std_logic_vector(12 downto 0);
33  ping_send: in std_logic;
34 --
35  pkt_drop_status: in std_logic;
36  status_data: in std_logic_vector(7 downto 0);
37  status_addr: in std_logic_vector(12 downto 0);
38  status_we: in std_logic;
39  status_end_addr: in std_logic_vector(12 downto 0);
40  status_send: in std_logic;
41 --
42  mac_rx_valid: in std_logic;
43  rxram_busy: in std_logic;
44 --
45  dia: out std_logic_vector(7 downto 0);
46  addra: out std_logic_vector(12 downto 0);
47  wea: out std_logic;
48  rxram_end_addr: out std_logic_vector(12 downto 0);
49  rxram_send: out std_logic;
50  rxram_dropped: out std_logic
51  );
52 end udp_rxram_mux;
53 
54 architecture rtl of udp_rxram_mux is
55 
56  signal ram_ready, rxram_send_sig: std_logic;
57 
58 begin
59 
60  rxram_send <= rxram_send_sig and ram_ready;
61 
62 do_ram_ready: process(mac_clk)
63  variable ram_ready_int, rxram_dropped_int: std_logic;
64  begin
65  if rising_edge(mac_clk) then
66  if rx_reset = '1' or rarp_mode = '1' then
67  ram_ready_int := '1';
68  elsif mac_rx_valid = '1' and rxram_busy = '1' then
69  ram_ready_int := '0';
70  end if;
71  if rxram_send_sig = '1' and ram_ready_int = '0' then
72  rxram_dropped_int := '1';
73  else
74  rxram_dropped_int := '0';
75  end if;
76  ram_ready <= ram_ready_int
77 -- pragma translate_off
78  after 4 ns
79 -- pragma translate_on
80  ;
81  rxram_dropped <= rxram_dropped_int
82 -- pragma translate_off
83  after 4 ns
84 -- pragma translate_on
85  ;
86  end if;
87  end process;
88 
89 send_packet: process(mac_clk)
90  variable rxram_end_addr_int: std_logic_vector(12 downto 0);
91  variable rxram_send_int: std_logic;
92  begin
93  if rising_edge(mac_clk) then
94  if rarp_send = '1' then
95  rxram_end_addr_int := rarp_end_addr;
96  rxram_send_int := '1';
97  elsif arp_send = '1' then
98  rxram_end_addr_int := arp_end_addr;
99  rxram_send_int := '1';
100  elsif ping_send = '1' then
101  rxram_end_addr_int := ping_end_addr;
102  rxram_send_int := '1';
103  elsif status_send = '1' then
104  rxram_end_addr_int := status_end_addr;
105  rxram_send_int := '1';
106  else
107  rxram_end_addr_int := (Others => '0');
108  rxram_send_int := '0';
109  end if;
110  rxram_end_addr <= rxram_end_addr_int
111 -- pragma translate_off
112  after 4 ns
113 -- pragma translate_on
114  ;
115  rxram_send_sig <= rxram_send_int
116 -- pragma translate_off
117  after 4 ns
118 -- pragma translate_on
119  ;
120  end if;
121  end process;
122 
123 build_packet: process(mac_clk)
124  variable dia_int: std_logic_vector(7 downto 0);
125  variable addra_int: std_logic_vector(12 downto 0);
126  variable wea_int: std_logic;
127  begin
128  if rising_edge(mac_clk) then
129  if ram_ready = '1' then
130  if rarp_mode = '1' then
131  dia_int := rarp_data;
132  addra_int := rarp_addr;
133  wea_int := rarp_we;
134  elsif pkt_drop_arp = '0' then
135  dia_int := arp_data;
136  addra_int := arp_addr;
137  wea_int := arp_we;
138  elsif pkt_drop_ping = '0' then
139  dia_int := ping_data;
140  addra_int := ping_addr;
141  wea_int := ping_we;
142  elsif pkt_drop_status = '0' then
143  dia_int := status_data;
144  addra_int := status_addr;
145  wea_int := status_we;
146  else
147  dia_int := (Others => '0');
148  addra_int := (Others => '0');
149  wea_int := '0';
150  end if;
151  else
152  dia_int := (Others => '0');
153  addra_int := (Others => '0');
154  wea_int := '0';
155  end if;
156  dia <= dia_int
157 -- pragma translate_off
158  after 4 ns
159 -- pragma translate_on
160  ;
161  addra <= addra_int
162 -- pragma translate_off
163  after 4 ns
164 -- pragma translate_on
165  ;
166  wea <= wea_int
167 -- pragma translate_off
168  after 4 ns
169 -- pragma translate_on
170  ;
171  end if;
172  end process;
173 
174 end rtl;