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

Back to ROD documentation
error_counter.vhd
1 ----------------------------------------------------------------------------------
2 -- Company:
3 -- Engineer:
4 --
5 -- Create Date: 17.04.2019 15:02:22
6 -- Design Name:
7 -- Module Name: error_counter - 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 
31 -- Uncomment the following library declaration if instantiating
32 -- any Xilinx leaf cells in this code.
33 --library UNISIM;
34 --use UNISIM.VComponents.all;
35 
36 
37 entity error_counter is
38  generic(
39  cwidth: positive := 4
40  );
41  Port (
42  clock : in STD_LOGIC;
43  counter_reset : in STD_LOGIC;
44  system_reset : in STD_LOGIC;
45  error : in STD_LOGIC;
46  error_count : out STD_LOGIC_VECTOR(cwidth-1 downto 0)
47 
48 
49  );
50 end error_counter;
51 
52 architecture RTL of error_counter is
53 
54 signal counter : std_logic_vector(cwidth-1 downto 0);
55 signal count_max : std_logic_vector(cwidth-1 downto 0);
56 
57 begin
58 
59 count_max <= (others => '1');
60 
61 process(clock, counter_reset, system_reset)
62  begin
63  if (counter_reset or system_reset) = '1' then -- async (p)reset -> put 'reset in sensitivity list
64  counter <= (others => '0');
65  elsif rising_edge(clock) then
66  if (error = '1') and (counter < count_max) then
67  counter <= (counter + 1);
68  else
69  counter <= counter;
70  end if;
71  end if;
72  end process;
73 
74  error_count(cwidth-1 downto 0) <= counter(cwidth-1 downto 0);
75 
76 
77 end RTL;