xls icon indicating copy to clipboard operation
xls copied to clipboard

Enhance tracing/logging

Open mczyz-antmicro opened this issue 1 year ago • 3 comments

  1. In Verilog there are severity tasks: $fatal, $error, $warning, $info (c.f. IEEE Standard for SystemVerilog 1800-2017 Chapter 20.10 Severity tasks) and I feel that creating corresponding functions, e.g. $fatal -> fatal! would be intuitive and improve output readability. Here is an example, where code is significantly reduced:
  • Current DSLX implementation:
if value_ok != value_err {
    trace_fmt!("Error occurred, expected {}, got {}", value_ok, value_err);
    assert_eq(value_ok, value_err);
} else {}
  • I propose that the following syntax is enabled:
error!(value_ok == value_err,"This error occurred because of reasons");
  • Alternatively, a more general assert statement:
assert(value_ok == value_err, "This error occurred because of reasons");

I believe that this functionality is already implemented in the IR.

  • This type of feature needs to be expanded in the Verilog form to:
assert (value_ok == value_err) $error("This error occurred because of reasons");
  1. I also think that DSLX needs verbosity levels for the trace and/or trace_fmt! function. The implementation could define functions, which derive from existing trace_fmt!() function: trace_fmt_log!(), trace_fmt_warn!(), trace_fmt_err!(). This feature is useful for DSLX module development - if I run multiple tests, the output quickly becomes cluttered. The function prototypes could also use a global enum for the verbosity level, i.e. trace_fmt!(DSLX_WARN, "Warning message").

  2. I wish I could set a hierarchy level of traces, e.g. if I am debugging state of the top-level proc, then I would like to suppress output from 2nd level and following children of the top-level, but use traces from all 1st level children. This feature could work like a filter, e.g. --set_trace_enable_level = 1 or by selecting proc names: --set_trace_enable_name proc_name_*

Related issues

Issues related to this one:

  • https://github.com/google/xls/issues/481
  • https://github.com/google/xls/issues/651
  • https://github.com/google/xls/issues/1071
  • https://github.com/google/xls/issues/1082
  • https://github.com/google/xls/issues/1236

mczyz-antmicro avatar Feb 13 '24 15:02 mczyz-antmicro

I presume fatal is expected to terminate the simulation/evaluation?

The fatal/error/info levels also matches the Google C++ logging library levels (and others I presume). Numeric verbosity levels in trace statements could correspond to VLOGging.

@grebe added verbosity levels to trace statements in the IR. These should be surfaced in the DSLX. That could be the initial step.

A follow on could add fatal/error/info functionality.

meheff avatar May 01 '24 02:05 meheff

Yes, fatal should terminate evaluation

mczyz-antmicro avatar May 06 '24 09:05 mczyz-antmicro

NB That the IR already supports verbosity levels in trace_fmt! but this isn't exposed to DSLX. Having support for this would be nice.

allight avatar Oct 02 '24 17:10 allight

@allight did we ever add the doc for https://github.com/google/xls/commit/0af76338b7e5ed64ed718c56af46f68d23b134cd ? (is it ready to be documented, i.e: plugged in the interpreter flags?)

proppy avatar Jan 09 '25 07:01 proppy

related: it would be nice to be able to dump leveled log into a structured format (json, proto) that could be more easily queried offline.

proppy avatar Jan 09 '25 08:01 proppy