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