1 ------------------------------------------------------------------------------ 2 -- This file is a part of the GRLIB VHDL IP LIBRARY 3 -- Copyright (C) 2003 - 2008, Gaisler Research 4 -- Copyright (C) 2008 - 2012, Aeroflex Gaisler 6 -- This program is free software; you can redistribute it and/or modify 7 -- it under the terms of the GNU General Public License as published by 8 -- the Free Software Foundation; either version 2 of the License, or 9 -- (at your option) any later version. 11 -- This program is distributed in the hope that it will be useful, 12 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 13 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 -- GNU General Public License for more details. 16 -- You should have received a copy of the GNU General Public License 17 -- along with this program; if not, write to the Free Software 18 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 ----------------------------------------------------------------------------- 22 -- Author: Jiri Gaisler - Gaisler Research 23 -- Description: I2C interface package 25 --! @ingroup protocols_i2c 26 ------------------------------------------------------------------------------ 29 use ieee.std_logic_1164.
all;
51 -------------------------------------------------------------------------------------------------- 57 enable : sl; -- Enable the master
62 op : sl;
-- 1 for write, 0 for read 63 busReq : sl;
-- 1 for bus request, 0 for read/write 64 addr : slv(9 downto 0);
-- i2c device address 67 wrData : slv(7 downto 0);
-- Data sent during write txn 76 rdData : slv(7 downto 0);
-- Data received during read txn 78 -------------------------------------------------------------------------------------------------- 82 regAddr : slv(
31 downto 0);
83 regWrData : slv(
31 downto 0);
86 regAddrSize : slv(
1 downto 0);
87 regDataSize : slv(
1 downto 0);
97 regAddr => (
others => '0'),
98 regWrData => (
others => '0'),
99 regOp => '0', --
1 for write,
0 for read
101 regAddrSize => (
others => '0'),
102 regDataSize => (
others => '0'),
113 regFailCode : slv(
7 downto 0);
114 regRdData : slv(
31 downto 0);
120 regFailCode => (
others => '0'),
121 regRdData => (
others => '0'));
125 -------------------------------------------------------------------------------------------------- 136 txData => (others => '0'), 151 rxData => (others => '0'), 156 ------------------------------------------------------------------------------------------------- 157 -- AXI Bridge Generic Type, stick here for now 158 ------------------------------------------------------------------------------------------------- 179 0 => (MakeI2cAxiLiteDevType("0000000", 8, 8, '0')), 180 1 => (MakeI2cAxiLiteDevType("0000010", 16, 16, '0')), 181 2 => (MakeI2cAxiLiteDevType("0000100", 32, 8, '0')), 182 3 => (MakeI2cAxiLiteDevType("0001000", 32, 32, '0')));
186 -------------------------------------------------------------------------------------------------- 192 rst :
in ;
-- active high reset 193 nReset :
in ;
-- asynchornous active low reset 194 -- (not used in GRLIB) 195 ena :
in ;
-- core enable signal 197 clk_cnt :
in (
15 downto 0);
-- 4x SCL 205 din :
in (
7 downto 0);
213 dout :
out (
7 downto 0);
216 scl_i :
in ;
-- i2c clock line input 217 scl_o :
out ;
-- i2c clock line output 218 scl_oen :
out ;
-- i2c clock line output enable, active low 219 sda_i :
in ;
-- i2c data line input 220 sda_o :
out ;
-- i2c data line output 221 sda_oen :
out -- i2c data line output enable, active low 248 report "i2cAddress param must have length of 7 or 10" severity error;
256 end function MakeI2cAxiLiteDevType;
261 for i
in devMap'
range loop 267 end function maxAddrSize;
269 end package body I2cPkg;
array(natural range <> ) of I2cRegMasterInType I2cRegMasterInArray
in filtstd_logic_vector(( filter- 1)* dynfilt downto 0)
I2cRegMasterOutType :=(regAck => '0',regFail => '0',regFailCode =>( others => '0'),regRdData =>( others => '0')) I2C_REG_MASTER_OUT_INIT_C
in clk_cntstd_logic_vector( 15 downto 0)
slv( 15 downto 0) prescale
I2cSlaveOutType :=(rxActive => '0',rxValid => '0',rxData =>( others => '0'),txActive => '0',txAck => '0',nack => '0') I2C_SLAVE_OUT_INIT_C
slv( 7 downto 0) := X"01" I2C_INVALID_ADDR_ERROR_C
array(natural range <> ) of I2cAxiLiteDevType I2cAxiLiteDevArray
array(natural range <> ) of I2cRegMasterOutType I2cRegMasterOutArray
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
slv( 7 downto 0) := X"02" I2C_WRITE_ACK_ERROR_C
slv( 9 downto 0) i2cAddress
I2cAxiLiteDevType MakeI2cAxiLiteDevTypei2cAddress,dataSize,addrSize,endianness,repeatStart,
I2cSlaveInType :=(enable => '0',txValid => '0',txData =>( others => '0'),rxAck => '0') I2C_SLAVE_IN_INIT_C
array(natural range <> ) of i2c_out_type i2c_out_array
array(natural range <> ) of i2c_in_type i2c_in_array
natural maxAddrSizedevMap,
I2cAxiLiteDevArray( 0 to 3) :=( 0=>( MakeI2cAxiLiteDevType( "0000000", 8, 8, '0')), 1=>( MakeI2cAxiLiteDevType( "0000010", 16, 16, '0')), 2=>( MakeI2cAxiLiteDevType( "0000100", 32, 8, '0')), 3=>( MakeI2cAxiLiteDevType( "0001000", 32, 32, '0'))) I2C_AXIL_DEV_ARRAY_DEFAULT_C
out doutstd_logic_vector( 7 downto 0)
in dinstd_logic_vector( 7 downto 0)
slv( 7 downto 0) := X"03" I2C_ARBITRATION_LOST_ERROR_C