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

Back to eFEX documentation
fifo_spy.vhd
Go to the documentation of this file.
1 
10 
12 LIBRARY ieee;
13 USE ieee.std_logic_1164.all;
14 use ieee.numeric_std.all;
15 
17 LIBRARY ipbus_lib;
18 USE ipbus_lib.ipbus.all;
19 
21 ENTITY fifo_spy IS
22  GENERIC(
23  IPBUS_ADDR_WIDTH : positive := 10
24  );
25  port (
26 --- data to FIFO
27  clk_320 : in std_logic;
28  rst_320 : in std_logic;
29  fifo_data : in std_logic_vector (63 DOWNTO 0);
30  fifo_valid : in std_logic;
31  fifo_last : in std_logic;
32  fifo_tready : in std_logic;
33 -- interface to IPBus
34  clk_ipb : in std_logic;
35  rst_ipb : in std_logic;
36  rst_ipbus_addr : in std_logic;
37  ipbus_wraparound : in std_logic;
38  ipb_in : in ipb_wbus;
39  ipb_out : out ipb_rbus
40  );
41 END ENTITY fifo_spy;
42 
44 Architecture rtl of fifo_spy is
45 
46 Component ipbus_dpram64 is
47  generic(
48  ADDR_WIDTH: positive
49  );
50  port(
51  clk: in std_logic;
52  rst: in std_logic;
53  ipb_in: in ipb_wbus;
54  ipb_out: out ipb_rbus;
55  rclk: in std_logic;
56  we: in std_logic := '0';
57  d: in std_logic_vector(63 downto 0) := (others => '0');
58  q: out std_logic_vector(63 downto 0);
59  addr: in std_logic_vector(ADDR_WIDTH - 1 downto 0)
60  );
61 End Component ipbus_dpram64;
62 
63  SIGNAL IPBus_RAM_addr, IPBus_RAM_addr_i : std_logic_vector(IPBUS_ADDR_WIDTH-1 downto 0);
64  SIGNAL IPBus_RAM_din, IPBus_RAM_din_i, fifo_data_i : std_logic_vector(63 DOWNTO 0);
65  SIGNAL IPBus_RAM_we, IPBus_RAM_we_i, fifo_valid_i, fifo_last_i, fifo_tready_i : std_logic;
66 
67 Begin
68 
69  IPbus_RAM : ipbus_dpram64
70  GENERIC MAP (
71  ADDR_WIDTH => IPBUS_ADDR_WIDTH
72  )
73  PORT MAP (
74  clk => clk_ipb,
75  rst => rst_ipb,
76  ipb_in => ipb_in,
77  ipb_out => ipb_out,
78  rclk => clk_320,
79  we => IPBus_RAM_we,
80  d => IPBus_RAM_din,
81  q => Open,
82  addr => IPBus_RAM_addr
83  );
84 
85 ipbus_ram_block: process(clk_320)
86  variable ram_addr, next_addr: unsigned(IPBUS_ADDR_WIDTH-1 downto 0) := (Others => '0');
87  constant max_addr: unsigned(IPBUS_ADDR_WIDTH-1 downto 0) := (Others => '1');
88  constant min_addr: unsigned(IPBUS_ADDR_WIDTH-1 downto 0) := to_unsigned(1, IPBUS_ADDR_WIDTH);
89  variable ram_we, endaddr_pending, we_active: std_logic;
90  variable ram_data: std_logic_vector(63 downto 0);
91  begin
92  if rising_edge(clk_320) then
93  ram_we := '0';
94  ram_addr := next_addr;
95  ram_data := (Others => '0');
96  if (rst_320 = '1') or (rst_ipbus_addr = '1') then
97  next_addr := min_addr;
98  endaddr_pending := '0';
99  we_active := '1';
100  elsif (fifo_valid_i = '1') and (fifo_tready_i = '1') then
101  ram_we := we_active;
102  ram_data := fifo_data_i;
103  endaddr_pending := fifo_last_i;
104  if (next_addr = max_addr) then
105  next_addr := min_addr;
106 -- Disable WE if wrapping around in RAM and ipbus_wraparound not set
107  we_active := ipbus_wraparound;
108  else
109  next_addr := next_addr + 1;
110  end if;
111  elsif (endaddr_pending = '1') then
112  ram_we := we_active;
113  ram_addr := (Others => '0');
114  ram_data(63 downto IPBUS_ADDR_WIDTH+1) := (Others => '0');
115  ram_data(IPBUS_ADDR_WIDTH downto 1) := std_logic_vector(next_addr);
116  ram_data(0) := '0';
117  endaddr_pending := '0';
118  end if;
119  IPBus_RAM_we_i <= ram_we
120 -- pragma translate_off
121  after 2 ns
122 -- pragma translate_on
123  ;
124  IPBus_RAM_din_i <= ram_data
125 -- pragma translate_off
126  after 2 ns
127 -- pragma translate_on
128  ;
129  IPBus_RAM_addr_i <= std_logic_vector(ram_addr)
130 -- pragma translate_off
131  after 2 ns
132 -- pragma translate_on
133  ;
134  end if;
135  end process ipbus_ram_block;
136 
137 fifo_reg_block: process(clk_320)
138  begin
139  if rising_edge(clk_320) then
140  fifo_data_i <= fifo_data
141 -- pragma translate_off
142  after 2 ns
143 -- pragma translate_on
144  ;
145  fifo_valid_i <= fifo_valid
146 -- pragma translate_off
147  after 2 ns
148 -- pragma translate_on
149  ;
150  fifo_last_i <= fifo_last
151 -- pragma translate_off
152  after 2 ns
153 -- pragma translate_on
154  ;
155  fifo_tready_i <= fifo_tready
156 -- pragma translate_off
157  after 2 ns
158 -- pragma translate_on
159  ;
160  end if;
161  end process fifo_reg_block;
162 
163 ipbus_ram_reg_block: process(clk_320)
164  begin
165  if rising_edge(clk_320) then
166  IPBus_RAM_din <= IPBus_RAM_din_i
167 -- pragma translate_off
168  after 2 ns
169 -- pragma translate_on
170  ;
171  IPBus_RAM_addr <= IPBus_RAM_addr_i
172 -- pragma translate_off
173  after 2 ns
174 -- pragma translate_on
175  ;
176  IPBus_RAM_we <= IPBus_RAM_we_i
177 -- pragma translate_off
178  after 2 ns
179 -- pragma translate_on
180  ;
181  end if;
182  end process ipbus_ram_reg_block;
183 
184 END Architecture rtl;
Capture FIFO traffic into IPBus DPRAM64...
Definition: fifo_spy.vhd:44
Capture FIFO traffic into IPBus DPRAM64...
Definition: fifo_spy.vhd:21