]> jspc29.x-matter.uni-frankfurt.de Git - TOMcat.git/commitdiff
us ticker added
authorMichael Boehmer <mboehmer@ph.tum.de>
Wed, 20 Jul 2022 06:27:37 +0000 (08:27 +0200)
committerMichael Boehmer <mboehmer@ph.tum.de>
Wed, 20 Jul 2022 06:27:37 +0000 (08:27 +0200)
code/clock_reset_handler.vhd
gbe/tomcat_gbe.vhd

index 43bfcf6cd8d67498c6fa6eed4000e08008ce48b2..26f5cf3a06ee043e87e663473c1cf189383a791a 100644 (file)
@@ -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
index 36605b936be7acdd570ee5457ecf08ea8753d9f1..fe49f2cdc923824c68f98d5855e738f8b22c21fb 100644 (file)
@@ -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
 ---------------------------------------------------------------------------