3 -- Top level of the ipbus bus master
5 -- Bridges ethernet MAC interface and / or out-of-band interfaces
8 -- Dave Newbold, Sep 2012
11 use ieee.std_logic_1164.
all;
17 MAC_CFG: ipb_mac_cfg := EXTERNAL;
18 IP_CFG: ipb_ip_cfg := EXTERNAL;
19 -- Number of address bits to select RX or TX buffer in UDP I/F
20 -- Number of RX and TX buffers is 2**BUFWIDTH
22 -- Numer of address bits to select internal buffer in UDP I/F
23 -- Number of internal buffers is 2**INTERNALWIDTH
25 -- Number of address bits within each buffer in UDP I/F
26 -- Size of each buffer is 2**ADDRWIDTH
28 -- UDP port for IPbus traffic in this instance of UDP I/F
29 IPBUSPORT: (15 DOWNTO 0) := x"C351";
30 -- Flag whether this UDP I/F instance ignores everything except IPBus traffic
31 SECONDARYPORT: := '0';
35 mac_clk: in ;
-- Ethernet MAC clock (125MHz)
36 rst_macclk: in ;
-- MAC clock domain sync reset
37 ipb_clk: in ;
-- IPbus clock
38 rst_ipb: in ;
-- IPbus clock domain sync reset
39 mac_rx_data: in (7 downto 0);
-- AXI4 style MAC signals
43 mac_tx_data: out (7 downto 0);
48 ipb_out: out ipb_wbus;
-- IPbus bus signals
52 mac_addr: in (47 downto 0) := X"000000000000";
-- Static MAC and IP addresses
53 ip_addr: in (31 downto 0) := X"00000000";
55 RARP_select: in := '0';
60 oob_in: in ipbus_trans_in_array(N_OOB - 1 downto 0) := (others => ('0', X"00000000", '0'));
61 oob_out: out ipbus_trans_out_array(N_OOB - 1 downto 0)
68 signal trans_in, trans_in_udp: ipbus_trans_in;
69 signal trans_out, trans_out_udp: ipbus_trans_out;
70 signal udp_rxpacket_ignored, udp_rxpacket_dropped: ;
71 signal cfg, cfg_out: (127 downto 0);
72 signal my_mac_addr: (47 downto 0);
73 signal my_ip_addr, my_ip_addr_udp: (31 downto 0);
74 -- signal last_hdr: (31 downto 0);
75 signal pkt_rx_i, pkt_tx_i, udp_en, rarp_en: ;
76 signal buf_in_a: ipbus_trans_in_array(N_OOB downto 0);
77 signal buf_out_a: ipbus_trans_out_array(N_OOB downto 0);
81 udp_if:
entity work.udp_if
generic map(
83 INTERNALWIDTH => INTERNALWIDTH,
84 ADDRWIDTH => ADDRWIDTH,
85 IPBUSPORT => IPBUSPORT,
86 SECONDARYPORT => SECONDARYPORT
90 rst_macclk => rst_macclk,
93 IP_addr => my_ip_addr,
94 MAC_addr => my_mac_addr,
97 mac_rx_data => mac_rx_data,
98 mac_rx_error => mac_rx_error,
99 mac_rx_last => mac_rx_last,
100 mac_rx_valid => mac_rx_valid,
101 mac_tx_ready => mac_tx_ready,
102 pkt_done_read => trans_out_udp.pkt_done,
103 pkt_done_write => trans_out_udp.pkt_done,
104 raddr => trans_out_udp.raddr,
105 waddr => trans_out_udp.waddr,
106 wdata => trans_out_udp.wdata,
107 we => trans_out_udp.we,
108 busy => trans_in_udp.busy,
109 mac_tx_data => mac_tx_data,
110 mac_tx_error => mac_tx_error,
111 mac_tx_last => mac_tx_last,
112 mac_tx_valid => mac_tx_valid,
113 My_IP_addr => my_ip_addr_udp ,
114 pkt_rdy => trans_in_udp.pkt_rdy,
115 rdata => trans_in_udp.rdata,
116 rxpacket_ignored => udp_rxpacket_ignored,
117 rxpacket_dropped => udp_rxpacket_dropped
120 arb_gen: if N_OOB > 0 generate
122 buf_in_a <= oob_in & trans_in_udp;
123 trans_out_udp <= buf_out_a(0);
124 oob_out <= buf_out_a(N_OOB downto 1);
127 generic map(NSRC => N_OOB +
1 )
132 buf_out => buf_out_a,
133 trans_out => trans_in,
134 trans_in => trans_out
139 n_arb_gen: if N_OOB = 0 generate
140 trans_in <= trans_in_udp;
141 trans_out_udp <= trans_out;
146 rst => rst_ipb,
-- This is probably not what we want...
150 ipb_grant => ipb_grant,
151 trans_in => trans_in,
152 trans_out => trans_out,
153 cfg_vector_in => cfg_out,
154 cfg_vector_out => cfg,
159 cfg_out <= my_ip_addr_udp & X"000" & "00" & rarp_en & udp_en & my_mac_addr & X"00000000";
160 -- cfg_out <= my_ip_addr_udp & X"000" & "00" & rarp_en & udp_en & my_mac_addr & last_hdr;
162 with MAC_CFG select my_mac_addr <=
163 mac_addr when EXTERNAL,
164 cfg(79 downto 32) when others;
166 with IP_CFG select my_ip_addr <=
167 ip_addr when EXTERNAL,
168 cfg(127 downto 96) when others;
170 udp_en <= cfg(80) or enable;
172 rarp_en <= cfg(81) or RARP_select;
174 stretch_rx:
entity work.
stretcher port map(
180 stretch_tx:
entity work.
stretcher port map(
189 -- latch_hdr: process (ipb_clk)
191 -- if rising_edge(ipb_clk) then
192 -- if rst_ipb = '1' then
193 -- last_hdr <= (Others => '1');
194 -- elsif trans_out_udp.pkt_done = '1' then
195 -- last_hdr <= "0" & trans_in_udp.pkt_rdy & trans_in_udp.busy & trans_out_udp.we & trans_out_udp.waddr & trans_out_udp.wdata(
15 downto 0);