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

Back to eFEX documentation
efex_topo_frame_sm.vhd
1 ---!@file
9 LIBRARY ieee;
10 USE ieee.std_logic_1164.all;
11 USE ieee.std_logic_arith.all;
14  PORT(
16  bcn : IN std_logic_vector (3 DOWNTO 0);
18  clk : IN std_logic;
20  crc_start : out std_logic;
22  crc : IN std_logic_vector (8 DOWNTO 0);
24  reset : IN std_logic;
26  tobo_data : IN std_logic_vector (31 DOWNTO 0);
28  tobo_data_reg : IN std_logic_vector (31 DOWNTO 0);
30  tobo_sync : IN std_logic;
32  tobo_valid : IN std_logic;
34  crc_data : OUT std_logic_vector (31 DOWNTO 0);
36  tx_ctrl : OUT std_logic;
38  tx_data : OUT std_logic_vector (31 DOWNTO 0)
39 
40  );
41 
42 
43 
44 END ENTITY efex_topo_frame_sm ;
46 ARCHITECTURE fsm OF efex_topo_frame_sm IS
47 
48  -- Architecture Declarations
49  signal cntr : unsigned(3 downto 0);
50  constant fexid : std_logic_vector(1 downto 0):="01";
51  constant fexfld : std_logic_vector(8 downto 0):= (others => '0');
52  TYPE STATE_TYPE IS (
53  idle,
54  empty,
55  trialer_0,
56  kchar,
57  empty_1,
58  str,
59  wait0,
60  wait1,
61  empty_data,
62  fin,
63  wait_2,
64  wait_3,
65  trialer_1,
66  fin1
67  );
68 
69  -- Declare current and next state signals
70  SIGNAL current_state : STATE_TYPE;
71 
72 BEGIN
73 
74  -----------------------------------------------------------------
75  clocked_proc : PROCESS (
76  clk,
77  reset
78  )
79  -----------------------------------------------------------------
80  BEGIN
81  IF (reset = '1') THEN
82  current_state <= idle;
83  ELSIF (clk'EVENT AND clk = '1') THEN
84 
85  -- Combined Actions
86  CASE current_state IS
87  WHEN idle =>
88  cntr <= (others => '0');
89  tx_data <= x"00000000";
90  crc_data<= (others => '0');
91  tx_ctrl <= '0';
92  crc_start<= '0';
93  IF ((tobo_sync = '1' AND tobo_valid = '0')) THEN
94  crc_start <= '1';
95  current_state <= empty;
96  ELSIF (tobo_sync = '1' AND tobo_valid ='1') THEN
97  crc_start <= '1' ;
98  current_state <= str;
99  ELSE
100  current_state <= idle;
101  END IF;
102  WHEN empty =>
103  cntr<= cntr+1;
104  tx_data <= x"00000000";
105  tx_ctrl <= '0';
106  crc_data<= x"00000000";
107  crc_start <='0';
108  IF ((cntr = 4)) THEN
109  current_state <= kchar;
110  ELSE
111  current_state <= empty;
112  END IF;
113  WHEN trialer_0 =>
114  cntr <= cntr +1 ;
115  crc_start <= '0';
116  tx_data <= crc & fexfld & fexid & bcn & x"bc";
117  tx_ctrl <= '1' ;
118  crc_data <= (others => '0');
119  current_state <= empty;
120  WHEN kchar =>
121  cntr <= (others => '0') ;
122  crc_data <= x"00" &'0'& fexfld & fexid & bcn & x"00" ;
123  tx_data <= x"00000000" ;
124  tx_ctrl <= '0' ;
125  current_state <= empty_1;
126  WHEN empty_1 =>
127  cntr <= (others => '0') ;
128  crc_data<= tobo_data;
129  tx_data <= x"00000000" ;
130  tx_ctrl <= '0' ;
131  crc_start <= '1';
132  IF (tobo_valid = '0') THEN
133  current_state <= trialer_0;
134  ELSIF (tobo_valid = '1') THEN
135  current_state <= trialer_1;
136  ELSE
137  current_state <= empty_1;
138  END IF;
139  WHEN str =>
140  crc_start <= '0';
141  crc_data<= tobo_data;
143  tx_ctrl <= '0' ;
144  cntr <= cntr +1;
145  IF (tobo_valid ='0' and cntr = 4) THEN
146  current_state <= wait1;
147  ELSIF (tobo_valid ='0') THEN
148  current_state <= empty_data;
149  ELSIF (cntr = 4) THEN
150  current_state <= wait0;
151  ELSE
152  current_state <= str;
153  END IF;
154  WHEN wait0 =>
156  crc_data <= x"00" &'0'& fexfld & fexid & bcn & x"00" ;
157  cntr <= (others => '0') ;
158  tx_ctrl <= '0' ;
159  current_state <= wait_3;
160  WHEN wait1 =>
161  cntr <= (others => '0') ;
163  tx_ctrl <= '0' ;
164  crc_data <= x"00" &'0'& fexfld & fexid & bcn & x"00" ;
165  current_state <= wait_2;
166  WHEN empty_data =>
168  crc_data<= (others => '0') ;
169  tx_ctrl <= '0' ;
170  cntr <= cntr +1;
171  IF (cntr = 4) THEN
172  current_state <= wait1;
173  ELSE
174  current_state <= empty_data;
175  END IF;
176  WHEN fin =>
177  crc_data <= tobo_data ; --
178  --cntr <= (others => '0') ;
179  tx_data <= crc & fexfld & fexid & bcn & x"bc";
180  tx_ctrl <= '1' ;
181  crc_start <='0';
182  cntr <= cntr +1;
183  current_state <= str;
184  WHEN wait_2 =>
185  cntr <= (others => '0') ;
186  crc_data <= tobo_data ; --
188  tx_ctrl <= '0' ;
189  crc_start <= '1';
190  IF (tobo_valid = '1') THEN
191  current_state <= fin;
192  ELSIF (tobo_valid = '0') THEN
193  current_state <= fin1;
194  ELSE
195  current_state <= wait_2;
196  END IF;
197  WHEN wait_3 =>
198  cntr <= (others => '0') ;
199  crc_data <= tobo_data; --
201  tx_ctrl <= '0' ;
202  crc_start <= '1';
203  IF (tobo_valid ='1') THEN
204  current_state <= fin;
205  ELSIF (tobo_valid ='0') THEN
206  current_state <= fin1;
207  ELSE
208  current_state <= wait_3;
209  END IF;
210  WHEN trialer_1 =>
211  cntr <= cntr +1 ;
212  crc_start <= '0';
213  tx_data <= crc & fexfld & fexid & bcn & x"bc";
214  tx_ctrl <= '1' ;
216  current_state <= str;
217  WHEN fin1 =>
218  crc_data <= tobo_data;
219  cntr <= cntr+1 ;
220  tx_data <= crc & fexfld & fexid & bcn & x"bc";
221  tx_ctrl <= '1' ;
222  crc_start <='0';
223  IF (tobo_valid ='0') THEN
224  crc_data<= (others => '0');
225  current_state <= empty;
226  ELSE
227  current_state <= fin1;
228  END IF;
229  WHEN OTHERS =>
230  current_state <= idle;
231  END CASE;
232  END IF;
233  END PROCESS clocked_proc;
234 
235 END ARCHITECTURE fsm;
236 
237 -- TYPE STATE_TYPE IS (
238 -- idle,
239 -- empty,
240 -- trialer_0,
241 -- kchar,
242 -- empty_1,
243 -- str,
244 -- wait0,
245 -- wait1,
246 -- empty_data,
247 -- fin,
248 -- wait_2,
249 -- wait_3,
250 -- trialer_1
251 -- );
252 
253 -- -- Declare current and next state signals
254 -- SIGNAL current_state : STATE_TYPE;
255 
256 --BEGIN
257 
258 -- -----------------------------------------------------------------
259 -- clocked_proc : PROCESS (
260 -- clk,
261 -- reset
262 -- )
263 -- -----------------------------------------------------------------
264 -- BEGIN
265 -- IF (reset = '1') THEN
266 -- current_state <= idle;
267 -- ELSIF (clk'EVENT AND clk = '1') THEN
268 
269 -- -- Combined Actions
270 -- CASE current_state IS
271 -- WHEN idle =>
272 -- cntr <= (others => '0');
273 -- tx_data <= x"00000000";
274 -- crc_data<= (others => '0');
275 -- tx_ctrl <= '0';
276 -- crc_start<= '0';
277 -- IF ((tobo_sync = '1' AND tobo_valid = '0')) THEN
278 -- crc_start <= '1';
279 -- current_state <= empty;
280 -- ELSIF (tobo_valid ='1') THEN
281 -- crc_start <= '1' ;
282 -- current_state <= str;
283 -- ELSE
284 -- current_state <= idle;
285 -- END IF;
286 -- WHEN empty =>
287 -- cntr<= cntr+1;
288 -- tx_data <= x"00000000";
289 -- tx_ctrl <= '0';
290 -- crc_data<= x"00000000";
291 -- crc_start <='0';
292 -- IF ((cntr = 4)) THEN
293 -- current_state <= kchar;
294 -- ELSE
295 -- current_state <= empty;
296 -- END IF;
297 -- WHEN trialer_0 =>
298 -- cntr <= cntr +1 ;
299 -- crc_start <= '0';
300 -- tx_data <= crc & fexfld & fexid & bcn & x"bc";
301 -- tx_ctrl <= '1' ;
302 -- crc_data <= (others => '0');
303 -- current_state <= empty;
304 -- WHEN kchar =>
305 -- cntr <= (others => '0') ;
306 -- crc_data <= x"00" &'0'& fexfld & fexid & bcn & x"00" ;
307 -- tx_data <= x"00000000" ;
308 -- tx_ctrl <= '0' ;
309 -- current_state <= empty_1;
310 -- WHEN empty_1 =>
311 -- cntr <= (others => '0') ;
312 -- crc_data<= tobo_data;
313 -- tx_data <= x"00000000" ;
314 -- tx_ctrl <= '0' ;
315 -- crc_start <= '1';
316 -- IF (tobo_valid = '0') THEN
317 -- current_state <= trialer_0;
318 -- ELSIF (tobo_valid = '1') THEN
319 -- current_state <= trialer_1;
320 -- ELSE
321 -- current_state <= empty_1;
322 -- END IF;
323 -- WHEN str =>
324 -- crc_start <= '0';
325 -- crc_data<= tobo_data;
326 -- tx_data <= tobo_data_reg ;
327 -- tx_ctrl <= '0' ;
328 -- cntr <= cntr +1;
329 -- IF (tobo_valid ='0' and cntr = 4) THEN
330 -- current_state <= wait1;
331 -- ELSIF (tobo_valid ='0') THEN
332 -- current_state <= empty_data;
333 -- ELSIF (cntr = 4) THEN
334 -- current_state <= wait0;
335 -- ELSE
336 -- current_state <= str;
337 -- END IF;
338 -- WHEN wait0 =>
339 -- tx_data <= tobo_data_reg ;
340 -- crc_data <= x"00" &'0'& fexfld & fexid & bcn & x"00" ;
341 -- cntr <= (others => '0') ;
342 -- tx_ctrl <= '0' ;
343 -- current_state <= wait_3;
344 -- WHEN wait1 =>
345 -- cntr <= (others => '0') ;
346 -- tx_data <= tobo_data_reg ;
347 -- tx_ctrl <= '0' ;
348 -- crc_data <= x"00" &'0'& fexfld & fexid & bcn & x"00" ;
349 -- current_state <= wait_2;
350 -- WHEN empty_data =>
351 -- tx_data <= tobo_data_reg;
352 -- crc_data<= (others => '0') ;
353 -- tx_ctrl <= '0' ;
354 -- cntr <= cntr +1;
355 -- IF (cntr = 4) THEN
356 -- current_state <= wait1;
357 -- ELSE
358 -- current_state <= empty_data;
359 -- END IF;
360 -- WHEN fin =>
361 -- crc_data <= tobo_data ;
362 -- --cntr <= (others => '0') ;
363 -- tx_data <= crc & fexfld & fexid & bcn & x"bc";
364 -- tx_ctrl <= '1' ;
365 -- crc_start <='0';
366 -- cntr <= cntr +1;
367 -- IF (tobo_valid ='1') THEN
368 -- current_state <= str;
369 -- ELSIF (tobo_valid ='0') THEN
370 -- crc_data<= (others => '0');
371 -- current_state <= empty;
372 -- ELSE
373 -- current_state <= fin;
374 -- END IF;
375 -- WHEN wait_2 =>
376 -- cntr <= (others => '0') ;
377 -- crc_data <= tobo_data ;
378 -- tx_data <= tobo_data_reg ;
379 -- tx_ctrl <= '0' ;
380 -- crc_start <= '1';
381 -- current_state <= fin;
382 -- WHEN wait_3 =>
383 -- cntr <= (others => '0') ;
384 -- crc_data <= tobo_data ;
385 -- tx_data <= tobo_data_reg ;
386 -- tx_ctrl <= '0' ;
387 -- crc_start <= '1';
388 -- current_state <= fin;
389 -- WHEN trialer_1 =>
390 -- cntr <= cntr +1 ;
391 -- crc_start <= '0';
392 -- tx_data <= crc & fexfld & fexid & bcn & x"bc";
393 -- tx_ctrl <= '1' ;
394 -- crc_data<= tobo_data;
395 -- current_state <= str;
396 -- WHEN OTHERS =>
397 -- current_state <= idle;
398 -- END CASE;
399 -- END IF;
400 -- END PROCESS clocked_proc;
401 
402 --END ARCHITECTURE fsm;
403 
404 
405 
in bcn std_logic_vector( 3 DOWNTO 0)
bnc of the tobs
in tobo_data std_logic_vector( 31 DOWNTO 0)
tob data
in reset std_logic
reset synch
out tx_ctrl std_logic
tx control of the MGT
in crc std_logic_vector( 8 DOWNTO 0)
crc bits
in clk std_logic
fabric clock of 280MHz
in tobo_data_reg std_logic_vector( 31 DOWNTO 0)
tob data pipe
in tobo_valid std_logic
tob valid
out crc_data std_logic_vector( 31 DOWNTO 0)
input to the crc calculator
out crc_start std_logic
stsrt crc generation
out tx_data std_logic_vector( 31 DOWNTO 0)
MGT tx data.
in tobo_sync std_logic
tob synch