SURF  1.0
AxiI2cCxpCore.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : AxiI2cCxpCore.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2014-10-21
5 -- Last update: 2016-09-20
6 -------------------------------------------------------------------------------
7 -- Description: AXI-Lite interface to CXP
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 use ieee.numeric_std.all;
21 
22 use work.StdRtlPkg.all;
23 use work.AxiLitePkg.all;
24 use work.I2cPkg.all;
25 use work.AxiI2cCxpPkg.all;
26 
27 library unisim;
28 use unisim.vcomponents.all;
29 
30 --! @see entity
31  --! @ingroup devices_transceivers_cxp
32 entity AxiI2cCxpCore is
33  generic (
34  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
38  STATUS_CNT_WIDTH_G : natural range 1 to 32 := 32;
40  port (
41  -- CXP Ports
44  -- AXI-Lite Register Interface
49  -- Clocks and Resets
50  axiClk : in sl;
51  axiRst : in sl);
52 end AxiI2cCxpCore;
53 
54 architecture mapping of AxiI2cCxpCore is
55 
56  -- Note: PRESCALE_G = (clk_freq / (5 * i2c_freq)) - 1
57  -- FILTER_G = (min_pulse_time / clk_period) + 1
58  constant I2C_SCL_5xFREQ_C : real := 5.0 * I2C_SCL_FREQ_G;
59  constant PRESCALE_C : natural := (getTimeRatio(AXI_CLK_FREQ_G, I2C_SCL_5xFREQ_C)) - 1;
60  constant FILTER_C : natural := natural(AXI_CLK_FREQ_G * I2C_MIN_PULSE_G) + 1;
61 
64 
65  signal i2ci : i2c_in_type;
66  signal i2co : i2c_out_type;
67 
70 
71  signal irqRstL : sl;
72  signal oeL : sl;
73 
74 begin
75 
76  IOBUF_SCL : IOBUF
77  port map (
78  O => i2ci.scl, -- Buffer output
79  IO => cxpInOut.scl, -- Buffer inout port (connect directly to top-level port)
80  I => i2co.scl, -- Buffer input
81  T => i2co.scloen); -- 3-state enable input, high=input, low=output
82 
83  IOBUF_SDA : IOBUF
84  port map (
85  O => i2ci.sda, -- Buffer output
86  IO => cxpInOut.sda, -- Buffer inout port (connect directly to top-level port)
87  I => i2co.sda, -- Buffer input
88  T => i2co.sdaoen); -- 3-state enable input, high=input, low=output
89 
90  IOBUF_RST : IOBUF
91  port map (
92  O => irqRstL, -- Buffer output
93  IO => cxpInOut.irqRstL, -- Buffer inout port (connect directly to top-level port)
94  I => '0', -- Buffer input
95  T => oeL); -- 3-state enable input, high=input, low=output
96 
97  oeL <= not(config.rst);
98 
99  status.irq <= not(irqRstL);
101 
102  AxiI2cCxpReg_Inst : entity work.AxiI2cCxpReg
103  generic map(
104  TPD_G => TPD_G,
107  port map(
108  -- I2C Register Interface
111  -- AXI-Lite Register Interface
116  -- Register Inputs/Outputs
117  status => status,
118  config => config,
119  -- Clock and Reset
120  axiClk => axiClk,
121  axiRst => axiRst);
122 
123  I2cRegMaster_Inst : entity work.I2cRegMaster
124  generic map(
125  TPD_G => TPD_G,
127  FILTER_G => FILTER_C,
129  port map (
130  -- I2C Port Interface
131  i2ci => i2ci,
132  i2co => i2co,
133  -- I2C Register Interface
136  -- Clock and Reset
137  clk => axiClk,
138  srst => axiRst);
139 
140 end mapping;
in regInI2cRegMasterInType
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
real := 5.0* I2C_SCL_FREQ_G I2C_SCL_5xFREQ_C
STATUS_CNT_WIDTH_Gnatural range 1 to 32:= 32
in i2cii2c_in_type
i2c_in_type
Definition: I2cPkg.vhd:34
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
TPD_Gtime := 1 ns
in srstsl := '0'
STATUS_CNT_WIDTH_Gnatural range 1 to 32:= 32
OUTPUT_EN_POLARITY_Ginteger range 0 to 1:= 0
in cxpInAxiI2cCxpInType
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
TPD_Gtime := 1 ns
out i2cRegMasterInI2cRegMasterInType
I2cRegMasterOutType i2cRegMasterOut
out axiWriteSlaveAxiLiteWriteSlaveType
inout cxpInOutAxiI2cCxpInOutType
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
I2cRegMasterOutType
Definition: I2cPkg.vhd:110
out axiReadSlaveAxiLiteReadSlaveType
AxiI2cCxpConfigType config
I2C_SCL_FREQ_Greal := 100.0E+3
i2c_out_type
Definition: I2cPkg.vhd:41
I2C_MIN_PULSE_Greal := 100.0E-9
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
_library_ ieeeieee
AxiI2cCxpStatusType status
in axiWriteMasterAxiLiteWriteMasterType
I2cRegMasterInType
Definition: I2cPkg.vhd:79
I2cRegMasterInType i2cRegMasterIn
in i2cRegMasterOutI2cRegMasterOutType
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
natural := natural( AXI_CLK_FREQ_G* I2C_MIN_PULSE_G)+ 1 FILTER_C
in axiReadMasterAxiLiteReadMasterType
in axiWriteMasterAxiLiteWriteMasterType
in axiReadMasterAxiLiteReadMasterType
in statusAxiI2cCxpStatusType
TPD_Gtime := 1 ns
out axiReadSlaveAxiLiteReadSlaveType
out i2coi2c_out_type
AXI_CLK_FREQ_Greal := 200.0E+6
FILTER_Ginteger range 2 to 512:= 8
out regOutI2cRegMasterOutType
natural :=( getTimeRatio( AXI_CLK_FREQ_G, I2C_SCL_5xFREQ_C))- 1 PRESCALE_C
out configAxiI2cCxpConfigType
PRESCALE_Ginteger range 0 to 655535:= 62
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
out axiWriteSlaveAxiLiteWriteSlaveType