verilator手册中 9.1.10 How do I generate FST waveforms (traces) in C++ or SystemC?

FST Trace File Format Support in Verilator

FST is a trace file format developed by GTKWave. Verilator provides basic FST support. To dump traces in FST format, add the --trace-fst option to Verilator and either:

1. Use $dumpfile & $dumpvars in Verilog

This is similar to the VCD example above.

2. In C++:

Change the include described in the VCD example above:

#include "verilated_fst_c.h"
VerilatedFstC* tfp = new VerilatedFstC;

3. In SystemC:

Change the include described in the VCD example above:

#include "verilated_fst_sc.h"
VerilatedFstC* tfp = new VerilatedFstSc;

Currently, supporting both FST and VCD in a single simulation is not supported, but such usage should be unlikely. You can, however, #ifdef around the trace format in your C++ main loop and select either VCD or FST at compile time.

Verilator 中的 FST 跟踪文件格式支持

FST 是 GTKWave 开发的一个跟踪文件格式。Verilator 提供了基本的 FST 支持。要以 FST 格式导出跟踪,向 Verilator 添加 --trace-fst 选项,并采取以下任一方法:

1. 在 Verilog 中使用 $dumpfile$dumpvars

这与上面的 VCD 示例类似。

2. 在 C++ 中:

更改 VCD 示例中的包含方式:

#include "verilated_fst_c.h"
VerilatedFstC* tfp = new VerilatedFstC;

3. 在 SystemC 中:

更改 VCD 示例中的包含方式:

#include "verilated_fst_sc.h"
VerilatedFstC* tfp = new VerilatedFstSc;

目前,Verilator 不支持在同一仿真中同时使用 FST 和 VCD,但这种用法应该不太可能发生。然而,您可以在 C++ 主循环中使用 #ifdef 来选择编译时使用 VCD 或 FST 格式。

参考手册9.1.8的代码可以很轻松的完成。

注意!!!

生成.fst文件时(比如.cpp文件里面有个循环还在执行),如果在终端里用Ctrl+C终端循环,将会导致.fst文件生成失败,出现以下报错:

xxxx:xxxx$ gtkwave waveform.fst

GTKWave Analyzer v3.3.121 (w)1999-2024 BSI

GTKWAVE | Could not initialize 'waveform.fst', exiting.

具体可参考下面这篇文章:verilator生成.fit文件GTKwave无法读取

posted @ 2025-12-05 10:52  阿坤不咕  阅读(0)  评论(0)    收藏  举报