From: Michael Boehmer Date: Wed, 20 Jul 2022 06:27:37 +0000 (+0200) Subject: us ticker added X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=c4ec7f7a56533b2ac63f94a78c6f3f0a66e1d8c3;p=TOMcat.git us ticker added --- diff --git a/code/clock_reset_handler.vhd b/code/clock_reset_handler.vhd index 43bfcf6..26f5cf3 100644 --- a/code/clock_reset_handler.vhd +++ b/code/clock_reset_handler.vhd @@ -21,6 +21,7 @@ entity clock_reset_handler is CLEAR_N_OUT : out std_logic; -- TICK_MS_OUT : out std_logic; + TICK_US_OUT : out std_logic; -- LED_RED_OUT : out std_logic; LED_GREEN_OUT : out std_logic @@ -33,9 +34,13 @@ signal timer : unsigned(15 downto 0) := (others => '0'); signal clear_n_i : std_logic; signal reset_i : std_logic; -signal counter : unsigned(16 downto 0); -signal counter_done_x : std_logic; -signal counter_done : std_logic; +signal ms_counter : unsigned(16 downto 0); +signal ms_counter_done_x : std_logic; +signal ms_counter_done : std_logic; + +signal us_counter : unsigned(6 downto 0); +signal us_counter_done_x : std_logic; +signal us_counter_done : std_logic; attribute syn_keep : boolean; attribute syn_preserve : boolean; @@ -49,22 +54,42 @@ begin CLK_OUT <= CLK_IN; --------------------------------------------------------------------------- +-- 1ms tick counter --------------------------------------------------------------------------- -THE_MS_COUNTER_PROC: process( CLK_IN ) -begin - if( rising_edge(CLK_IN) ) then - counter_done <= counter_done_x; - if( counter_done = '1' ) then - counter <= b"1_1110_1000_0100_0110"; - else - counter <= counter - 1; + THE_MS_COUNTER_PROC: process( CLK_IN ) + begin + if( rising_edge(CLK_IN) ) then + ms_counter_done <= ms_counter_done_x; + if( ms_counter_done = '1' ) then + ms_counter <= b"1_1110_1000_0100_0110"; + else + ms_counter <= ms_counter - 1; + end if; end if; - end if; -end process THE_MS_COUNTER_PROC; + end process THE_MS_COUNTER_PROC; + + ms_counter_done_x <= '1' when (ms_counter = b"0_0000_0000_0000_0000") else '0'; + + TICK_MS_OUT <= ms_counter_done; -counter_done_x <= '1' when (counter = b"0_0000_0000_0000_0000") else '0'; +--------------------------------------------------------------------------- +-- 1us tick counter +--------------------------------------------------------------------------- + THE_US_COUNTER_PROC: process( CLK_IN ) + begin + if( rising_edge(CLK_IN) ) then + us_counter_done <= us_counter_done_x; + if( us_counter_done = '1' ) then + us_counter <= b"111_1011"; + else + us_counter <= us_counter - 1; + end if; + end if; + end process THE_US_COUNTER_PROC; + + us_counter_done_x <= '1' when (us_counter = b"000_0000") else '0'; -TICK_MS_OUT <= counter_done; + TICK_US_OUT <= us_counter_done; --------------------------------------------------------------------------- -- Startup timer, generates inital reset diff --git a/gbe/tomcat_gbe.vhd b/gbe/tomcat_gbe.vhd index 36605b9..fe49f2c 100644 --- a/gbe/tomcat_gbe.vhd +++ b/gbe/tomcat_gbe.vhd @@ -193,7 +193,8 @@ begin CLEAR_OUT => clear_i, CLEAR_N_OUT => clear_n_i, -- - TICK_MS_OUT => tick_int, + TICK_MS_OUT => open, --tick_int, + TICK_US_OUT => tick_int, -- LED_RED_OUT => open, LED_GREEN_OUT => open @@ -438,25 +439,9 @@ begin debug(31) <= debug(80); debug(32) <= debug(81); debug(33) <= clk_sys; - ---DEBUG_OUT(3 downto 0) <= state; ---DEBUG_OUT(4) <= ff_empty; ---DEBUG_OUT(5) <= ff_full; ---DEBUG_OUT(6) <= ff_wr_en; ---DEBUG_OUT(7) <= ff_rd_en; ---DEBUG_OUT(15 downto 8) <= ff_q(7 downto 0); ---DEBUG_OUT(16) <= ff_q(8); ---DEBUG_OUT(17) <= local_eop; --------------------------------------------------------------------------- --------------------------------------------------------------------------- ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- - --------------------------------------------------------------------------- -- SCTRL endpoint for GbE standalone ---------------------------------------------------------------------------