如何更改倾倒VCD文件的时间尺度?[英] How to change timescale of VCD file dumped?

本文是小编为大家收集整理的关于如何更改倾倒VCD文件的时间尺度?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我正在尝试在"现实世界"项目上使用凿子,并且我正在编写C ++中的TestBench代码部分. 效果很好,我可以在gtkwave中看到我的所有转储信号.

但我默认情况下,我对时间表的问题是函数模块 - > 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 ++后端提供的方法,如果我们使用凿子类测试,则问题保持不变. 我修改了凿子代码,以在隐式对象中添加 ofient .然后,我修改了VCD类以使用正确的周期值转储VCD.您可以查看补丁https://github.com/martoni/chisel/commit/7d6e0c19b4cb705e99e6fbd4444444444416fec692f0b8f0b8fhttp://rel="nnnor ="nnnor="nnnor ="nonnor="nnof="nnof="nnof="nnof="nnof ="rel ="

然后更改时间表,您只需要在顶部凿子模块中添加以下行:

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

此补丁已用于凿子的2.2.28版.

本文地址:https://www.itbaoku.cn/post/2091007.html

问题描述

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.

But I have a problem for timescale, by default, the function module->dump() record signal with timescale at 1ps:

$timescale 1ps $end

Do you know how to change it ?

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");
}

推荐答案

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.

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"
[...]
}

This patch has been commited for the version 2.2.28 of Chisel.