gpt4 book ai didi

c++ - 如何更改转储的 VCD 文件的时间刻度?

转载 作者:行者123 更新时间:2023-11-30 05:41:59 24 4
gpt4 key购买 nike

我正在尝试在“真实世界”项目中使用 Chisel,并且正在用 C++ 编写测试台代码部分。效果很好,我可以使用 gtkwave 在 dump.vcd 文件中看到所有转储信号。

但我对时间刻度有疑问,默认情况下,功能模块->dump() 记录时间刻度为 1ps 的信号:

$timescale 1ps $end

你知道怎么改吗?

我发现在测试平台 C++ 代码中更改它的唯一方法是在关闭 vcd 后重新打开它并修改第一行:

#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++后端,如果我们使用chisel class Test,问题仍然存在。我修改了 Chisel 代码以在 implicitClock 对象中添加 period。然后我修改了 Vcd 类以使用正确的周期值转储 VCD。可以看到补丁here .

然后要更改时间刻度,您只需在顶部 Chisel 模块中添加以下行:

class myModule extends Module {
[...]
Driver.implicitClock.period = "10ns"
[...]
}

此补丁已为 Chisel 2.2.28 版提交。

关于c++ - 如何更改转储的 VCD 文件的时间刻度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30886309/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com