| 1 |
2 |
pjf |
----------------------------------------------------------------------------------
|
| 2 |
|
|
-- Company:
|
| 3 |
|
|
-- Engineer:
|
| 4 |
|
|
--
|
| 5 |
|
|
-- Create Date: 09:38:49 06/13/2011
|
| 6 |
|
|
-- Design Name:
|
| 7 |
|
|
-- Module Name: UDP_Complete_nomac - Behavioral
|
| 8 |
|
|
-- Project Name:
|
| 9 |
|
|
-- Target Devices:
|
| 10 |
|
|
-- Tool versions:
|
| 11 |
|
|
-- Description:
|
| 12 |
|
|
--
|
| 13 |
|
|
-- Dependencies:
|
| 14 |
|
|
--
|
| 15 |
|
|
-- Revision:
|
| 16 |
|
|
-- Revision 0.01 - File Created
|
| 17 |
|
|
-- Revision 0.02 - separated RX and TX clocks
|
| 18 |
|
|
-- Additional Comments:
|
| 19 |
|
|
--
|
| 20 |
|
|
----------------------------------------------------------------------------------
|
| 21 |
|
|
library IEEE;
|
| 22 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
| 23 |
|
|
use IEEE.NUMERIC_STD.ALL;
|
| 24 |
|
|
use work.axi.all;
|
| 25 |
|
|
use work.ipv4_types.all;
|
| 26 |
|
|
use work.arp_types.all;
|
| 27 |
|
|
|
| 28 |
|
|
entity UDP_Complete_nomac is
|
| 29 |
|
|
Port (
|
| 30 |
|
|
-- UDP TX signals
|
| 31 |
|
|
udp_tx_start : in std_logic; -- indicates req to tx UDP
|
| 32 |
|
|
udp_txi : in udp_tx_type; -- UDP tx cxns
|
| 33 |
|
|
udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
|
| 34 |
|
|
udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
|
| 35 |
|
|
-- UDP RX signals
|
| 36 |
|
|
udp_rx_start : out std_logic; -- indicates receipt of udp header
|
| 37 |
|
|
udp_rxo : out udp_rx_type;
|
| 38 |
|
|
-- IP RX signals
|
| 39 |
|
|
ip_rx_hdr : out ipv4_rx_header_type;
|
| 40 |
|
|
-- system signals
|
| 41 |
|
|
rx_clk : in STD_LOGIC;
|
| 42 |
|
|
tx_clk : in STD_LOGIC;
|
| 43 |
|
|
reset : in STD_LOGIC;
|
| 44 |
|
|
our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
|
| 45 |
|
|
our_mac_address : in std_logic_vector (47 downto 0);
|
| 46 |
|
|
-- status signals
|
| 47 |
|
|
arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
|
| 48 |
|
|
ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
|
| 49 |
|
|
-- MAC Transmitter
|
| 50 |
|
|
mac_tx_tdata : out std_logic_vector(7 downto 0); -- data byte to tx
|
| 51 |
|
|
mac_tx_tvalid : out std_logic; -- tdata is valid
|
| 52 |
|
|
mac_tx_tready : in std_logic; -- mac is ready to accept data
|
| 53 |
|
|
mac_tx_tlast : out std_logic; -- indicates last byte of frame
|
| 54 |
|
|
-- MAC Receiver
|
| 55 |
|
|
mac_rx_tdata : in std_logic_vector(7 downto 0); -- data byte received
|
| 56 |
|
|
mac_rx_tvalid : in std_logic; -- indicates tdata is valid
|
| 57 |
|
|
mac_rx_tready : out std_logic; -- tells mac that we are ready to take data
|
| 58 |
|
|
mac_rx_tlast : in std_logic -- indicates last byte of the trame
|
| 59 |
|
|
);
|
| 60 |
|
|
end UDP_Complete_nomac;
|
| 61 |
|
|
|
| 62 |
|
|
|
| 63 |
|
|
architecture structural of UDP_Complete_nomac is
|
| 64 |
|
|
|
| 65 |
|
|
------------------------------------------------------------------------------
|
| 66 |
|
|
-- Component Declaration for UDP TX
|
| 67 |
|
|
------------------------------------------------------------------------------
|
| 68 |
|
|
|
| 69 |
|
|
COMPONENT UDP_TX
|
| 70 |
|
|
PORT(
|
| 71 |
|
|
-- UDP Layer signals
|
| 72 |
|
|
udp_tx_start : in std_logic; -- indicates req to tx UDP
|
| 73 |
|
|
udp_txi : in udp_tx_type; -- UDP tx cxns
|
| 74 |
|
|
udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
|
| 75 |
|
|
udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
|
| 76 |
|
|
-- system signals
|
| 77 |
|
|
clk : in STD_LOGIC; -- same clock used to clock mac data and ip data
|
| 78 |
|
|
reset : in STD_LOGIC;
|
| 79 |
|
|
-- IP layer TX signals
|
| 80 |
|
|
ip_tx_start : out std_logic;
|
| 81 |
|
|
ip_tx : out ipv4_tx_type; -- IP tx cxns
|
| 82 |
|
|
ip_tx_result : in std_logic_vector (1 downto 0); -- tx status (changes during transmission)
|
| 83 |
|
|
ip_tx_data_out_ready : in std_logic -- indicates IP TX is ready to take data
|
| 84 |
|
|
);
|
| 85 |
|
|
END COMPONENT;
|
| 86 |
|
|
|
| 87 |
|
|
------------------------------------------------------------------------------
|
| 88 |
|
|
-- Component Declaration for UDP RX
|
| 89 |
|
|
------------------------------------------------------------------------------
|
| 90 |
|
|
|
| 91 |
|
|
COMPONENT UDP_RX
|
| 92 |
|
|
PORT(
|
| 93 |
|
|
-- UDP Layer signals
|
| 94 |
|
|
udp_rx_start : out std_logic; -- indicates receipt of udp header
|
| 95 |
|
|
udp_rxo : out udp_rx_type;
|
| 96 |
|
|
-- system signals
|
| 97 |
|
|
clk : in STD_LOGIC;
|
| 98 |
|
|
reset : in STD_LOGIC;
|
| 99 |
|
|
-- IP layer RX signals
|
| 100 |
|
|
ip_rx_start : in std_logic; -- indicates receipt of ip header
|
| 101 |
|
|
ip_rx : in ipv4_rx_type
|
| 102 |
|
|
);
|
| 103 |
|
|
END COMPONENT;
|
| 104 |
|
|
|
| 105 |
|
|
------------------------------------------------------------------------------
|
| 106 |
|
|
-- Component Declaration for the IP layer
|
| 107 |
|
|
------------------------------------------------------------------------------
|
| 108 |
|
|
|
| 109 |
|
|
component IP_complete_nomac
|
| 110 |
|
|
Port (
|
| 111 |
|
|
-- IP Layer signals
|
| 112 |
|
|
ip_tx_start : in std_logic;
|
| 113 |
|
|
ip_tx : in ipv4_tx_type; -- IP tx cxns
|
| 114 |
|
|
ip_tx_result : out std_logic_vector (1 downto 0); -- tx status (changes during transmission)
|
| 115 |
|
|
ip_tx_data_out_ready : out std_logic; -- indicates IP TX is ready to take data
|
| 116 |
|
|
ip_rx_start : out std_logic; -- indicates receipt of ip frame.
|
| 117 |
|
|
ip_rx : out ipv4_rx_type;
|
| 118 |
|
|
-- system signals
|
| 119 |
|
|
rx_clk : in STD_LOGIC;
|
| 120 |
|
|
tx_clk : in STD_LOGIC;
|
| 121 |
|
|
reset : in STD_LOGIC;
|
| 122 |
|
|
our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
|
| 123 |
|
|
our_mac_address : in std_logic_vector (47 downto 0);
|
| 124 |
|
|
-- status signals
|
| 125 |
|
|
arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
|
| 126 |
|
|
ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
|
| 127 |
|
|
-- MAC Transmitter
|
| 128 |
|
|
mac_tx_tdata : out std_logic_vector(7 downto 0); -- data byte to tx
|
| 129 |
|
|
mac_tx_tvalid : out std_logic; -- tdata is valid
|
| 130 |
|
|
mac_tx_tready : in std_logic; -- mac is ready to accept data
|
| 131 |
|
|
mac_tx_tlast : out std_logic; -- indicates last byte of frame
|
| 132 |
|
|
-- MAC Receiver
|
| 133 |
|
|
mac_rx_tdata : in std_logic_vector(7 downto 0); -- data byte received
|
| 134 |
|
|
mac_rx_tvalid : in std_logic; -- indicates tdata is valid
|
| 135 |
|
|
mac_rx_tready : out std_logic; -- tells mac that we are ready to take data
|
| 136 |
|
|
mac_rx_tlast : in std_logic -- indicates last byte of the trame
|
| 137 |
|
|
);
|
| 138 |
|
|
end component;
|
| 139 |
|
|
|
| 140 |
|
|
-- IP TX connectivity
|
| 141 |
|
|
signal ip_tx_int : ipv4_tx_type;
|
| 142 |
|
|
signal ip_tx_start_int : std_logic;
|
| 143 |
|
|
signal ip_tx_result_int : std_logic_vector (1 downto 0);
|
| 144 |
|
|
signal ip_tx_data_out_ready_int : std_logic;
|
| 145 |
|
|
|
| 146 |
|
|
-- IP RX connectivity
|
| 147 |
|
|
signal ip_rx_int : ipv4_rx_type;
|
| 148 |
|
|
signal ip_rx_start_int : std_logic := '0';
|
| 149 |
|
|
|
| 150 |
|
|
|
| 151 |
|
|
begin
|
| 152 |
|
|
|
| 153 |
|
|
-- output followers
|
| 154 |
|
|
ip_rx_hdr <= ip_rx_int.hdr;
|
| 155 |
|
|
|
| 156 |
|
|
-- Instantiate the UDP TX block
|
| 157 |
|
|
udp_tx_block: UDP_TX PORT MAP (
|
| 158 |
|
|
-- UDP Layer signals
|
| 159 |
|
|
udp_tx_start => udp_tx_start,
|
| 160 |
|
|
udp_txi => udp_txi,
|
| 161 |
|
|
udp_tx_result => udp_tx_result,
|
| 162 |
|
|
udp_tx_data_out_ready=> udp_tx_data_out_ready,
|
| 163 |
|
|
-- system signals
|
| 164 |
|
|
clk => tx_clk,
|
| 165 |
|
|
reset => reset,
|
| 166 |
|
|
-- IP layer TX signals
|
| 167 |
|
|
ip_tx_start => ip_tx_start_int,
|
| 168 |
|
|
ip_tx => ip_tx_int,
|
| 169 |
|
|
ip_tx_result => ip_tx_result_int,
|
| 170 |
|
|
ip_tx_data_out_ready => ip_tx_data_out_ready_int
|
| 171 |
|
|
);
|
| 172 |
|
|
|
| 173 |
|
|
-- Instantiate the UDP RX block
|
| 174 |
|
|
udp_rx_block: UDP_RX PORT MAP (
|
| 175 |
|
|
-- UDP Layer signals
|
| 176 |
|
|
udp_rxo => udp_rxo,
|
| 177 |
|
|
udp_rx_start => udp_rx_start,
|
| 178 |
|
|
-- system signals
|
| 179 |
|
|
clk => rx_clk,
|
| 180 |
|
|
reset => reset,
|
| 181 |
|
|
-- IP layer RX signals
|
| 182 |
|
|
ip_rx_start => ip_rx_start_int,
|
| 183 |
|
|
ip_rx => ip_rx_int
|
| 184 |
|
|
);
|
| 185 |
|
|
|
| 186 |
|
|
------------------------------------------------------------------------------
|
| 187 |
|
|
-- Instantiate the IP layer
|
| 188 |
|
|
------------------------------------------------------------------------------
|
| 189 |
|
|
IP_block : IP_complete_nomac PORT MAP
|
| 190 |
|
|
(
|
| 191 |
|
|
-- IP interface
|
| 192 |
|
|
ip_tx_start => ip_tx_start_int,
|
| 193 |
|
|
ip_tx => ip_tx_int,
|
| 194 |
|
|
ip_tx_result => ip_tx_result_int,
|
| 195 |
|
|
ip_tx_data_out_ready => ip_tx_data_out_ready_int,
|
| 196 |
|
|
ip_rx_start => ip_rx_start_int,
|
| 197 |
|
|
ip_rx => ip_rx_int,
|
| 198 |
|
|
-- System interface
|
| 199 |
|
|
rx_clk => rx_clk,
|
| 200 |
|
|
tx_clk => tx_clk,
|
| 201 |
|
|
reset => reset,
|
| 202 |
|
|
our_ip_address => our_ip_address,
|
| 203 |
|
|
our_mac_address => our_mac_address,
|
| 204 |
|
|
-- status signals
|
| 205 |
|
|
arp_pkt_count => arp_pkt_count,
|
| 206 |
|
|
ip_pkt_count => ip_pkt_count,
|
| 207 |
|
|
-- MAC Transmitter
|
| 208 |
|
|
mac_tx_tdata => mac_tx_tdata,
|
| 209 |
|
|
mac_tx_tvalid => mac_tx_tvalid,
|
| 210 |
|
|
mac_tx_tready => mac_tx_tready,
|
| 211 |
|
|
mac_tx_tlast => mac_tx_tlast,
|
| 212 |
|
|
-- MAC Receiver
|
| 213 |
|
|
mac_rx_tdata => mac_rx_tdata,
|
| 214 |
|
|
mac_rx_tvalid => mac_rx_tvalid,
|
| 215 |
|
|
mac_rx_tready => mac_rx_tready,
|
| 216 |
|
|
mac_rx_tlast => mac_rx_tlast
|
| 217 |
|
|
);
|
| 218 |
|
|
|
| 219 |
|
|
|
| 220 |
|
|
end structural;
|
| 221 |
|
|
|