像 DUT 这样的 ROM 的 Verilog 测试平台不工作

Verilog testbench for ROM like DUT not working

我正在尝试实现一个测试台并编写所有 我的 DUT 到文件的可能输入组合:

module CONTROL_LOGIC_tb();
    // Inputs
    reg [3:0] select_i;
    reg [15:0] addr_i;
    // Output
    wire [7:0] ctrl_o;

    // Instantiate the UUT
    CONTROL_LOGIC UUT(
        .select_i(select_i),
        .ctrl_i(addr_i),
        .ctrl_o(ctrl_o) );

    // Do test
    integer outFile;
    integer idx;

    initial begin
        select_i = 0;
        outFile = $fopen(".\CTRL.bin", "wb");

        for (idx = 0; idx < 65536; idx = idx +1)
        begin
            addr_i = idx;
            $fwrite(outFile, "%c", ctrl_o);
        end
        $fclose(outFile);
        $finish;
    end
endmodule

很遗憾,文件 'CTRL.bin' 中没有填充任何有用的数据。 然而,它的大小为 64kB...至少这有效!

我在使用变量 'idx' 作为 DUT 输入时做错了什么?

ps:我在 ispLever 中使用 Aldec 功能模拟(是否重要?)。

您的 for 循环没有延迟:

for (idx = 0; idx < 65536; idx = idx +1)

您的输入之间必须始终存在一些延迟,否则生成它们的代码只会在零时间内运行,每个新输入只会覆盖前一个输入,并且没有任何输入会应用于被测设计,例如:

for (idx = 0; idx < 65536; idx = idx +1)
    begin
        addr_i = idx;
        #10;
        $fwrite(outFile, "%c", ctrl_o);
    end