SURF  1.0
AxiI2cSfpCore.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : AxiI2cSfpCore.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2014-04-18
5 -- Last update: 2016-09-20
6 -------------------------------------------------------------------------------
7 -- Description: AXI-Lite interface to SFP
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.AxiI2cSfpPkg.all;
26 
27 library unisim;
28 use unisim.vcomponents.all;
29 
30 --! @see entity
31  --! @ingroup devices_transceivers_sfp
32 entity AxiI2cSfpCore 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;
39  ALLOW_TX_DISABLE_G : boolean := false;
41  port (
42  -- SFP Ports
46  -- AXI-Lite Register Interface
51  -- Clocks and Resets
52  axiClk : in sl;
53  axiRst : in sl);
54 end AxiI2cSfpCore;
55 
56 architecture mapping of AxiI2cSfpCore is
57 
58  -- Note: PRESCALE_G = (clk_freq / (5 * i2c_freq)) - 1
59  -- FILTER_G = (min_pulse_time / clk_period) + 1
60  constant I2C_SCL_5xFREQ_C : real := 5.0 * I2C_SCL_FREQ_G;
61  constant PRESCALE_C : natural := (getTimeRatio(AXI_CLK_FREQ_G, I2C_SCL_5xFREQ_C)) - 1;
62  constant FILTER_C : natural := natural(AXI_CLK_FREQ_G * I2C_MIN_PULSE_G) + 1;
63 
66 
67  signal i2ci : i2c_in_type;
68  signal i2co : i2c_out_type;
69 
72 
73 begin
74 
75  IOBUF_SCL : IOBUF
76  port map (
77  O => i2ci.scl, -- Buffer output
78  IO => sfpInOut.scl, -- Buffer inout port (connect directly to top-level port)
79  I => i2co.scl, -- Buffer input
80  T => i2co.scloen); -- 3-state enable input, high=input, low=output
81 
82  IOBUF_SDA : IOBUF
83  port map (
84  O => i2ci.sda, -- Buffer output
85  IO => sfpInOut.sda, -- Buffer inout port (connect directly to top-level port)
86  I => i2co.sda, -- Buffer input
87  T => i2co.sdaoen); -- 3-state enable input, high=input, low=output
88 
89  IOBUF_RATE0 : IOBUF
90  port map (
91  O => open, -- Buffer output
92  IO => sfpInOut.rateSel(0), -- Buffer inout port (connect directly to top-level port)
93  I => config.rateSel(0), -- Buffer input
94  T => '0'); -- 3-state enable input, high=input, low=output
95 
96  IOBUF_RATE1 : IOBUF -- Reserved for future use
97  port map (
98  O => open, -- Buffer output
99  IO => sfpInOut.rateSel(1), -- Buffer inout port (connect directly to top-level port)
100  I => '0', -- Buffer input
101  T => '1'); -- 3-state enable input, high=input, low=output
102 
104 
108 
109  AxiI2cSfpReg_Inst : entity work.AxiI2cSfpReg
110  generic map(
111  TPD_G => TPD_G,
115  port map(
116  -- I2C Register Interface
119  -- AXI-Lite Register Interface
124  -- Register Inputs/Outputs
125  status => status,
126  config => config,
127  -- Clock and Reset
128  axiClk => axiClk,
129  axiRst => axiRst);
130 
131  I2cRegMaster_Inst : entity work.I2cRegMaster
132  generic map(
133  TPD_G => TPD_G,
135  FILTER_G => FILTER_C,
137  port map (
138  -- I2C Port Interface
139  i2ci => i2ci,
140  i2co => i2co,
141  -- I2C Register Interface
144  -- Clock and Reset
145  clk => axiClk,
146  srst => axiRst);
147 
148 end mapping;
in regInI2cRegMasterInType
I2C_SCL_FREQ_Greal := 100.0E+3
out sfpOutAxiI2cSfpOutType
out configAxiI2cSfpConfigType
out axiReadSlaveAxiLiteReadSlaveType
in axiWriteMasterAxiLiteWriteMasterType
AxiI2cSfpConfigType config
inout sfpInOutAxiI2cSfpInOutType
TPD_Gtime := 1 ns
in axiReadMasterAxiLiteReadMasterType
in i2cii2c_in_type
natural := natural( AXI_CLK_FREQ_G* I2C_MIN_PULSE_G)+ 1 FILTER_C
i2c_in_type
Definition: I2cPkg.vhd:34
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
_library_ ieeeieee
in axiWriteMasterAxiLiteWriteMasterType
in srstsl := '0'
in axiReadMasterAxiLiteReadMasterType
in sfpInAxiI2cSfpInType
I2cRegMasterInType i2cRegMasterIn
OUTPUT_EN_POLARITY_Ginteger range 0 to 1:= 0
in i2cRegMasterOutI2cRegMasterOutType
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
TPD_Gtime := 1 ns
real := 5.0* I2C_SCL_FREQ_G I2C_SCL_5xFREQ_C
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
I2cRegMasterOutType
Definition: I2cPkg.vhd:110
STATUS_CNT_WIDTH_Gnatural range 1 to 32:= 32
TPD_Gtime := 1 ns
natural :=( getTimeRatio( AXI_CLK_FREQ_G, I2C_SCL_5xFREQ_C))- 1 PRESCALE_C
i2c_out_type
Definition: I2cPkg.vhd:41
AXI_CLK_FREQ_Greal := 200.0E+6
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
I2cRegMasterInType
Definition: I2cPkg.vhd:79
out axiWriteSlaveAxiLiteWriteSlaveType
out i2cRegMasterInI2cRegMasterInType
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
I2cRegMasterOutType i2cRegMasterOut
STATUS_CNT_WIDTH_Gnatural range 1 to 32:= 32
out i2coi2c_out_type
out axiReadSlaveAxiLiteReadSlaveType
out axiWriteSlaveAxiLiteWriteSlaveType
FILTER_Ginteger range 2 to 512:= 8
out regOutI2cRegMasterOutType
ALLOW_TX_DISABLE_Gboolean := false
AxiI2cSfpStatusType status
ALLOW_TX_DISABLE_Gboolean := false
in statusAxiI2cSfpStatusType
PRESCALE_Ginteger range 0 to 655535:= 62
I2C_MIN_PULSE_Greal := 100.0E-9
std_logic_vector slv
Definition: StdRtlPkg.vhd:29