1 ------------------------------------------------------------------------------- 2 -- File : AxiStreamResize.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2016-06-16 5 -- Last update: 2016-06-16 6 ------------------------------------------------------------------------------- 8 -- Block to resize AXI Streams. Re-sizing is always little endian. 9 -- Resizer should not be used when interleaving tDests 10 ------------------------------------------------------------------------------- 11 -- This file is part of 'SLAC Firmware Standard Library'. 12 -- It is subject to the license terms in the LICENSE.txt file found in the 13 -- top-level directory of this distribution and at: 14 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 15 -- No part of 'SLAC Firmware Standard Library', including this file, 16 -- may be copied, modified, propagated, or distributed except according to 17 -- the terms contained in the LICENSE.txt file. 18 ------------------------------------------------------------------------------- 21 use ieee.std_logic_1164.
all;
22 use ieee.std_logic_unsigned.
all;
23 use ieee.std_logic_arith.
all;
33 -- General Configurations 37 -- AXI Stream Port Configurations 65 constant COUNT_C : := ite(SLV_BYTES_C > MST_BYTES_C, SLV_BYTES_C / MST_BYTES_C, MST_BYTES_C / SLV_BYTES_C);
67 type RegType is record 68 count : slv(bitSize(COUNT_C)-1 downto 0);
73 constant REG_INIT_C : RegType := ( 74 count => (others => '0'), 79 signal r : RegType := REG_INIT_C;
84 -- Make sure data widths are appropriate. 85 assert ((SLV_BYTES_C >= MST_BYTES_C and SLV_BYTES_C mod MST_BYTES_C = 0) or 86 (MST_BYTES_C >= SLV_BYTES_C and MST_BYTES_C mod SLV_BYTES_C = 0)) 87 report "Data widths must be even number multiples of each other" severity failure;
89 -- When going from a large bus to a small bus, ready is neccessary 90 assert (SLV_BYTES_C <= MST_BYTES_C or READY_EN_G = true) 91 report "READY_EN_G must be true if slave width is great than master" severity failure;
96 variable idx : ;
-- index version of counter 97 variable byteCnt : ;
-- Number of valid bytes in incoming bus 98 variable bytes : ;
-- byte version of counter 101 idx := conv_integer(r.count);
102 bytes := (idx+1) * MST_BYTES_C;
108 -- Choose ready source and clear valid 113 -- Inbound data with normalized user bits (8 user bits) 115 ibM.tUser := (others=>'0');
117 for i in 0 to 15 loop 118 ibM.tUser((i*8)+(SLV_USER_C-1) downto (i*8)) := sAxisMaster.tUser((i*SLV_USER_C)+(SLV_USER_C-1) downto (i*SLV_USER_C));
122 if v.obMaster.tValid = '0' then 125 if MST_BYTES_C > SLV_BYTES_C then 128 -- init when count = 0 129 if (r.count = 0) then 131 v.obMaster.tKeep := (others=>'0');
132 v.obMaster.tStrb := (others=>'0');
135 v.obMaster.tData((SLV_BYTES_C*8*idx)+((SLV_BYTES_C*8)-1) downto (SLV_BYTES_C*8*idx)) := ibM.tData((SLV_BYTES_C*8)-1 downto 0);
136 v.obMaster.tUser((SLV_BYTES_C*8*idx)+((SLV_BYTES_C*8)-1) downto (SLV_BYTES_C*8*idx)) := ibM.tUser((SLV_BYTES_C*8)-1 downto 0);
137 v.obMaster.tStrb((SLV_BYTES_C*idx)+(SLV_BYTES_C-1) downto (SLV_BYTES_C*idx)) := ibM.tStrb(SLV_BYTES_C-1 downto 0);
138 v.obMaster.tKeep((SLV_BYTES_C*idx)+(SLV_BYTES_C-1) downto (SLV_BYTES_C*idx)) := ibM.tKeep(SLV_BYTES_C-1 downto 0);
140 v.obMaster.tId := ibM.tId;
144 -- Determine if we move data 146 if r.count = (COUNT_C-1) or ibM.tLast = '1' then 148 v.count := (others => '0');
150 v.count := r.count + 1;
159 v.obMaster.tData((MST_BYTES_C*8)-1 downto 0) := ibM.tData((MST_BYTES_C*8*idx)+((MST_BYTES_C*8)-1) downto (MST_BYTES_C*8*idx));
160 v.obMaster.tUser((MST_BYTES_C*8)-1 downto 0) := ibM.tUser((MST_BYTES_C*8*idx)+((MST_BYTES_C*8)-1) downto (MST_BYTES_C*8*idx));
161 v.obMaster.tStrb(MST_BYTES_C-1 downto 0) := ibM.tStrb((MST_BYTES_C*idx)+(MST_BYTES_C-1) downto (MST_BYTES_C*idx));
162 v.obMaster.tKeep(MST_BYTES_C-1 downto 0) := ibM.tKeep((MST_BYTES_C*idx)+(MST_BYTES_C-1) downto (MST_BYTES_C*idx));
164 v.obMaster.tId := ibM.tId;
167 -- Determine if we move data 169 if (r.count = (COUNT_C-1)) or ((bytes >= byteCnt) and (ibM.tLast = '1')) then 170 v.count := (others => '0');
174 v.count := r.count + 1;
176 v.obMaster.tLast := '0';
180 -- Drop transfers with no tKeep bits set, except on tLast 187 if SLV_BYTES_C = MST_BYTES_C then 193 -- Outbound data with proper user bits 197 for i in 0 to 15 loop 198 mAxisMaster.tUser((i*MST_USER_C)+(MST_USER_C-1) downto (i*MST_USER_C)) <= r.obMaster.tUser((i*8)+(MST_USER_C-1) downto (i*8));
209 if axisRst = '1' or (SLV_BYTES_C = MST_BYTES_C) then 210 r <= REG_INIT_C after TPD_G;
212 r <= rin after TPD_G;
SLAVE_AXI_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
natural range 1 to 16 TDATA_BYTES_C
out mAxisMasterAxiStreamMasterType
AxiStreamSlaveType :=(tReady => '0') AXI_STREAM_SLAVE_INIT_C
in mAxisSlaveAxiStreamSlaveType
in sAxisMasterAxiStreamMasterType
natural range 0 to 8 TUSER_BITS_C
READY_EN_Gboolean := true
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
MASTER_AXI_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
out sAxisSlaveAxiStreamSlaveType