eFEX firmware  1.7.3
ATLAS l1-calo - electron and tau feature extraction firmware for eFEX boards

Back to eFEX documentation
AlgoInputStage.vhd
Go to the documentation of this file.
1 
9 
10 library IEEE;
11 use IEEE.STD_LOGIC_1164.all;
12 use IEEE.NUMERIC_STD.all;
13 
14 use work.DataTypes.all;
15 use work.AlgoDataTypes.all;
16 
18 entity AlgoInputStage is
19  generic(ENCODING_MODE : integer);
20  port (CLK200 : in std_logic;
21  IN_Load : in std_logic;
22  IN_Data : in AlgoInput;
23  IN_Position : in AlgoRegister;
24  IN_BCN : in std_logic_vector(11 downto 0);
25 
26  IN_threshold_l0 : in AlgoWords(INPUT_COLUMNS-1 downto 0);
27  IN_threshold_l1 : in AlgoWords(INPUT_COLUMNS-1 downto 0);
28  IN_threshold_l2 : in AlgoWords(INPUT_COLUMNS-1 downto 0);
29  IN_threshold_l3 : in AlgoWords(INPUT_COLUMNS-1 downto 0);
30  IN_threshold_had_lar : in AlgoWords(INPUT_COLUMNS-1 downto 0);
31  IN_threshold_had_tile : in AlgoWords(INPUT_COLUMNS-1 downto 0);
32 
33  OUT_Load : out std_logic;
34  OUT_BCN_200 : out std_logic_vector(11 downto 0);
35  OUT_Data : out TriggerTowerMatrix
36  );
37 end AlgoInputStage;
38 
40 architecture Behavioral of AlgoInputStage is
41  signal InData : AlgoInput;
42  signal OutData : TriggerTowerMatrix;
43  signal Load_i, Load_d : std_logic;
44  signal BCN_i, BCN_d, BCN_200 : std_logic_vector(11 downto 0);
45 
46  signal had_position : std_logic_vector(2 downto 0);
47  signal is_tile : std_logic_vector(INPUT_ROWS*INPUT_COLUMNS-1 downto 0);
48 
49 
50  signal hadronic_threshold : array_std_logic_vector(INPUT_ROWS*INPUT_COLUMNS-1 downto 0)(INPUT_DATA_WIDTH-1 downto 0);
51 
52 -- ####### Mark signals ########
53 
54  attribute keep : string;
55  attribute max_fanout : integer;
56  attribute keep of OUT_Load : signal is "true";
57  attribute max_fanout of OUT_Load : signal is 50;
58 
59 -- #######################################
60 
61 begin
62  Load_i <= IN_Load;
63  BCN_i <= IN_BCN;
64  had_position <= IN_Position(HADRONIC_POSITION_BIT_END downto HADRONIC_POSITION_BIT_START);
65 
66  --InData <= IN_DATA when IN_BCN(0) < IN_align_frame_BCN_min or IN_BCN(0) > IN_align_frame_BCN_max else ZERO_ALGO_INPUT;
67  InData <= IN_DATA; --temporary fix
68 
69  column_for : for i in 0 to INPUT_COLUMNS - 1 generate
70  row_for : for j in 0 to INPUT_ROWS - 1 generate
71 
72  layer0_for : for k in 0 to LAYER0-1 generate
73  EnergyConverter0 : entity work.EnergyConverter
74  generic map (ENCODING_MODE => ENCODING_MODE)
75  port map (
76  clk => CLK200,
77  is_hadronic => '0',
78  IN_threshold => IN_threshold_l0(i),
79  IN_Load => Load_i,
80  IN_Data => InData(i)(j).Layer0(k),
81  OUT_Data => OutData(i)(j).Layer0(k));
82  end generate layer0_for;
83 
84  layer1_for : for k in 0 to LAYER1-1 generate
85  EnergyConverter1 : entity work.EnergyConverter
86  generic map (ENCODING_MODE => ENCODING_MODE)
87  port map (
88  clk => CLK200,
89  is_hadronic => '0',
90  IN_threshold => IN_threshold_l1(i),
91  IN_Load => Load_i,
92  IN_Data => InData(i)(j).Layer1(k),
93  OUT_Data => OutData(i)(j).Layer1(k));
94  end generate layer1_for;
95 
96  layer2_for : for k in 0 to LAYER2-1 generate
97  EnergyConverter2 : entity work.EnergyConverter
98  generic map (ENCODING_MODE => ENCODING_MODE)
99  port map (
100  clk => CLK200,
101  is_hadronic => '0',
102  IN_threshold => IN_threshold_l2(i),
103  IN_Load => Load_i,
104  IN_Data => InData(i)(j).Layer2(k),
105  OUT_Data => OutData(i)(j).Layer2(k));
106  end generate layer2_for;
107 
108  layer3_for : for k in 0 to LAYER3-1 generate
109  EnergyConverter3 : entity work.EnergyConverter
110  generic map (ENCODING_MODE => ENCODING_MODE)
111  port map (
112  clk => CLK200,
113  is_hadronic => '0',
114  IN_threshold => IN_threshold_l3(i),
115  IN_Load => Load_i,
116  IN_Data => InData(i)(j).Layer3(k),
117  OUT_Data => OutData(i)(j).Layer3(k));
118  end generate layer3_for;
119 
120  LAR_OR_TILE_IF : if i = 0 or i = 1 generate
121  -- First to columns should be Lar (is_tile=0) in position 1,3,4
122  is_tile(i*INPUT_ROWS+j) <= '0' when had_position = "001" or had_position = "011" or had_position = "100" else '1';
123  hadronic_threshold(i*INPUT_ROWS+j) <= IN_threshold_had_lar(i) when had_position = "001" or had_position = "011" or had_position = "100"
124  else IN_threshold_had_tile(i);
125 
126  elsif i = 4 or i = 5 generate
127  --Last two columns should be LAr (is_tile = 0) in position 2,3,4
128  is_tile(i*INPUT_ROWS+j) <= '0' when had_position = "010" or had_position = "011" or had_position = "100" else '1';
129 
130  hadronic_threshold(i*INPUT_ROWS+j) <= IN_threshold_had_lar(i) when had_position = "010" or had_position = "011" or had_position = "100"
131  else IN_threshold_had_tile(i);
132 
133  else generate
134  --All other columns should be Lar in position 3,4
135  is_tile(i*INPUT_ROWS+j) <= '0' when had_position = "011" or had_position = "100" else '1';
136 
137  hadronic_threshold(i*INPUT_ROWS+j) <= IN_threshold_had_lar(i) when had_position = "011" or had_position = "100"
138  else IN_threshold_had_tile(i);
139 
140  end generate;
141 
142 
143  EnergyConverterH : entity work.EnergyConverter
144  generic map (ENCODING_MODE => ENCODING_MODE)
145  port map (
146  clk => CLK200,
147  is_hadronic => is_tile(i*INPUT_ROWS+j),
148  IN_threshold => hadronic_threshold(i*INPUT_ROWS+j),
149  IN_Load => Load_i,
150  IN_Data => InData(i)(j).Hadron(0),
151  OUT_Data => OutData(i)(j).Hadron(0));
152 
153  end generate row_for;
154  end generate column_for;
155 
156  OUT_Data <= OutData;
157 
158  process (CLK200)
159  begin
160  if rising_edge(CLK200) then
161  Load_d <= Load_i;
162  OUT_Load <= Load_d;
163  end if;
164  end process;
165 
166  process (CLK200)
167  begin
168  if rising_edge(CLK200) then
169  if Load_i = '1' then
170  BCN_200 <= BCN_i;
171  else
172  BCN_200 <= BCN_200;
173  end if;
174  BCN_d <= BCN_200;
175  end if;
176  end process;
177 
178  OUT_BCN_200 <= BCN_d;
179 
180 end Behavioral;
181 
182 
External data-types and functions.
array(natural range <> ) of AlgoWord AlgoWords
External arra of AlgoWord.
( INPUT_COLUMNS- 1 downto 0) AlgoColumn AlgoInput
Algorithm INPUT port.
Input Stage Module.
Input Stage Module.
Energy converter module.