1 -------------------------------------------------------------------------------     2 -- File       : IcmpEngine.vhd     3 -- Company    : SLAC National Accelerator Laboratory     4 -- Created    : 2016-08-16     5 -- Last update: 2016-09-16     6 -------------------------------------------------------------------------------     7 -- Description: ICMP Engine (A.K.A. "ping" protocol)     8 -------------------------------------------------------------------------------     9 -- This file is part of 'SLAC Firmware Standard Library'.    10 -- It is subject to the license terms in the LICENSE.txt file found in the     11 -- top-level directory of this distribution and at:     12 --    https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.     13 -- No part of 'SLAC Firmware Standard Library', including this file,     14 -- may be copied, modified, propagated, or distributed except according to     15 -- the terms contained in the LICENSE.txt file.    16 -------------------------------------------------------------------------------    19 use ieee.std_logic_1164.
all;
    20 use ieee.std_logic_unsigned.
all;
    21 use ieee.std_logic_arith.
all;
    29  --! @ingroup ethernet_IpV4Engine    34       -- Local Configurations    35       localIp      : 
in  slv(
31 downto 0);  --  big-Endian 
configuration       36       -- Interface to ICMP Engine    54    type RegType is record    56       checksum     : slv(15 downto 0);
    61    constant REG_INIT_C : RegType := (    62       tData        => (others => '0'),    63       checksum     => (others => '0'),    68    signal r   : RegType := REG_INIT_C;
    71    -- attribute dont_touch      : string;    72    -- attribute dont_touch of r : signal is "TRUE";       80       -- Latch the current value    92       -- Update the variable    95       ------------------------------------------------    96       -- Notes: Non-Standard IPv4 Pseudo Header Format    97       ------------------------------------------------    98       -- tData[0][47:0]   = Remote MAC Address    99       -- tData[0][63:48]  = zeros   100       -- tData[0][95:64]  = Remote IP Address    101       -- tData[0][127:96] = Local IP address   102       -- tData[1][7:0]    = zeros   103       -- tData[1][15:8]   = Protocol Type = ICMP   104       -- tData[1][31:16]  = IPv4 Pseudo header length   105       -- tData[1][39:32]  = Type of message   106       -- tData[1][47:40]  = Code   107       -- tData[1][63:48]  = Checksum   108       -- tData[1][95:64]  = ICMP Header    109       -- tData[1][127:96] = ICMP Datagram    110       ------------------------------------------------            114          ----------------------------------------------------------------------   120                -- Check for SOF with no EOF   122                   -- Copy IPv4 base header   124                   -- Swap the IP addresses   133          ----------------------------------------------------------------------   137                -- Check for Echo request   139                   -- Map the inbound checksum to little Endian   142                   -- Update the checksum for outbound data packet   143                   v.checksum              := v.checksum + x"0800";
   144                   ---------------------------------------------------------   145                   -- Note: To save FPGA resources, we do NOT cache the data    146                   --       for properly calculating the checksum.  Instead,    147                   --       we calculate the outbound checksum with respect    148                   --       to the inbound checksum and assume that the    149                   --       computer interface will probably check our    151                   ---------------------------------------------------------   152                   -- Send the IPv4 base header   163          ----------------------------------------------------------------------   169                -- Send the IPv4 base header   188          ----------------------------------------------------------------------   194                -- Send the IPv4 base header   206       ----------------------------------------------------------------------   214       -- Register the variable for next clock cycle   223    seq : 
process (
clk) 
is   225       if rising_edge(clk) then   226          r <= rin after TPD_G;
 
out obIcmpMasterAxiStreamMasterType  
 
in obIcmpSlaveAxiStreamSlaveType  
 
AxiStreamMasterType  :=(tValid  => '0',tData  =>( others => '0'),tStrb  =>( others => '1'),tKeep  =>( others => '1'),tLast  => '0',tDest  =>( others => '0'),tId  =>( others => '0'),tUser  =>( others => '0')) AXI_STREAM_MASTER_INIT_C
 
in localIpslv( 31 downto  0)  
 
AxiStreamSlaveType  :=(tReady  => '0') AXI_STREAM_SLAVE_INIT_C
 
out ibIcmpSlaveAxiStreamSlaveType  
 
in ibIcmpMasterAxiStreamMasterType  
 
AxiStreamConfigType  :=(TSTRB_EN_C  =>   false,TDATA_BYTES_C  => 16,TDEST_BITS_C  => 8,TID_BITS_C  => 0,TKEEP_MODE_C  =>   TKEEP_COMP_C,TUSER_BITS_C  => 4,TUSER_MODE_C  =>   TUSER_FIRST_LAST_C) EMAC_AXIS_CONFIG_C