Verilator仿真(C++)中修改SystemVerilog模块参数值

问题描述 投票:0回答:1

是否可以从用 C++ 编写的测试平台修改经过验证的 SystemVerilog 的参数。例如,考虑下面的模块。

module my_module #(
    parameter WIDTH = 16
)
(
    input logic i_clk, // input clock
    input logic i_rst, // input reset
    output logic [7:0] o_out // output
);

假设我验证了这个模块,我可以在实例化验证模块后在 C++ 中执行以下操作:

// Something to the effect of...
VerilatedContext* contextp = new VerilatedContext;
Vmy_module* top = new Vmy_module{contextp};
//...
top->i_rst = 1;

如果我想修改 WIDTH 参数的默认值(从 C++ 代码中),我该怎么做呢?

我已经尝试将其标记为公开(通过

/*verilator public*/
)但无济于事。我也用过DPI接口读取其他模块内部信号,但是,我不确定它们是否可以应用于写入/修改参数。

verilog system-verilog verilator
1个回答
0
投票

您不能在运行时在 Verilator 中覆盖参数的值。

/*verilator public*/
pragma 用于访问来自 C++ 测试平台的信号。

您可以在使用

-G
选项将 SystemVerilog 代码转换为 C++ 之前覆盖参数。

© www.soinside.com 2019 - 2024. All rights reserved.