Skip to content

fix(verilator): make sure to define TRACE#7601

Merged
waruqi merged 2 commits into
xmake-io:devfrom
PFiS1737:fix-verilator-trace
Jun 13, 2026
Merged

fix(verilator): make sure to define TRACE#7601
waruqi merged 2 commits into
xmake-io:devfrom
PFiS1737:fix-verilator-trace

Conversation

@PFiS1737

@PFiS1737 PFiS1737 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

说明

启用 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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

如果仅启用了 FST 或 SAIF 跟踪(例如通过 --trace-fst),options_table["trace"] 可能会是 nilfalse,这会导致 switches.TRACE 被错误地设置为 "0"。为了保证 VM_TRACE 宏正确定义,我们应该在启用了任意一种跟踪选项(tracetrace_vcdtrace_fsttrace_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"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verilator 会在任意类型的 tracing 启用后,将 trace 字段设置为 true

Comment thread xmake/rules/verilator/verilator.lua Outdated
@waruqi waruqi added this to the v3.1.0 milestone Jun 12, 2026
@waruqi waruqi merged commit 8830f33 into xmake-io:dev Jun 13, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants