1 ------------------------------------------------------------------------------- 2 -- File : AxiDac7654Spi.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2013-05-22 5 -- Last update: 2016-09-20 6 ------------------------------------------------------------------------------- 7 -- Description: SPI Interface 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_unsigned.
all;
21 use ieee.std_logic_arith.
all;
27 --! @ingroup devices_Ti_dac7654 52 constant MAX_CNT_C : := getTimeRatio(166.4E-9
, AXI_CLK_PERIOD_C);
64 signal state : StateType := RST_S;
72 signal ch : slv(1 downto 0) := (others => '0');
73 signal pntr : range 0 to 23 := 0;
74 signal cnt : range 0 to MAX_CNT_C := 0;
88 if rising_edge(axiClk) then 97 pntr <= 0 after TPD_G;
98 ch <= (others => '0') after TPD_G;
100 state <= RST_S after TPD_G;
103 ---------------------------------------------------------------------- 105 cnt <= cnt + 1 after TPD_G;
106 if cnt = getTimeRatio(19.2E-9
, AXI_CLK_PERIOD_C) then -- 19.2ns wait 108 cnt <= 0 after TPD_G;
109 state <= IDLE_S after TPD_G;
111 ---------------------------------------------------------------------- 115 state <= SCK_LOW_S after TPD_G;
117 ---------------------------------------------------------------------- 129 cnt <= cnt + 1 after TPD_G;
130 if cnt = getTimeRatio(32.0E-9
, AXI_CLK_PERIOD_C) then -- 32ns wait 131 cnt <= 0 after TPD_G;
132 state <= SCK_HIGH_S after TPD_G;
134 ---------------------------------------------------------------------- 137 cnt <= cnt + 1 after TPD_G;
138 if cnt = getTimeRatio(32.0E-9
, AXI_CLK_PERIOD_C) then -- 32ns wait 139 cnt <= 0 after TPD_G;
140 pntr <= pntr + 1 after TPD_G;
143 pntr <= 0 after TPD_G;
144 state <= TLD2_WAIT_S after TPD_G;
146 state <= SCK_LOW_S after TPD_G;
149 ---------------------------------------------------------------------- 150 when TLD2_WAIT_S => --required settling time between rising edge of SCK and falling of LOAD 151 cnt <= cnt + 1 after TPD_G;
152 if cnt = getTimeRatio(12.8E-9
, AXI_CLK_PERIOD_C) then -- 12.8ns wait 153 cnt <= 0 after TPD_G;
154 state <= LOAD_S after TPD_G;
156 ---------------------------------------------------------------------- 159 cnt <= cnt + 1 after TPD_G;
160 if cnt = getTimeRatio(51.2E-9
, AXI_CLK_PERIOD_C) then -- 51.2ns wait 162 cnt <= 0 after TPD_G;
163 state <= LDAC_S after TPD_G;
165 ---------------------------------------------------------------------- 168 cnt <= cnt + 1 after TPD_G;
169 if cnt = getTimeRatio(166.4E-9
, AXI_CLK_PERIOD_C) then -- 166.4 ns wait 171 cnt <= 0 after TPD_G;
172 ch <= ch + 1 after TPD_G;
174 ch <= (others => '0') after TPD_G;
176 state <= HANDSHAKE_S after TPD_G;
179 state <= SCK_LOW_S after TPD_G;
182 ---------------------------------------------------------------------- 186 state <= IDLE_S after TPD_G;
188 ----------------------------------------------------------------------
AXI_CLK_FREQ_Greal := 125.0E+6
in spiInAxiDac7654SpiInType
out spiOutAxiDac7654SpiOutType