1 ------------------------------------------------------------------------------- 2 -- File : Ad9249Config.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2013-09-23 5 -- Last update: 2016-12-12 6 ------------------------------------------------------------------------------- 7 -- Description: AD9249 Configuration/Status Module 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;
24 use UNISIM.VCOMPONENTS.
all;
30 --! @ingroup devices_AnalogDevices_ad9249 55 end entity Ad9249Config;
60 signal rdData : slv(23 downto 0);
66 signal coreSDout : sl;
69 signal shiftCount : slv(bitSize(24)-1 downto 0);
73 constant PWDN_ADDR_BIT_C : := 11 + CHIP_SEL_WIDTH_C;
74 constant PWDN_ADDR_C : slv(PWDN_ADDR_BIT_C downto 0) := toSlv(2**PWDN_ADDR_BIT_C, PWDN_ADDR_BIT_C+1);
76 type StateType is (WAIT_AXI_TXN_S, WAIT_CYCLE_S, WAIT_SPI_TXN_DONE_S);
79 type RegType is record 84 chipSel : slv(CHIP_SEL_WIDTH_C-1 downto 0);
85 wrData : slv(23 downto 0);
90 constant REG_INIT_C : RegType := ( 91 state => WAIT_AXI_TXN_S, 94 chipSel => (others => '0'), 95 wrData => (others => '0'), 97 pdwn => (others => '0'));
99 signal r : RegType := REG_INIT_C;
100 signal rin : RegType;
105 variable v : RegType;
114 when WAIT_AXI_TXN_S => 116 -- Chip powerdown signal is local registers 118 axiSlaveRegister(axilEp, PWDN_ADDR_C + i*4, 0, v.pdwn(i));
121 -- Any other address is forwarded to the chip via SPI 123 v.wrData(23) := '0';
-- Write bit 124 v.wrData(22 downto 21) := "00";
-- Number of bytes (1) 125 v.wrData(20 downto 17) := "0000";
-- Unused address bits 130 v.state := WAIT_CYCLE_S;
134 v.wrData(23) := '1';
-- read bit 135 v.wrData(22 downto 21) := "00";
-- Number of bytes (1) 136 v.wrData(20 downto 17) := "0000";
-- Unused address bits 138 v.wrData(7 downto 0) := (others => '1');
-- Make bus float to Z so slave can 139 -- drive during data segment 142 v.state := WAIT_CYCLE_S;
148 -- Wait 1 cycle for rdEn to drop 150 v.state := WAIT_SPI_TXN_DONE_S;
152 when WAIT_SPI_TXN_DONE_S => 155 v.state := WAIT_AXI_TXN_S;
156 if (r.wrData(23) = '0') then 190 r <= rin after TPD_G;
199 CPHA_G => '0',
-- Sample on leading edge 200 CPOL_G => '0',
-- Sample on rising edge 217 -- Bus lines float to Z when not being driven to '0'. 218 -- Lines should all have resistor pullups off chip 219 -- SCLK_OBUFT : OBUFT 226 -- Allow input when doing a read and in the data segment of the shift operation 227 sdioDir <= '1' when shiftCount >= 16 and r.wrData(23)='1' else '0';
235 -- CSB_OBUFT : for i in NUM_CHIPS_G*2-1 downto 0 generate 236 -- CSB0_OBUFT : OBUFT 244 end architecture rtl;
AXIL_ERR_RESP_Gslv( 1 downto 0) := AXI_RESP_DECERR_C
out spiCsLslv( NUM_CHIPS_G- 1 downto 0)
out adcPdwnslv( NUM_CHIPS_G- 1 downto 0)
in wrDataslv( DATA_SIZE_G- 1 downto 0)
out rdDataslv( DATA_SIZE_G- 1 downto 0)
AXIL_CLK_PERIOD_Greal := 8.0e-9
SPI_SCLK_PERIOD_Greal := 1.0E-6
AxiLiteReadSlaveType axiReadSlave
AxiLiteStatusType axiStatus
in chipSelslv( log2(NUM_CHIPS_G )- 1 downto 0)
out axilWriteSlaveAxiLiteWriteSlaveType
AxiLiteWriteSlaveType axiWriteSlave
slv( 1 downto 0) := "11" AXI_RESP_DECERR_C
SCLK_PERIOD_Greal := 1.0e-6
NUM_CHIPS_Gpositive range 1 to 8:= 4
AxiLiteReadSlaveType :=(arready => '0',rdata =>( others => '0'),rresp =>( others => '0'),rvalid => '0') AXI_LITE_READ_SLAVE_INIT_C
out shiftCountslv( bitSize(DATA_SIZE_G )- 1 downto 0)
out adcCsbslv( NUM_CHIPS_G* 2- 1 downto 0)
in axilWriteMasterAxiLiteWriteMasterType
out axilReadSlaveAxiLiteReadSlaveType
in axilReadMasterAxiLiteReadMasterType
CLK_PERIOD_Greal := 8.0E-9
AxiLiteWriteSlaveType :=(awready => '0',wready => '0',bresp =>( others => '0'),bvalid => '0') AXI_LITE_WRITE_SLAVE_INIT_C