hw_cpu_dwt.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef __HW_CPU_DWT_H__
34 #define __HW_CPU_DWT_H__
35 
36 //*****************************************************************************
37 //
38 // This section defines the register offsets of
39 // CPU_DWT component
40 //
41 //*****************************************************************************
42 // Control
43 #define CPU_DWT_O_CTRL 0x00000000
44 
45 // Current PC Sampler Cycle Count
46 #define CPU_DWT_O_CYCCNT 0x00000004
47 
48 // CPI Count
49 #define CPU_DWT_O_CPICNT 0x00000008
50 
51 // Exception Overhead Count
52 #define CPU_DWT_O_EXCCNT 0x0000000C
53 
54 // Sleep Count
55 #define CPU_DWT_O_SLEEPCNT 0x00000010
56 
57 // LSU Count
58 #define CPU_DWT_O_LSUCNT 0x00000014
59 
60 // Fold Count
61 #define CPU_DWT_O_FOLDCNT 0x00000018
62 
63 // Program Counter Sample
64 #define CPU_DWT_O_PCSR 0x0000001C
65 
66 // Comparator 0
67 #define CPU_DWT_O_COMP0 0x00000020
68 
69 // Mask 0
70 #define CPU_DWT_O_MASK0 0x00000024
71 
72 // Function 0
73 #define CPU_DWT_O_FUNCTION0 0x00000028
74 
75 // Comparator 1
76 #define CPU_DWT_O_COMP1 0x00000030
77 
78 // Mask 1
79 #define CPU_DWT_O_MASK1 0x00000034
80 
81 // Function 1
82 #define CPU_DWT_O_FUNCTION1 0x00000038
83 
84 // Comparator 2
85 #define CPU_DWT_O_COMP2 0x00000040
86 
87 // Mask 2
88 #define CPU_DWT_O_MASK2 0x00000044
89 
90 // Function 2
91 #define CPU_DWT_O_FUNCTION2 0x00000048
92 
93 // Comparator 3
94 #define CPU_DWT_O_COMP3 0x00000050
95 
96 // Mask 3
97 #define CPU_DWT_O_MASK3 0x00000054
98 
99 // Function 3
100 #define CPU_DWT_O_FUNCTION3 0x00000058
101 
102 // Lock Access Register
103 #define CPU_DWT_O_LAR 0x00000FB0
104 
105 //*****************************************************************************
106 //
107 // Register: CPU_DWT_O_CTRL
108 //
109 //*****************************************************************************
110 
111 // Field: [28] NUMCOMP
112 //
113 // Number of comparators implemented
114 #define CPU_DWT_CTRL_NUMCOMP 0xF0000000
115 #define CPU_DWT_CTRL_NUMCOMP_BITN 28
116 #define CPU_DWT_CTRL_NUMCOMP_M 0xF0000000
117 #define CPU_DWT_CTRL_NUMCOMP_S 28
118 
119 // Field: [25] NOCYCCNT
120 //
121 // When set, CYCCNT is not supported.
122 #define CPU_DWT_CTRL_NOCYCCNT 0x02000000
123 #define CPU_DWT_CTRL_NOCYCCNT_BITN 25
124 #define CPU_DWT_CTRL_NOCYCCNT_M 0x02000000
125 #define CPU_DWT_CTRL_NOCYCCNT_S 25
126 
127 // Field: [24] NOPRFCNT
128 //
129 // When set, FOLDCNT, LSUCNT, SLEEPCNT, EXCCNT, and CPICNT are not supported.
130 #define CPU_DWT_CTRL_NOPRFCNT 0x01000000
131 #define CPU_DWT_CTRL_NOPRFCNT_BITN 24
132 #define CPU_DWT_CTRL_NOPRFCNT_M 0x01000000
133 #define CPU_DWT_CTRL_NOPRFCNT_S 24
134 
135 // Field: [22] CYCEVTENA
136 //
137 // Enables Cycle count event. Emits an event when the POSTCNT counter triggers
138 // it. See CYCTAP and POSTPRESET for details. This event is only emitted if
139 // PCSAMPLEENA is disabled. PCSAMPLEENA overrides the setting of this bit.
140 //
141 // 0: Cycle count events disabled
142 // 1: Cycle count events enabled
143 #define CPU_DWT_CTRL_CYCEVTENA 0x00400000
144 #define CPU_DWT_CTRL_CYCEVTENA_BITN 22
145 #define CPU_DWT_CTRL_CYCEVTENA_M 0x00400000
146 #define CPU_DWT_CTRL_CYCEVTENA_S 22
147 
148 // Field: [21] FOLDEVTENA
149 //
150 // Enables Folded instruction count event. Emits an event when FOLDCNT
151 // overflows (every 256 cycles of folded instructions). A folded instruction is
152 // one that does not incur even one cycle to execute. For example, an IT
153 // instruction is folded away and so does not use up one cycle.
154 //
155 // 0: Folded instruction count events disabled.
156 // 1: Folded instruction count events enabled.
157 #define CPU_DWT_CTRL_FOLDEVTENA 0x00200000
158 #define CPU_DWT_CTRL_FOLDEVTENA_BITN 21
159 #define CPU_DWT_CTRL_FOLDEVTENA_M 0x00200000
160 #define CPU_DWT_CTRL_FOLDEVTENA_S 21
161 
162 // Field: [20] LSUEVTENA
163 //
164 // Enables LSU count event. Emits an event when LSUCNT overflows (every 256
165 // cycles of LSU operation). LSU counts include all LSU costs after the initial
166 // cycle for the instruction.
167 //
168 // 0: LSU count events disabled.
169 // 1: LSU count events enabled.
170 #define CPU_DWT_CTRL_LSUEVTENA 0x00100000
171 #define CPU_DWT_CTRL_LSUEVTENA_BITN 20
172 #define CPU_DWT_CTRL_LSUEVTENA_M 0x00100000
173 #define CPU_DWT_CTRL_LSUEVTENA_S 20
174 
175 // Field: [19] SLEEPEVTENA
176 //
177 // Enables Sleep count event. Emits an event when SLEEPCNT overflows (every 256
178 // cycles that the processor is sleeping).
179 //
180 // 0: Sleep count events disabled.
181 // 1: Sleep count events enabled.
182 #define CPU_DWT_CTRL_SLEEPEVTENA 0x00080000
183 #define CPU_DWT_CTRL_SLEEPEVTENA_BITN 19
184 #define CPU_DWT_CTRL_SLEEPEVTENA_M 0x00080000
185 #define CPU_DWT_CTRL_SLEEPEVTENA_S 19
186 
187 // Field: [18] EXCEVTENA
188 //
189 // Enables Interrupt overhead event. Emits an event when EXCCNT overflows
190 // (every 256 cycles of interrupt overhead).
191 //
192 // 0x0: Interrupt overhead event disabled.
193 // 0x1: Interrupt overhead event enabled.
194 #define CPU_DWT_CTRL_EXCEVTENA 0x00040000
195 #define CPU_DWT_CTRL_EXCEVTENA_BITN 18
196 #define CPU_DWT_CTRL_EXCEVTENA_M 0x00040000
197 #define CPU_DWT_CTRL_EXCEVTENA_S 18
198 
199 // Field: [17] CPIEVTENA
200 //
201 // Enables CPI count event. Emits an event when CPICNT overflows (every 256
202 // cycles of multi-cycle instructions).
203 //
204 // 0: CPI counter events disabled.
205 // 1: CPI counter events enabled.
206 #define CPU_DWT_CTRL_CPIEVTENA 0x00020000
207 #define CPU_DWT_CTRL_CPIEVTENA_BITN 17
208 #define CPU_DWT_CTRL_CPIEVTENA_M 0x00020000
209 #define CPU_DWT_CTRL_CPIEVTENA_S 17
210 
211 // Field: [16] EXCTRCENA
212 //
213 // Enables Interrupt event tracing.
214 //
215 // 0: Interrupt event trace disabled.
216 // 1: Interrupt event trace enabled.
217 #define CPU_DWT_CTRL_EXCTRCENA 0x00010000
218 #define CPU_DWT_CTRL_EXCTRCENA_BITN 16
219 #define CPU_DWT_CTRL_EXCTRCENA_M 0x00010000
220 #define CPU_DWT_CTRL_EXCTRCENA_S 16
221 
222 // Field: [12] PCSAMPLEENA
223 //
224 // Enables PC Sampling event. A PC sample event is emitted when the POSTCNT
225 // counter triggers it. See CYCTAP and POSTPRESET for details. Enabling this
226 // bit overrides CYCEVTENA.
227 //
228 // 0: PC Sampling event disabled.
229 // 1: Sampling event enabled.
230 #define CPU_DWT_CTRL_PCSAMPLEENA 0x00001000
231 #define CPU_DWT_CTRL_PCSAMPLEENA_BITN 12
232 #define CPU_DWT_CTRL_PCSAMPLEENA_M 0x00001000
233 #define CPU_DWT_CTRL_PCSAMPLEENA_S 12
234 
235 // Field: [11:10] SYNCTAP
236 //
237 // Selects a synchronization packet rate. CYCCNTENA and CPU_ITM:TCR.SYNCENA
238 // must also be enabled for this feature.
239 // Synchronization packets (if enabled) are generated on tap transitions (0 to1
240 // or 1 to 0).
241 // ENUMs:
242 // BIT28 Tap at bit 28 of CYCCNT
243 // BIT26 Tap at bit 26 of CYCCNT
244 // BIT24 Tap at bit 24 of CYCCNT
245 // DIS Disabled. No synchronization packets
246 #define CPU_DWT_CTRL_SYNCTAP_W 2
247 #define CPU_DWT_CTRL_SYNCTAP_M 0x00000C00
248 #define CPU_DWT_CTRL_SYNCTAP_S 10
249 #define CPU_DWT_CTRL_SYNCTAP_BIT28 0x00000C00
250 #define CPU_DWT_CTRL_SYNCTAP_BIT26 0x00000800
251 #define CPU_DWT_CTRL_SYNCTAP_BIT24 0x00000400
252 #define CPU_DWT_CTRL_SYNCTAP_DIS 0x00000000
253 
254 // Field: [9] CYCTAP
255 //
256 // Selects a tap on CYCCNT. These are spaced at bits [6] and [10]. When the
257 // selected bit in CYCCNT changes from 0 to 1 or 1 to 0, it emits into the
258 // POSTCNT, post-scalar counter. That counter then counts down. On a bit change
259 // when post-scalar is 0, it triggers an event for PC sampling or cycle count
260 // event (see details in CYCEVTENA).
261 // ENUMs:
262 // BIT10 Selects bit [10] to tap
263 // BIT6 Selects bit [6] to tap
264 #define CPU_DWT_CTRL_CYCTAP 0x00000200
265 #define CPU_DWT_CTRL_CYCTAP_BITN 9
266 #define CPU_DWT_CTRL_CYCTAP_M 0x00000200
267 #define CPU_DWT_CTRL_CYCTAP_S 9
268 #define CPU_DWT_CTRL_CYCTAP_BIT10 0x00000200
269 #define CPU_DWT_CTRL_CYCTAP_BIT6 0x00000000
270 
271 // Field: [8:5] POSTCNT
272 //
273 // Post-scalar counter for CYCTAP. When the selected tapped bit changes from 0
274 // to 1 or 1 to 0, the post scalar counter is down-counted when not 0. If 0, it
275 // triggers an event for PCSAMPLEENA or CYCEVTENA use. It also reloads with the
276 // value from POSTPRESET.
277 #define CPU_DWT_CTRL_POSTCNT_W 4
278 #define CPU_DWT_CTRL_POSTCNT_M 0x000001E0
279 #define CPU_DWT_CTRL_POSTCNT_S 5
280 
281 // Field: [4:1] POSTPRESET
282 //
283 // Reload value for post-scalar counter POSTCNT. When 0, events are triggered
284 // on each tap change (a power of 2). If this field has a non-0 value, it forms
285 // a count-down value, to be reloaded into POSTCNT each time it reaches 0. For
286 // example, a value 1 in this register means an event is formed every other tap
287 // change.
288 #define CPU_DWT_CTRL_POSTPRESET_W 4
289 #define CPU_DWT_CTRL_POSTPRESET_M 0x0000001E
290 #define CPU_DWT_CTRL_POSTPRESET_S 1
291 
292 // Field: [0] CYCCNTENA
293 //
294 // Enable CYCCNT, allowing it to increment and generate synchronization and
295 // count events. If NOCYCCNT = 1, this bit reads zero and ignore writes.
296 #define CPU_DWT_CTRL_CYCCNTENA 0x00000001
297 #define CPU_DWT_CTRL_CYCCNTENA_BITN 0
298 #define CPU_DWT_CTRL_CYCCNTENA_M 0x00000001
299 #define CPU_DWT_CTRL_CYCCNTENA_S 0
300 
301 //*****************************************************************************
302 //
303 // Register: CPU_DWT_O_CYCCNT
304 //
305 //*****************************************************************************
306 // Field: [31:0] CYCCNT
307 //
308 // Current PC Sampler Cycle Counter count value. When enabled, this counter
309 // counts the number of core cycles, except when the core is halted. The cycle
310 // counter is a free running counter, counting upwards (this counter will not
311 // advance in power modes where free-running clock to CPU stops). It wraps
312 // around to 0 on overflow. The debugger must initialize this to 0 when first
313 // enabling.
314 #define CPU_DWT_CYCCNT_CYCCNT_W 32
315 #define CPU_DWT_CYCCNT_CYCCNT_M 0xFFFFFFFF
316 #define CPU_DWT_CYCCNT_CYCCNT_S 0
317 
318 //*****************************************************************************
319 //
320 // Register: CPU_DWT_O_CPICNT
321 //
322 //*****************************************************************************
323 // Field: [7:0] CPICNT
324 //
325 // Current CPI counter value. Increments on the additional cycles (the first
326 // cycle is not counted) required to execute all instructions except those
327 // recorded by LSUCNT. This counter also increments on all instruction fetch
328 // stalls. If CTRL.CPIEVTENA is set, an event is emitted when the counter
329 // overflows. This counter initializes to 0 when it is enabled using
330 // CTRL.CPIEVTENA.
331 #define CPU_DWT_CPICNT_CPICNT_W 8
332 #define CPU_DWT_CPICNT_CPICNT_M 0x000000FF
333 #define CPU_DWT_CPICNT_CPICNT_S 0
334 
335 //*****************************************************************************
336 //
337 // Register: CPU_DWT_O_EXCCNT
338 //
339 //*****************************************************************************
340 // Field: [7:0] EXCCNT
341 //
342 // Current interrupt overhead counter value. Counts the total cycles spent in
343 // interrupt processing (for example entry stacking, return unstacking,
344 // pre-emption). An event is emitted on counter overflow (every 256 cycles).
345 // This counter initializes to 0 when it is enabled using CTRL.EXCEVTENA.
346 #define CPU_DWT_EXCCNT_EXCCNT_W 8
347 #define CPU_DWT_EXCCNT_EXCCNT_M 0x000000FF
348 #define CPU_DWT_EXCCNT_EXCCNT_S 0
349 
350 //*****************************************************************************
351 //
352 // Register: CPU_DWT_O_SLEEPCNT
353 //
354 //*****************************************************************************
355 // Field: [7:0] SLEEPCNT
356 //
357 // Sleep counter. Counts the number of cycles during which the processor is
358 // sleeping. An event is emitted on counter overflow (every 256 cycles). This
359 // counter initializes to 0 when it is enabled using CTRL.SLEEPEVTENA. Note
360 // that the sleep counter is clocked using CPU's free-running clock. In some
361 // power modes the free-running clock to CPU is gated to minimize power
362 // consumption. This means that the sleep counter will be invalid in these
363 // power modes.
364 #define CPU_DWT_SLEEPCNT_SLEEPCNT_W 8
365 #define CPU_DWT_SLEEPCNT_SLEEPCNT_M 0x000000FF
366 #define CPU_DWT_SLEEPCNT_SLEEPCNT_S 0
367 
368 //*****************************************************************************
369 //
370 // Register: CPU_DWT_O_LSUCNT
371 //
372 //*****************************************************************************
373 // Field: [7:0] LSUCNT
374 //
375 // LSU counter. This counts the total number of cycles that the processor is
376 // processing an LSU operation. The initial execution cost of the instruction
377 // is not counted. For example, an LDR that takes two cycles to complete
378 // increments this counter one cycle. Equivalently, an LDR that stalls for two
379 // cycles (i.e. takes four cycles to execute), increments this counter three
380 // times. An event is emitted on counter overflow (every 256 cycles). This
381 // counter initializes to 0 when it is enabled using CTRL.LSUEVTENA.
382 #define CPU_DWT_LSUCNT_LSUCNT_W 8
383 #define CPU_DWT_LSUCNT_LSUCNT_M 0x000000FF
384 #define CPU_DWT_LSUCNT_LSUCNT_S 0
385 
386 //*****************************************************************************
387 //
388 // Register: CPU_DWT_O_FOLDCNT
389 //
390 //*****************************************************************************
391 // Field: [7:0] FOLDCNT
392 //
393 // This counts the total number folded instructions. This counter initializes
394 // to 0 when it is enabled using CTRL.FOLDEVTENA.
395 #define CPU_DWT_FOLDCNT_FOLDCNT_W 8
396 #define CPU_DWT_FOLDCNT_FOLDCNT_M 0x000000FF
397 #define CPU_DWT_FOLDCNT_FOLDCNT_S 0
398 
399 //*****************************************************************************
400 //
401 // Register: CPU_DWT_O_PCSR
402 //
403 //*****************************************************************************
404 // Field: [31:0] EIASAMPLE
405 //
406 // Execution instruction address sample, or 0xFFFFFFFF if the core is halted.
407 #define CPU_DWT_PCSR_EIASAMPLE_W 32
408 #define CPU_DWT_PCSR_EIASAMPLE_M 0xFFFFFFFF
409 #define CPU_DWT_PCSR_EIASAMPLE_S 0
410 
411 //*****************************************************************************
412 //
413 // Register: CPU_DWT_O_COMP0
414 //
415 //*****************************************************************************
416 // Field: [31:0] COMP
417 //
418 // Reference value to compare against PC or the data address as given by
419 // FUNCTION0. Comparator 0 can also compare against the value of the PC Sampler
420 // Counter (CYCCNT).
421 #define CPU_DWT_COMP0_COMP_W 32
422 #define CPU_DWT_COMP0_COMP_M 0xFFFFFFFF
423 #define CPU_DWT_COMP0_COMP_S 0
424 
425 //*****************************************************************************
426 //
427 // Register: CPU_DWT_O_MASK0
428 //
429 //*****************************************************************************
430 // Field: [3:0] MASK
431 //
432 // Mask on data address when matching against COMP0. This is the size of the
433 // ignore mask. That is, DWT matching is performed as:(ADDR ANDed with (0xFFFF
434 // left bit-shifted by MASK)) == COMP0. However, the actual comparison is
435 // slightly more complex to enable matching an address wherever it appears on a
436 // bus. So, if COMP0 is 3, this matches a word access of 0, because 3 would be
437 // within the word.
438 #define CPU_DWT_MASK0_MASK_W 4
439 #define CPU_DWT_MASK0_MASK_M 0x0000000F
440 #define CPU_DWT_MASK0_MASK_S 0
441 
442 //*****************************************************************************
443 //
444 // Register: CPU_DWT_O_FUNCTION0
445 //
446 //*****************************************************************************
447 // Field: [24] MATCHED
448 //
449 // This bit is set when the comparator matches, and indicates that the
450 // operation defined by FUNCTION has occurred since this bit was last read.
451 // This bit is cleared on read.
452 #define CPU_DWT_FUNCTION0_MATCHED 0x01000000
453 #define CPU_DWT_FUNCTION0_MATCHED_BITN 24
454 #define CPU_DWT_FUNCTION0_MATCHED_M 0x01000000
455 #define CPU_DWT_FUNCTION0_MATCHED_S 24
456 
457 // Field: [7] CYCMATCH
458 //
459 // This bit is only available in comparator 0. When set, COMP0 will compare
460 // against the cycle counter (CYCCNT).
461 #define CPU_DWT_FUNCTION0_CYCMATCH 0x00000080
462 #define CPU_DWT_FUNCTION0_CYCMATCH_BITN 7
463 #define CPU_DWT_FUNCTION0_CYCMATCH_M 0x00000080
464 #define CPU_DWT_FUNCTION0_CYCMATCH_S 7
465 
466 // Field: [5] EMITRANGE
467 //
468 // Emit range field. This bit permits emitting offset when range match occurs.
469 // PC sampling is not supported when emit range is enabled.
470 // This field only applies for: FUNCTION = 1, 2, 3, 12, 13, 14, and 15.
471 #define CPU_DWT_FUNCTION0_EMITRANGE 0x00000020
472 #define CPU_DWT_FUNCTION0_EMITRANGE_BITN 5
473 #define CPU_DWT_FUNCTION0_EMITRANGE_M 0x00000020
474 #define CPU_DWT_FUNCTION0_EMITRANGE_S 5
475 
476 // Field: [3:0] FUNCTION
477 //
478 // Function settings.
479 //
480 // 0x0: Disabled
481 // 0x1: EMITRANGE = 0, sample and emit PC through ITM. EMITRANGE = 1, emit
482 // address offset through ITM
483 // 0x2: EMITRANGE = 0, emit data through ITM on read and write. EMITRANGE = 1,
484 // emit data and address offset through ITM on read or write.
485 // 0x3: EMITRANGE = 0, sample PC and data value through ITM on read or write.
486 // EMITRANGE = 1, emit address offset and data value through ITM on read or
487 // write.
488 // 0x4: Watchpoint on PC match.
489 // 0x5: Watchpoint on read.
490 // 0x6: Watchpoint on write.
491 // 0x7: Watchpoint on read or write.
492 // 0x8: ETM trigger on PC match
493 // 0x9: ETM trigger on read
494 // 0xA: ETM trigger on write
495 // 0xB: ETM trigger on read or write
496 // 0xC: EMITRANGE = 0, sample data for read transfers. EMITRANGE = 1, sample
497 // Daddr (lower 16 bits) for read transfers
498 // 0xD: EMITRANGE = 0, sample data for write transfers. EMITRANGE = 1, sample
499 // Daddr (lower 16 bits) for write transfers
500 // 0xE: EMITRANGE = 0, sample PC + data for read transfers. EMITRANGE = 1,
501 // sample Daddr (lower 16 bits) + data for read transfers
502 // 0xF: EMITRANGE = 0, sample PC + data for write transfers. EMITRANGE = 1,
503 // sample Daddr (lower 16 bits) + data for write transfers
504 //
505 // Note 1: If the ETM is not fitted, then ETM trigger is not possible.
506 // Note 2: Data value is only sampled for accesses that do not fault (MPU or
507 // bus fault). The PC is sampled irrespective of any faults. The PC is only
508 // sampled for the first address of a burst.
509 // Note 3: PC match is not recommended for watchpoints because it stops after
510 // the instruction. It mainly guards and triggers the ETM.
511 #define CPU_DWT_FUNCTION0_FUNCTION_W 4
512 #define CPU_DWT_FUNCTION0_FUNCTION_M 0x0000000F
513 #define CPU_DWT_FUNCTION0_FUNCTION_S 0
514 
515 //*****************************************************************************
516 //
517 // Register: CPU_DWT_O_COMP1
518 //
519 //*****************************************************************************
520 // Field: [31:0] COMP
521 //
522 // Reference value to compare against PC or the data address as given by
523 // FUNCTION1.
524 // Comparator 1 can also compare data values. So this register can contain
525 // reference values for data matching.
526 #define CPU_DWT_COMP1_COMP_W 32
527 #define CPU_DWT_COMP1_COMP_M 0xFFFFFFFF
528 #define CPU_DWT_COMP1_COMP_S 0
529 
530 //*****************************************************************************
531 //
532 // Register: CPU_DWT_O_MASK1
533 //
534 //*****************************************************************************
535 // Field: [3:0] MASK
536 //
537 // Mask on data address when matching against COMP1. This is the size of the
538 // ignore mask. That is, DWT matching is performed as:(ADDR ANDed with (0xFFFF
539 // left bit-shifted by MASK)) == COMP1. However, the actual comparison is
540 // slightly more complex to enable matching an address wherever it appears on a
541 // bus. So, if COMP1 is 3, this matches a word access of 0, because 3 would be
542 // within the word.
543 #define CPU_DWT_MASK1_MASK_W 4
544 #define CPU_DWT_MASK1_MASK_M 0x0000000F
545 #define CPU_DWT_MASK1_MASK_S 0
546 
547 //*****************************************************************************
548 //
549 // Register: CPU_DWT_O_FUNCTION1
550 //
551 //*****************************************************************************
552 // Field: [24] MATCHED
553 //
554 // This bit is set when the comparator matches, and indicates that the
555 // operation defined by FUNCTION has occurred since this bit was last read.
556 // This bit is cleared on read.
557 #define CPU_DWT_FUNCTION1_MATCHED 0x01000000
558 #define CPU_DWT_FUNCTION1_MATCHED_BITN 24
559 #define CPU_DWT_FUNCTION1_MATCHED_M 0x01000000
560 #define CPU_DWT_FUNCTION1_MATCHED_S 24
561 
562 // Field: [19:16] DATAVADDR1
563 //
564 // Identity of a second linked address comparator for data value matching when
565 // DATAVMATCH == 1 and LNK1ENA == 1.
566 #define CPU_DWT_FUNCTION1_DATAVADDR1_W 4
567 #define CPU_DWT_FUNCTION1_DATAVADDR1_M 0x000F0000
568 #define CPU_DWT_FUNCTION1_DATAVADDR1_S 16
569 
570 // Field: [15:12] DATAVADDR0
571 //
572 // Identity of a linked address comparator for data value matching when
573 // DATAVMATCH == 1.
574 #define CPU_DWT_FUNCTION1_DATAVADDR0_W 4
575 #define CPU_DWT_FUNCTION1_DATAVADDR0_M 0x0000F000
576 #define CPU_DWT_FUNCTION1_DATAVADDR0_S 12
577 
578 // Field: [11:10] DATAVSIZE
579 //
580 // Defines the size of the data in the COMP1 register that is to be matched:
581 //
582 // 0x0: Byte
583 // 0x1: Halfword
584 // 0x2: Word
585 // 0x3: Unpredictable.
586 #define CPU_DWT_FUNCTION1_DATAVSIZE_W 2
587 #define CPU_DWT_FUNCTION1_DATAVSIZE_M 0x00000C00
588 #define CPU_DWT_FUNCTION1_DATAVSIZE_S 10
589 
590 // Field: [9] LNK1ENA
591 //
592 // Read only bit-field only supported in comparator 1.
593 //
594 // 0: DATAVADDR1 not supported
595 // 1: DATAVADDR1 supported (enabled)
596 #define CPU_DWT_FUNCTION1_LNK1ENA 0x00000200
597 #define CPU_DWT_FUNCTION1_LNK1ENA_BITN 9
598 #define CPU_DWT_FUNCTION1_LNK1ENA_M 0x00000200
599 #define CPU_DWT_FUNCTION1_LNK1ENA_S 9
600 
601 // Field: [8] DATAVMATCH
602 //
603 // Data match feature:
604 //
605 // 0: Perform address comparison
606 // 1: Perform data value compare. The comparators given by DATAVADDR0 and
607 // DATAVADDR1 provide the address for the data comparison. The FUNCTION setting
608 // for the comparators given by DATAVADDR0 and DATAVADDR1 are overridden and
609 // those comparators only provide the address match for the data comparison.
610 //
611 // This bit is only available in comparator 1.
612 #define CPU_DWT_FUNCTION1_DATAVMATCH 0x00000100
613 #define CPU_DWT_FUNCTION1_DATAVMATCH_BITN 8
614 #define CPU_DWT_FUNCTION1_DATAVMATCH_M 0x00000100
615 #define CPU_DWT_FUNCTION1_DATAVMATCH_S 8
616 
617 // Field: [5] EMITRANGE
618 //
619 // Emit range field. This bit permits emitting offset when range match occurs.
620 // PC sampling is not supported when emit range is enabled.
621 // This field only applies for: FUNCTION = 1, 2, 3, 12, 13, 14, and 15.
622 #define CPU_DWT_FUNCTION1_EMITRANGE 0x00000020
623 #define CPU_DWT_FUNCTION1_EMITRANGE_BITN 5
624 #define CPU_DWT_FUNCTION1_EMITRANGE_M 0x00000020
625 #define CPU_DWT_FUNCTION1_EMITRANGE_S 5
626 
627 // Field: [3:0] FUNCTION
628 //
629 // Function settings:
630 //
631 // 0x0: Disabled
632 // 0x1: EMITRANGE = 0, sample and emit PC through ITM. EMITRANGE = 1, emit
633 // address offset through ITM
634 // 0x2: EMITRANGE = 0, emit data through ITM on read and write. EMITRANGE = 1,
635 // emit data and address offset through ITM on read or write.
636 // 0x3: EMITRANGE = 0, sample PC and data value through ITM on read or write.
637 // EMITRANGE = 1, emit address offset and data value through ITM on read or
638 // write.
639 // 0x4: Watchpoint on PC match.
640 // 0x5: Watchpoint on read.
641 // 0x6: Watchpoint on write.
642 // 0x7: Watchpoint on read or write.
643 // 0x8: ETM trigger on PC match
644 // 0x9: ETM trigger on read
645 // 0xA: ETM trigger on write
646 // 0xB: ETM trigger on read or write
647 // 0xC: EMITRANGE = 0, sample data for read transfers. EMITRANGE = 1, sample
648 // Daddr (lower 16 bits) for read transfers
649 // 0xD: EMITRANGE = 0, sample data for write transfers. EMITRANGE = 1, sample
650 // Daddr (lower 16 bits) for write transfers
651 // 0xE: EMITRANGE = 0, sample PC + data for read transfers. EMITRANGE = 1,
652 // sample Daddr (lower 16 bits) + data for read transfers
653 // 0xF: EMITRANGE = 0, sample PC + data for write transfers. EMITRANGE = 1,
654 // sample Daddr (lower 16 bits) + data for write transfers
655 //
656 // Note 1: If the ETM is not fitted, then ETM trigger is not possible.
657 // Note 2: Data value is only sampled for accesses that do not fault (MPU or
658 // bus fault). The PC is sampled irrespective of any faults. The PC is only
659 // sampled for the first address of a burst.
660 // Note 3: FUNCTION is overridden for comparators given by DATAVADDR0 and
661 // DATAVADDR1 if DATAVMATCH is also set. The comparators given by DATAVADDR0
662 // and DATAVADDR1 can then only perform address comparator matches for
663 // comparator 1 data matches.
664 // Note 4: If the data matching functionality is not included during
665 // implementation it is not possible to set DATAVADDR0, DATAVADDR1, or
666 // DATAVMATCH. This means that the data matching functionality is not available
667 // in the implementation. Test the availability of data matching by writing and
668 // reading DATAVMATCH. If it is not settable then data matching is unavailable.
669 // Note 5: PC match is not recommended for watchpoints because it stops after
670 // the instruction. It mainly guards and triggers the ETM.
671 #define CPU_DWT_FUNCTION1_FUNCTION_W 4
672 #define CPU_DWT_FUNCTION1_FUNCTION_M 0x0000000F
673 #define CPU_DWT_FUNCTION1_FUNCTION_S 0
674 
675 //*****************************************************************************
676 //
677 // Register: CPU_DWT_O_COMP2
678 //
679 //*****************************************************************************
680 // Field: [31:0] COMP
681 //
682 // Reference value to compare against PC or the data address as given by
683 // FUNCTION2.
684 #define CPU_DWT_COMP2_COMP_W 32
685 #define CPU_DWT_COMP2_COMP_M 0xFFFFFFFF
686 #define CPU_DWT_COMP2_COMP_S 0
687 
688 //*****************************************************************************
689 //
690 // Register: CPU_DWT_O_MASK2
691 //
692 //*****************************************************************************
693 // Field: [3:0] MASK
694 //
695 // Mask on data address when matching against COMP2. This is the size of the
696 // ignore mask. That is, DWT matching is performed as:(ADDR ANDed with (0xFFFF
697 // left bit-shifted by MASK)) == COMP2. However, the actual comparison is
698 // slightly more complex to enable matching an address wherever it appears on a
699 // bus. So, if COMP2 is 3, this matches a word access of 0, because 3 would be
700 // within the word.
701 #define CPU_DWT_MASK2_MASK_W 4
702 #define CPU_DWT_MASK2_MASK_M 0x0000000F
703 #define CPU_DWT_MASK2_MASK_S 0
704 
705 //*****************************************************************************
706 //
707 // Register: CPU_DWT_O_FUNCTION2
708 //
709 //*****************************************************************************
710 // Field: [24] MATCHED
711 //
712 // This bit is set when the comparator matches, and indicates that the
713 // operation defined by FUNCTION has occurred since this bit was last read.
714 // This bit is cleared on read.
715 #define CPU_DWT_FUNCTION2_MATCHED 0x01000000
716 #define CPU_DWT_FUNCTION2_MATCHED_BITN 24
717 #define CPU_DWT_FUNCTION2_MATCHED_M 0x01000000
718 #define CPU_DWT_FUNCTION2_MATCHED_S 24
719 
720 // Field: [5] EMITRANGE
721 //
722 // Emit range field. This bit permits emitting offset when range match occurs.
723 // PC sampling is not supported when emit range is enabled.
724 // This field only applies for: FUNCTION = 1, 2, 3, 12, 13, 14, and 15.
725 #define CPU_DWT_FUNCTION2_EMITRANGE 0x00000020
726 #define CPU_DWT_FUNCTION2_EMITRANGE_BITN 5
727 #define CPU_DWT_FUNCTION2_EMITRANGE_M 0x00000020
728 #define CPU_DWT_FUNCTION2_EMITRANGE_S 5
729 
730 // Field: [3:0] FUNCTION
731 //
732 // Function settings.
733 //
734 // 0x0: Disabled
735 // 0x1: EMITRANGE = 0, sample and emit PC through ITM. EMITRANGE = 1, emit
736 // address offset through ITM
737 // 0x2: EMITRANGE = 0, emit data through ITM on read and write. EMITRANGE = 1,
738 // emit data and address offset through ITM on read or write.
739 // 0x3: EMITRANGE = 0, sample PC and data value through ITM on read or write.
740 // EMITRANGE = 1, emit address offset and data value through ITM on read or
741 // write.
742 // 0x4: Watchpoint on PC match.
743 // 0x5: Watchpoint on read.
744 // 0x6: Watchpoint on write.
745 // 0x7: Watchpoint on read or write.
746 // 0x8: ETM trigger on PC match
747 // 0x9: ETM trigger on read
748 // 0xA: ETM trigger on write
749 // 0xB: ETM trigger on read or write
750 // 0xC: EMITRANGE = 0, sample data for read transfers. EMITRANGE = 1, sample
751 // Daddr (lower 16 bits) for read transfers
752 // 0xD: EMITRANGE = 0, sample data for write transfers. EMITRANGE = 1, sample
753 // Daddr (lower 16 bits) for write transfers
754 // 0xE: EMITRANGE = 0, sample PC + data for read transfers. EMITRANGE = 1,
755 // sample Daddr (lower 16 bits) + data for read transfers
756 // 0xF: EMITRANGE = 0, sample PC + data for write transfers. EMITRANGE = 1,
757 // sample Daddr (lower 16 bits) + data for write transfers
758 //
759 // Note 1: If the ETM is not fitted, then ETM trigger is not possible.
760 // Note 2: Data value is only sampled for accesses that do not fault (MPU or
761 // bus fault). The PC is sampled irrespective of any faults. The PC is only
762 // sampled for the first address of a burst.
763 // Note 3: PC match is not recommended for watchpoints because it stops after
764 // the instruction. It mainly guards and triggers the ETM.
765 #define CPU_DWT_FUNCTION2_FUNCTION_W 4
766 #define CPU_DWT_FUNCTION2_FUNCTION_M 0x0000000F
767 #define CPU_DWT_FUNCTION2_FUNCTION_S 0
768 
769 //*****************************************************************************
770 //
771 // Register: CPU_DWT_O_COMP3
772 //
773 //*****************************************************************************
774 // Field: [31:0] COMP
775 //
776 // Reference value to compare against PC or the data address as given by
777 // FUNCTION3.
778 #define CPU_DWT_COMP3_COMP_W 32
779 #define CPU_DWT_COMP3_COMP_M 0xFFFFFFFF
780 #define CPU_DWT_COMP3_COMP_S 0
781 
782 //*****************************************************************************
783 //
784 // Register: CPU_DWT_O_MASK3
785 //
786 //*****************************************************************************
787 // Field: [3:0] MASK
788 //
789 // Mask on data address when matching against COMP3. This is the size of the
790 // ignore mask. That is, DWT matching is performed as:(ADDR ANDed with (0xFFFF
791 // left bit-shifted by MASK)) == COMP3. However, the actual comparison is
792 // slightly more complex to enable matching an address wherever it appears on a
793 // bus. So, if COMP3 is 3, this matches a word access of 0, because 3 would be
794 // within the word.
795 #define CPU_DWT_MASK3_MASK_W 4
796 #define CPU_DWT_MASK3_MASK_M 0x0000000F
797 #define CPU_DWT_MASK3_MASK_S 0
798 
799 //*****************************************************************************
800 //
801 // Register: CPU_DWT_O_FUNCTION3
802 //
803 //*****************************************************************************
804 // Field: [24] MATCHED
805 //
806 // This bit is set when the comparator matches, and indicates that the
807 // operation defined by FUNCTION has occurred since this bit was last read.
808 // This bit is cleared on read.
809 #define CPU_DWT_FUNCTION3_MATCHED 0x01000000
810 #define CPU_DWT_FUNCTION3_MATCHED_BITN 24
811 #define CPU_DWT_FUNCTION3_MATCHED_M 0x01000000
812 #define CPU_DWT_FUNCTION3_MATCHED_S 24
813 
814 // Field: [5] EMITRANGE
815 //
816 // Emit range field. This bit permits emitting offset when range match occurs.
817 // PC sampling is not supported when emit range is enabled.
818 // This field only applies for: FUNCTION = 1, 2, 3, 12, 13, 14, and 15.
819 #define CPU_DWT_FUNCTION3_EMITRANGE 0x00000020
820 #define CPU_DWT_FUNCTION3_EMITRANGE_BITN 5
821 #define CPU_DWT_FUNCTION3_EMITRANGE_M 0x00000020
822 #define CPU_DWT_FUNCTION3_EMITRANGE_S 5
823 
824 // Field: [3:0] FUNCTION
825 //
826 // Function settings.
827 //
828 // 0x0: Disabled
829 // 0x1: EMITRANGE = 0, sample and emit PC through ITM. EMITRANGE = 1, emit
830 // address offset through ITM
831 // 0x2: EMITRANGE = 0, emit data through ITM on read and write. EMITRANGE = 1,
832 // emit data and address offset through ITM on read or write.
833 // 0x3: EMITRANGE = 0, sample PC and data value through ITM on read or write.
834 // EMITRANGE = 1, emit address offset and data value through ITM on read or
835 // write.
836 // 0x4: Watchpoint on PC match.
837 // 0x5: Watchpoint on read.
838 // 0x6: Watchpoint on write.
839 // 0x7: Watchpoint on read or write.
840 // 0x8: ETM trigger on PC match
841 // 0x9: ETM trigger on read
842 // 0xA: ETM trigger on write
843 // 0xB: ETM trigger on read or write
844 // 0xC: EMITRANGE = 0, sample data for read transfers. EMITRANGE = 1, sample
845 // Daddr (lower 16 bits) for read transfers
846 // 0xD: EMITRANGE = 0, sample data for write transfers. EMITRANGE = 1, sample
847 // Daddr (lower 16 bits) for write transfers
848 // 0xE: EMITRANGE = 0, sample PC + data for read transfers. EMITRANGE = 1,
849 // sample Daddr (lower 16 bits) + data for read transfers
850 // 0xF: EMITRANGE = 0, sample PC + data for write transfers. EMITRANGE = 1,
851 // sample Daddr (lower 16 bits) + data for write transfers
852 //
853 // Note 1: If the ETM is not fitted, then ETM trigger is not possible.
854 // Note 2: Data value is only sampled for accesses that do not fault (MPU or
855 // bus fault). The PC is sampled irrespective of any faults. The PC is only
856 // sampled for the first address of a burst.
857 // Note 3: PC match is not recommended for watchpoints because it stops after
858 // the instruction. It mainly guards and triggers the ETM.
859 #define CPU_DWT_FUNCTION3_FUNCTION_W 4
860 #define CPU_DWT_FUNCTION3_FUNCTION_M 0x0000000F
861 #define CPU_DWT_FUNCTION3_FUNCTION_S 0
862 
863 #endif // __CPU_DWT__
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale