fix(verilator): make sure to define TRACE#7601
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for the TRACE switch in the Verilator rule, ensuring it is set based on the trace option and when parsing VCD, FST, or SAIF tracing configurations. The review feedback highlights two issues: first, switches.TRACE will be incorrectly set to "0" if only specific tracing formats (like FST or SAIF) are enabled; second, during configuration parsing, subsequent keys could overwrite switches.TRACE back to "0" even if a previous option had enabled it. Code suggestions are provided to ensure switches.TRACE remains "1" if any tracing option is active.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| switches.TIMING = options_table["use_timing"] and "1" or "0" | ||
| -- The thread field is a integer in float format, we need to convert it to string. | ||
| switches.THREADS = string.format("%d", options_table["threads"] or 1) | ||
| switches.TRACE = options_table["trace"] and "1" or "0" |
There was a problem hiding this comment.
如果仅启用了 FST 或 SAIF 跟踪(例如通过 --trace-fst),options_table["trace"] 可能会是 nil 或 false,这会导致 switches.TRACE 被错误地设置为 "0"。为了保证 VM_TRACE 宏正确定义,我们应该在启用了任意一种跟踪选项(trace、trace_vcd、trace_fst 或 trace_saif)时,都将 switches.TRACE 设置为 "1"。
switches.TRACE = (options_table["trace"] or options_table["trace_vcd"] or options_table["trace_fst"] or options_table["trace_saif"]) and "1" or "0"
There was a problem hiding this comment.
verilator 会在任意类型的 tracing 启用后,将 trace 字段设置为 true
说明
启用 tracing 功能需要至少定义
VM_TRACE,其他的比如VM_TRACE_VCD其实是可选内容。当前没有定义
VM_TRACE导致 tracing 没有波形输出。此 PR 修复了这个问题。
参考
https://github.com/verilator/verilator/blob/master/verilator-config.cmake.in#L644-L660
https://github.com/verilator/verilator/blob/master/verilator-config.cmake.in#L732