如何更改VCD文件转储的时间尺度? [英] How to change timescale of VCD file dumped?
问题描述
我正在尝试在现实世界"项目中使用Chisel,并且正在用C ++编写testbench代码部分. 效果很好,我可以使用gtkwave在dump.vcd文件中看到所有转储的信号.
I'm trying to use Chisel on a "real-world" project and I'm writing the testbench code part in C++. That work well, I can see all my dumped signals in the dump.vcd file with gtkwave.
但是我在时间尺度上有一个问题,默认情况下,功能模块-> dump()记录时间尺度为1ps的信号:
But I have a problem for timescale, by default, the function module->dump() record signal with timescale at 1ps:
$timescale 1ps $end
您知道如何更改吗?
我发现在testbench C ++代码中对其进行更改的唯一方法是在关闭它并修改第一行之后重新打开VCD:
The only way I found to change it in the testbench C++ code is to re-open the vcd after closing it and modify the first line :
#define CYCLE_PERIOD_NS 10
FILE *f = fopen("./dump.vcd", "w");
module->set_dumpfile(f);
[...]
/*several module->dump() call */
[...]
if (f) {
fclose(f);
std::string line;
std::ifstream input("./dump.vcd");
std::ofstream output("./tmp.vcd");
std::getline(input, line);
output << "$timescale " << CYCLE_PERIOD_NS << "ns $end" << endl;
while(std::getline(input, line)) {
output << line << endl;
}
rename("./tmp.vcd", "./dump.vcd");
}
推荐答案
我给出的方法仅适用于C ++后端,如果使用凿子类Test,问题仍然存在. 我修改了Chisel代码,以在隐式时钟对象中添加期间.然后,我修改了Vcd类,以转储具有正确周期值的VCD.您可以在此处.
The method I given work only for C++ backend, the problem remain the same if we use chisel class Test. I modified Chisel code to add the period in implicitClock object. Then I modified the Vcd class to dump VCD with the correct period value. You can see the patch here.
然后要更改时间刻度,只需在顶部的Chisel模块中添加以下行:
Then to change timescale you just have to add the following line in your top Chisel module:
class myModule extends Module {
[...]
Driver.implicitClock.period = "10ns"
[...]
}
此补丁已针对Chisel的2.2.28版本提交.
This patch has been commited for the version 2.2.28 of Chisel.
这篇关于如何更改VCD文件转储的时间尺度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!