google / xls

XLS: Accelerated HW Synthesis
http://google.github.io/xls/
Apache License 2.0
1.21k stars 178 forks source link

Enhance tracing/logging #1299

Open mczyz-antmicro opened 8 months ago

mczyz-antmicro commented 8 months ago
  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:
if value_ok != value_err {
    trace_fmt!("Error occurred, expected {}, got {}", value_ok, value_err);
    assert_eq(value_ok, value_err);
} else {}
error!(value_ok == value_err,"This error occurred because of reasons");
assert(value_ok == value_err, "This error occurred because of reasons");

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

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:

meheff commented 6 months ago

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.

mczyz-antmicro commented 5 months ago

Yes, fatal should terminate evaluation

allight commented 3 weeks ago

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.