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

Back to ROD documentation
priority_encoder.vhd
1 ----------------------------------------------------------------------------------
2 -- Company: University of Cambridge
3 -- Engineer: Ed Flaherty
4 --
5 -- Create Date: 20.08.2019 11:26:23
6 -- Design Name:
7 -- Module Name: priority_encoder - 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 use ieee.numeric_std.all;
25 -- Uncomment the following library declaration if using
26 -- arithmetic functions with Signed or Unsigned values
27 --use IEEE.NUMERIC_STD.ALL;
28 
29 -- Uncomment the following library declaration if instantiating
30 -- any Xilinx leaf cells in this code.
31 --library UNISIM;
32 --use UNISIM.VComponents.all;
33 
35  Port (
36  chan_ena : in STD_LOGIC_VECTOR (23 downto 0);
37  clock : in STD_LOGIC;
38  first_chan : out STD_LOGIC_vector(4 downto 0);
39  last_chan : out STD_LOGIC_vector(4 downto 0)
40  );
42 
43 architecture RTL of priority_encoder is
44 
45 begin
46 
47 ---------------------------------------------------------------------
48 -------- calculate the lowest channel that is running---------
49 ---------------------------------------------------------------------
50 --high_low : PROCESS(chan_ena)
51 high_low : PROCESS(clock)
52  VARIABLE low_chan : integer := 0;
53 begin
54  if rising_edge(clock) then
55  for i in 23 downto 0 loop
56  if chan_ena(i) = '1' then
57  low_chan := i;
58  end if;
59  end loop;
60  end if;
61 first_chan <= std_logic_vector(to_unsigned(low_chan,5));
62 end process;
63 
64 ---------------------------------------------------------------------
65 -------- calculate the highest channel that is running---------
66 ---------------------------------------------------------------------
67 --low_high : PROCESS(chan_ena)
68 low_high : PROCESS(clock)
69  VARIABLE high_chan : integer := 23;
70 begin
71  if rising_edge(clock) then
72  for i in 0 to 23 loop
73  if chan_ena(i) = '1' then
74  high_chan := i;
75  end if;
76  end loop;
77  end if;
78 last_chan <= std_logic_vector(to_unsigned(high_chan,5));
79 end process;
80 
81 end RTL;