ROD firmware  1.0.5
ATLAS l1-calo - ROD_eFEX and ROD_jFEX firmware for the L1Calo ROD board

Back to ROD documentation
tob_rx_timer.vhd
1 ----------------------------------------------------------------------------------
2 -- Company:
3 -- Engineer:
4 --
5 -- Create Date: 22.04.2022 15:09:38
6 -- Design Name:
7 -- Module Name: tob_rx_timer - RTL
8 -- Project Name:
9 -- Target Devices:
10 -- Tool Versions:
11 -- Description:
12 --
13 -- Dependencies:
14 --
15 -- Revision:
16 -- Revision 0.01 - File Created
17 -- Additional Comments:
18 --
19 ----------------------------------------------------------------------------------
20 
21 
22 library IEEE;
23 use IEEE.STD_LOGIC_1164.ALL;
24 
25 -- Uncomment the following library declaration if using
26 -- arithmetic functions with Signed or Unsigned values
27 -- use IEEE.NUMERIC_STD.ALL;
28 use IEEE.STD_LOGIC_UNSIGNED.ALL;
29 
30 -- Uncomment the following library declaration if instantiating
31 -- any Xilinx leaf cells in this code.
32 --library UNISIM;
33 --use UNISIM.VComponents.all;
34 
35 entity tob_rx_timer is
36  Port (
37  pp_clock : in STD_LOGIC;
38  L1A : in STD_LOGIC;
39  s_tvalid : in STD_LOGIC;
40  reset : in STD_LOGIC;
41  tob_rx_time : out std_logic_vector(15 downto 0);
42  tob_rx_time_max : out std_logic_vector(15 downto 0)
43  );
44 
45 
46 
47 end tob_rx_timer;
48 
49 architecture RTL of tob_rx_timer is
50 
51 signal time_count : std_logic_vector(15 downto 0):= x"0000";
52 signal stop : std_logic;
53 signal tob_rx_time_i : std_logic_vector(15 downto 0):= x"0000";
54 signal tob_rx_time_max_i : std_logic_vector(15 downto 0) := x"0000";
55 
56 begin
57 
58 
59 process(pp_clock, L1A)
60  begin
61  if (L1A = '1') or (reset = '1') then -- async (p)reset -> put 'reset in sensitivity list
62  time_count <= (others => '0');
63  stop <= '0';
64  elsif rising_edge(pp_clock) then
65  if s_tvalid = '0' and (stop = '0') then
66  time_count <= (time_count + 1);
67  elsif s_tvalid = '1' then
68  stop <= '1';
69  time_count <= time_count;
70  else
71  stop <= stop;
72  time_count <= time_count;
73  end if;
74  end if;
75  end process;
76 
77 process(pp_clock)
78  begin
79  if rising_edge(pp_clock) then
80  if reset = '1' then
81  tob_rx_time_i <= (others => '0');
82  elsif stop = '1' then
83  tob_rx_time_i <= time_count;
84  else
85  tob_rx_time_i <= tob_rx_time_i;
86  end if;
87  end if;
88 end process;
89 
90 process(pp_clock)
91  begin
92  if rising_edge(pp_clock) then
93  if (reset = '1') then
94  tob_rx_time_max_i <= (others => '0');
95  elsif stop = '1' then
96  if tob_rx_time_i > tob_rx_time_max_i then
97  tob_rx_time_max_i <= tob_rx_time_i;
98  else
99  tob_rx_time_max_i <= tob_rx_time_max_i;
100  end if;
101  else
102  tob_rx_time_max_i <= tob_rx_time_max_i;
103  end if;
104  end if;
105  end process;
106 
107 
108 
109 tob_rx_time <= tob_rx_time_i;
110 tob_rx_time_max <= tob_rx_time_max_i;
111 
112 end RTL;