From 1da0204d2dfbc43857d8426eab5151c6bebda3f8 Mon Sep 17 00:00:00 2001 From: Michael Boehmer Date: Sun, 29 May 2022 23:27:20 +0200 Subject: [PATCH] I2C UID works now with TMP117 --- special/trb_net_i2cwire.vhd | 1 - trb_net16_endpoint_hades_full_gbe.vhd | 44 +++++++++++++++---- ...t16_endpoint_hades_full_handler_record.vhd | 2 +- trb_net_components.vhd | 22 ++++++++++ trb_net_std.vhd | 13 +++--- 5 files changed, 64 insertions(+), 18 deletions(-) diff --git a/special/trb_net_i2cwire.vhd b/special/trb_net_i2cwire.vhd index 264de3f..4445656 100644 --- a/special/trb_net_i2cwire.vhd +++ b/special/trb_net_i2cwire.vhd @@ -298,7 +298,6 @@ begin if( RESET = '1') then temp_int <= (others => '0'); elsif( (CURRENT_STATE = RD_TMP) and (valid_int = '1') ) then --- elsif( (temp_we = '1') ) then temp_int <= i2c_dr_int(15 downto 4); end if; end if; diff --git a/trb_net16_endpoint_hades_full_gbe.vhd b/trb_net16_endpoint_hades_full_gbe.vhd index ac38bc5..4fa68d7 100644 --- a/trb_net16_endpoint_hades_full_gbe.vhd +++ b/trb_net16_endpoint_hades_full_gbe.vhd @@ -45,7 +45,7 @@ entity trb_net16_endpoint_hades_full_gbe is REGIO_COMPILE_TIME : std_logic_vector(31 downto 0) := x"00000000"; REGIO_INCLUDED_FEATURES : std_logic_vector(63 downto 0) := (others => '0'); REGIO_HARDWARE_VERSION : std_logic_vector(31 downto 0) := x"12345678"; - REGIO_USE_1WIRE_INTERFACE : integer := c_YES; --c_YES,c_NO,c_MONITOR,c_I2C,c_XDNA + REGIO_USE_1WIRE_INTERFACE : integer := c_YES; --c_YES,c_NO,c_MONITOR,c_I2C,c_XDNA,C_I2C_TC REGIO_USE_VAR_ENDPOINT_ID : integer range c_NO to c_YES := c_NO; CLOCK_FREQUENCY : integer range 1 to 200 := 100; USE_GBE : integer range 0 to 1 := c_YES @@ -892,11 +892,11 @@ begin STAT_ADDR_DEBUG => STAT_ADDR_DEBUG ); gen_no1wire : if REGIO_USE_1WIRE_INTERFACE = c_NO generate - ONEWIRE_DATA <= REGIO_IDRAM_DATA_IN; - ONEWIRE_ADDR <= REGIO_IDRAM_ADDR_IN; - ONEWIRE_WRITE <= REGIO_IDRAM_WR_IN; - REGIO_IDRAM_DATA_OUT <= buf_IDRAM_DATA_OUT; - REGIO_ONEWIRE_INOUT <= '0'; + ONEWIRE_DATA <= REGIO_IDRAM_DATA_IN; + ONEWIRE_ADDR <= REGIO_IDRAM_ADDR_IN; + ONEWIRE_WRITE <= REGIO_IDRAM_WR_IN; + REGIO_IDRAM_DATA_OUT <= buf_IDRAM_DATA_OUT; + REGIO_ONEWIRE_INOUT <= '0'; REGIO_ONEWIRE_MONITOR_OUT <= '0'; end generate; @@ -921,9 +921,8 @@ begin gen_1wire : if REGIO_USE_1WIRE_INTERFACE = c_YES generate - REGIO_IDRAM_DATA_OUT <= (others => '0'); - STAT_ONEWIRE <= buf_stat_onewire; + STAT_ONEWIRE <= buf_stat_onewire; onewire_interface : trb_net_onewire generic map( @@ -946,6 +945,7 @@ begin ); end generate; gen_1wire_monitor : if REGIO_USE_1WIRE_INTERFACE = c_MONITOR generate + REGIO_IDRAM_DATA_OUT <= (others => '0'); REGIO_ONEWIRE_MONITOR_OUT <= '0'; @@ -966,8 +966,10 @@ begin ); end generate; gen_i2c : if REGIO_USE_1WIRE_INTERFACE = c_I2C generate + REGIO_ONEWIRE_MONITOR_OUT <= '0'; REGIO_ONEWIRE_INOUT <= '0'; + i2c_interface : trb_net_i2cwire generic map( USE_TEMPERATURE_READOUT => c_YES, @@ -989,6 +991,32 @@ begin STAT => buf_stat_onewire ); end generate; + gen_i2c_tomcat : if REGIO_USE_1WIRE_INTERFACE = c_I2C_TC generate + + REGIO_ONEWIRE_MONITOR_OUT <= '0'; + REGIO_ONEWIRE_INOUT <= '0'; + + i2c_interface2 : trb_net_i2cwire2 + generic map( + USE_TEMPERATURE_READOUT => c_YES, + CLK_PERIOD => 10 + ) + port map( + CLK => CLK, + RESET => RESET, + READOUT_ENABLE_IN => '1', + --connection to I2C interface + SCL_INOUT => I2C_SCL, + SDA_INOUT => I2C_SDA, + --connection to id ram, according to memory map in TrbNetRegIO + DATA_OUT => ONEWIRE_DATA, + ADDR_OUT => ONEWIRE_ADDR, + WRITE_OUT => ONEWIRE_WRITE, + TEMP_OUT => temperature, + ID_OUT => unique_id_out_i, + STAT => buf_stat_onewire + ); + end generate; end generate; end generate; gentermbuf: if USE_CHANNEL(i) = c_NO generate diff --git a/trb_net16_endpoint_hades_full_handler_record.vhd b/trb_net16_endpoint_hades_full_handler_record.vhd index a7411ad..ccc18c6 100644 --- a/trb_net16_endpoint_hades_full_handler_record.vhd +++ b/trb_net16_endpoint_hades_full_handler_record.vhd @@ -20,7 +20,7 @@ entity trb_net16_endpoint_hades_full_handler_record is BROADCAST_BITMASK : std_logic_vector(7 downto 0) := x"FF"; REGIO_INIT_ENDPOINT_ID : std_logic_vector(15 downto 0) := x"0001"; REGIO_USE_VAR_ENDPOINT_ID : integer range c_NO to c_YES := c_NO; - REGIO_USE_1WIRE_INTERFACE : integer range 0 to 4 := c_YES; + REGIO_USE_1WIRE_INTERFACE : integer range 0 to 5 := c_YES; TIMING_TRIGGER_RAW : integer range 0 to 1 := c_YES; --Configure data handler DATA_INTERFACE_NUMBER : integer range 1 to 16 := 1; diff --git a/trb_net_components.vhd b/trb_net_components.vhd index dc988f2..c96329e 100644 --- a/trb_net_components.vhd +++ b/trb_net_components.vhd @@ -1601,6 +1601,28 @@ end component; end component; + component trb_net_i2cwire2 is + generic( + USE_TEMPERATURE_READOUT : integer range 0 to 1 := 1; + CLK_PERIOD : integer := 10 --clk period in ns + ); + port( + CLK : in std_logic; + RESET : in std_logic; + READOUT_ENABLE_IN : in std_logic := '1'; + --connection to I2C interface + SCL_INOUT : inout std_logic; + SDA_INOUT : inout std_logic; + --connection to id ram, according to memory map in TrbNetRegIO + DATA_OUT : out std_logic_vector(15 downto 0); + ADDR_OUT : out std_logic_vector(2 downto 0); + WRITE_OUT : out std_logic; + TEMP_OUT : out std_logic_vector(11 downto 0); + ID_OUT : out std_logic_vector(63 downto 0); + STAT : out std_logic_vector(31 downto 0) + ); + end component; + component trb_net16_ibuf is generic ( diff --git a/trb_net_std.vhd b/trb_net_std.vhd index 2b616d9..c442f05 100644 --- a/trb_net_std.vhd +++ b/trb_net_std.vhd @@ -18,16 +18,12 @@ package trb_net_std is --Trigger Info constant TRIG_SUPPRESS_BIT : integer range 0 to 15 := 0; - - -- some basic definitions for the whole network ----------------------------------------------- - constant c_DATA_WIDTH : integer := 16; constant c_NUM_WIDTH : integer := 3; constant c_MUX_WIDTH : integer := 3; --!!! - --assigning channel names constant c_TRG_LVL1_CHANNEL : integer := 0; constant c_DATA_CHANNEL : integer := 1; @@ -60,11 +56,12 @@ package trb_net_std is constant c_FIFO_INFTY : integer := 7; --simple logic - constant c_YES : integer := 1; - constant c_NO : integer := 0; + constant c_YES : integer := 1; + constant c_NO : integer := 0; constant c_MONITOR : integer := 2; - constant c_I2C : integer := 3; - constant c_XDNA : integer := 4; + constant c_I2C : integer := 3; + constant c_XDNA : integer := 4; + constant c_I2C_TC : integer := 5; --media interface steering constant c_IS_UNUSED : integer := 0; -- 2.43.0