google / google/xls

[enhancement] Preserve all trace log levels in generated Verilog

Open
#3,078 1 comment 0 reactions 0 assignees View on GitHub
codegen enhancement verification
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

### What's hard to do? (limit 100 words)

The trace log levels from DSLX are not kept in the generated Verilog. Because of this, every time you want to change the log level for simulation, you need to regenerate the design.

Right now, the [TraceVerbosityPass](https://github.com/google/xls/blob/65aa30d29a36e34040707b7eaf4a8dbb5e06651d/xls/codegen/trace_verbosity_pass.cc#L54) in codegen removes traces that don’t match the log level set via [max_trace_verbosity](https://github.com/google/xls/blob/65aa30d29a36e34040707b7eaf4a8dbb5e06651d/xls/tools/codegen_flags.cc#L168) codegen option. As a consequence, the final SystemVerilog only has a subset of the original logs.

It would be more flexible if all logs were preserved, so the log level could be controlled directly during simulation.

### Current best alternative workaround (limit 100 words)

Change the value of `max_trace_verbosity` codegen option, regenerate the design, and simulate it again

### Your view of the "best case XLS enhancement" (limit 100 words)

To get similar flexibility in SystemVerilog and allow changing the log level during simulation without modifying the generated code, the toolchain could use simple macros instead of directly generating `$display` calls. The default verbosity level could be set using a `define`.

For example:

```systemverilog
`define VERBOSITY 0

`define LOG(level, msg) \
if (`VERBOSITY >= level) $display("%s", msg);
```
This approach could let the toolchain adjust verbosity at simulation time by overriding the `VERBOSITY` define.

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.