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

Back to ROD documentation
edge_error_counter.vhd
1 ----------------------------------------------------------------------------------
2 -- Company:
3 -- Engineer:
4 --
5 -- Create Date: 17.04.2019 15:02:22
6 -- Design Name: edge_error_counter
7 -- Module Name: edge_error_counter - RTL
8 -- Project Name:
9 -- Target Devices:
10 -- Tool Versions:
11 -- Description: This error counter only increments on the leading edge of an error signal input. It can be used in cases
12 -- where the error signal lasts for many clock cycles on a single error
13 --
14 -- Dependencies:
15 --
16 -- Revision:
17 -- Revision 0.01 - File Created
18 -- Additional Comments:
19 --
20 ----------------------------------------------------------------------------------
21 
22 
23 library IEEE;
24 use IEEE.STD_LOGIC_1164.ALL;
25 
26 -- Uncomment the following library declaration if using
27 -- arithmetic functions with Signed or Unsigned values
28 use IEEE.NUMERIC_STD.ALL;
29 use IEEE.STD_LOGIC_UNSIGNED.ALL;
30 
31 
32 -- Uncomment the following library declaration if instantiating
33 -- any Xilinx leaf cells in this code.
34 --library UNISIM;
35 --use UNISIM.VComponents.all;
36 
37 
39  generic(
40  cwidth: positive := 4
41  );
42  Port (
43  clock : in STD_LOGIC;
44  counter_reset : in STD_LOGIC;
45  system_reset : in STD_LOGIC;
46  error : in STD_LOGIC;
47  error_count : out STD_LOGIC_VECTOR(cwidth-1 downto 0)
48 
49 
50  );
52 
53 architecture RTL of edge_error_counter is
54 
55 signal counter : std_logic_vector(cwidth-1 downto 0);
56 signal count_max : std_logic_vector(cwidth-1 downto 0);
57 signal error_pulse : std_logic;
58 signal error_samp : std_logic;
59 
60 begin
61 
62 count_max <= (others => '1');
63 
64 
65 --sample the incoming error signal
66 process(clock, counter_reset, system_reset)
67  begin
68  if (counter_reset or system_reset) = '1' then -- async (p)reset -> put 'reset in sensitivity list
69  error_samp <= '0';
70  elsif rising_edge(clock) then
71  error_samp <= error;
72  end if;
73  end process;
74 
75 
76 process(clock, counter_reset, system_reset)
77  begin
78  if (counter_reset or system_reset) = '1' then -- async (p)reset -> put 'reset in sensitivity list
79  counter <= (others => '0');
80  elsif rising_edge(clock) then
81  if (error = '1') and (error_samp = '0') and (counter < count_max) then
82  counter <= (counter + 1);
83  else
84  counter <= counter;
85  end if;
86  end if;
87  end process;
88 
89 
90 
91  error_count(cwidth-1 downto 0) <= counter(cwidth-1 downto 0);
92 
93 
94 end RTL;