data/full_repos/permissive/481490387/lab04/cache/testbench.v
1: b'%Warning-STMTDLY: data/full_repos/permissive/481490387/lab04/cache/testbench.v:26: Unsupported: Ignoring delay on this delayed statement.\n    #0\n    ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Warning-STMTDLY: data/full_repos/permissive/481490387/lab04/cache/testbench.v:31: Unsupported: Ignoring delay on this delayed statement.\n    #105 \n    ^\n%Warning-STMTDLY: data/full_repos/permissive/481490387/lab04/cache/testbench.v:35: Unsupported: Ignoring delay on this delayed statement.\nalways #10 clk = ~clk;\n       ^\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:38: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h1)\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:39: Can\'t find definition of \'test_addr\' in dotted variable: \'g0.test_addr\'\n        $display("           %x", g0.test_addr);\n                                     ^~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:40: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h2 && g0.next_state == 4\'h2 && !g0.cache_whit)\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:40: Can\'t find definition of \'next_state\' in dotted variable: \'g0.next_state\'\n    if (g0.current_state == 4\'h2 && g0.next_state == 4\'h2 && !g0.cache_whit)\n                                       ^~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:40: Can\'t find definition of \'cache_whit\' in dotted variable: \'g0.cache_whit\'\n    if (g0.current_state == 4\'h2 && g0.next_state == 4\'h2 && !g0.cache_whit)\n                                                                 ^~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:41: Can\'t find definition of \'data_from_trace\' in dotted variable: \'g0.data_from_trace\'\n        $display("    Cache                 %x", g0.data_from_trace);\n                                                    ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:42: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h2 && g0.next_state == 4\'h2 && g0.cache_whit)\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:42: Can\'t find definition of \'next_state\' in dotted variable: \'g0.next_state\'\n    if (g0.current_state == 4\'h2 && g0.next_state == 4\'h2 && g0.cache_whit)\n                                       ^~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:42: Can\'t find definition of \'cache_whit\' in dotted variable: \'g0.cache_whit\'\n    if (g0.current_state == 4\'h2 && g0.next_state == 4\'h2 && g0.cache_whit)\n                                                                ^~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:43: Can\'t find definition of \'cache_wdata\' in dotted variable: \'g0.cache_wdata\'\n        $display("    Cache                 %x", g0.cache_wdata);\n                                                    ^~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:44: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h2 && g0.cache_hit)\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:44: Can\'t find definition of \'cache_hit\' in dotted variable: \'g0.cache_hit\'\n    if (g0.current_state == 4\'h2 && g0.cache_hit)\n                                       ^~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:46: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h3)\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:47: Can\'t find definition of \'data_from_cache\' in dotted variable: \'g0.data_from_cache\'\n        $display("Cache           %x", g0.data_from_cache);\n                                          ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:48: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h3 && (g0.next_state == 4\'h1 && !rd_test_success || g0.next_state == 4\'h5 && rd_test_success))\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:48: Can\'t find definition of \'next_state\' in dotted variable: \'g0.next_state\'\n    if (g0.current_state == 4\'h3 && (g0.next_state == 4\'h1 && !rd_test_success || g0.next_state == 4\'h5 && rd_test_success))\n                                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:48: Can\'t find definition of \'next_state\' in dotted variable: \'g0.next_state\'\n    if (g0.current_state == 4\'h3 && (g0.next_state == 4\'h1 && !rd_test_success || g0.next_state == 4\'h5 && rd_test_success))\n                                                                                     ^~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:50: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h5)\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:51: Can\'t find definition of \'test_addr\' in dotted variable: \'g0.test_addr\'\n        $display("         %x           %x", g0.test_addr, g0.cache_wdata);\n                                                ^~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:51: Can\'t find definition of \'cache_wdata\' in dotted variable: \'g0.cache_wdata\'\n        $display("         %x           %x", g0.test_addr, g0.cache_wdata);\n                                                              ^~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:52: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h6 && g0.cache_hit)\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:52: Can\'t find definition of \'cache_hit\' in dotted variable: \'g0.cache_hit\'\n    if (g0.current_state == 4\'h6 && g0.cache_hit)\n                                       ^~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:54: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h6 && !g0.cache_hit)\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:54: Can\'t find definition of \'cache_hit\' in dotted variable: \'g0.cache_hit\'\n    if (g0.current_state == 4\'h6 && !g0.cache_hit)\n                                        ^~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:56: Can\'t find definition of \'current_state\' in dotted variable: \'g0.current_state\'\n    if (g0.current_state == 4\'h8 && g0.next_state != 4\'h8)\n           ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:56: Can\'t find definition of \'next_state\' in dotted variable: \'g0.next_state\'\n    if (g0.current_state == 4\'h8 && g0.next_state != 4\'h8)\n                                       ^~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:76: Can\'t find definition of \'test_addr\' in dotted variable: \'g0.test_addr\'\n        $fwrite(fp_w, "At read addr %x, expect %x, but get %x\\n", g0.test_addr, g0.data_from_trace, g0.data_from_cache);\n                                                                     ^~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:76: Can\'t find definition of \'data_from_trace\' in dotted variable: \'g0.data_from_trace\'\n        $fwrite(fp_w, "At read addr %x, expect %x, but get %x\\n", g0.test_addr, g0.data_from_trace, g0.data_from_cache);\n                                                                                   ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/481490387/lab04/cache/testbench.v:76: Can\'t find definition of \'data_from_cache\' in dotted variable: \'g0.data_from_cache\'\n        $fwrite(fp_w, "At read addr %x, expect %x, but get %x\\n", g0.test_addr, g0.data_from_trace, g0.data_from_cache);\n                                                                                                       ^~~~~~~~~~~~~~~\n%Error: Exiting due to 29 error(s), 3 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module testbench();

reg         clk;
reg         reset;
wire [12:0] end_addr = 13'b1_1111_1111_1111;
wire [11:0] count;
wire        rd_test_success;
wire        test_success;
wire        test_fail;

driver g0 (
    .clk_in             (clk            ),
    .reset_in           (reset          ),
    .end_addr           (end_addr       ),
    .count              (count          ),
    .rd_test_success    (rd_test_success),
    .test_success       (test_success   ),
    .test_fail          (test_fail      )
);

integer fp_w;
reg f0;
initial begin
    #0
    fp_w  = $fopen("result.txt", "w");
    reset = 1;
    clk   = 0;
    f0    = 0;
    #105 
    reset = 0;
end

always #10 clk = ~clk;

always @(posedge clk) begin
    if (g0.current_state == 4'h1)
        $display("���ʵ�ַΪ %x", g0.test_addr);
    if (g0.current_state == 4'h2 && g0.next_state == 4'h2 && !g0.cache_whit)
        $display("�ȴ�Cache��Ӧ��Ӧ�õ����� %x", g0.data_from_trace);
    if (g0.current_state == 4'h2 && g0.next_state == 4'h2 && g0.cache_whit)
        $display("�ȴ�Cache��Ӧ��Ӧ�õ����� %x", g0.cache_wdata);
    if (g0.current_state == 4'h2 && g0.cache_hit)
        $display("Cache������!");
    if (g0.current_state == 4'h3)
        $display("Cache��ȡ������ %x", g0.data_from_cache);
    if (g0.current_state == 4'h3 && (g0.next_state == 4'h1 && !rd_test_success || g0.next_state == 4'h5 && rd_test_success))
        $display("�õ�ַ������ȷ����������һ����ַ\n ----------- ");
    if (g0.current_state == 4'h5)
        $display("д��ַΪ %x��д����Ϊ %x", g0.test_addr, g0.cache_wdata);
    if (g0.current_state == 4'h6 && g0.cache_hit)
        $display("Cacheд����!");
    if (g0.current_state == 4'h6 && !g0.cache_hit)
        $display("Cacheдȱʧ!");
    if (g0.current_state == 4'h8 && g0.next_state != 4'h8)
        $display("��ǰCache�б��滻");
end

always @(posedge clk) begin
    if (rd_test_success & !f0) begin
        $fwrite(fp_w, "CACHE-READING TEST PASSED\n");
        $fwrite(fp_w, "Cycles spent on reading cache: %x\n", count);
        $display("=======================��Cache����ȫ��ͨ��=========================");
        f0 <= 1;
    end
    if (test_success) begin
        $fwrite(fp_w, "CACHE-WRITING-HIT TEST PASSED\n");
        $fclose(fp_w);
        $display("=======================Cacheд����ȫ��ͨ��=========================");
        $display("========================���в���ȫ��ͨ����==========================");
        $stop;
    end
    if (test_fail) begin   
        $fwrite(fp_w, "TEST FAILED\n");
        $fwrite(fp_w, "At read addr %x, expect %x, but get %x\n", g0.test_addr, g0.data_from_trace, g0.data_from_cache);
        $fclose(fp_w);
        $display("==========================����δͨ���������뿴���������Ϣ==========================");
        $stop;
    end
end

endmodule
module testbench();


reg         clk;
reg         reset;
wire [12:0] end_addr = 13'b1_1111_1111_1111;
wire [11:0] count;
wire        rd_test_success;
wire        test_success;
wire        test_fail;

driver g0 (
    .clk_in             (clk            ),
    .reset_in           (reset          ),
    .end_addr           (end_addr       ),
    .count              (count          ),
    .rd_test_success    (rd_test_success),
    .test_success       (test_success   ),
    .test_fail          (test_fail      )
);

integer fp_w;
reg f0;
initial begin
    #0
    fp_w  = $fopen("result.txt", "w");
    reset = 1;
    clk   = 0;
    f0    = 0;
    #105 
    reset = 0;
end

always #10 clk = ~clk;

always @(posedge clk) begin
    if (g0.current_state == 4'h1)
        $display("���ʵ�ַΪ %x", g0.test_addr);
    if (g0.current_state == 4'h2 && g0.next_state == 4'h2 && !g0.cache_whit)
        $display("�ȴ�Cache��Ӧ��Ӧ�õ����� %x", g0.data_from_trace);
    if (g0.current_state == 4'h2 && g0.next_state == 4'h2 && g0.cache_whit)
        $display("�ȴ�Cache��Ӧ��Ӧ�õ����� %x", g0.cache_wdata);
    if (g0.current_state == 4'h2 && g0.cache_hit)
        $display("Cache������!");
    if (g0.current_state == 4'h3)
        $display("Cache��ȡ������ %x", g0.data_from_cache);
    if (g0.current_state == 4'h3 && (g0.next_state == 4'h1 && !rd_test_success || g0.next_state == 4'h5 && rd_test_success))
        $display("�õ�ַ������ȷ����������һ����ַ\n ----------- ");
    if (g0.current_state == 4'h5)
        $display("д��ַΪ %x��д����Ϊ %x", g0.test_addr, g0.cache_wdata);
    if (g0.current_state == 4'h6 && g0.cache_hit)
        $display("Cacheд����!");
    if (g0.current_state == 4'h6 && !g0.cache_hit)
        $display("Cacheдȱʧ!");
    if (g0.current_state == 4'h8 && g0.next_state != 4'h8)
        $display("��ǰCache�б��滻");
end

always @(posedge clk) begin
    if (rd_test_success & !f0) begin
        $fwrite(fp_w, "CACHE-READING TEST PASSED\n");
        $fwrite(fp_w, "Cycles spent on reading cache: %x\n", count);
        $display("=======================��Cache����ȫ��ͨ��=========================");
        f0 <= 1;
    end
    if (test_success) begin
        $fwrite(fp_w, "CACHE-WRITING-HIT TEST PASSED\n");
        $fclose(fp_w);
        $display("=======================Cacheд����ȫ��ͨ��=========================");
        $display("========================���в���ȫ��ͨ����==========================");
        $stop;
    end
    if (test_fail) begin   
        $fwrite(fp_w, "TEST FAILED\n");
        $fwrite(fp_w, "At read addr %x, expect %x, but get %x\n", g0.test_addr, g0.data_from_trace, g0.data_from_cache);
        $fclose(fp_w);
        $display("==========================����δͨ���������뿴���������Ϣ==========================");
        $stop;
    end
end

endmodule