OpenCores
URL https://opencores.org/ocsvn/udp_ip_stack/udp_ip_stack/trunk

Subversion Repositories udp_ip_stack

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /udp_ip_stack/tags/v1.1/rtl/vhdl/ml605
    from Rev 4 to Rev 5
    Reverse comparison

Rev 4 → Rev 5

/IP_complete.vhd
0,0 → 1,251
----------------------------------------------------------------------------------
-- Company:
-- Engineer: Peter Fall
--
-- Create Date: 20:25:56 06/03/2011
-- Design Name:
-- Module Name: IP_complete - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description: Implements complete IP stack with ARP and MAC
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use work.axi.all;
use work.ipv4_types.all;
use work.arp_types.all;
 
entity IP_complete is
Port (
-- IP Layer signals
ip_tx_start : in std_logic;
ip_tx : in ipv4_tx_type; -- IP tx cxns
ip_tx_result : out std_logic_vector (1 downto 0); -- tx status (changes during transmission)
ip_tx_data_out_ready : out std_logic; -- indicates IP TX is ready to take data
ip_rx_start : out std_logic; -- indicates receipt of ip frame.
ip_rx : out ipv4_rx_type;
-- system signals
clk_in_p : in std_logic; -- 200MHz clock input from board
clk_in_n : in std_logic;
clk_out : out std_logic;
reset : in STD_LOGIC;
our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
our_mac_address : in std_logic_vector (47 downto 0);
-- status signals
arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
-- GMII Interface
phy_resetn : out std_logic;
gmii_txd : out std_logic_vector(7 downto 0);
gmii_tx_en : out std_logic;
gmii_tx_er : out std_logic;
gmii_tx_clk : out std_logic;
gmii_rxd : in std_logic_vector(7 downto 0);
gmii_rx_dv : in std_logic;
gmii_rx_er : in std_logic;
gmii_rx_clk : in std_logic;
gmii_col : in std_logic;
gmii_crs : in std_logic;
mii_tx_clk : in std_logic
);
end IP_complete;
 
architecture structural of IP_complete is
 
------------------------------------------------------------------------------
-- Component Declaration for the IP layer
------------------------------------------------------------------------------
 
COMPONENT IP_complete_nomac
PORT(
-- IP Layer signals
ip_tx_start : in std_logic;
ip_tx : in ipv4_tx_type; -- IP tx cxns
ip_tx_result : out std_logic_vector (1 downto 0); -- tx status (changes during transmission)
ip_tx_data_out_ready : out std_logic; -- indicates IP TX is ready to take data
ip_rx_start : out std_logic; -- indicates receipt of ip frame.
ip_rx : out ipv4_rx_type;
-- system signals
rx_clk : in STD_LOGIC;
tx_clk : in STD_LOGIC;
reset : in STD_LOGIC;
our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
our_mac_address : in std_logic_vector (47 downto 0);
-- status signals
arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
-- MAC Transmitter
mac_tx_tdata : out std_logic_vector(7 downto 0); -- data byte to tx
mac_tx_tvalid : out std_logic; -- tdata is valid
mac_tx_tready : in std_logic; -- mac is ready to accept data
mac_tx_tfirst : out std_logic; -- indicates first byte of frame
mac_tx_tlast : out std_logic; -- indicates last byte of frame
-- MAC Receiver
mac_rx_tdata : in std_logic_vector(7 downto 0); -- data byte received
mac_rx_tvalid : in std_logic; -- indicates tdata is valid
mac_rx_tready : out std_logic; -- tells mac that we are ready to take data
mac_rx_tlast : in std_logic -- indicates last byte of the trame
);
END COMPONENT;
 
 
------------------------------------------------------------------------------
-- Component Declaration for the MAC layer
------------------------------------------------------------------------------
component mac_layer
port (
-- System controls
------------------
glbl_rst : in std_logic; -- asynchronous reset
mac_reset : in std_logic; -- reset mac layer
clk_in_p : in std_logic; -- 200MHz clock input from board
clk_in_n : in std_logic;
-- MAC Transmitter (AXI-S) Interface
---------------------------------------------
mac_tx_clock : out std_logic; -- data sampled on rising edge
mac_tx_tdata : in std_logic_vector(7 downto 0); -- data byte to tx
mac_tx_tvalid : in std_logic; -- tdata is valid
mac_tx_tready : out std_logic; -- mac is ready to accept data
mac_tx_tlast : in std_logic; -- indicates last byte of frame
 
-- MAC Receiver (AXI-S) Interface
------------------------------------------
mac_rx_clock : out std_logic; -- data valid on rising edge
mac_rx_tdata : out std_logic_vector(7 downto 0); -- data byte received
mac_rx_tvalid : out std_logic; -- indicates tdata is valid
mac_rx_tready : in std_logic; -- tells mac that we are ready to take data
mac_rx_tlast : out std_logic; -- indicates last byte of the trame
-- GMII Interface
-----------------
phy_resetn : out std_logic;
gmii_txd : out std_logic_vector(7 downto 0);
gmii_tx_en : out std_logic;
gmii_tx_er : out std_logic;
gmii_tx_clk : out std_logic;
gmii_rxd : in std_logic_vector(7 downto 0);
gmii_rx_dv : in std_logic;
gmii_rx_er : in std_logic;
gmii_rx_clk : in std_logic;
gmii_col : in std_logic;
gmii_crs : in std_logic;
mii_tx_clk : in std_logic
);
end component;
 
---------------------------
-- Signals
---------------------------
-- MAC RX bus
signal mac_rx_clock : std_logic;
signal mac_rx_tdata : std_logic_vector (7 downto 0);
signal mac_rx_tvalid : std_logic;
signal mac_rx_tready : std_logic;
signal mac_rx_tlast : std_logic;
-- MAC TX bus
signal mac_tx_clock : std_logic;
signal mac_tx_tdata : std_logic_vector (7 downto 0);
signal mac_tx_tvalid : std_logic;
signal mac_tx_tready : std_logic;
signal mac_tx_tlast : std_logic;
-- control signals
signal mac_tx_tready_int : std_logic;
signal mac_tx_granted_int : std_logic;
 
begin
 
clk_out <= mac_rx_clock;
 
------------------------------------------------------------------------------
-- Instantiate the IP layer
------------------------------------------------------------------------------
 
IP_layer : IP_complete_nomac PORT MAP
(
-- IP Layer signals
ip_tx_start => ip_tx_start,
ip_tx => ip_tx,
ip_tx_result => ip_tx_result,
ip_tx_data_out_ready => ip_tx_data_out_ready,
ip_rx_start => ip_rx_start,
ip_rx => ip_rx,
-- system signals
rx_clk => mac_rx_clock,
tx_clk => mac_rx_clock,
reset => reset,
our_ip_address => our_ip_address,
our_mac_address => our_mac_address,
-- status signals
arp_pkt_count => arp_pkt_count,
ip_pkt_count => ip_pkt_count,
-- MAC Transmitter
mac_tx_tready => mac_tx_tready_int,
mac_tx_tvalid => mac_tx_tvalid,
mac_tx_tfirst => open,
mac_tx_tlast => mac_tx_tlast,
mac_tx_tdata => mac_tx_tdata,
-- MAC Receiver
mac_rx_tdata => mac_rx_tdata,
mac_rx_tvalid => mac_rx_tvalid,
mac_rx_tready => mac_rx_tready,
mac_rx_tlast => mac_rx_tlast
);
 
------------------------------------------------------------------------------
-- Instantiate the MAC layer
------------------------------------------------------------------------------
mac_block : mac_layer
Port map(
-- System controls
------------------
glbl_rst => reset,
mac_reset => '0',
clk_in_p => clk_in_p,
clk_in_n => clk_in_n,
-- MAC Transmitter (AXI-S) Interface
---------------------------------------------
mac_tx_clock => mac_tx_clock,
mac_tx_tdata => mac_tx_tdata,
mac_tx_tvalid => mac_tx_tvalid,
mac_tx_tready => mac_tx_tready_int,
mac_tx_tlast => mac_tx_tlast,
 
-- MAC Receiver (AXI-S) Interface
------------------------------------------
mac_rx_clock => mac_rx_clock,
mac_rx_tdata => mac_rx_tdata,
mac_rx_tvalid => mac_rx_tvalid,
mac_rx_tready => mac_rx_tready,
mac_rx_tlast => mac_rx_tlast,
-- GMII Interface
-----------------
phy_resetn => phy_resetn,
gmii_txd => gmii_txd,
gmii_tx_en => gmii_tx_en,
gmii_tx_er => gmii_tx_er,
gmii_tx_clk => gmii_tx_clk,
gmii_rxd => gmii_rxd,
gmii_rx_dv => gmii_rx_dv,
gmii_rx_er => gmii_rx_er,
gmii_rx_clk => gmii_rx_clk,
gmii_col => gmii_col,
gmii_crs => gmii_crs,
mii_tx_clk => mii_tx_clk
);
 
end structural;
 
/UDP_Complete.vhd
0,0 → 1,269
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 17:51:18 06/11/2011
-- Design Name:
-- Module Name: UDP_Complete - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Revision 0.02 - separated RX and TX clocks
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use work.axi.all;
use work.ipv4_types.all;
use work.arp_types.all;
 
entity UDP_Complete is
Port (
-- UDP TX signals
udp_tx_start : in std_logic; -- indicates req to tx UDP
udp_txi : in udp_tx_type; -- UDP tx cxns
udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
-- UDP RX signals
udp_rx_start : out std_logic; -- indicates receipt of udp header
udp_rxo : out udp_rx_type;
-- IP RX signals
ip_rx_hdr : out ipv4_rx_header_type;
-- system signals
clk_in_p : in std_logic; -- 200MHz clock input from board
clk_in_n : in std_logic;
clk_out : out std_logic;
reset : in STD_LOGIC;
our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
our_mac_address : in std_logic_vector (47 downto 0);
-- status signals
arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
-- GMII Interface
phy_resetn : out std_logic;
gmii_txd : out std_logic_vector(7 downto 0);
gmii_tx_en : out std_logic;
gmii_tx_er : out std_logic;
gmii_tx_clk : out std_logic;
gmii_rxd : in std_logic_vector(7 downto 0);
gmii_rx_dv : in std_logic;
gmii_rx_er : in std_logic;
gmii_rx_clk : in std_logic;
gmii_col : in std_logic;
gmii_crs : in std_logic;
mii_tx_clk : in std_logic
);
end UDP_Complete;
 
architecture structural of UDP_Complete is
 
------------------------------------------------------------------------------
-- Component Declaration for UDP complete no mac
------------------------------------------------------------------------------
 
COMPONENT UDP_Complete_nomac
PORT(
-- UDP TX signals
udp_tx_start : in std_logic; -- indicates req to tx UDP
udp_txi : in udp_tx_type; -- UDP tx cxns
udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
-- UDP RX signals
udp_rx_start : out std_logic; -- indicates receipt of udp header
udp_rxo : out udp_rx_type;
-- IP RX signals
ip_rx_hdr : out ipv4_rx_header_type;
-- system signals
rx_clk : in STD_LOGIC;
tx_clk : in STD_LOGIC;
reset : in STD_LOGIC;
our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
our_mac_address : in std_logic_vector (47 downto 0);
-- status signals
arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
-- MAC Transmitter
mac_tx_tdata : out std_logic_vector(7 downto 0); -- data byte to tx
mac_tx_tvalid : out std_logic; -- tdata is valid
mac_tx_tready : in std_logic; -- mac is ready to accept data
mac_tx_tfirst : out std_logic; -- indicates first byte of frame
mac_tx_tlast : out std_logic; -- indicates last byte of frame
-- MAC Receiver
mac_rx_tdata : in std_logic_vector(7 downto 0); -- data byte received
mac_rx_tvalid : in std_logic; -- indicates tdata is valid
mac_rx_tready : out std_logic; -- tells mac that we are ready to take data
mac_rx_tlast : in std_logic -- indicates last byte of the trame
);
END COMPONENT;
 
 
------------------------------------------------------------------------------
-- Component Declaration for the MAC layer
------------------------------------------------------------------------------
component mac_layer
port (
-- System controls
------------------
glbl_rst : in std_logic; -- asynchronous reset
mac_reset : in std_logic; -- reset mac layer
clk_in_p : in std_logic; -- 200MHz clock input from board
clk_in_n : in std_logic;
-- MAC Transmitter (AXI-S) Interface
---------------------------------------------
mac_tx_clock : out std_logic; -- data sampled on rising edge
mac_tx_tdata : in std_logic_vector(7 downto 0); -- data byte to tx
mac_tx_tvalid : in std_logic; -- tdata is valid
mac_tx_tready : out std_logic; -- mac is ready to accept data
mac_tx_tlast : in std_logic; -- indicates last byte of frame
 
-- MAC Receiver (AXI-S) Interface
------------------------------------------
mac_rx_clock : out std_logic; -- data valid on rising edge
mac_rx_tdata : out std_logic_vector(7 downto 0); -- data byte received
mac_rx_tvalid : out std_logic; -- indicates tdata is valid
mac_rx_tready : in std_logic; -- tells mac that we are ready to take data
mac_rx_tlast : out std_logic; -- indicates last byte of the trame
-- GMII Interface
-----------------
phy_resetn : out std_logic;
gmii_txd : out std_logic_vector(7 downto 0);
gmii_tx_en : out std_logic;
gmii_tx_er : out std_logic;
gmii_tx_clk : out std_logic;
gmii_rxd : in std_logic_vector(7 downto 0);
gmii_rx_dv : in std_logic;
gmii_rx_er : in std_logic;
gmii_rx_clk : in std_logic;
gmii_col : in std_logic;
gmii_crs : in std_logic;
mii_tx_clk : in std_logic
);
end component;
 
 
---------------------------
-- Signals
---------------------------
-- MAC RX bus
signal mac_rx_clock : std_logic;
signal mac_rx_tdata : std_logic_vector (7 downto 0);
signal mac_rx_tvalid : std_logic;
signal mac_rx_tready : std_logic;
signal mac_rx_tlast : std_logic;
-- MAC TX bus
signal mac_tx_clock : std_logic;
signal mac_tx_tdata : std_logic_vector (7 downto 0);
signal mac_tx_tvalid : std_logic;
signal mac_tx_tready : std_logic;
signal mac_tx_tlast : std_logic;
-- control signals
signal mac_tx_tready_int : std_logic;
signal mac_tx_granted_int : std_logic;
 
 
begin
 
 
process (mac_tx_clock)
begin
-- output followers
clk_out <= mac_tx_clock;
end process;
 
------------------------------------------------------------------------------
-- Instantiate the UDP layer
------------------------------------------------------------------------------
 
udp_block: UDP_Complete_nomac PORT MAP (
-- UDP TX signals
udp_tx_start => udp_tx_start,
udp_txi => udp_txi,
udp_tx_result => udp_tx_result,
udp_tx_data_out_ready => udp_tx_data_out_ready,
-- UDP RX signals
udp_rx_start => udp_rx_start,
udp_rxo => udp_rxo,
-- IP RX signals
ip_rx_hdr => ip_rx_hdr,
-- system signals
rx_clk => mac_rx_clock,
tx_clk => mac_tx_clock,
reset => reset,
our_ip_address => our_ip_address,
our_mac_address => our_mac_address,
-- status signals
arp_pkt_count => arp_pkt_count,
ip_pkt_count => ip_pkt_count,
 
-- MAC Transmitter
mac_tx_tready => mac_tx_tready_int,
mac_tx_tvalid => mac_tx_tvalid,
mac_tx_tfirst => open,
mac_tx_tlast => mac_tx_tlast,
mac_tx_tdata => mac_tx_tdata,
-- MAC Receiver
mac_rx_tdata => mac_rx_tdata,
mac_rx_tvalid => mac_rx_tvalid,
mac_rx_tready => mac_rx_tready,
mac_rx_tlast => mac_rx_tlast
);
 
 
------------------------------------------------------------------------------
-- Instantiate the MAC layer
------------------------------------------------------------------------------
mac_block : mac_layer
Port map(
-- System controls
------------------
glbl_rst => reset,
mac_reset => '0',
clk_in_p => clk_in_p,
clk_in_n => clk_in_n,
-- MAC Transmitter (AXI-S) Interface
---------------------------------------------
mac_tx_clock => mac_tx_clock,
mac_tx_tdata => mac_tx_tdata,
mac_tx_tvalid => mac_tx_tvalid,
mac_tx_tready => mac_tx_tready_int,
mac_tx_tlast => mac_tx_tlast,
 
-- MAC Receiver (AXI-S) Interface
------------------------------------------
mac_rx_clock => mac_rx_clock,
mac_rx_tdata => mac_rx_tdata,
mac_rx_tvalid => mac_rx_tvalid,
mac_rx_tready => mac_rx_tready,
mac_rx_tlast => mac_rx_tlast,
-- GMII Interface
-----------------
phy_resetn => phy_resetn,
gmii_txd => gmii_txd,
gmii_tx_en => gmii_tx_en,
gmii_tx_er => gmii_tx_er,
gmii_tx_clk => gmii_tx_clk,
gmii_rxd => gmii_rxd,
gmii_rx_dv => gmii_rx_dv,
gmii_rx_er => gmii_rx_er,
gmii_rx_clk => gmii_rx_clk,
gmii_col => gmii_col,
gmii_crs => gmii_crs,
mii_tx_clk => mii_tx_clk
);
 
 
end structural;
 
/UDP_integration_example.vhd
0,0 → 1,367
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 11:01:00 06/11/2011
-- Design Name:
-- Module Name: UDP_integration_example - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use work.axi.all;
use work.ipv4_types.all;
use work.arp_types.all;
 
entity UDP_integration_example is
port (
-- System signals
------------------
reset : in std_logic; -- asynchronous reset
clk_in_p : in std_logic; -- 200MHz clock input from board
clk_in_n : in std_logic;
 
-- System controls
------------------
PBTX : in std_logic;
UDP_RX : out std_logic;
UDP_Start : out std_logic;
PBTX_LED : out std_logic;
TX_Started : out std_logic;
TX_Completed : out std_logic;
reset_leds : in std_logic;
display : out std_logic_vector(7 downto 0);
-- GMII Interface
-----------------
phy_resetn : out std_logic;
gmii_txd : out std_logic_vector(7 downto 0);
gmii_tx_en : out std_logic;
gmii_tx_er : out std_logic;
gmii_tx_clk : out std_logic;
gmii_rxd : in std_logic_vector(7 downto 0);
gmii_rx_dv : in std_logic;
gmii_rx_er : in std_logic;
gmii_rx_clk : in std_logic;
gmii_col : in std_logic;
gmii_crs : in std_logic;
mii_tx_clk : in std_logic
);
end UDP_integration_example;
 
architecture Behavioral of UDP_integration_example is
 
------------------------------------------------------------------------------
-- Component Declaration for the complete IP layer
------------------------------------------------------------------------------
component UDP_Complete
Port (
-- UDP TX signals
udp_tx_start : in std_logic; -- indicates req to tx UDP
udp_txi : in udp_tx_type; -- UDP tx cxns
udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
-- UDP RX signals
udp_rx_start : out std_logic; -- indicates receipt of udp header
udp_rxo : out udp_rx_type;
-- IP RX signals
ip_rx_hdr : out ipv4_rx_header_type;
-- system signals
clk_in_p : in std_logic; -- 200MHz clock input from board
clk_in_n : in std_logic;
clk_out : out std_logic;
reset : in STD_LOGIC;
our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
our_mac_address : in std_logic_vector (47 downto 0);
-- status signals
arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
-- GMII Interface
phy_resetn : out std_logic;
gmii_txd : out std_logic_vector(7 downto 0);
gmii_tx_en : out std_logic;
gmii_tx_er : out std_logic;
gmii_tx_clk : out std_logic;
gmii_rxd : in std_logic_vector(7 downto 0);
gmii_rx_dv : in std_logic;
gmii_rx_er : in std_logic;
gmii_rx_clk : in std_logic;
gmii_col : in std_logic;
gmii_crs : in std_logic;
mii_tx_clk : in std_logic
);
end component;
 
 
type state_type is (IDLE, DATA_OUT);
type count_mode_type is (RST, INCR, HOLD);
type set_clr_type is (SET, CLR, HOLD);
 
-- system signals
signal clk_int : std_logic;
signal our_mac : STD_LOGIC_VECTOR (47 downto 0);
signal our_ip : STD_LOGIC_VECTOR (31 downto 0);
signal udp_tx_int : udp_tx_type;
signal udp_tx_result_int : std_logic_vector (1 downto 0);
signal udp_tx_data_out_ready_int : std_logic;
signal udp_rx_int : udp_rx_type;
signal udp_tx_start_int : std_logic;
signal udp_rx_start_int : std_logic;
signal arp_pkt_count_int : STD_LOGIC_VECTOR(7 downto 0);
signal ip_pkt_count_int : STD_LOGIC_VECTOR(7 downto 0);
signal ip_rx_hdr_int : ipv4_rx_header_type;
-- state signals
signal state : state_type;
signal count : unsigned (7 downto 0);
signal tx_hdr : udp_tx_header_type;
signal tx_start_reg : std_logic;
signal tx_started_reg : std_logic;
signal tx_fin_reg : std_logic;
signal udp_rx_start_reg : std_logic;
-- control signals
signal next_state : state_type;
signal set_state : std_logic;
signal set_count : count_mode_type;
signal set_hdr : std_logic;
signal set_tx_start : set_clr_type;
signal set_last : std_logic;
signal set_tx_started : set_clr_type;
signal set_tx_fin : set_clr_type;
signal set_udp_rx_start_reg : set_clr_type;
begin
 
process (
our_ip, our_mac, udp_rx_int, udp_tx_start_int, udp_rx_start_int, ip_rx_hdr_int, udp_rx_start_reg,
udp_tx_int, count, clk_int, ip_pkt_count_int, arp_pkt_count_int,
reset, tx_started_reg, tx_fin_reg, tx_start_reg
)
begin
-- set up our local addresses
our_ip <= x"c0a80509"; -- 192.168.5.9
our_mac <= x"002320212223";
-- determine RX good and error LEDs
if udp_rx_int.hdr.is_valid = '1' then
UDP_RX <= '1';
else
UDP_RX <= '0';
end if;
UDP_Start <= udp_rx_start_reg;
TX_Started <= tx_start_reg; --tx_started_reg;
TX_Completed <= tx_fin_reg;
-- set display leds to show IP pkt rx count on 7..4 and arp rx count on 3..0
display (7 downto 4) <= ip_pkt_count_int (3 downto 0);
display (3 downto 0) <= arp_pkt_count_int (3 downto 0);
end process;
-- AUTO TX process - on receipt of any UDP pkt, send a response
-- TX response process - COMB
tx_proc_combinatorial: process(
-- inputs
udp_rx_start_int, udp_tx_data_out_ready_int, udp_tx_int.data.data_out_valid, PBTX, reset_leds,
-- state
state, count, tx_hdr, tx_start_reg, tx_started_reg, tx_fin_reg, udp_rx_start_reg,
-- controls
next_state, set_state, set_count, set_hdr, set_tx_start, set_last,
set_tx_started, set_tx_fin, set_udp_rx_start_reg
)
begin
-- set output_followers
udp_tx_int.hdr <= tx_hdr;
udp_tx_int.data.data_out_last <= set_last;
udp_tx_start_int <= tx_start_reg;
 
-- set control signal defaults
next_state <= IDLE;
set_state <= '0';
set_count <= HOLD;
set_hdr <= '0';
set_tx_start <= HOLD;
set_last <= '0';
set_tx_started <= HOLD;
set_tx_fin <= HOLD;
set_udp_rx_start_reg <= HOLD;
-- FSM
case state is
when IDLE =>
udp_tx_int.data.data_out <= (others => '0');
udp_tx_int.data.data_out_valid <= '0';
if udp_rx_start_int = '1' or PBTX = '1' then
set_udp_rx_start_reg <= SET;
set_tx_started <= SET;
set_hdr <= '1';
set_tx_start <= SET;
set_tx_fin <= CLR;
set_count <= RST;
next_state <= DATA_OUT;
set_state <= '1';
elsif reset_leds = '1' then
set_udp_rx_start_reg <= CLR;
set_tx_started <= CLR;
set_tx_fin <= CLR;
end if;
when DATA_OUT =>
udp_tx_int.data.data_out <= std_logic_vector(count) or x"40";
udp_tx_int.data.data_out_valid <= udp_tx_data_out_ready_int;
if udp_tx_data_out_ready_int = '1' then
set_tx_start <= CLR;
if unsigned(count) = x"03" then
set_last <= '1';
set_tx_fin <= SET;
set_tx_started <= CLR;
next_state <= IDLE;
set_state <= '1';
else
set_count <= INCR;
end if;
end if;
end case;
end process;
 
-- TX response process - SEQ
tx_proc_sequential: process(clk_int)
begin
if rising_edge(clk_int) then
if reset = '1' then
-- reset state variables
state <= IDLE;
count <= x"00";
tx_start_reg <= '0';
tx_hdr.dst_ip_addr <= (others => '0');
tx_hdr.dst_port <= (others => '0');
tx_hdr.src_port <= (others => '0');
tx_hdr.data_length <= (others => '0');
tx_hdr.checksum <= (others => '0');
tx_started_reg <= '0';
tx_fin_reg <= '0';
PBTX_LED <= '0';
else
PBTX_LED <= PBTX;
-- Next rx_state processing
if set_state = '1' then
state <= next_state;
else
state <= state;
end if;
-- count processing
case set_count is
when RST => count <= x"00";
when INCR => count <= count + 1;
when HOLD => count <= count;
end case;
-- set tx hdr
if set_hdr = '1' then
tx_hdr.dst_ip_addr <= udp_rx_int.hdr.src_ip_addr;
tx_hdr.dst_port <= udp_rx_int.hdr.src_port;
tx_hdr.src_port <= udp_rx_int.hdr.dst_port;
tx_hdr.data_length <= x"0004";
tx_hdr.checksum <= x"0000";
else
tx_hdr <= tx_hdr;
end if;
-- set tx start signal
case set_tx_start is
when SET => tx_start_reg <= '1';
when CLR => tx_start_reg <= '0';
when HOLD => tx_start_reg <= tx_start_reg;
end case;
 
-- set tx started signal
case set_tx_started is
when SET => tx_started_reg <= '1';
when CLR => tx_started_reg <= '0';
when HOLD => tx_started_reg <= tx_started_reg;
end case;
 
-- set tx finished signal
case set_tx_fin is
when SET => tx_fin_reg <= '1';
when CLR => tx_fin_reg <= '0';
when HOLD => tx_fin_reg <= tx_fin_reg;
end case;
 
-- set UDP START signal
case set_udp_rx_start_reg is
when SET => udp_rx_start_reg <= '1';
when CLR => udp_rx_start_reg <= '0';
when HOLD => udp_rx_start_reg <= udp_rx_start_reg;
end case;
end if;
end if;
 
end process;
------------------------------------------------------------------------------
-- Instantiate the UDP layer
------------------------------------------------------------------------------
UDP_block : UDP_Complete PORT MAP
(
-- UDP interface
udp_tx_start => udp_tx_start_int,
udp_txi => udp_tx_int,
udp_tx_result => udp_tx_result_int,
udp_tx_data_out_ready=> udp_tx_data_out_ready_int,
udp_rx_start => udp_rx_start_int,
udp_rxo => udp_rx_int,
-- IP RX signals
ip_rx_hdr => ip_rx_hdr_int,
-- System interface
clk_in_p => clk_in_p,
clk_in_n => clk_in_n,
clk_out => clk_int,
reset => reset,
our_ip_address => our_ip,
our_mac_address => our_mac,
-- status signals
arp_pkt_count => arp_pkt_count_int,
ip_pkt_count => ip_pkt_count_int,
-- GMII Interface
-----------------
phy_resetn => phy_resetn,
gmii_txd => gmii_txd,
gmii_tx_en => gmii_tx_en,
gmii_tx_er => gmii_tx_er,
gmii_tx_clk => gmii_tx_clk,
gmii_rxd => gmii_rxd,
gmii_rx_dv => gmii_rx_dv,
gmii_rx_er => gmii_rx_er,
gmii_rx_clk => gmii_rx_clk,
gmii_col => gmii_col,
gmii_crs => gmii_crs,
mii_tx_clk => mii_tx_clk
);
 
 
end Behavioral;
 
/udp_constraints.ucf
0,0 → 1,76
CONFIG PART = xc6vlx240tff1156-1;
 
 
########## ML605 Board ##########
NET clk_in_p LOC = J9 |IOSTANDARD = LVDS_25 |DIFF_TERM = TRUE;
NET clk_in_n LOC = H9 |IOSTANDARD = LVDS_25 |DIFF_TERM = TRUE;
 
Net reset LOC = H10 |IOSTANDARD = LVCMOS15 |TIG;
 
# downgrade the Place:1153 error in the mapper
NET "reset" CLOCK_DEDICATED_ROUTE = FALSE;
 
#### Module LEDs_8Bit constraints
NET "display[0]" LOC = AC22;
NET "display[1]" LOC = AC24;
NET "display[2]" LOC = AE22;
NET "display[3]" LOC = AE23;
NET "display[4]" LOC = AB23;
NET "display[5]" LOC = AG23;
NET "display[6]" LOC = AE24;
NET "display[7]" LOC = AD24;
 
NET PBTX_LED LOC = AD21;
 
#### Module Push_Buttons_4Bit constraints
NET PBTX LOC = H17;
NET reset_leds LOC = G26;
 
#### Module DIP_Switches_4Bit constraints
 
 
Net phy_resetn LOC = AH13 |IOSTANDARD = LVCMOS25 |TIG;
 
Net gmii_rxd<7> LOC = AC13 |IOSTANDARD = LVCMOS25;
Net gmii_rxd<6> LOC = AC12 |IOSTANDARD = LVCMOS25;
Net gmii_rxd<5> LOC = AD11 |IOSTANDARD = LVCMOS25;
Net gmii_rxd<4> LOC = AM12 |IOSTANDARD = LVCMOS25;
Net gmii_rxd<3> LOC = AN12 |IOSTANDARD = LVCMOS25;
Net gmii_rxd<2> LOC = AE14 |IOSTANDARD = LVCMOS25;
Net gmii_rxd<1> LOC = AF14 |IOSTANDARD = LVCMOS25;
Net gmii_rxd<0> LOC = AN13 |IOSTANDARD = LVCMOS25;
 
Net gmii_txd<7> LOC = AF11 |IOSTANDARD = LVCMOS25;
Net gmii_txd<6> LOC = AE11 |IOSTANDARD = LVCMOS25;
Net gmii_txd<5> LOC = AM10 |IOSTANDARD = LVCMOS25;
Net gmii_txd<4> LOC = AL10 |IOSTANDARD = LVCMOS25;
Net gmii_txd<3> LOC = AG11 |IOSTANDARD = LVCMOS25;
Net gmii_txd<2> LOC = AG10 |IOSTANDARD = LVCMOS25;
Net gmii_txd<1> LOC = AL11 |IOSTANDARD = LVCMOS25;
Net gmii_txd<0> LOC = AM11 |IOSTANDARD = LVCMOS25;
 
Net gmii_col LOC = AK13 |IOSTANDARD = LVCMOS25;
Net gmii_crs LOC = AL13 |IOSTANDARD = LVCMOS25;
Net mii_tx_clk LOC = AD12 |IOSTANDARD = LVCMOS25;
 
Net gmii_tx_en LOC = AJ10 |IOSTANDARD = LVCMOS25;
Net gmii_tx_er LOC = AH10 |IOSTANDARD = LVCMOS25;
Net gmii_tx_clk LOC = AH12 |IOSTANDARD = LVCMOS25;
 
Net gmii_rx_dv LOC = AM13 |IOSTANDARD = LVCMOS25;
Net gmii_rx_er LOC = AG12 |IOSTANDARD = LVCMOS25;
# P20 - GCLK7
Net gmii_rx_clk LOC = AP11 |IOSTANDARD = LVCMOS25;
 
 
 
NET "clk_in_p" TNM_NET = "clk_in_p";
TIMESPEC "TS_emac1_clk_in_p" = PERIOD "clk_in_p" 5.000 ns HIGH 50% INPUT_JITTER 50.0ps;
 
 
# Ethernet GTX_CLK high quality 125 MHz reference clock
NET "*mac_block/gtx_clk_bufg" TNM_NET = "ref_gtx_clk";
TIMEGRP "emac1_clk_ref_gtx" = "ref_gtx_clk";
TIMESPEC TS_emac1_clk_ref_gtx = PERIOD "N/A" 8 ns HIGH 50%;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.