2

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

但是我的时间刻度有问题,默认情况下,函数module->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");
}
4

1 回答 1

1

我给出的方法仅适用于 C++ 后端,如果我们使用凿子类 Test,问题仍然存在。我修改了凿子代码以在implicitClock 对象中添加句点。然后我修改了 Vcd 类以使用正确的周期值转储 VCD。你可以在这里看到补丁。

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

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

该补丁已针对 Chisel 的 2.2.28 版本提交。

于 2015-06-24T08:04:04.750 回答