Skip to content

Commit 923b61c

Browse files
authored
[tracer] update simulation-mode trace logging (#1368)
2 parents ed92aaa + 1aaa1d2 commit 923b61c

File tree

4 files changed

+217
-181
lines changed

4 files changed

+217
-181
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ mimpid = 0x01040312 -> Version 01.04.03.12 -> v1.4.3.12
2929

3030
| Date | Version | Comment | Ticket |
3131
|:----:|:-------:|:--------|:------:|
32+
| 09.09.2025 | 1.12.1.5 | TRACER: rework instruction decoding logic and add all remaining ISA extensions | [#1368](https://github.com/stnolting/neorv32/pull/1368) |
3233
| 05.09.2025 | 1.12.1.4 | improve TRACER's simulation-mode instruction decoding | [#1366](https://github.com/stnolting/neorv32/pull/1366) |
3334
| 05.09.2025 | 1.12.1.3 | minor rtl edits: add `ndmresetpending` & `stickyunavail` bits to DM's `dmstatus` register; fix interrupt-entry after `wfi` | [#1364](https://github.com/stnolting/neorv32/pull/1364) |
3435
| 04.09.2025 | 1.12.1.2 | :bug: fix debug module's `command.transfer` bit logic (ignore `aarsize` & `regno` if `transfer=0`) | [#1363](https://github.com/stnolting/neorv32/pull/1363) |

docs/datasheet/soc_tracer.adoc

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,41 +145,39 @@ trace logging is enabled by the `IO_TRACER_SIMLOG_EN` top generic. This also req
145145
simulation, all traced instructions are written to log files in the simulator's home folder:
146146

147147
* `neorv32.tracer0.log` for CPU 0
148-
* `neorv32.tracer1.log` for CPU 1 (only if the <<_dual_core_configuration>> is enabled)
148+
* `neorv32.tracer1.log` for CPU 1 (only if <<_dual_core_configuration>> is enabled)
149149
150150
The trace log is structured line by line where each line describes an executed instruction.
151151
The start of an exemplary trace log might look like this:
152152

153153
.Exemplary cut-out from a simulation trace log (here: `neorv32.tracer1.log` showing boot of core 1)
154154
[source, log]
155155
----
156-
50 226 0x0000019c 0x10500073 M wfi
157-
51 890622 0x000000c8 0xfff44737 M lui x14, 0xfff44000 <TRAP_ENTRY> <1>
158-
52 890624 0x000000cc 0x00872103 M lw x2, 2(x14)
159-
53 890632 0x000000d0 0x00c72603 M lw x12, 12(x14)
160-
54 890650 0x000000d4 0xfff40737 M lui x14, 0xfff40000
161-
55 890652 0x000000d8 0x00072223 M sw x14, 4(x0)
162-
56 890676 0x000000dc 0x05c0006f M jal x0, 92
163-
57 890703 0x00000138 0x80000197 M auipc x3, 0x80000000
164-
58 890705 0x0000013c 0x6c818193 M addi x3, x8, 1736
165-
59 890721 0x00000140 0x0ff0000f M fence
166-
60 890728 0x00000144 0x0000100f M fence.i
167-
61 890750 0x00000148 0x30029073 M csrrw x0, mstatus, x5
156+
51 929749 0x0000009c 0xfff44737 M lui x14, 0xfff44000 <TRAP_ENTRY> <1>
157+
52 929751 0x000000a0 0x00872103 M lw x2, 2(x14)
158+
53 929759 0x000000a4 0x00c72603 M c.lw x12, 12(x14)
159+
54 929767 0x000000a6 0xfff40737 M lui x14, 0xfff40000
160+
55 929770 0x000000aa 0x00072223 M sw x14, 4(x0)
161+
56 929778 0x000000ae 0x04a0006f M c.jal x0, 74
162+
57 929798 0x000000f8 0x80000197 M auipc x3, 0x80000000
163+
58 929800 0x000000fc 0x70818193 M addi x3, x8, 1800
164+
59 929824 0x00000100 0x0ff0000f M fence
165+
60 929831 0x00000104 0x0000100f M fence.i
166+
61 929853 0x00000108 0x30029073 M csrrw x0, mstatus, x5
168167
----
169168
<1> This line is used for explanation (see below).
170169

171170
Column structure:
172171

173172
[start=1]
174-
. `51`: Instruction index ("order"); a linear increasing counter that starts at zero and increments with each executed instruction; printed as decimal integer
175-
. `890622`: Time stamp; a linear increasing counter that starts at zero and increments with each clock cycle; printed as decimal integer
176-
. `0x000000c8`: Instruction address (program counter); printed as hexadecimal 32-bit value (with `0x` prefix)
177-
. `0xfff44737`: 32-bit instruction word; printed as hexadecimal 32-bit value (with `0x` prefix); compressed 16-bit instructions are shown in their decompressed 32-bit format
173+
. `51`: Instruction index ("order"); a linear increasing counter that starts at zero and increments with each executed instruction; printed as decimal integer.
174+
. `890622`: Time stamp; a linear increasing counter that starts at zero and increments with each clock cycle; printed as decimal integer.
175+
. `0x000000c8`: Instruction address (program counter); printed as hexadecimal 32-bit value (`0x` prefix).
176+
. `0xfff44737`: 32-bit instruction word; printed as hexadecimal 32-bit value (`0x` prefix); compressed 16-bit instructions are shown in their decompressed 32-bit format.
178177
. `M`: Current operating mode / privilege level (`M` = machine-mode, `U` = user-mode, `D` = debug-mode); printed as single character
179-
. `lui x14, 0xfff44000`: The decoded instruction mnemonic plus operands. For unknown/unsupported instructions the instruction class is printed in capital letters
180-
together with a prefixed `illegal_` (e.g. `illegal_ALU`). Decompressed 16-bit instructions have a prefixed `c.` (e.g. `c.lw`).
181-
. If the processor encounters a trap (synchronous exception or interrupt) `<TRAP_ENTRY>` is printed at the end of the line that corresponds
182-
to the first instruction of the according trap handler.
178+
. `lui`: The decoded instruction mnemonic. For unknown instructions `INVALID` is printed instead. Decompressed 16-bit instructions have a prefixed `c.` (e.g. `c.lw`).
179+
. `x14, 0xfff44000`: Operands of the decoded instruction.
180+
. If the CPU encounters a trap (synchronous exception or interrupt) `<TRAP_ENTRY>` is printed at the end of the line corresponding to the first instruction of the trap handler.
183181

184182
.Instruction Execution Time
185183
[TIP]

rtl/core/neorv32_package.vhd

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ package neorv32_package is
2828

2929
-- Architecture Constants -----------------------------------------------------------------
3030
-- -------------------------------------------------------------------------------------------
31-
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01120104"; -- hardware version
31+
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01120105"; -- hardware version
3232
constant archid_c : natural := 19; -- official RISC-V architecture ID
3333
constant XLEN : natural := 32; -- native data path width
3434

@@ -779,6 +779,7 @@ package neorv32_package is
779779
function is_power_of_two_f(input : natural) return boolean;
780780
function replicate_f(input : std_ulogic; num : natural) return std_ulogic_vector;
781781
function print_hex_f(data : std_ulogic_vector) return string;
782+
function match_f(input : std_ulogic_vector; pattern : std_ulogic_vector) return boolean;
782783

783784
-- **********************************************************************************************************
784785
-- NEORV32 Processor Top Entity (component prototype)
@@ -1166,4 +1167,22 @@ package body neorv32_package is
11661167
return res_v;
11671168
end function print_hex_f;
11681169

1170+
-- Check if vector matches binary pattern (skip elements compared with '-') ---------------
1171+
-- -------------------------------------------------------------------------------------------
1172+
function match_f(input : std_ulogic_vector; pattern : std_ulogic_vector) return boolean is
1173+
variable match_v : boolean;
1174+
begin
1175+
if (input'length /= pattern'length) then -- no match if different sizes
1176+
return false;
1177+
else
1178+
match_v := true;
1179+
for i in input'length-1 downto 0 loop
1180+
if (pattern(i) = '1') or (pattern(i) = '0') then -- valid pattern value, skip everything else
1181+
match_v := match_v and boolean(pattern(i) = input(i));
1182+
end if;
1183+
end loop;
1184+
return match_v;
1185+
end if;
1186+
end function match_f;
1187+
11691188
end neorv32_package;

0 commit comments

Comments
 (0)