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

Back to eFEX documentation
fsm_TOB_wr_to_FIFO.vhd
Go to the documentation of this file.
1 
10 
11 
12 library IEEE;
13 use IEEE.STD_LOGIC_1164.ALL;
14 
15 use IEEE.NUMERIC_STD.ALL;
16 
17 library TOB_rdout_lib;
18 use TOB_rdout_lib.TOB_rdout_ip_pkg.ALL;
19 use TOB_rdout_lib.data_type_pkg.all;
20 
23  Port (
25  CLK_IN : in STD_LOGIC;
27  TOB_FIFO_sw_rst : in std_logic ;
29  L1A_in : in STD_LOGIC;
31  SIPO_sync_in : in STD_LOGIC;
33  pre_ld_wr_addr : in STD_LOGIC_VECTOR (8 downto 0);
35  DPR_locations_to_rd : in STD_LOGIC_VECTOR (2 downto 0);
37  trigger_slice_in : in STD_LOGIC_VECTOR(3 downto 0) ;
39  DPR_rd_addr : out STD_LOGIC_VECTOR (8 downto 0);
41  DPR_wr_addr : out STD_LOGIC_VECTOR (8 downto 0);
43  DRP_rd_en : out STD_LOGIC ;
45  FIFO_wr_en : out STD_LOGIC;
47  tob_data_dpram_fsm : out STD_LOGIC_VECTOR (7 downto 0)
48  );
50 
52 architecture Behavioral of fsm_TOB_wr_to_FIFO is
53 
54  signal SIPO_sync_in_i : std_logic ;
55  signal FIFO_wr_en_i : std_logic := '0' ;
56  signal DRP_rd_en_i : std_logic ;
57  signal DPR_rd_addr_i : STD_LOGIC_VECTOR (8 downto 0);
58  signal DPR_rd_addr_tmp : unsigned (8 downto 0);
59  signal DPR_wr_addr_i : STD_LOGIC_VECTOR (8 downto 0);
60 -- signal pre_ld_wr_addr_i : STD_LOGIC_VECTOR (8 downto 0);
61  signal slice_count_i : unsigned (2 downto 0);
62 
63 -- ####### Mark signals ########
64  attribute keep : string ;
65  attribute max_fanout : integer;
66  attribute keep of DPR_wr_addr_i : signal is "true" ;
67  attribute max_fanout of DPR_wr_addr_i : signal is 40;
68  attribute keep of DPR_rd_addr_i : signal is "true" ;
69  attribute max_fanout of DPR_rd_addr_i : signal is 40;
70  attribute keep of FIFO_wr_en_i : signal is "true" ;
71  attribute max_fanout of FIFO_wr_en_i : signal is 40;
72  attribute keep of DRP_rd_en_i : signal is "true" ;
73  attribute max_fanout of DRP_rd_en_i : signal is 40;
74 
75 -- #######################################
76 
77  TYPE STATE_TYPE IS (
78  idle,
79  ser_1,
80  ser_2,
81  ser_3,
82  ser_4
83  ) ;
84 
85  SIGNAL current_state : STATE_TYPE;
86  signal count : integer range 0 to 7;
87  signal tmp : std_logic_vector (7 downto 0);
88 begin
89  -- input ports
90  SIPO_sync_in_i <= SIPO_sync_in ;
91  slice_count_i <= unsigned (DPR_locations_to_rd) ;
92 
93  -- output ports
94  DRP_rd_en <= DRP_rd_en_i ;
95  DPR_rd_addr <= STD_LOGIC_VECTOR (DPR_rd_addr_tmp) ;
96  FIFO_wr_en <= FIFO_wr_en_i ;
97  DPR_wr_addr <= DPR_wr_addr_i ;
98 
99 -- This process generates the Circular DPRAM Write address by adding the pre-load offset with Circular DPRAM Read address.
100 -- It operates with the 280 MHz clock but increments once every 7 clock to read TOBs.
101 -- It operates with the 200 MHz clock but increments once every 5 clock to read XTOBs.
102 
103 U0_clk_proc : process (CLK_IN)
104  begin
105  if CLK_IN'event and CLK_IN = '1' then
106  -- write address = read_addr + offset
107  DPR_wr_addr_i <= std_logic_vector ( unsigned(pre_ld_wr_addr) + unsigned(DPR_rd_addr_i) ) ;
108 
109  end if;
110  end process;
111 
112 -- This counter generates the Circular DPRAM Read address.
113 -- It increments once when SIPO_sync_in signal is active.
114 
115 U2_rd_addr : entity TOB_rdout_lib.cntr_ram_addr_9b
116  Port map (
117  -- as words are placed together in parallel,
118  -- only one increment is needed every 1 start bit (40MHz)
119  CE => SIPO_sync_in_i ,
120  CLK => CLK_IN ,
121  RST => TOB_FIFO_sw_rst,
122  Q => DPR_rd_addr_i
123  );
124 
125 -- This FSM transfers TOB data from DPRAM into de-randomising FIFO (buffer).
126 
127 U3_rd_XTOB_fsm : process (CLK_IN)
128 
129  begin
130  if CLK_IN'event and CLK_IN = '1' then
131  if ( TOB_FIFO_sw_rst = '1' )then -- RST OR TOB_FIFO_sw_rst
132  current_state <= idle ;
133  FIFO_wr_en_i <= '0' ;
134  DRP_rd_en_i <= '0' ;
135  count <= 0 ;
136  DPR_rd_addr_tmp <= (others => '0');
137  tob_data_dpram_fsm <= X"00";
138  else
139  CASE current_state is
140  when idle =>
141  tob_data_dpram_fsm <= X"01";
142  if L1A_in = '1' then -- on L1A
143  DPR_rd_addr_tmp <= (unsigned(DPR_rd_addr_i) - unsigned(trigger_slice_in));
144  DRP_rd_en_i <= '1' ; -- read 1st location
145  FIFO_wr_en_i <= '0'; -- delay by 1 clk so data is on o/p reg of DPRAM
146  current_state <= ser_1 ;
147  count <= count + 1 ;
148  else
149  current_state <= idle ;
150  end if;
151  when ser_1 =>
152  tob_data_dpram_fsm <= X"02";
153  -- if slice_count_i = 1 then -- default is at least one location, max is 5
154  if slice_count_i = count then -- default is at least one location, max is 5
155  current_state <= ser_4 ;
156  DRP_rd_en_i <= '1' ; -- extra enable cycle for reg at o/p of DPRAM
157  FIFO_wr_en_i <= '1'; -- wr enable into FIFO
158  count <= count + 1 ;
159  else
160  current_state <= ser_1 ; -- was ser_2
161  DPR_rd_addr_tmp <= DPR_rd_addr_tmp + 1 ;
162  DRP_rd_en_i <= '1' ; -- read next location
163  FIFO_wr_en_i <= '1';
164  count <= count + 1 ;
165  end if;
166 
167  when ser_4 =>
168  DRP_rd_en_i <= '0' ;
169  FIFO_wr_en_i <= '0' ;
170  tob_data_dpram_fsm <= X"03";
171  if count = 6 then
172  current_state <= idle ;
173  count <= 0 ;
174  else
175  current_state <= ser_4;
176  count <= count + 1 ;
177  end if;
178  when others =>
179  NULL;
180  end case;
181  end if;
182  END IF;
183  end process;
184 
185  tmp <= std_logic_vector(to_unsigned(count, tmp'length));
186 
187 --U2_ila_XTOB_BCN_in : ila_ipbus_fabric_rd_wr
188 --PORT MAP (
189 -- clk => CLK_IN,
190 -- probe0(7 downto 0) => tmp , -- 36b
191 -- probe0(15 downto 8) => (others => '0') , -- 36b
192 -- probe0(24 downto 16) => DPR_rd_addr_i (8 downto 0), -- 36b
193 -- probe0(33 downto 25) => DPR_wr_addr_i (8 downto 0) , -- 36b
194 -- probe0(35 downto 34) => (others => '0') , -- 36b
195 -- probe1 => (others => '0'), -- 36b
196 -- probe2(0) => SIPO_sync_in_i , -- 1b
197 -- probe3(0) => DRP_rd_en_i , -- 1b
198 -- probe4(0) => FIFO_wr_en_i , -- 1b
199 -- probe5 => (others => '0'), -- 36b
200 -- probe6 => (others => '0'), -- 36b
201 -- probe7(0) => L1A_in, -- 1b
202 -- probe8(0) => TOB_FIFO_sw_rst , -- 1b
203 -- probe9(0) => '0' -- 1b
204 --);
205 
206 end Behavioral;
207 
Top of fsm_TOB_wr_to_FIFO for process FPGA.
Top of fsm_TOB_wr_to_FIFO for process FPGA.
in trigger_slice_in STD_LOGIC_VECTOR( 3 downto 0)
Trigger slice number - on L1A.
in SIPO_sync_in STD_LOGIC
SIPO TOBs synch signal input.
in DPR_locations_to_rd STD_LOGIC_VECTOR( 2 downto 0)
number of multi-slice locations to read from DPRAM
out DPR_rd_addr STD_LOGIC_VECTOR( 8 downto 0)
DPRAM read address.
out DRP_rd_en STD_LOGIC
DPRAM read enable.
in pre_ld_wr_addr STD_LOGIC_VECTOR( 8 downto 0)
latency pre-load for DRPAM write address
out FIFO_wr_en STD_LOGIC
enable sorted TOBs write into derandomisatiion FIFO
in L1A_in STD_LOGIC
L1A signal input.
in CLK_IN STD_LOGIC
Clock input signal.
in TOB_FIFO_sw_rst std_logic
TOB Readout FIFO reset Pulse by software command.
out tob_data_dpram_fsm STD_LOGIC_VECTOR( 7 downto 0)
Monitor state machine status register.
out DPR_wr_addr STD_LOGIC_VECTOR( 8 downto 0)
DPRAM write address.