1 ------------------------------------------------------------------------------- 2 -- File : AxiStreamShift.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2014-04-25 5 -- Last update: 2016-10-27 6 ------------------------------------------------------------------------------- 8 -- Block to shift data bytes within an AXI stream. Both left and right shifting 9 -- are allowed. This block will move a packet at a time. Transfer of a new packet 10 -- will pause until a new shift command is provided. 11 ------------------------------------------------------------------------------- 12 -- This file is part of 'SLAC Firmware Standard Library'. 13 -- It is subject to the license terms in the LICENSE.txt file found in the 14 -- top-level directory of this distribution and at: 15 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 16 -- No part of 'SLAC Firmware Standard Library', including this file, 17 -- may be copied, modified, propagated, or distributed except according to 18 -- the terms contained in the LICENSE.txt file. 19 ------------------------------------------------------------------------------- 22 use ieee.std_logic_1164.
all;
23 use ieee.std_logic_arith.
all;
24 use ieee.std_logic_unsigned.
all;
57 type StateType is (S_IDLE_C, S_FIRST_C, S_SHIFT_C, S_LAST_C);
59 type RegType is record 62 shiftBytes : slv(3 downto 0);
68 constant REG_INIT_C : RegType := ( 71 shiftBytes => (others => '0'), 77 signal r : RegType := REG_INIT_C;
81 procedure shiftData (shiftBytes :
in slv(
3 downto 0);
87 variable shiftInt : positive;
88 variable lDiv : positive;
89 variable rDiv : positive;
90 variable nextEmpty : ;
96 if shiftBytes = 0 then 100 shiftInt := conv_integer(shiftBytes);
102 if shiftDir = '0' then 114 mOut.tData((i*8)+7 downto (i*8)) := mDelay.tData(((i+rDiv)*8)+7 downto (i+rDiv)*8);
115 mOut.tUser((i*user)+(user-1) downto (i*user)) := mDelay.tUser(((i+rDiv)*user)+(user-1) downto (i+rDiv)*user);
125 -- There are valid values which will be taken from the delayed register. 126 if mInput.tValid = '1' and mInput.tKeep(i+rDiv) = '1' then 130 mOut.tData((i*8)+7 downto (i*8)) := mInput.tData(((i-lDiv)*8)+7 downto (i-lDiv)*8);
131 mOut.tUser((i*user)+(user-1) downto (i*user)) := mInput.tUser(((i-lDiv)*user)+(user-1) downto (i-lDiv)*user);
137 -- Choose ID and Dest values 146 -- Detect frame end from next register or current register 147 if (mDelay.tValid = '1' and mDelay.tLast = '1') or (mInput.tValid = '1' and mInput.tLast = '1' and nextEmpty) then 160 -- attribute dont_touch : string; 161 -- attribute dont_touch of r : signal is "TRUE"; 173 variable v : RegType;
176 -- Latch the current value 183 shiftData (r.shiftBytes, r.shiftDir, (r.state = S_FIRST_C), sAxisMaster, r.delay, sMaster);
196 -- Shift start request 198 v.state := S_FIRST_C;
205 -- Keep sampling shift configuration if start is held 213 v.state := S_SHIFT_C;
216 if r.shiftDir = '0' or r.shiftBytes = 0 then 220 if sMaster.tLast = '1' then 226 -- Move a frame until tLast 230 if r.master.tValid = '0' or pipeAxisSlave.tReady = '1' then 241 if sMaster.tLast = '1' then 244 -- Last is is delayed block 245 if r.delay.tLast = '1' then 255 if pipeAxisSlave.tReady = '1' then 261 -- Mask off the unused tStrb and tKeep bits 272 -- Register the variable for next clock cycle 277 pipeAxisMaster <= r.master;
296 r <= rin after TPD_G;
PIPE_STAGES_Gnatural range 0 to 16:= 0
out sAxisSlaveAxiStreamSlaveType
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
ADD_VALID_EN_Gboolean := false
in sAxisMasterAxiStreamMasterType
out sAxisSlaveAxiStreamSlaveType
natural range 1 to 16 TDATA_BYTES_C
in mAxisSlaveAxiStreamSlaveType
in axiShiftCntslv( 3 downto 0)
out mAxisMasterAxiStreamMasterType
in sAxisMasterAxiStreamMasterType
AxiStreamSlaveType :=(tReady => '0') AXI_STREAM_SLAVE_INIT_C
BYP_SHIFT_Gboolean := false
natural range 0 to 8 TUSER_BITS_C
out mAxisMasterAxiStreamMasterType
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
in mAxisSlaveAxiStreamSlaveType
AXIS_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
PIPE_STAGES_Ginteger range 0 to 16:= 0