1 ------------------------------------------------------------------------------- 2 -- File : SaciPrepRdout.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 07/21/2016 5 -- Last update: 07/21/2016 6 ------------------------------------------------------------------------------- 7 -- Description: The AXI lite master to issue SACI prepare for readout command 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;
27 --! @ingroup protocols_saci 40 -- Prepare for readout req/ack 44 -- Optional AXI lite slave port for status readout 50 -- AXI lite master port for command issue 61 type StateType is (S_IDLE_C, S_IS_ASIC_C, S_WRITE_C, S_WRITE_AXI_C, S_READ_C, S_READ_AXI_C);
63 type RegType is record 66 timer : slv(23 downto 0);
68 rdTimeout : slv(31 downto 0);
69 rdFail : slv(31 downto 0);
70 wrTimeout : slv(31 downto 0);
71 wrFail : slv(31 downto 0);
79 constant REG_INIT_C : RegType := ( 80 asicMask => (others=>'0'), 82 timer => (others => '1'), 84 rdTimeout => (others=>'0'), 85 rdFail => (others=>'0'), 86 wrTimeout => (others=>'0'), 87 wrFail => (others=>'0'), 94 signal r : RegType := REG_INIT_C;
97 function asicBaseAddr(asic : )
return slv is 99 return toSlv(asic*(2**22), 32);
105 variable v : RegType;
106 variable regCon : AxiLiteEndPointType;
114 axiSlaveRegisterR(regCon, x"00", 0, r.rdFail);
115 axiSlaveRegisterR(regCon, x"04", 0, r.rdTimeout);
116 axiSlaveRegisterR(regCon, x"08", 0, r.wrFail);
117 axiSlaveRegisterR(regCon, x"0C", 0, r.wrTimeout);
118 axiSlaveRegisterR(regCon, x"10", 0, r.asicMask);
122 -- State machine for SACI mediation 123 -- SACI command is issued via the AXI lite master bus 131 -- If we see a multi-pixel write request, handle it 136 -- Read the ASIC mask 140 v.timer := (others => '1');
142 -- Start AXI transaction 145 v.state := S_READ_AXI_C;
149 v.timer := r.timer - 1;
151 -- Clear control signals on ack 160 v.rdFail := r.rdFail + 1;
164 -- End transaction on timeout 168 v.rdTimeout := r.rdTimeout + 1;
171 -- Transaction is done 176 v.state := S_IS_ASIC_C;
180 -- Check if ASIC is enabled 185 elsif (r.asicMask(r.asicCnt) = '1') then 186 v.state := S_WRITE_C;
188 v.asicCnt := r.asicCnt + 1;
191 -- Prepare Write Transactions 193 -- Prepare for readout: CMD = 0, ADDR = 0, DATA = 0 198 v.timer := (others => '1');
203 v.state := S_WRITE_AXI_C;
205 -- Write Transaction, AXI 206 when S_WRITE_AXI_C => 207 v.timer := r.timer - 1;
209 -- Clear control signals on ack 220 v.wrFail := r.wrFail + 1;
224 -- End transaction on timeout 229 v.wrTimeout := r.wrTimeout + 1;
232 -- Transaction is done 240 v.asicCnt := r.asicCnt + 1;
241 v.state := S_IS_ASIC_C;
266 r <= rin after TPD_G;
in mAxilWriteSlaveAxiLiteWriteSlaveType
AXIL_ERR_RESP_Gslv( 1 downto 0) := AXI_RESP_DECERR_C
out mAxilReadMasterAxiLiteReadMasterType
MASK_REG_ADDR_Gslv( 31 downto 0) := x"00000034"
in sAxilReadMasterAxiLiteReadMasterType
out sAxilWriteSlaveAxiLiteWriteSlaveType
in sAxilWriteMasterAxiLiteWriteMasterType
slv( 1 downto 0) := "11" AXI_RESP_DECERR_C
SACI_BASE_ADDR_Gslv( 31 downto 0) := x"02000000"
out sAxilReadSlaveAxiLiteReadSlaveType
AxiLiteReadSlaveType :=(arready => '0',rdata =>( others => '0'),rresp =>( others => '0'),rvalid => '0') AXI_LITE_READ_SLAVE_INIT_C
AxiLiteReadMasterType :=(araddr =>( others => '0'),arprot =>( others => '0'),arvalid => '0',rready => '1') AXI_LITE_READ_MASTER_INIT_C
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
slv( 1 downto 0) := "00" AXI_RESP_OK_C
SACI_NUM_CHIPS_Gnatural range 1 to 4:= 4
in mAxilReadSlaveAxiLiteReadSlaveType
out mAxilWriteMasterAxiLiteWriteMasterType
AxiLiteWriteSlaveType :=(awready => '0',wready => '0',bresp =>( others => '0'),bvalid => '0') AXI_LITE_WRITE_SLAVE_INIT_C