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

Back to eFEX documentation
fsm_RAW_data_wr_to_DPR.vhd
Go to the documentation of this file.
1 
16 
17 library IEEE;
18 use IEEE.STD_LOGIC_1164.ALL;
19 use IEEE.NUMERIC_STD.ALL;
20 
21 library TOB_rdout_lib;
22 use TOB_rdout_lib.TOB_rdout_ip_pkg.ALL;
23 use TOB_rdout_lib.data_type_pkg.all;
24 
27  Port (
29  CLK_280M : in STD_LOGIC;
31  RST : in STD_LOGIC;
33  L1A_in : in STD_LOGIC;
35  pre_ld_wr_addr : in STD_LOGIC_VECTOR (9 downto 0);
37  DPR_rd_addr : out STD_LOGIC_VECTOR (9 downto 0);
39  DPR_wr_addr : out STD_LOGIC_VECTOR (9 downto 0);
41  DRP_rd_en : out STD_LOGIC ;
43  FIFO_wr_en : out STD_LOGIC ; -- en wr into FIFO
45  en_error_valid : out STD_LOGIC;
47  raw_data_dpram_fsm : out STD_LOGIC_VECTOR (7 downto 0)
48  );
50 
53 
54  signal CLK_280M_i : std_logic ;
55  signal RST_i : std_logic ;
56  signal L1A_in_1 : std_logic ;
57  signal FIFO_wr_en_i : std_logic := '0' ;
58  signal FIFO_wr_en_tmp : std_logic := '0' ;
59  signal DRP_rd_en_i : std_logic ;
60  signal en_error_valid_i : std_logic ;
61  signal DPR_rd_addr_i : STD_LOGIC_VECTOR (9 downto 0);
62  signal DPR_wr_addr_i : STD_LOGIC_VECTOR (9 downto 0);
63 
64  TYPE STATE_TYPE IS (
65  idle,
66  rd_mem,
67  wait_1,
68  ser_1,
69  ser_2,
70  ser_3,
71  ser_4
72  );
73 
74  SIGNAL current_state : STATE_TYPE;
75  signal count : integer range 0 to 8;
76 
77 -- ####### Mark signals ########
78  attribute keep : string ;
79  attribute max_fanout : integer;
80  attribute keep of FIFO_wr_en_i : signal is "true" ;
81  attribute max_fanout of FIFO_wr_en_i : signal is 30;
82  attribute keep of DRP_rd_en_i : signal is "true" ;
83  attribute max_fanout of DRP_rd_en_i : signal is 30;
84  attribute keep of DPR_rd_addr_i : signal is "true" ;
85  attribute max_fanout of DPR_rd_addr_i : signal is 30;
86  attribute keep of DPR_wr_addr_i : signal is "true" ;
87  attribute max_fanout of DPR_wr_addr_i : signal is 10;
88  attribute keep of pre_ld_wr_addr : signal is "true" ;
89  attribute max_fanout of pre_ld_wr_addr : signal is 30;
90 -- #######################################
91 
92 begin
93 
94  CLK_280M_i <= CLK_280M ;
95  RST_i <= RST ;
96 
97  DRP_rd_en <= DRP_rd_en_i ;
98  DPR_rd_addr <= DPR_rd_addr_i ;
99  FIFO_wr_en <= FIFO_wr_en_i ; -- was FIFO_wr_en_tmp
100  DPR_wr_addr <= DPR_wr_addr_i ;
101  en_error_valid <= en_error_valid_i; -- disable capture of error flags from last RAW word
102 
103 
104 -- The U2_rd_addr counter generates the read address for circular Dual Port RAM.
105 -- For every cycle of the 280 MHz clock, this counter is incremented.
106 -- This counter wraps round to ZERO when it reaches full count.
107 -- The write address of the Dual Port RAM is generated by adding the programmable Offset Value with Read Address.
108 -- Therefore: write address = read_addr + offset
109 
110 U2_rd_addr : entity work.cntr_ram_addr_10b
111  Port map (
112  CE => '1' , -- needs to count at 280MHz
113  CLK => CLK_280M_i ,
114  RST => RST_i,
115  Q => DPR_rd_addr_i
116  );
117 
118  -- write address = read_addr + offset
119  DPR_wr_addr_i <= std_logic_vector ( unsigned(pre_ld_wr_addr) + unsigned(DPR_rd_addr_i) ) ;
120 
121 -- Upon receiving an L1A, this process transfers 7 x 32-b words from the Circular DPRAM to the de-randomisation FIFO.
122 --
123 U3_rd_fsm : process (CLK_280M_i)
124  -- reads data from DPRAM to FIFO
125  begin
126  if CLK_280M_i'event and CLK_280M_i = '1' then
127  L1A_in_1 <= L1A_in ;
128  if RST_i = '1' then
129  FIFO_wr_en_i <= '0' ;
130  DRP_rd_en_i <= '0' ;
131  en_error_valid_i <= '0'; -- disable capture of error flags from last RAW word
132  count <= 0 ;
133  current_state <= idle ;
134  raw_data_dpram_fsm <= x"00";
135  else
136  CASE current_state is
137  when idle =>
138  count <= 0 ;
139  FIFO_wr_en_i <= '0';
140  DRP_rd_en_i <= '0' ;
141  en_error_valid_i <= '0'; -- disable capture of error flags from last RAW word
142  raw_data_dpram_fsm <= x"01";
143  if L1A_in_1 = '1' then -- on L1A rd data from FIFO into DPRAM
144  current_state <= rd_mem ; -- 1 clk extra delay for data to come out of DPRAM internal register
145  else
146  current_state <= idle ;
147  end if;
148 
149  when rd_mem => -- 1 clk for data to come out of DPRAM
150  DRP_rd_en_i <= '1' ;
151  FIFO_wr_en_i <= '0';
152  current_state <= wait_1 ;
153  raw_data_dpram_fsm <= x"02";
154 
155  when wait_1 => -- 1 clk for data to come out of DPRAM
156  DRP_rd_en_i <= '1' ;
157  FIFO_wr_en_i <= '1';
158  en_error_valid_i <= '1'; -- enable capture of error flags from RAW word
159  current_state <= ser_1 ;
160  count <= count + 1 ;
161  raw_data_dpram_fsm <= x"03";
162 
163  when ser_1 =>
164  en_error_valid_i <= '0';
165  raw_data_dpram_fsm <= x"04";
166  if count < 6 then -- this is 6th word
167  DRP_rd_en_i <= '1' ;
168  FIFO_wr_en_i <= '1';
169  count <= count + 1 ;
170  current_state <= ser_1 ;
171  else
172  en_error_valid_i <= '0'; -- enable capture of error flags from last RAW word
173  if L1A_in_1 = '1' then -- if L1A = 1
174  DRP_rd_en_i <= '1' ;
175  FIFO_wr_en_i <= '1'; -- to capture the 7th data word from DPRAM
176  count <= 0 ;
177  current_state <= wait_1 ; -- 1 clk for data to come out of DPRAM
178  else
179  current_state <= idle ;
180  DRP_rd_en_i <= '0' ;
181  FIFO_wr_en_i <= '1' ; -- to capture the 7th data word from DPRAM
182  count <= 0 ;
183  end if;
184  end if;
185 
186  when others =>
187  NULL;
188  end case;
189  end if;
190  END IF;
191 
192  end process;
193 
194 --ila_raw_addr_DPram : ila_ipbus_fabric_rd_wr
195 --PORT MAP (
196 -- clk => CLK_280M_i ,
197 -- probe0 => RAW_DPR_wr_addr_vec , -- 32b
198 -- probe1 => RAW_DPR_rd_addr_vec , -- 32b
199 -- probe2 => L1A_in_i_vec , -- 1b
200 -- probe3(0) => DRP_rd_en_i, -- 1b
201 -- probe4 => (others => '0' ), -- 1b
202 -- probe5 => state_ID_vec, --32b
203 -- probe6 => count_vec, -- 32b
204 -- probe7(0) => FIFO_wr_en_i, -- 1b
205 -- probe8 => (others => '0' ) , -- 1b
206 -- probe9 => (others => '0' ) -- 1b
207 --);
208 
209 end Behavioral;
Transfer calorimeter data from Circular DPRAM to de-randomisation FIFO.
Transfer calorimeter data from Circular DPRAM to de-randomisation FIFO.
out DPR_wr_addr STD_LOGIC_VECTOR( 9 downto 0)
DPRAM write address.
out DPR_rd_addr STD_LOGIC_VECTOR( 9 downto 0)
DPRAM read address.
out DRP_rd_en STD_LOGIC
DPRAM read enable.
out FIFO_wr_en STD_LOGIC
FIFO write enable.
in L1A_in STD_LOGIC
TTC L1A input.
out raw_data_dpram_fsm STD_LOGIC_VECTOR( 7 downto 0)
Monitor state machine status register.
out en_error_valid STD_LOGIC
Enable capture of error flags from last RAW word.
in pre_ld_wr_addr STD_LOGIC_VECTOR( 9 downto 0)
latency offset for DPRAM wr address
in RST STD_LOGIC
Reset input.
in CLK_280M STD_LOGIC
Clock 280 MHz.