1 ------------------------------------------------------------------------------- 2 -- File : AxiLtc2270Reg.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2014-04-21 5 -- Last update: 2015-01-13 6 ------------------------------------------------------------------------------- 7 -- Description: AXI-Lite Register Access 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;
28 use unisim.vcomponents.
all;
31 --! @ingroup devices_Linear_lct2270 47 -- AXI-Lite Register Interface (axiClk domain) 52 -- Register Inputs/Outputs (axiClk domain) 54 config :
out AxiLtc2270ConfigType;
71 type RegType is record 77 serReg : slv(15 downto 0);
78 pntr : slv(3 downto 0);
79 cnt : range 0 to HALF_SCLK_C;
80 timer : range 0 to TIMEOUT_1S_C;
82 armed : slv(1 downto 0);
84 regOut : AxiLtc2270ConfigType;
90 constant REG_INIT_C : RegType := ( 100 (others => (others => '0')), 102 (others => (others => (others => '0'))), 108 signal r : RegType := REG_INIT_C;
109 signal rin : RegType;
120 adcCs <= '0' when (r.debug = '0') else r.csL;
-- '0' = Clock Duty Cycle Stabilizer Off 121 adcSck <= '1' when (r.debug = '0') else r.sck;
-- '1' = Double Data Rate LVDS Output Mode 122 adcSdi <= '0' when (r.debug = '0') else r.sdi;
-- '0' = Normal Operation 126 O =>
sdo,
-- Buffer output 127 IO =>
adcSdo,
-- Buffer inout port (connect directly to top-level port) 128 I => '0',
-- Buffer input 129 T => r.debug
);
-- 3-state enable input, high=input, low=output 131 ------------------------------- 132 -- Configuration Register 133 ------------------------------- 136 variable v : RegType;
138 variable axiWriteResp : slv(1 downto 0);
139 variable axiReadResp : slv(1 downto 0);
141 -- Latch the current value 144 -- Determine the transaction type 147 -- Reset strobe signals 152 -- Increment the counter 153 v.timer := r.timer + 1;
154 -- Check the timer for 1 second timeout 155 if r.timer = TIMEOUT_1S_C then 159 v.armed := (others => '1');
162 -- Process for collecting 8 consecutive samples after each 1 second timeout 164 -- Check the armed and valid flag 165 if (r.armed(i) = '1') and (regIn.adcValid(i) = '1') then 167 v.adcSmpl(i, conv_integer(r.smplCnt(i))) := regIn.adcData(i);
168 -- Increment the counter 169 v.smplCnt(i) := r.smplCnt(i) + 1;
170 -- Check the counter value 171 if r.smplCnt(i) = 7 then 173 v.smplCnt(i) := (others => '0');
181 -- Check for an out of 32 bit aligned address 184 v.serReg(15) := '0';
-- Write 185 v.serReg(14 downto 13) := "00";
188 v.state := SCK_LOW_S;
190 -- Decode address and perform write 269 -- Check for an out of 32 bit aligned address 271 -- Reset the register 274 v.serReg(15) := '1';
-- Read 275 v.serReg(14 downto 13) := "00";
277 v.serReg(7 downto 0) := (others => '0');
278 v.state := SCK_LOW_S;
280 -- Decode address and assign read data 362 ---------------------------------------------------------------------- 366 ---------------------------------------------------------------------- 370 v.sdi := r.serReg(conv_integer(15-r.pntr));
372 if r.cnt = HALF_SCLK_C then 378 v.state := SCK_HIGH_S;
380 ---------------------------------------------------------------------- 384 if r.cnt = HALF_SCLK_C then 386 v.pntr := r.pntr + 1;
388 v.pntr := (others => '0');
389 -- Check if we need to perform a read or write reponse 390 if r.serReg(15) = '0' then 399 v.state := SCK_LOW_S;
402 ---------------------------------------------------------------------- 414 -- Register the variable for next clock cycle 428 if rising_edge(axiClk) then 429 r <= rin after TPD_G;
433 ------------------------------- 434 -- Synchronization: Outputs 435 ------------------------------- 436 config.dmode <= regOut.dmode;
439 for ch in 0 to 1 generate 441 for i in 0 to 7 generate 448 din => regOut.delayIn.data
(ch, i
),
450 dout => config.delayIn.data
(ch, i
));
451 end generate GEN_DAT_CONFIG;
452 end generate GEN_CH_CONFIG;
454 SyncOut_delayIn_load :
entity work.
RstSync 461 syncRst => config.delayIn.load
);
463 SyncOut_delayIn_rst :
entity work.
RstSync 470 syncRst => config.delayIn.rst
);
472 ------------------------------- 473 -- Synchronization: Inputs 474 ------------------------------- 475 regIn.adcData <= status.adcData;
476 regIn.adcValid <= status.adcValid;
483 dataIn => status.delayOut.rdy,
484 dataOut => regIn.delayOut.rdy
);
487 for ch in 0 to 1 generate 489 for i in 0 to 7 generate 496 din => status.delayOut.data
(ch, i
),
498 dout => regIn.delayOut.data
(ch, i
));
499 end generate GEN_DAT_STATUS;
500 end generate GEN_CH_STATUS;
DELAY_INIT_GSlv5VectorArray ( 0 to 1, 0 to 7):=( others =>( others =>( others => '0')))
array(natural range <> ) of slv( 2 downto 0) Slv3Array
AxiLtc2270ConfigType :=(( others => '0'), AXI_LTC2270_DELAY_IN_INIT_C) AXI_LTC2270_CONFIG_INIT_C
in dinslv( DATA_WIDTH_G- 1 downto 0)
out axiReadSlaveAxiLiteReadSlaveType
Slv16Array( 0 to 1) adcData
AxiLtc2270DelayInType delayIn
out doutslv( DATA_WIDTH_G- 1 downto 0)
AxiLiteStatusType axiStatus
Slv5VectorArray ( 0 to 1, 0 to 7) data
out axiWriteSlaveAxiLiteWriteSlaveType
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
RELEASE_DELAY_Ginteger range 3 to positive'high:= 3
slv( 1 downto 0) adcValid
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
AxiLtc2270StatusType :=(( others => '0'),( others => x"0000"), AXI_LTC2270_DELAY_OUT_INIT_C) AXI_LTC2270_STATUS_INIT_C
AxiLtc2270DelayOutType delayOut
in axiReadMasterAxiLiteReadMasterType
AxiLiteReadSlaveType :=(arready => '0',rdata =>( others => '0'),rresp =>( others => '0'),rvalid => '0') AXI_LITE_READ_SLAVE_INIT_C
in statusAxiLtc2270StatusType
in axiWriteMasterAxiLiteWriteMasterType
AXI_CLK_FREQ_Greal := 200.0E+6
slv( 1 downto 0) := "00" AXI_RESP_OK_C
DMODE_INIT_Gslv( 1 downto 0) := "00"
STATUS_CNT_WIDTH_Gnatural range 1 to 32:= 32
array(natural range <> ,natural range <> ) of slv( 4 downto 0) Slv5VectorArray
AxiLiteWriteSlaveType :=(awready => '0',wready => '0',bresp =>( others => '0'),bvalid => '0') AXI_LITE_WRITE_SLAVE_INIT_C
array(natural range <> ,natural range <> ) of slv( 15 downto 0) Slv16VectorArray
DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 16