1 ------------------------------------------------------------------------------- 2 -- File : I2cRegMasterMux.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2013-09-21 5 -- Last update: 2013-11-20 6 ------------------------------------------------------------------------------- 7 -- Description: Multiplexes access to a single I2cRegMaster module 8 -- Attached devices may also lock others out in order to execute multiple 9 -- transactions in a row. To do this, lockReq must be set high for the first 10 -- transaction and set low for the last transaction. 11 ------------------------------------------------------------------------------- 12 -- This file is part of 'SLAC Firmware Standard Library'. 13 -- It is subject to the license terms in the LICENSE.txt file found in the 14 -- top-level directory of this distribution and at: 15 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 16 -- No part of 'SLAC Firmware Standard Library', including this file, 17 -- may be copied, modified, propagated, or distributed except according to 18 -- the terms contained in the LICENSE.txt file. 19 ------------------------------------------------------------------------------- 22 use ieee.std_logic_1164.
all;
23 use ieee.std_logic_arith.
all;
24 use ieee.std_logic_unsigned.
all;
30 --! @ingroup protocols_i2c 40 lockReq :
in slv(NUM_INPUTS_C-1
downto 0) := (
others => '0');
41 regIn :
in I2cRegMasterInArray(
0 to NUM_INPUTS_C-1);
42 regOut :
out I2cRegMasterOutArray(
0 to NUM_INPUTS_C-1);
46 end entity I2cRegMasterMux;
50 type RegType is record 53 regOut : I2cRegMasterOutArray(
0 to NUM_INPUTS_C-1);
57 constant REG_INIT_C : RegType := ( 59 sel => (others => '0'), 60 regOut => (
others => I2C_REG_MASTER_OUT_INIT_C),
63 signal r : RegType := REG_INIT_C;
74 selInt := conv_integer(r.sel);
76 if (r.locked = '0') then 77 v.sel := r.sel + 1;
-- Increment only if no channel has a lock 85 v.locked := lockReq(selInt);
-- Grant lock if requested 105 r <= REG_INIT_C after TPD_G;
106 elsif (rising_edge(clk)) then 107 r <= rin after TPD_G;
111 end architecture rtl;
I2cRegMasterOutType :=(regAck => '0',regFail => '0',regFailCode =>( others => '0'),regRdData =>( others => '0')) I2C_REG_MASTER_OUT_INIT_C
NUM_INPUTS_Cnatural range 2 to 8:= 2
out masterInI2cRegMasterInType
in lockReqslv( NUM_INPUTS_C- 1 downto 0) :=( others => '0')
out regOutI2cRegMasterOutArray( 0 to NUM_INPUTS_C- 1)
in masterOutI2cRegMasterOutType
I2cRegMasterInType :=(i2cAddr =>( others => '0'),tenbit => '0',regAddr =>( others => '0'),regWrData =>( others => '0'),regOp => '0',regAddrSkip => '0',regAddrSize =>( others => '0'),regDataSize =>( others => '0'),regReq => '0',busReq => '0',endianness => '0',repeatStart => '0') I2C_REG_MASTER_IN_INIT_C
in regInI2cRegMasterInArray( 0 to NUM_INPUTS_C- 1)