1 -------------------------------------------------------------------------------     2 -- File       : SrpV0AxiLite.vhd     3 -- Company    : SLAC National Accelerator Laboratory     4 -- Created    : 2014-04-09     5 -- Last update: 2016-05-11     6 -------------------------------------------------------------------------------     7 -- Description: SLAC Register Protocol Version 0, AXI-Lite Interface     9 -- Documentation: https://confluence.slac.stanford.edu/x/aRmVD    11 -- Note: This module only supports 32-bit aligned addresses and 32-bit transactions.      13 -------------------------------------------------------------------------------    14 -- This file is part of 'SLAC Firmware Standard Library'.    15 -- It is subject to the license terms in the LICENSE.txt file found in the     16 -- top-level directory of this distribution and at:     17 --    https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.     18 -- No part of 'SLAC Firmware Standard Library', including this file,     19 -- may be copied, modified, propagated, or distributed except according to     20 -- the terms contained in the LICENSE.txt file.    21 -------------------------------------------------------------------------------    24 use ieee.std_logic_1164.
all;
    25 use ieee.std_logic_arith.
all;
    26 use ieee.std_logic_unsigned.
all;
    34  --! @ingroup protocols_srp    46       USE_BUILT_IN_G      :                     := false;
  --if set to true, this module is only Xilinx compatible only!!!    53       -- AXI Stream IO Config    57       -- Streaming Slave (Rx) Interface (sAxisClk domain)     64       -- Streaming Master (Tx) Data Interface (mAxisClk domain)    70       -- AXI Lite Bus (axiLiteClk domain)    83    constant SLAVE_FIFO_SSI_CONFIG_C  : AxiStreamConfigType := ssiAxiStreamConfig(4, TKEEP_COMP_C);
    84    constant MASTER_FIFO_SSI_CONFIG_C : AxiStreamConfigType := ssiAxiStreamConfig(4, TKEEP_COMP_C);
    92    type StateType is (S_IDLE_C, S_ADDR_C, S_WRITE_C, S_WRITE_AXI_C, S_READ_SIZE_C,    93                       S_READ_C, S_READ_AXI_C, S_STATUS_C, S_DUMP_C);
    95    type RegType is record    96       echo    : slv(31 downto 0);
    97       address : slv(31 downto 0);
    98       rdSize  : slv(8 downto 0);
    99       rdCount : slv(8 downto 0);
   100       timer   : slv(23 downto 0);
   112    constant REG_INIT_C : RegType := (   113       echo                => (others => '0'),   114       address             => (others => '0'),   115       rdSize              => (others => '0'),   116       rdCount             => (others => '0'),   117       timer               => (others => '1'),   126    signal r   : RegType := REG_INIT_C;
   127    signal rin : RegType;
   129    -- attribute dont_touch                    : string;   130    -- attribute dont_touch of r               : signal is "TRUE";   131    -- attribute dont_touch of sFifoAxisMaster : signal is "TRUE";   132    -- attribute dont_touch of sFifoAxisSlave  : signal is "TRUE";      133    -- attribute dont_touch of mFifoAxisMaster : signal is "TRUE";   134    -- attribute dont_touch of mFifoAxisSlave  : signal is "TRUE";   135    -- attribute dont_touch of mFifoAxisCtrl   : signal is "TRUE";   139    ----------------------------------   141    ----------------------------------   142    SlaveAxiStreamFifo : 
entity work.
SsiFifo   171    -------------------------------------   172    -- Master State Machine   173    -------------------------------------   176       variable v : RegType;
   181       v.mFifoAxisMaster        := sFifoAxisMaster;
   182       v.mFifoAxisMaster.tUser  := (others => '0');
   183       v.mFifoAxisMaster.tKeep  := (others => '1');
   184       v.mFifoAxisMaster.tValid := '0';
   185       v.mFifoAxisMaster.tLast  := '0';
   187       v.sFifoAxisSlave.tReady := '0';
   197             v.address             := (others => '0');
   198             v.rdSize              := (others => '0');
   199             v.rdCount             := (others => '0');
   204             if sFifoAxisMaster.tValid = '1' and mFifoAxisCtrl.pause = '0' then   205                v.sFifoAxisSlave.tReady := '1';
   208                if sFifoAxisMaster.tLast = '0' then   209                   v.mFifoAxisMaster.tValid := '1';
  -- Echo word 0   210                   v.mFifoAxisMaster.tUser  := sFifoAxisMaster.tUser;
   211                   v.mFifoAxisMaster.tData  := sFifoAxisMaster.tData;
   218             v.sFifoAxisSlave.tReady := '1';
   220             if sFifoAxisMaster.tValid = '1' then   223                   v.address(31 downto 26) := sFifoAxisMaster.tData(29 downto 24);
   226                v.address(25 downto 2)   := sFifoAxisMaster.tData(23 downto 0);
   227                v.mFifoAxisMaster.tValid := '1';
  -- Echo word 1   229                -- Short frame, return error   230                if sFifoAxisMaster.tLast = '1' then   232                   v.state := S_STATUS_C;
   235                elsif sFifoAxisMaster.tData(31 downto 30) = "00" then   236                   v.state := S_READ_SIZE_C;
   239                elsif sFifoAxisMaster.tData(31 downto 30) = "01" then   240                   v.state := S_WRITE_C;
   249          -- Prepare Write Transaction   255             v.sFifoAxisSlave.tReady      := '1';
   256             v.timer                      := (others => '1');
   258             if sFifoAxisMaster.tValid = '1' then   259                if sFifoAxisMaster.tLast = '1' then   261                   if (not axiStreamPacked(SLAVE_FIFO_SSI_CONFIG_C, sFifoAxisMaster)) then   264                   v.state := S_STATUS_C;
   266                   v.mFifoAxisMaster.tValid      := '1';
  -- Echo write data   270                   v.state                       := S_WRITE_AXI_C;
   274          -- Write Transaction, AXI   275          when S_WRITE_AXI_C =>   276             v.timer := r.timer - 1;
   278             -- Clear control signals on ack   293             -- End transaction on timeout   301             -- Transaction is done   306                v.address := r.address + 4;
   307                v.state   := S_WRITE_C;
   311          when S_READ_SIZE_C =>   312             v.rdCount := (others => '0');
   313             v.rdSize  := sFifoAxisMaster.tData(8 downto 0);
   315             -- Don't read if EOF (need for dump later)   316             if sFifoAxisMaster.tValid = '1' then   317                v.sFifoAxisSlave.tReady := not sFifoAxisMaster.tLast;
   325             v.timer                     := (others => '1');
   327             -- Start AXI transaction   330             v.state                      := S_READ_AXI_C;
   334             v.timer := r.timer - 1;
   336             -- Clear control signals on ack   349             -- End transaction on timeout   356             -- Transaction is done   358                v.mFifoAxisMaster.tValid := '1';
   359                v.address                := r.address + 4;
   360                v.rdCount                := r.rdCount + 1;
   362                if r.rdCount = r.rdSize then   371             v.sFifoAxisSlave.tReady := '1';
   373             if sFifoAxisMaster.tValid = '1' and sFifoAxisMaster.tLast = '1' then   375                if (not axiStreamPacked(SLAVE_FIFO_SSI_CONFIG_C, sFifoAxisMaster)) then   378                v.state := S_STATUS_C;
   383             v.mFifoAxisMaster.tValid             := '1';
   384             v.mFifoAxisMaster.tLast              := '1';
   385             v.mFifoAxisMaster.tData(63 downto 0) := (others => '0');
   386             v.mFifoAxisMaster.tData(17)          := r.timeout;
   387             v.mFifoAxisMaster.tData(16)          := r.fail;
   403       sFifoAxisSlave      <= v.sFifoAxisSlave;
   404       mFifoAxisMaster     <= r.mFifoAxisMaster;
   411          r <= rin after TPD_G;
   416    ----------------------------------   418    ---------------------------------- 
FIFO_ADDR_WIDTH_Ginteger   range  4 to  48:= 9
 
out sAxisCtrlAxiStreamCtrlType  
 
ALTERA_RAM_Gstring  :=   "M9K"
 
SLAVE_READY_EN_Gboolean  :=   true
 
out mAxiLiteWriteMasterAxiLiteWriteMasterType  
 
USE_BUILT_IN_Gboolean  :=   false
 
PIPE_STAGES_Gnatural   range  0 to  16:= 1
 
ALTERA_SYN_Gboolean  :=   false
 
out mAxisMasterAxiStreamMasterType  
 
FIFO_PAUSE_THRESH_Gpositive  := 1
 
ALTERA_RAM_Gstring  :=   "M9K"
 
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 mAxiLiteWriteSlaveAxiLiteWriteSlaveType  
 
SLAVE_AXI_CONFIG_GAxiStreamConfigType  :=   AXI_STREAM_CONFIG_INIT_C
 
FIFO_ADDR_WIDTH_Ginteger   range  4 to  48:= 9
 
in sAxisMasterAxiStreamMasterType  
 
FIFO_FIXED_THRESH_Gboolean  :=   true
 
GEN_SYNC_FIFO_Gboolean  :=   false
 
GEN_SYNC_FIFO_Gboolean  :=   false
 
XIL_DEVICE_Gstring  :=   "7SERIES"
 
XIL_DEVICE_Gstring  :=   "7SERIES"
 
ALTERA_SYN_Gboolean  :=   false
 
AXI_STREAM_CONFIG_GAxiStreamConfigType  :=   AXI_STREAM_CONFIG_INIT_C
 
SLAVE_READY_EN_Gboolean  :=   false
 
GEN_SYNC_FIFO_Gboolean  :=   false
 
out sAxisCtrlAxiStreamCtrlType  
 
FIFO_PAUSE_THRESH_Ginteger   range  1 to ( 2** 24):= 2** 8
 
INT_PIPE_STAGES_Gnatural   range  0 to  16:= 0
 
EN_32BIT_ADDR_Gboolean  :=   false
 
FIFO_FIXED_THRESH_Gboolean  :=   true
 
AxiStreamSlaveType  :=(tReady  => '0') AXI_STREAM_SLAVE_INIT_C
 
XIL_DEVICE_Gstring  :=   "7SERIES"
 
USE_BUILT_IN_Gboolean  :=   false
 
in mAxiLiteReadSlaveAxiLiteReadSlaveType  
 
out sAxisSlaveAxiStreamSlaveType  
 
ALTERA_SYN_Gboolean  :=   false
 
in mAxisSlaveAxiStreamSlaveType  
 
AxiLiteReadMasterType  :=(araddr  =>( others => '0'),arprot  =>( others => '0'),arvalid  => '0',rready  => '1') AXI_LITE_READ_MASTER_INIT_C
 
RESP_THOLD_Ginteger   range  0 to ( 2** 24):= 1
 
out sAxisSlaveAxiStreamSlaveType  
 
AxiStreamConfigType  :=(TSTRB_EN_C  =>   false,TDATA_BYTES_C  => 16,TDEST_BITS_C  => 4,TID_BITS_C  => 0,TKEEP_MODE_C  =>   TKEEP_NORMAL_C,TUSER_BITS_C  => 4,TUSER_MODE_C  =>   TUSER_NORMAL_C) AXI_STREAM_CONFIG_INIT_C
 
out mAxisMasterAxiStreamMasterType  
 
EN_FRAME_FILTER_Gboolean  :=   true
 
FIFO_ADDR_WIDTH_Ginteger   range  4 to  48:= 9
 
AxiLiteWriteMasterType  :=(awaddr  =>( others => '0'),awprot  =>( others => '0'),awvalid  => '0',wdata  =>( others => '0'),wstrb  =>( others => '1'),wvalid  => '0',bready  => '1') AXI_LITE_WRITE_MASTER_INIT_C
 
in sAxisMasterAxiStreamMasterType  
 
out mAxisMasterAxiStreamMasterType  
 
slv( 1 downto  0)  :=   "00" AXI_RESP_OK_C
 
SLAVE_AXI_CONFIG_GAxiStreamConfigType  :=   SSI_CONFIG_INIT_C
 
in mAxisSlaveAxiStreamSlaveType  
 
CASCADE_SIZE_Gpositive  := 1
 
out sAxisCtrlAxiStreamCtrlType  
 
ALTERA_RAM_Gstring  :=   "M9K"
 
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
 
PIPE_STAGES_Gnatural  := 1
 
MASTER_AXI_CONFIG_GAxiStreamConfigType  :=   SSI_CONFIG_INIT_C
 
MASTER_AXI_CONFIG_GAxiStreamConfigType  :=   AXI_STREAM_CONFIG_INIT_C
 
out sAxisSlaveAxiStreamSlaveType  
 
out mAxiLiteReadMasterAxiLiteReadMasterType  
 
in sAxisMasterAxiStreamMasterType