Skip to content

Commit 4f63fac

Browse files
authored
Merge pull request #285 from pluveto/feature/report-source-location-doc
docs(report): new section Including Scala Source Location
2 parents 93f8c5d + b73c3e0 commit 4f63fac

File tree

1 file changed

+40
-1
lines changed
  • source/SpinalHDL/Other language features

1 file changed

+40
-1
lines changed

source/SpinalHDL/Other language features/report.rst

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,46 @@ will result in:
4242
4343
$display("NOTE miaou %t", $time);
4444
45+
Including Scala Source Location
46+
-------------------------------
47+
48+
After 1.13.0, you can optionally include the Scala call-site location (file and line) in the report output, which allows most IDEs to jump to the source when clicking the log line.
49+
50+
There are two ways to enable it:
51+
52+
.. code-block:: scala
53+
54+
// Per-call
55+
report("HELLO", includeSourceLocation = true)
56+
57+
// Globally (for all `report(...)` calls in this elaboration)
58+
SpinalConfig(reportIncludeSourceLocation = true).generateVerilog(new TopLevel)
59+
60+
Example generated output (Verilog):
61+
62+
.. code-block:: verilog
63+
64+
$display("NOTE(path/to/MyTopLevel.scala:123) HELLO");
65+
66+
You can customize the location prefix format globally using `SpinalConfig.reportSourceLocationFormat`, with the following placeholders:
67+
68+
- `$SEVERITY` (NOTE/WARNING/ERROR/FAILURE)
69+
- `$FILE` (Scala file path)
70+
- `$LINE`
71+
72+
Example (IDE-friendly clickable output):
73+
74+
.. code-block:: scala
75+
76+
SpinalConfig(
77+
reportIncludeSourceLocation = true,
78+
reportSourceLocationFormat = "$FILE:$LINE: $SEVERITY "
79+
).generateVerilog(new TopLevel)
80+
81+
.. code-block:: verilog
82+
83+
$display("path/to/MyTopLevel.scala:123: NOTE HELLO");
84+
4585
**Automatic Handling of Scala Primitive Types (SpinalHDL ^1.12.2)**
4686

4787
You can embed Scala primitive types (e.g., `Int`, `Boolean`, `Float`, `BigInt`, `BigDecimal`, `Char`, `Byte`, `Short`, `Long`) within `L""` interpolated strings without explicit `.toString()` calls.
@@ -106,4 +146,3 @@ This will produce a compact, readable output like:
106146
.. code-block:: text
107147
108148
PacketHeader(packetLength=0x0c, packetType=0x1, payload=DataPayload(value=0x5678, checksum=0x78))
109-

0 commit comments

Comments
 (0)