Skip to content

Commit d46088d

Browse files
committed
[dv,doc] Update README.md files for logging
Signed-off-by: martin-velay <mvelay@lowrisc.org>
1 parent 468eef9 commit d46088d

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

hw/top_chip/dv/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ For more details, see: [sim_sram_axi/README.md](./sim_sram_axi/README.md)
7171
7272
* **Test Status:** The SW writes Pass/Fail status to `SW_DV_TEST_STATUS_ADDR`.
7373
The `sw_test_status_if` detects this and signals the UVM environment to terminate the simulation.
74-
* **Logging:** The SW writes debug strings to `SW_DV_LOG_ADDR`.
75-
The `sw_logger_if` captures these characters and prints them to the simulation log, avoiding the latency of the UART peripheral.
74+
* **Logging:** The SW uses the `DV_LOG_INFO` / `DV_LOG_WARNING` / `DV_LOG_ERROR` / `DV_LOG_FATAL` macros (defined in `sw/device/lib/test_framework/dv_log.h`) to emit log messages.
75+
Each call allocates a static `log_fields_t` struct (severity, file, line, argument count, format string) in the `.logs.fields` ELF section, then writes its address followed by any variadic arguments to `SW_DV_LOG_ADDR`.
76+
At build time, `util/build_sw_collateral_for_sim.py` invokes `extract_sw_logs.py` on the firmware ELF to produce a `<name>.logs.txt` database mapping each struct address to its decoded fields.
77+
At simulation time, `sw_logger_if` intercepts the write, looks up the struct address in the database, substitutes the arguments into the format string, and prints the fully formatted message to the simulation log.
78+
This bypasses the slowness of the UART peripheral and requires no string formatting on the CPU.
7679
7780
## Simulation commands
7881

hw/top_chip/dv/sim_sram_axi/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ These signals are used to generate the `wr_valid` signal, qualifying valid AXI w
7272

7373
In the Testbench Top (`tb.sv`), higher-level verification interfaces are `bind`-ed to this signal and their virtual handle is added into the `uvm_config_db`:
7474
1. **`sw_test_status_if`**: Monitors writes to `SW_DV_TEST_STATUS_ADDR` to detect if the test Passed or Failed.
75-
2. **`sw_logger_if`**: Monitors writes to `SW_DV_LOG_ADDR` to capture `printf` characters and display them in the simulation log.
75+
2. **`sw_logger_if`**: Monitors writes to `SW_DV_LOG_ADDR` to decode SW log messages.
76+
The SW writes the address of a static `log_fields_t` struct (severity, file, line, nargs, format string) plus any variadic arguments.
77+
A pre-generated `<name>.logs.txt` database (produced by `extract_sw_logs.py` at build time) maps each struct address to its fields;
78+
the interface looks up the address, substitutes the arguments, and prints the formatted message to the simulation log.
7679

7780
## Usage
7881

0 commit comments

Comments
 (0)