ROD firmware  1.0.5
ATLAS l1-calo - ROD_eFEX and ROD_jFEX firmware for the L1Calo ROD board

Back to ROD documentation
Processor_trace_module.vhd
1 ----------------------------------------------------------------------------------
2 -- Company:
3 -- Engineer:
4 --
5 -- Create Date: 24.03.2022 10:45:16
6 -- Design Name:
7 -- Module Name: Processor_trace_module - RTL
8 -- Project Name:
9 -- Target Devices:
10 -- Tool Versions:
11 -- Description:
12 --
13 -- Dependencies:
14 --
15 -- Revision:
16 -- Revision 0.01 - File Created
17 -- Additional Comments:
18 --
19 ----------------------------------------------------------------------------------
20 
21 
22 library IEEE;
23 use IEEE.STD_LOGIC_1164.ALL;
24 use IEEE.STD_LOGIC_UNSIGNED.ALL;
25 use IEEE.NUMERIC_STD.ALL;
26 use work.ipbus.all;
27 use work.ipbus_decode_L1CaloHubRodTrace.all;
28 
30  generic(
31  ADDR_WIDTH: positive := 8;
32  DATA_WIDTH: positive := 32
33  );
34  Port (
35  ipb_clk : in std_logic;
36  ipb_rst : in std_logic;
37  ipb_in : in ipb_wbus;
38  ipb_out : out ipb_rbus;
39 
40  pp_clock : in STD_LOGIC;
41  reset : in STD_LOGIC;
42  trace_input : in STD_LOGIC_VECTOR (23 downto 0); --connect to signals to be traced in addition to state
43  state : in STD_LOGIC_VECTOR (7 downto 0); --processor "state" plus any other signals to trace
44 -- trig_state : in STD_LOGIC_VECTOR (7 downto 0); --the state to trigger on
45  wd_event : in STD_LOGIC; --watchdog overflow signal
46  timeout_error : in STD_LOGIC --one pp_clock cycle timeout error pulse
47 
48 );
49 
50 
51 
52 end Processor_trace_module;
53 
54 architecture RTL of Processor_trace_module is
55 
56 component ipbus_dpram is
57  generic(
58  ADDR_WIDTH: positive := 8;
59  DATA_WIDTH: positive := 32
60  );
61  port(
62 
63 -- ipb_addr: in std_logic_vector(ADDR_WIDTH - 1 downto 0);
64 -- ipb_rdata: out std_logic_vector(31 downto 0);
65 -- ipb_strobe: in std_logic;
66 -- ipb_write: in std_logic;
67 -- ipb_wdata: in std_logic_vector(DATA_WIDTH - 1 downto 0);
68 -- ipb_ack : out std_logic;
69 -- ipb_err : out std_logic;
70 
71 
72  clk: in std_logic;
73  rst: in std_logic;
74  ipb_in: in ipb_wbus;
75  ipb_out: out ipb_rbus;
76  rclk: in std_logic;
77  we: in std_logic := '0';
78  d: in std_logic_vector(DATA_WIDTH - 1 downto 0) := (others => '0');
79  q: out std_logic_vector(DATA_WIDTH - 1 downto 0);
80  addr: in std_logic_vector(ADDR_WIDTH - 1 downto 0)
81  );
82 
83 
84 
85 end component;
86 
87 component proc_trace is
88  generic ( addr_width : integer := 8;
89  data_width : integer := 32);
90  Port ( clock : in STD_LOGIC;
91  reset : in STD_LOGIC;
92  trace_input : in STD_LOGIC_VECTOR (23 downto 0); --connect to signals to be traced in addition to state
93  state : in STD_LOGIC_VECTOR (7 downto 0); --processor "state" plus any other signals to trace
94  trig_state : in STD_LOGIC_VECTOR (7 downto 0); --the state to trigger on
95  wd_event : in STD_LOGIC; --watchdog overflow signal
96  timeout_error : in STD_LOGIC; --one pp_clock cycle timeout error pulse
97 
98  arm_wd : in STD_LOGIC; --from ipbus pulse register
99  arm_immediate : in STD_LOGIC; --from ipbus pulse register
100  arm_state : in STD_LOGIC; --from ipbus pulse register
101  arm_timeout : in STD_LOGIC; --from ipbus pulse register
102 
103  armed : out STD_LOGIC; --status output to ipbus read register
104  triggered : out STD_LOGIC; --status output to ipbus read register
105 
106  read : in STD_LOGIC; --ipbus register read signal for the trace data out register(strobe and not we)
107  reset_pointer : in STD_LOGIC; --reset the read pointer to start at beginning of trace again
108 -- trace_data_out : out Std_logic_vector (31 downto 0); --trace data output to ipbus read register
109  addr_pointer : out std_logic_vector(addr_width-1 downto 0)
110 
111  ---------memory interface ---
112 -- rclk: in std_logic
113 -- we: out std_logic := '0';
114 -- d: out std_logic_vector(DATA_WIDTH - 1 downto 0) := (others => '0');
115 -- q: in std_logic_vector(DATA_WIDTH - 1 downto 0);
116 -- addr: out std_logic_vector(ADDR_WIDTH - 1 downto 0)
117 
118 
119  );
120 end component;
121 
122 signal ipbw: ipb_wbus_array(N_SLAVES - 1 downto 0);
123 signal ipbr: ipb_rbus_array(N_SLAVES - 1 downto 0);
124 signal trig_state : STD_LOGIC_VECTOR (7 downto 0); --the state to trigger on
125 signal trace_control_reg_rst : std_logic;
126 signal trace_control_reg_stb : std_logic;
127 signal trace_control : std_logic_vector (31 downto 0);
128 
129 
130 signal arm_wd : STD_LOGIC; --from ipbus pulse register
131 signal arm_immediate : STD_LOGIC; --from ipbus pulse register
132 signal arm_state : STD_LOGIC; --
133 signal arm_timeout : STD_LOGIC; --from ipbus pulse register
134 signal trigger_pattern : std_logic_vector(31 downto 0);
135 signal addr_pointer : std_logic_vector(addr_width-1 downto 0);
136 signal trace_data_in : std_logic_vector(data_width-1 downto 0);
137 signal trace_data_out : std_logic_vector(data_width-1 downto 0);
138 signal armed : std_logic; --status output to ipbus read register
139 signal triggered : std_logic;
140 signal ipb_read_strobe : std_logic;
141 signal reset_pointer : std_logic;
142 signal clear : std_logic;
143 signal trace_reset : std_logic;
144 signal trigger_status : std_logic_vector (31 downto 0);
145 signal trigger_pointer : std_logic_vector (31 downto 0);
146 
147 begin
148 
149 fabric: entity work.ipbus_fabric_sel
150  generic map(
151  NSLV => N_SLAVES,
152  SEL_WIDTH => IPBUS_SEL_WIDTH)
153  port map(
154  ipb_in => ipb_in,
155  ipb_out => ipb_out,
156 
157  sel => ipbus_sel_L1CaloHubRodTrace(ipb_in.ipb_addr),
158  ipb_to_slaves => ipbw,
159  ipb_from_slaves => ipbr
160  );
161 
162 
163 
164 --------------------registers------------------------------
165 --pulse reg for arming the capture mech -----
166 Trace_Control_reg: entity work.ipbus_reg_v
167  port map(
168  clk => ipb_clk,
169  reset => trace_control_reg_rst,
170  ipbus_in => ipbw(N_SLV_TRACE_CONTROL),
171  ipbus_out => ipbr(N_SLV_TRACE_CONTROL),
172  stb(0) => trace_control_reg_stb,
173  q(0) => trace_control
174  );
175 trace_control_reg_rst <= trace_control_reg_stb or ipb_rst;
176 
177 arm_wd <= trace_control(0);
178 arm_state <= trace_control(1);
179 arm_immediate <= trace_control(2);
180 arm_timeout <= trace_control(3);
181 clear <= trace_control(4);
182 reset_pointer <= trace_control(5) or trace_control(4);
183 
184 
185 
186 
187 
188 trigger_status_reg: entity work.ipbus_syncreg_v
189  generic map (
190  N_CTRL => 0,
191  N_STAT => 1
192  )
193  port map(
194  clk => ipb_clk,
195  rst => ipb_rst,
196  ipb_in => ipbw(N_SLV_TRIGGER_STATUS),
197  ipb_out => ipbr(N_SLV_TRIGGER_STATUS),
198  slv_clk => pp_clock,
199  d(0) => trigger_status,
200  qmask => (others => (others => '1')),
201  stb => open,
202  rstb => open
203  );
204 
205 trigger_status(0) <= armed;
206 trigger_status(1) <= triggered;
207 trigger_status(31 downto 2) <= (others => '0');
208 
209 
210 Trigger_pattern_reg: entity work.ipbus_reg_v
211  port map(
212  clk => ipb_clk,
213  reset => ipb_rst,
214  ipbus_in => ipbw(N_SLV_TRIGGER_PATTERN),
215  ipbus_out => ipbr(N_SLV_TRIGGER_PATTERN),
216  q(0) => trigger_pattern
217  );
218 
219 
220 trig_state <= trigger_pattern(7 downto 0);
221 
222 trigger_pointer_reg: entity work.ipbus_syncreg_v
223  generic map (
224  N_CTRL => 0,
225  N_STAT => 1
226  )
227  port map(
228  clk => ipb_clk,
229  rst => ipb_rst,
230  ipb_in => ipbw(N_SLV_TRIGGER_POINTER),
231  ipb_out => ipbr(N_SLV_TRIGGER_POINTER),
232  slv_clk => pp_clock,
233  d(0) => trigger_pointer,
234  qmask => (others => (others => '1')),
235  stb => open,
236  rstb => open
237  );
238 
239 trigger_pointer(addr_width-1 downto 0) <= addr_pointer;
240 trigger_pointer(31 downto addr_width) <= (others => '0');
241 
242 trace_words_reg: entity work.ipbus_syncreg_v
243  generic map (
244  N_CTRL => 0,
245  N_STAT => 1
246  )
247  port map(
248  clk => ipb_clk,
249  rst => ipb_rst,
250  ipb_in => ipbw(N_SLV_TRACE_WORDS),
251  ipb_out => ipbr(N_SLV_TRACE_WORDS),
252  slv_clk => pp_clock,
253  d(0) => trace_data_out,
254  qmask => (others => (others => '1')),
255  stb => open,
256  rstb => open
257  );
258 
259 trace_data_in <= trace_input(23 downto 0) & "00" & state(5 downto 0);
260 
261 trace_mem : ipbus_dpram
262  generic map (
263  ADDR_WIDTH => addr_width,
264  DATA_WIDTH => 32
265  )
266  PORT MAP (
267  clk => ipb_clk,
268  rst => reset,
269  ipb_in => ipbw(N_SLV_TRACE_MEMORY),
270  ipb_out => ipbr(N_SLV_TRACE_MEMORY),
271  rclk => pp_clock,
272  we => armed,
273  d => trace_data_in,
274  q => trace_data_out,
275  addr => addr_pointer(addr_width-1 downto 0)
276 
277  );
278 
279 
280 --ipb_read_strobe <= ipbw(N_SLV_TRACE_MEMORY).ipb_strobe;
281 ipb_read_strobe <= ipbw(N_SLV_TRACE_WORDS).ipb_strobe;
282 trace_reset <= ipb_rst or clear or reset;
283 
284 controller : proc_trace
285 
286  generic map ( addr_width => addr_width,
287  data_width => 32)
288  Port map (
289  clock => pp_clock,
290  reset => trace_reset,
291  trace_input => trace_input, --connect to signals to be traced in addition to state
292  state => state, --processor "state" plus any other signals to trace
293  trig_state => trig_state, --the state to trigger on
294  wd_event => wd_event, --watchdog overflow signal
295  timeout_error => timeout_error, --one pp_clock cycle timeout error pulse
296 
297  arm_wd => arm_wd, --from ipbus pulse register
298  arm_immediate => arm_immediate, --from ipbus pulse register
299  arm_state => arm_state, --from ipbus pulse register
300  arm_timeout => arm_timeout, --from ipbus pulse register
301 
302  armed => armed, --status output to ipbus read register
303  triggered => triggered, --status output to ipbus read register
304 
305  read => ipb_read_strobe, --ipbus register read signal for the trace data out register(strobe and not we)
306  reset_pointer => reset_pointer, --reset the read pointer to start at beginning of trace again
307  addr_pointer => addr_pointer
308  );
309 
310 
311 
312 end RTL;