1 ------------------------------------------------------------------------------- 2 -- File : SaciSlave.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2012-07-12 5 -- Last update: 2016-06-17 6 ------------------------------------------------------------------------------- 7 -- Description: Slave module for SACI interface. 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;
24 --! @ingroup protocols_saci 39 -- Silly reset hack to get saciSelL | rst onto dedicated reset bar 43 -- Detector (Parallel) Interface 56 type StateType is (WAIT_START_S, SHIFT_IN_S);
58 type RegType is record 59 shiftReg : slv(54 downto 0);
65 signal r, rin : RegType;
66 signal saciCmdFall : sl;
68 procedure shiftInLeft (
72 v := v(v'high-1 downto v'low) & i;
73 end procedure shiftInLeft;
77 -- Chip select also functions as async reset 81 -- Clock in serial input on falling edge 85 saciCmdFall <= '0' after TPD_G;
86 elsif (falling_edge(saciClk)) then 95 r.shiftReg <= (others => '0') after TPD_G;
96 r.state <= WAIT_START_S after TPD_G;
99 elsif (rising_edge(saciClk)) then 100 r <= rin after TPD_G;
105 variable v : RegType;
109 shiftInLeft(saciCmdFall, v.shiftReg);
111 -- Main state machine 116 -- Shift data out and look for next start bit 117 if (r.shiftReg(0) = '1') then 118 v.state := SHIFT_IN_S;
122 -- Wait for start bit to shift all the way in then assert exec and readL 123 if (r.shiftReg(52) = '1') then 125 v.readL := r.shiftReg(51);
128 if (r.exec = '1') then 129 v.shiftReg := r.shiftReg;
-- Pause shifting when exec high 135 v.state := WAIT_START_S;
136 if (r.shiftReg(52) = '1') then 137 v.shiftReg(32 downto 1) := (others => '0');
-- write 139 v.shiftReg(32 downto 1) := rdData;
-- read 145 v.shiftReg := (others => '0');
146 v.state := WAIT_START_S;
155 -- Assign outputs from registers 158 saciRsp <= r.shiftReg(54);
-- 52 = start, 51 = r/w at time of exec 159 cmd <= r.shiftReg(51 downto 45);
160 addr <= r.shiftReg(44 downto 33);
161 wrData <= r.shiftReg(32 downto 1);
166 end architecture rtl;
out addrslv( 11 downto 0)
in rdDataslv( 31 downto 0)
out wrDataslv( 31 downto 0)