SURF  1.0
AxiI2cMasterCore.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : AxiI2cMasterCore.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2014-04-22
5 -- Last update: 2017-05-09
6 -------------------------------------------------------------------------------
7 -- Description: AXI-Lite interface to generic I2C master controller
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 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 
21 use work.StdRtlPkg.all;
22 use work.AxiLitePkg.all;
23 use work.I2cPkg.all;
24 use work.AxiI2cMasterPkg.all;
25 
26 library unisim;
27 use unisim.vcomponents.all;
28 
29 --! @see entity
30  --! @ingroup protocols_i2c
32  generic (
33  TPD_G : time := 1 ns;
35  AXI_CLK_FREQ_G : real := 200.0E+6; -- units of Hz
36  I2C_SCL_FREQ_G : real := 100.0E+3; -- units of Hz
37  I2C_MIN_PULSE_G : real := 100.0E-9; -- units of seconds
39  port (
40  -- DAC Ports
42  -- AXI-Lite Register Interface
47  -- Clocks and Resets
48  axiClk : in sl;
49  axiRst : in sl);
50 end AxiI2cMasterCore;
51 
52 architecture mapping of AxiI2cMasterCore is
53 
54  -- Note: PRESCALE_G = (clk_freq / (5 * i2c_freq)) - 1
55  -- FILTER_G = (min_pulse_time / clk_period) + 1
56  constant I2C_SCL_5xFREQ_C : real := 5.0 * I2C_SCL_FREQ_G;
57  constant PRESCALE_C : natural := (getTimeRatio(AXI_CLK_FREQ_G, I2C_SCL_5xFREQ_C)) - 1;
58  constant FILTER_C : natural := natural(AXI_CLK_FREQ_G * I2C_MIN_PULSE_G) + 1;
59 
62 
63  signal i2ci : i2c_in_type;
64  signal i2co : i2c_out_type;
65 
66 begin
67 
68  IOBUF_SCL : IOBUF
69  port map (
70  O => i2ci.scl, -- Buffer output
71  IO => i2cInOut.scl, -- Buffer inout port (connect directly to top-level port)
72  I => i2co.scl, -- Buffer input
73  T => i2co.scloen); -- 3-state enable input, high=input, low=output
74 
75  IOBUF_SDA : IOBUF
76  port map (
77  O => i2ci.sda, -- Buffer output
78  IO => i2cInOut.sda, -- Buffer inout port (connect directly to top-level port)
79  I => i2co.sda, -- Buffer input
80  T => i2co.sdaoen); -- 3-state enable input, high=input, low=output
81 
82  I2cRegMasterAxiBridge_Inst : entity work.I2cRegMasterAxiBridge
83  generic map (
84  TPD_G => TPD_G,
86  EN_USER_REG_G => false,
88  port map (
89  -- I2C Interface
92  -- AXI-Lite Register Interface
97  -- Clock and Reset
98  axiClk => axiClk,
99  axiRst => axiRst);
100 
101  I2cRegMaster_Inst : entity work.I2cRegMaster
102  generic map(
103  TPD_G => TPD_G,
105  FILTER_G => FILTER_C,
107  port map (
108  -- I2C Port Interface
109  i2ci => i2ci,
110  i2co => i2co,
111  -- I2C Register Interface
114  -- Clock and Reset
115  clk => axiClk,
116  srst => axiRst);
117 
118 end mapping;
in regInI2cRegMasterInType
in axiWriteMasterAxiLiteWriteMasterType
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
I2C_SCL_FREQ_Greal := 100.0E+3
out axiWriteSlaveAxiLiteWriteSlaveType
natural := natural( AXI_CLK_FREQ_G* I2C_MIN_PULSE_G)+ 1 FILTER_C
in i2cii2c_in_type
i2c_in_type
Definition: I2cPkg.vhd:34
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
real := 5.0* I2C_SCL_FREQ_G I2C_SCL_5xFREQ_C
in axiReadMasterAxiLiteReadMasterType
in srstsl := '0'
out axiWriteSlaveAxiLiteWriteSlaveType
array(natural range <> ) of I2cAxiLiteDevType I2cAxiLiteDevArray
Definition: I2cPkg.vhd:176
OUTPUT_EN_POLARITY_Ginteger range 0 to 1:= 0
DEVICE_MAP_GI2cAxiLiteDevArray := I2C_AXIL_DEV_ARRAY_DEFAULT_C
in axiWriteMasterAxiLiteWriteMasterType
I2cRegMasterInType i2cRegMasterIn
TPD_Gtime := 1 ns
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
out axiReadSlaveAxiLiteReadSlaveType
AXI_CLK_FREQ_Greal := 200.0E+6
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
I2cRegMasterOutType
Definition: I2cPkg.vhd:110
in axiReadMasterAxiLiteReadMasterType
i2c_out_type
Definition: I2cPkg.vhd:41
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
_library_ unisimunisim
_library_ ieeeieee
I2cRegMasterInType
Definition: I2cPkg.vhd:79
DEVICE_MAP_GI2cAxiLiteDevArray := I2C_AXIL_DEV_ARRAY_DEFAULT_C
in i2cRegMasterOutI2cRegMasterOutType
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
out axiReadSlaveAxiLiteReadSlaveType
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
Definition: I2cPkg.vhd:178
out i2cRegMasterInI2cRegMasterInType
natural :=( getTimeRatio( AXI_CLK_FREQ_G, I2C_SCL_5xFREQ_C))- 1 PRESCALE_C
out i2coi2c_out_type
I2C_MIN_PULSE_Greal := 100.0E-9
FILTER_Ginteger range 2 to 512:= 8
out regOutI2cRegMasterOutType
inout i2cInOutAxiI2cMasterInOutType
PRESCALE_Ginteger range 0 to 655535:= 62
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
I2cRegMasterOutType i2cRegMasterOut