From 086707368d68a275e7bd8dbb0551dab740c3a04f Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Wed, 14 Feb 2024 17:31:46 +0100 Subject: [PATCH] add an uptime timer to ecp5 media interfaces --- media_interfaces/med_ecp5_sfp_sync.vhd | 14 +++++++++++++- media_interfaces/med_ecp5_sfp_sync_2.vhd | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/media_interfaces/med_ecp5_sfp_sync.vhd b/media_interfaces/med_ecp5_sfp_sync.vhd index 19ccba7..8c271dd 100644 --- a/media_interfaces/med_ecp5_sfp_sync.vhd +++ b/media_interfaces/med_ecp5_sfp_sync.vhd @@ -110,6 +110,7 @@ attribute nopad : string; attribute nopad of hdinp, hdinn, hdoutp, hdoutn : signal is "true"; signal stat_med : std_logic_vector(31 downto 0); +signal timer : unsigned(31 downto 0); begin @@ -350,7 +351,18 @@ stat_med(6) <= rx_los_low; stat_med(7) <= rx_ready; stat_med(8) <= tx_ready; stat_med(9) <= lsm_status; -stat_med(31 downto 10) <= (others => '0'); +stat_med(15 downto 10) <= (others => '0'); +stat_med(31 downto 16) <= timer(26 downto 11); + + + PROC_TIMER : process begin + wait until rising_edge(SYSCLK); + if stat_fsm_reset_i(8) = '0' or stat_fsm_reset_i(9) = '0' then + timer <= (others => '0'); + else + timer <= timer + 1; + end if; + end process; end architecture; diff --git a/media_interfaces/med_ecp5_sfp_sync_2.vhd b/media_interfaces/med_ecp5_sfp_sync_2.vhd index 08e4038..57c09d7 100644 --- a/media_interfaces/med_ecp5_sfp_sync_2.vhd +++ b/media_interfaces/med_ecp5_sfp_sync_2.vhd @@ -110,6 +110,9 @@ attribute nopad of hdinp, hdinn, hdoutp, hdoutn : signal is "true"; signal stat_med : std_logic_vector(63 downto 0); +type timer_t is array(0 to 1) of unsigned(31 downto 0); +signal timer : timer_t; + begin reset_n <= not RESET; @@ -388,7 +391,19 @@ THE_MED_CONTROL : entity work.med_sync_control stat_med(i*32+7) <= rx_ready(i); stat_med(i*32+8) <= tx_ready(i); stat_med(i*32+9) <= lsm_status(i); - stat_med(i*32+31 downto i*32+10) <= (others => '0'); + stat_med(i*32+15 downto i*32+10) <= (others => '0'); + stat_med(i*32+31 downto i*32+16) <= timer(i)(26 downto 11); + + + PROC_TIMER : process begin + wait until rising_edge(SYSCLK); + if stat_fsm_reset_i(i*32+8) = '1' or stat_fsm_reset_i(i*32+9) = '1' then + timer(i) <= (others => '0'); + else + timer(i) <= timer(i) + 1; + end if; + end process; + end generate; -- 2.43.0