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

Back to eFEX documentation
PISO_RAW_data.vhd
Go to the documentation of this file.
1 
13 
14 library IEEE;
15 use IEEE.STD_LOGIC_1164.ALL;
16 use ieee.numeric_std.all;
17 
18 library TOB_rdout_lib;
19 use TOB_rdout_lib.TOB_rdout_ip_pkg.ALL;
20 use TOB_rdout_lib.data_type_pkg.all;
21 
23 entity PISO_RAW_data is
24  Port (
25  RST : in STD_LOGIC;
27  RAW_link_data_in : in STD_LOGIC_VECTOR (226 downto 0); -- 227b input frames
29  data_sync_in : in STD_LOGIC;
31  clk_in_280M : in STD_LOGIC;
33  data_sync_out : out STD_LOGIC;
35  data_out_valid : out STD_LOGIC;
37  data_out : out STD_LOGIC_VECTOR (35 downto 0)
38  );
39  end PISO_RAW_data;
40 
42 architecture Behavioral of PISO_RAW_data is
43 
44  signal CLK_280M_i : std_logic ;
45  signal RST_i : std_logic ;
46  signal data_sync_in_1, data_sync_in_2 : std_logic ;
47  signal RAW_data_in_i : STD_LOGIC_VECTOR (223 downto 0) := (others => '0'); -- 224b input frames
48  signal data_sync_out_i : std_logic ;
49  signal data_out_valid_i : std_logic ;
50  signal data_out_i : STD_LOGIC_VECTOR (35 downto 0); -- 4b error plus 32b data
51  signal error_flag_i : STD_LOGIC_VECTOR (3 downto 0); -- or_of_err_flags 4-b error (zero + input_crc + input_disparity + not_in_table)
52 
53  TYPE STATE_TYPE IS (
54  idle, ser_1, ser_2, ser_3, ser_4,
55  ser_5, ser_6, ser_7
56  );
57 
58  SIGNAL current_state : STATE_TYPE;
59 
60 -- ####### Mark signals ########
61  attribute keep : string ;
62  attribute max_fanout : integer;
63  attribute keep of data_sync_in : signal is "true" ;
64  attribute max_fanout of data_sync_in : signal is 30;
65  attribute keep of data_sync_in_1 : signal is "true" ;
66  attribute max_fanout of data_sync_in_1 : signal is 30;
67  attribute keep of data_sync_in_2 : signal is "true" ;
68  attribute max_fanout of data_sync_in_2 : signal is 30;
69 
70 -- #######################################
71 
72 begin
73 
74  CLK_280M_i <= clk_in_280M ;
75  RST_i <= RST ;
76 
77  -- ouput
78  data_out <= data_out_i ;
79  data_sync_out <= data_sync_out_i ;
80  data_out_valid <= data_out_valid_i ;
81 
82  -- Process U2_280M_clk is used to pipeline the input data.
83  -- It also captures the RAW Data from MGT Links in the middle of the 40MHz signal pulse.
84 U2_280M_clk : process (CLK_280M_i)
85  begin
86  if rising_edge (CLK_280M_i) then
87  data_sync_in_1 <= data_sync_in ; -- delay data_sync_in, this already has 1 clk delay from generation
88  data_sync_in_2 <= data_sync_in_1 ; -- delay data_sync_in
89  end if;
90 
91  if rising_edge (CLK_280M_i) then -- capture data in middle of 40M clk
92  if data_sync_in_1 = '1' then
93  RAW_data_in_i <= RAW_link_data_in(223 downto 0); -- register input 224b data
94  -- 4b error flags for the current data from the same MGT
95  -- zero + input_crc + input_disparity + not_in_table
96  error_flag_i <= '0' & RAW_link_data_in(226) & RAW_link_data_in(225) & RAW_link_data_in(224);
97  end if;
98  end if;
99 end process;
100 
101 -- Process U3_wr_to_DPR_fsm is used to convert the 224-bit input data to 7x32-bit data.
102 -- It also changes the 32-b input data to 36-bit ouput data by adding the 4-bit error flags to the first word.
103 -- The 4 bit error flags are used when constructing an RAW Readout Frame (event)
104 U3_wr_to_DPR_fsm : process (CLK_280M_i)
105  begin
106  if CLK_280M_i'event and CLK_280M_i = '1' then
107  if RST_i = '1' then
108  current_state <= idle ;
109  data_out_valid_i <= '0';
110  else
111  CASE current_state is
112  when idle =>
113  data_sync_out_i <= '0';
114  if data_sync_in_2 = '1' then -- on start bit of 7 32b words
115  data_out_i <= error_flag_i & RAW_data_in_i(31 downto 0);
116  data_sync_out_i <= '1';
117  data_out_valid_i <= '1';
118  current_state <= ser_1 ;
119  end if;
120  when ser_1 =>
121  data_out_i <= error_flag_i & RAW_data_in_i(63 downto 32);
122  data_sync_out_i <= '0';
123  data_out_valid_i <= '1';
124  current_state <= ser_2 ;
125  when ser_2 =>
126  data_out_i <= error_flag_i & RAW_data_in_i(95 downto 64);
127  data_sync_out_i <= '0';
128  data_out_valid_i <= '1';
129  current_state <= ser_3 ;
130  when ser_3 =>
131  data_out_i <= error_flag_i & RAW_data_in_i(127 downto 96);
132  data_sync_out_i <= '0';
133  data_out_valid_i <= '1';
134  current_state <= ser_4 ;
135  when ser_4 =>
136  data_out_i <= error_flag_i & RAW_data_in_i(159 downto 128);
137  data_sync_out_i <= '0';
138  data_out_valid_i <= '1';
139  current_state <= ser_5 ;
140  when ser_5 =>
141  data_out_i <= error_flag_i & RAW_data_in_i(191 downto 160);
142  data_sync_out_i <= '0';
143  data_out_valid_i <= '1';
144  current_state <= ser_6 ;
145  when ser_6 =>
146  data_out_i <= error_flag_i & RAW_data_in_i(223 downto 192); -- add error flags
147  data_sync_out_i <= '0';
148  data_out_valid_i <= '1';
149  current_state <= idle ;
150  when others =>
151  NULL;
152  end case;
153  end if;
154  END IF;
155  end process ;
156 
157 end Behavioral;
Calorimeter data PISO for process FPGA.
Calorimeter data PISO for process FPGA.
in data_sync_in STD_LOGIC
calorimeter data valid/synch signal
in RAW_link_data_in STD_LOGIC_VECTOR( 226 downto 0)
calorimeter data array 49 x 227b input frames
out data_out_valid STD_LOGIC
calorimeter data valid signal out
out data_sync_out STD_LOGIC
calorimeter data synch signal out
in clk_in_280M STD_LOGIC
280MHz clock input signal
out data_out STD_LOGIC_VECTOR( 35 downto 0)
calorimeter Error & Data out 36b