1 -------------------------------------------------------------------------------     3 -- Company    : SLAC National Accelerator Laboratory     4 -- Created    : 2015-09-01     5 -- Last update: 2015-09-22     6 -------------------------------------------------------------------------------     7 -- Description: SALT TX Engine Module     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 protocols_salt_core    48 architecture rtl 
of SaltTx is
    61    type RegType is record    67       seqCnt      : slv(7 downto 0);
    69       cnt         : slv(15 downto 0);
    70       length      : slv(15 downto 0);
    71       checksum    : slv(31 downto 0);
    79    constant REG_INIT_C : RegType := (    85       seqCnt      => (others => '0'),    86       tDest       => (others => '0'),    87       cnt         => (others => '0'),    88       length      => (others => '0'),    89       checksum    => (others => '0'),    97    signal r   : RegType := REG_INIT_C;
   115          -- General Configurations   120          -- FIFO configurations   127          -- AXI Stream Port Configurations   144          -- General Configurations   149          -- FIFO configurations   155          -- AXI Stream Port Configurations   171    comb : 
process (gmiiMaster, mMaster, r, 
rst, rxMaster, sSlave, txSlave) 
is   172       variable v : RegType;
   174       -- Latch the current value   178       v.flushBuffer := '0';
   180       if txSlave.tReady = '1' then   182          v.txMaster.tLast  := '0';
   183          v.txMaster.tUser  := (others => '0');
   186       if sSlave.tReady = '1' then   188          v.sMaster.tLast  := '0';
   189          v.sMaster.tUser  := (others => '0');
   194          ----------------------------------------------------------------------   196             -- Reset flags/accumulators   197             v.flushBuffer := '1';
   201             v.length      := (others => '0');
   202             v.checksum    := (others => '0');
   203             v.cnt         := (others => '0');
   205             if (rxMaster.tValid = '1') then   212                   -- Latch the destination   215                   -- Increment the counter   216                   v.seqCnt := r.seqCnt + 1;
   221          ----------------------------------------------------------------------   223             -- Check if ready to move data   224             if (rxMaster.tValid = '1') and (v.sMaster.tValid = '0') then   228                v.sMaster        := rxMaster;
   229                -- Mask off tLast for intergap monitoring   230                v.sMaster.tLast  := '0';
   231                -- Increment the counter   232                v.length         := r.length + 1;
   234                if rxMaster.tLast = '1' then   239                   v.state := PREAMBLE_S;
   242                   v.state := PREAMBLE_S;
   245          ----------------------------------------------------------------------   247             -- Check if ready to move data   248             if (v.txMaster.tValid = '0') then   249                -- Write the preamble    255          ----------------------------------------------------------------------   257             -- Check if ready to move data   258             if (v.txMaster.tValid = '0') then   259                -- Write the preamble    265          ----------------------------------------------------------------------   267             -- Check if ready to move data   268             if (v.txMaster.tValid = '0') then   279          ----------------------------------------------------------------------   281             -- Check if ready to move data   282             if (v.txMaster.tValid = '0') then   285                v.txMaster.tData(15 downto 0)  := r.length;
   287                v.txMaster.tData(31 downto 24) := r.seqCnt;
   289                v.checksum                     := v.txMaster.tData(31 downto 0);
   293          ----------------------------------------------------------------------   295             -- Check for valid data   296             if (mMaster.tValid = '1') and (v.txMaster.tValid = '0') then   300                v.txMaster      := mMaster;
   302                v.checksum      := r.checksum + mMaster.tData(31 downto 0);
   303                -- Increment the counter   306                if v.cnt = r.length then   308                   v.flushBuffer := '1';
   310                   v.state       := CHECKSUM_S;
   313          ----------------------------------------------------------------------   315             -- Check if ready to move data   316             if (v.txMaster.tValid = '0') then   319                v.txMaster.tData(31 downto 0) := not(r.checksum);
  -- one's complement                           323          ----------------------------------------------------------------------   325             -- Check if ready to move data   326             if (v.txMaster.tValid = '0') then   329                -- Insert tLast for intergap monitoring   330                v.txMaster.tLast  := '1';
   344       ----------------------------------------------------------------------   347       -- Check the current state of gmiiSlave   348       if r.gmiiSlave.tReady = '0' then   349          -- Check the intergap counter   352             v.gmiiSlave.tReady := '1';
   354             v.gapCnt := r.gapCnt + 1;
   357          -- Check for GMII tLast   358          if (gmiiMaster.tValid = '1') and (gmiiMaster.tLast = '1') then   359             -- Reset the flag and counter   360             v.gmiiSlave.tReady := '0';
   370       -- Register the variable for next clock cycle   375       sMaster   <= r.sMaster;
   376       rxSlave   <= v.rxSlave;
   377       txMaster  <= r.txMaster;
   378       gmiiSlave <= r.gmiiSlave;
   382    seq : 
process (
clk) 
is   384       if rising_edge(clk) then   385          r <= rin after TPD_G;
   391          -- General Configurations   396          -- FIFO configurations   402          -- AXI Stream Port Configurations 
FIFO_ADDR_WIDTH_Ginteger   range  4 to  48:= 9
 
PIPE_STAGES_Gnatural   range  0 to  16:= 1
 
slv( 31 downto  0)  := x"CCCCCCCC" SOC_C
 
slv( 31 downto  0)  := x"D5555555" SFD_C
 
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
 
AxiStreamConfigType  :=   ssiAxiStreamConfig( 4,   TKEEP_COMP_C,   TUSER_FIRST_LAST_C, 8) SSI_SALT_CONFIG_C
 
SLAVE_AXI_CONFIG_GAxiStreamConfigType  :=   AXI_STREAM_CONFIG_INIT_C
 
SLAVE_AXI_CONFIG_GAxiStreamConfigType  :=   ssiAxiStreamConfig( 4)
 
in sAxisMasterAxiStreamMasterType  
 
SLAVE_READY_EN_Gboolean  :=   true
 
out sAxisSlaveAxiStreamSlaveType  
 
GEN_SYNC_FIFO_Gboolean  :=   false
 
AxiStreamConfigType  :=   ssiAxiStreamConfig( 1,   TKEEP_COMP_C,   TUSER_FIRST_LAST_C, 0) SSI_GMII_CONFIG_C
 
slv( 31 downto  0)  := x"DDDDDDDD" EOC_C
 
AxiStreamSlaveType  :=(tReady  => '0') AXI_STREAM_SLAVE_INIT_C
 
slv( 31 downto  0)  := x"FFFFFFFF" EOFE_C
 
COMMON_TX_CLK_Gboolean  :=   false
 
out sAxisSlaveAxiStreamSlaveType  
 
slv( 31 downto  0)  := x"BBBBBBBB" SOF_C
 
in sAxisMasterAxiStreamMasterType  
 
out mAxisMasterAxiStreamMasterType  
 
out txDataslv( 7 downto  0)  
 
natural  := 12 INTER_GAP_SIZE_C
 
in mAxisSlaveAxiStreamSlaveType  
 
CASCADE_SIZE_Ginteger   range  1 to ( 2** 24):= 1
 
USE_BUILT_IN_Gboolean  :=   false
 
FIFO_PAUSE_THRESH_Ginteger   range  1 to ( 2** 24):= 1
 
VALID_THOLD_Ginteger   range  0 to ( 2** 24):= 1
 
slv( 31 downto  0)  := x"55555555" PREAMBLE_C
 
MASTER_AXI_CONFIG_GAxiStreamConfigType  :=   AXI_STREAM_CONFIG_INIT_C
 
slv( 31 downto  0)  := x"EEEEEEEE" EOF_C
 
natural  :=( 1500/ 4) SALT_MAX_WORDS_C