1 ------------------------------------------------------------------------------- 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2013-04-02 5 -- Last update: 2016-04-26 6 ------------------------------------------------------------------------------- 7 -- Description: AXI4 Package File 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_arith.
all;
21 use ieee.std_logic_unsigned.
all;
29 ------------------------------------- 30 -- AXI bus, read master signal record 31 ------------------------------------- 33 -- Read Address channel 52 arid => (others => '0'), 53 arlen => (others => '0'), 59 arqos => (others => '0'), 65 arid => (others => '0'), 66 arlen => (others => '0'), 72 arqos => (others => '0'), 76 ------------------------------------ 77 -- AXI bus, read slave signal record 78 ------------------------------------ 80 -- Read Address channel 83 rdata : slv(1023 downto 0);
-- Read data from slave 86 rid : slv(31 downto 0);
-- Read ID tag 92 rdata => (others => '0'), 95 rid => (others => '0'), 96 rresp => (others => '0'));
99 rdata => (others => '0'), 102 rid => (others => '0'), 103 rresp => (others => '0'));
105 -------------------------------------- 106 -- AXI bus, write master signal record 107 -------------------------------------- 109 -- Write address channel 113 awlen : slv(7 downto 0);
-- Transfer count (burst length) 121 -- Write data channel 126 wstrb : slv(127 downto 0);
-- Write enable strobes, 1 per byte 133 awaddr => (others => '0'), 134 awid => (others => '0'), 135 awlen => (others => '0'), 136 awsize => (others => '0'), 138 awlock => (others => '0'), 139 awprot => (others => '0'), 141 awqos => (others => '0'), 143 wdata => (others => '0'), 146 wid => (others => '0'), 147 wstrb => (others => '0'), 151 awaddr => (others => '0'), 152 awid => (others => '0'), 153 awlen => (others => '0'), 154 awsize => (others => '0'), 156 awlock => (others => '0'), 157 awprot => (others => '0'), 159 awqos => (others => '0'), 161 wdata => (others => '0'), 164 wid => (others => '0'), 165 wstrb => (others => '0'), 168 ------------------------------------- 169 -- AXI bus, write slave signal record 170 ------------------------------------- 172 -- Write address channel 174 -- Write data channel 185 bresp => (others => '0'), 187 bid => (others => '0'));
191 bresp => (others => '0'), 193 bid => (others => '0'));
195 ------------------------ 196 -- AXI bus, fifo control 197 ------------------------ 210 ------------------------ 211 -- AXI bus configuration 212 ------------------------ 221 constant ADDR_WIDTH_C :
in positive
range 12 to 64 :=
32;
222 constant DATA_BYTES_C :
in positive
range 1 to 128 :=
4;
223 constant ID_BITS_C :
in positive
range 1 to 32 :=
12;
236 constant AXI_BURST_C :
in slv(
1 downto 0) := ;
237 constant AXI_CACHE_C :
in slv(
3 downto 0) := )
243 constant AXI_BURST_C :
in slv(
1 downto 0) := ;
244 constant AXI_CACHE_C :
in slv(
3 downto 0) := )
249 -- Calculate number of txns in a burst based on number of bytes and bus configuration 250 -- Returned value is number of txns-1, so can be assigned to AWLEN/ARLEN 253 burstBytes :
range 1 to 4096 :=
4096)
256 -- Calculate number of txns in a burst based upon burst size, total remaining bytes, 257 -- current address and bus configuration. 258 -- Address is used to set a transaction size aligned to 4k boundaries 259 -- Returned value is number of txns-1, so can be assigned to AWLEN/ARLEN 262 burstBytes :
range 1 to 4096 :=
4096;
267 -- Caclulate the byte count for a read request 278 constant ADDR_WIDTH_C :
in positive
range 12 to 64 :=
32;
279 constant DATA_BYTES_C :
in positive
range 1 to 128 :=
4;
280 constant ID_BITS_C :
in positive
range 1 to 32 :=
12;
291 end function axiConfig;
296 constant AXI_BURST_C :
in slv(
1 downto 0) := ;
297 constant AXI_CACHE_C :
in slv(
3 downto 0) := )
303 ret.
awlen := getAxiLen
(AXI_CONFIG_C,
4096);
308 end function axiWriteMasterInit;
312 constant AXI_BURST_C :
in slv(
1 downto 0) := ;
313 constant AXI_CACHE_C :
in slv(
3 downto 0) := )
319 ret.
arlen := getAxiLen
(AXI_CONFIG_C,
4096);
323 end function axiReadMasterInit;
327 if (i
) then return t;
else return e;
end if;
332 burstBytes :
range 1 to 4096 :=
4096)
335 -- burstBytes / data bytes width is number of txns required. 336 -- Subtract by 1 for A*LEN value for even divides. 337 -- Convert to SLV and truncate to size of A*LEN port for this AXI bus 338 -- This limits number of txns approraiately based on size of len port 339 -- Then resize to 8 bits because our records define A*LEN as 8 bits always. 341 end function getAxiLen;
343 -- Calculate number of txns in a burst based upon burst size, total remaining bytes, 344 -- current address and bus configuration. 345 -- Address is used to set a transaction size aligned to 4k boundaries 346 -- Returned value is number of txns-1, so can be assigned to AWLEN/ARLEN 349 burstBytes :
range 1 to 4096 :=
4096;
355 variable maxLen :
slv(7 downto 0);
358 max :=
4096 - conv_integer
(address
(11 downto 0));
359 req := minimum
(conv_integer
(totalBytes
),burstBytes
);
361 return getAxiLen
(axiConfig,minimum
(req,max
));
363 end function getAxiLen;
365 -- Calculate the byte count for a read request 370 constant addrLsb : := bitSize
(AxiConfig.
DATA_BYTES_C-
1);
371 variable tempSlv :
slv(AxiConfig.
LEN_BITS_C+addrLsb
downto 0);
373 tempSlv :=
(others=>'
0'
);
375 tempSlv
(AxiConfig.
LEN_BITS_C+addrLsb
downto addrLsb
) 378 tempSlv := tempSlv - axiRead.
araddr(addrLsb-
1 downto 0);
381 end function getAxiReadBytes;
383 end package body AxiPkg;
AxiWriteSlaveType :=(awready => '0',wready => '0',bresp =>( others => '0'),bvalid => '0',bid =>( others => '0')) AXI_WRITE_SLAVE_INIT_C
AxiReadMasterType :=(arvalid => '0',araddr =>( others => '0'),arid =>( others => '0'),arlen =>( others => '0'),arsize =>( others => '0'),arburst =>( others => '0'),arlock =>( others => '0'),arprot =>( others => '0'),arcache =>( others => '0'),arqos =>( others => '0'),arregion =>( others => '0'),rready => '0') AXI_READ_MASTER_INIT_C
slv( 1023 downto 0) rdata
array(natural range <> ) of AxiReadSlaveType AxiReadSlaveArray
slv( 1023 downto 0) wdata
AxiReadSlaveType :=(arready => '1',rdata =>( others => '0'),rlast => '0',rvalid => '0',rid =>( others => '0'),rresp =>( others => '0')) AXI_READ_SLAVE_FORCE_C
AxiCtrlType :=(pause => '0',overflow => '0') AXI_CTRL_UNUSED_C
AxiWriteMasterType axiWriteMasterInitAXI_CONFIG_C,bready,AXI_BURST_C,AXI_CACHE_C,
positive range 12 to 64 ADDR_WIDTH_C
AxiReadMasterType axiReadMasterInitAXI_CONFIG_C,AXI_BURST_C,AXI_CACHE_C,
AxiConfigType axiConfigADDR_WIDTH_C,DATA_BYTES_C,ID_BITS_C,LEN_BITS_C,
slv( 3 downto 0) awregion
slv( 3 downto 0) arregion
slv getAxiLenaxiConfig,burstBytes,
AxiReadMasterType :=(arvalid => '0',araddr =>( others => '0'),arid =>( others => '0'),arlen =>( others => '0'),arsize =>( others => '0'),arburst =>( others => '0'),arlock =>( others => '0'),arprot =>( others => '0'),arcache =>( others => '0'),arqos =>( others => '0'),arregion =>( others => '0'),rready => '1') AXI_READ_MASTER_FORCE_C
array(natural range <> ) of AxiReadMasterType AxiReadMasterArray
array(natural range <> ) of AxiWriteMasterType AxiWriteMasterArray
positive range 1 to 128 DATA_BYTES_C
AxiCtrlType :=(pause => '1',overflow => '0') AXI_CTRL_INIT_C
slv getAxiReadBytesaxiConfig,axiRead,
array(natural range <> ) of AxiWriteSlaveType AxiWriteSlaveArray
AxiConfigType :=axiConfig(ADDR_WIDTH_C => 32,DATA_BYTES_C => 4,ID_BITS_C => 12,LEN_BITS_C => 4) AXI_CONFIG_INIT_C
positive range 1 to 32 ID_BITS_C
AxiWriteMasterType :=(awvalid => '0',awaddr =>( others => '0'),awid =>( others => '0'),awlen =>( others => '0'),awsize =>( others => '0'),awburst =>( others => '0'),awlock =>( others => '0'),awprot =>( others => '0'),awcache =>( others => '0'),awqos =>( others => '0'),awregion =>( others => '0'),wdata =>( others => '0'),wlast => '0',wvalid => '0',wid =>( others => '0'),wstrb =>( others => '0'),bready => '0') AXI_WRITE_MASTER_INIT_C
array(natural range <> ) of AxiCtrlType AxiCtrlArray
AxiWriteMasterType :=(awvalid => '0',awaddr =>( others => '0'),awid =>( others => '0'),awlen =>( others => '0'),awsize =>( others => '0'),awburst =>( others => '0'),awlock =>( others => '0'),awprot =>( others => '0'),awcache =>( others => '0'),awqos =>( others => '0'),awregion =>( others => '0'),wdata =>( others => '0'),wlast => '0',wvalid => '0',wid =>( others => '0'),wstrb =>( others => '0'),bready => '1') AXI_WRITE_MASTER_FORCE_C
AxiWriteSlaveType :=(awready => '1',wready => '1',bresp =>( others => '0'),bvalid => '0',bid =>( others => '0')) AXI_WRITE_SLAVE_FORCE_C
natural range 0 to 8 LEN_BITS_C
AxiReadSlaveType :=(arready => '0',rdata =>( others => '0'),rlast => '0',rvalid => '0',rid =>( others => '0'),rresp =>( others => '0')) AXI_READ_SLAVE_INIT_C