From 70dc1b0f4bdf0d87b6058be5bd52322bf38093b0 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Thu, 19 Nov 2020 10:31:56 +0100 Subject: [PATCH] Include I2C to hub, add onewire monitor for old designs --- trb_net16_hub_base.vhd | 30 +++++++++++++++++++- trb_net16_hub_streaming_port_sctrl_accel.vhd | 13 +++++---- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/trb_net16_hub_base.vhd b/trb_net16_hub_base.vhd index f126196..7b3f0c4 100644 --- a/trb_net16_hub_base.vhd +++ b/trb_net16_hub_base.vhd @@ -33,7 +33,7 @@ entity trb_net16_hub_base is USE_VAR_ENDPOINT_ID : integer range c_NO to c_YES := c_NO; HARDWARE_VERSION : std_logic_vector(31 downto 0) := x"12345678"; CLOCK_FREQUENCY : integer range 1 to 200 := 100; - USE_ONEWIRE : integer range 0 to 2 := c_YES; + USE_ONEWIRE : integer range 0 to 3 := c_YES; BROADCAST_SPECIAL_ADDR : std_logic_vector(7 downto 0) := x"FF"; --media interfaces MII_NUMBER : integer range 0 to c_MAX_MII_PER_HUB := 4; @@ -81,6 +81,8 @@ entity trb_net16_hub_base is INT_REPLY_PACKET_NUM_IN : in std_logic_vector (INT_NUMBER*c_NUM_WIDTH downto 0) := (others => '0'); INT_REPLY_READ_OUT : out std_logic_vector (INT_NUMBER downto 0); ONEWIRE : inout std_logic; + I2C_SCL : inout std_logic; + I2C_SDA : inout std_logic; ONEWIRE_MONITOR_IN : in std_logic := '0'; ONEWIRE_MONITOR_OUT : out std_logic; COMMON_STAT_REGS : in std_logic_vector (std_COMSTATREG*32-1 downto 0) := (others => '0'); --Status of common STAT regs @@ -1260,6 +1262,32 @@ THE_BUS_HANDLER : trb_net16_regio_bus_handler ); end generate; + gen_i2c : if USE_ONEWIRE = c_I2C generate + ONEWIRE_MONITOR_OUT <= '0'; + ONEWIRE <= '0'; + i2c_interface : trb_net_i2cwire + generic map( + USE_TEMPERATURE_READOUT => c_YES, + CLK_PERIOD => 10 + ) + port map( + CLK => CLK, + RESET => reset_i, + 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 => TEMP_OUT, + ID_OUT => UNIQUE_ID_OUT, + STAT => open + ); + end generate; + + ------------------------------------------------- -- Include variable Endpoint ID ------------------------------------------------- diff --git a/trb_net16_hub_streaming_port_sctrl_accel.vhd b/trb_net16_hub_streaming_port_sctrl_accel.vhd index c969f05..b93a2cd 100644 --- a/trb_net16_hub_streaming_port_sctrl_accel.vhd +++ b/trb_net16_hub_streaming_port_sctrl_accel.vhd @@ -86,6 +86,7 @@ entity trb_net16_hub_streaming_port_sctrl_record is COMMON_STAT_REGS : out std_logic_vector (std_COMSTATREG*32-1 downto 0); --Status of common STAT regs COMMON_CTRL_REGS : out std_logic_vector (std_COMCTRLREG*32-1 downto 0); --Status of common STAT regs ONEWIRE : inout std_logic; + ONEWIRE_MONITOR_OUT : out std_logic; MY_ADDRESS_OUT : out std_logic_vector(15 downto 0); UNIQUE_ID_OUT : out std_logic_vector (63 downto 0); EXTERNAL_SEND_RESET : in std_logic := '0'; @@ -175,7 +176,8 @@ signal HUB_MED_CTRL_OP : std_logic_vector(mii*16-1 downto 0); signal reset_i_mux_io : std_logic; signal hub_make_network_reset : std_logic := '0'; -signal hub_got_network_reset : std_logic; +signal hub_got_network_reset : std_logic; +signal timer_i : TIMERS; signal timer_ticks : std_logic_vector(1 downto 0); signal hub_ctrl_debug : std_logic_vector(31 downto 0); signal buf_HUB_STAT_GEN : std_logic_vector(31 downto 0); @@ -333,11 +335,11 @@ end generate; REGIO_UNKNOWN_ADDR_IN => hubbus_tx.unknown, REGIO_TIMEOUT_OUT => hubbus_rx.timeout, - TIMER_TICKS_OUT(0) => TIMER.tick_us, - TIMER_TICKS_OUT(1) => TIMER.tick_ms, + TIMER_TICKS_OUT(0) => timer_i.tick_us, + TIMER_TICKS_OUT(1) => timer_i.tick_ms, ONEWIRE => ONEWIRE, ONEWIRE_MONITOR_IN => '0', - ONEWIRE_MONITOR_OUT=> open, + ONEWIRE_MONITOR_OUT=> ONEWIRE_MONITOR_OUT, MY_ADDRESS_OUT => my_address, UNIQUE_ID_OUT => UNIQUE_ID_OUT, COMMON_CTRL_REGS => common_ctrl, @@ -354,7 +356,8 @@ end generate; hub_ctrl_debug(2 downto 0) <= not io_error_in; hub_ctrl_debug(31 downto 3) <= (others => '0'); HUB_STAT_GEN <= buf_HUB_STAT_GEN; - timer_ticks <= TIMER.tick_ms & TIMER.tick_us; + timer_ticks <= timer_i.tick_ms & timer_i.tick_us; + TIMER <= timer_i; --------------------------------------------------------------------- -- I/O Buffers -- 2.43.0