google / google/xls

Enhance tracing/logging

Open
#1,299 5 comments 0 reactions 2 assignees Claimed by @richmckeever View on GitHub
dslx enhancement
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 14h
Merged PRs (30d)
122

Description

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](https://google.github.io/xls/ir_semantics/#assert).

* 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");
```

2. 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")`.

3. 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.