data/full_repos/permissive/444559342/mp2/hvl/memory.sv
1: b'%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:1: Cannot find include file: tb_itf.sv\n`include "tb_itf.sv" \n         ^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/444559342/mp2/hvl,data/full_repos/permissive/444559342/tb_itf.sv\n             data/full_repos/permissive/444559342/mp2/hvl,data/full_repos/permissive/444559342/tb_itf.sv.v\n             data/full_repos/permissive/444559342/mp2/hvl,data/full_repos/permissive/444559342/tb_itf.sv.sv\n             tb_itf.sv\n             tb_itf.sv.v\n             tb_itf.sv.sv\n             obj_dir/tb_itf.sv\n             obj_dir/tb_itf.sv.v\n             obj_dir/tb_itf.sv.sv\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:30: syntax error, unexpected iff, expecting \')\' or \',\' or or\n    always_ff @(itf.mcb iff itf.mcb.write && !_write) begin\n                        ^~~\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:60: syntax error, unexpected int, expecting IDENTIFIER or genvar\n                for (int i = 0; i < 4; ++i) begin\n                     ^~~\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:71: syntax error, unexpected \'.\', expecting IDENTIFIER\n                    itf.mcb.error <= 1\'b1;\n                           ^\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:79: syntax error, unexpected \'.\', expecting IDENTIFIER\n                    itf.mcb.error <= 1\'b1;\n                           ^\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:87: syntax error, unexpected \'.\', expecting IDENTIFIER\n                    itf.mcb.error <= 1\'b1;\n                           ^\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:95: syntax error, unexpected \'.\', expecting IDENTIFIER\n                    itf.mcb.error <= 1\'b1;\n                           ^\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:113: syntax error, unexpected \'.\', expecting IDENTIFIER\n                itf.mcb.rdata <= read_buffer;\n                       ^\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:114: syntax error, unexpected \'.\', expecting IDENTIFIER\n                itf.mcb.resp <= 1\'b1;\n                       ^\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:121: syntax error, unexpected \'.\', expecting IDENTIFIER\n                    itf.mcb.error <= 1\'b1;\n                           ^\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:129: syntax error, unexpected \'.\', expecting IDENTIFIER\n                    itf.mcb.error <= 1\'b1;\n                           ^\n%Error: data/full_repos/permissive/444559342/mp2/hvl/memory.sv:137: syntax error, unexpected \'.\', expecting IDENTIFIER\n                    itf.mcb.error <= 1\'b1;\n                           ^\n%Error: Cannot continue\n'
module memory #(
    parameter DELAY_CYCLE=25,
    parameter MEMFILE="memory.lst"
)
(
    tb_itf.mem itf
);

    logic [7:0] mem [logic [31:0]];
    logic [31:0] read_buffer;
    logic [31:0] _addr;
    logic [31:0] faddr;
    logic [31:0] write_buffer;


    initial
    begin
        $readmemh(MEMFILE, mem);
        itf.mcb.error <= 1'b0;
        itf.mcb.resp <= 0;
    end

    logic _read, _write;
    always @(itf.mcb) begin
        _read <= itf.mcb.read;
        _write <= itf.mcb.write;
    end

    always_ff @(itf.mcb iff itf.mcb.write && !_write) begin

    end

    initial begin
        forever begin
            fork : k1
                begin
                    @(itf.mcb iff itf.mcb.write && !_write)
                        write();
                    disable k1;
                end
                begin
                    @(itf.mcb iff itf.mcb.read && !_read)
                        read();
                    disable k1;
                end
            join
        end
    end


    task write;
        faddr =  itf.mcb.addr;
        _addr = itf.mcb.addr;
        write_buffer = itf.mcb.wdata;
        fork : g
            begin

                repeat (DELAY_CYCLE) @(itf.mcb);
                for (int i = 0; i < 4; ++i) begin
                    if (itf.mcb.byte_enable[i])
                        mem[_addr+i] = write_buffer[8*i +: 8];
                end
                itf.mcb.resp <= 1'b1;
                disable g;
            end
            begin

                @(itf.mcb iff itf.mcb.addr != faddr) begin
                    itf.report_error("Memory Error: write address changed");
                    itf.mcb.error <= 1'b1;
                    disable g;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.wdata != write_buffer) begin
                    itf.report_error("Memory Error: write data changed");
                    itf.mcb.error <= 1'b1;
                    disable g;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.write == 1'b0) begin
                    itf.report_error("Memory Error: write terminated prematurely");
                    itf.mcb.error <= 1'b1;
                    disable g;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.read) begin
                    itf.report_error("Memory Error: read asserted during write");
                    itf.mcb.error <= 1'b1;
                    disable g;
                end
            end
        join

        @(itf.mcb) itf.mcb.resp <= 1'b0;
    endtask


    task read;
        faddr = itf.mcb.addr;
        _addr = itf.mcb.addr;
        read_buffer = {mem[_addr+3], mem[_addr+2], mem[_addr+1], mem[_addr]};
        fork : f
            begin

                repeat (DELAY_CYCLE) @(itf.mcb);
                itf.mcb.rdata <= read_buffer;
                itf.mcb.resp <= 1'b1;
                disable f;
            end
            begin

                @(itf.mcb iff itf.mcb.read == 1'b0) begin
                    itf.report_error("Memory Error: read terminated prematurely");
                    itf.mcb.error <= 1'b1;
                    disable f;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.write) begin
                    itf.report_error("Memory Error: write asserted during read");
                    itf.mcb.error <= 1'b1;
                    disable f;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.addr != faddr) begin
                    itf.report_error("Memory Error: read address changed");
                    itf.mcb.error <= 1'b1;
                    disable f;
                end
            end
        join

        @(itf.mcb) itf.mcb.resp <= 1'b0;
    endtask

endmodule
module memory #(
    parameter DELAY_CYCLE=25,
    parameter MEMFILE="memory.lst"
)
(
    tb_itf.mem itf
);


    logic [7:0] mem [logic [31:0]];
    logic [31:0] read_buffer;
    logic [31:0] _addr;
    logic [31:0] faddr;
    logic [31:0] write_buffer;


    initial
    begin
        $readmemh(MEMFILE, mem);
        itf.mcb.error <= 1'b0;
        itf.mcb.resp <= 0;
    end

    logic _read, _write;
    always @(itf.mcb) begin
        _read <= itf.mcb.read;
        _write <= itf.mcb.write;
    end

    always_ff @(itf.mcb iff itf.mcb.write && !_write) begin

    end

    initial begin
        forever begin
            fork : k1
                begin
                    @(itf.mcb iff itf.mcb.write && !_write)
                        write();
                    disable k1;
                end
                begin
                    @(itf.mcb iff itf.mcb.read && !_read)
                        read();
                    disable k1;
                end
            join
        end
    end


    task write;
        faddr =  itf.mcb.addr;
        _addr = itf.mcb.addr;
        write_buffer = itf.mcb.wdata;
        fork : g
            begin

                repeat (DELAY_CYCLE) @(itf.mcb);
                for (int i = 0; i < 4; ++i) begin
                    if (itf.mcb.byte_enable[i])
                        mem[_addr+i] = write_buffer[8*i +: 8];
                end
                itf.mcb.resp <= 1'b1;
                disable g;
            end
            begin

                @(itf.mcb iff itf.mcb.addr != faddr) begin
                    itf.report_error("Memory Error: write address changed");
                    itf.mcb.error <= 1'b1;
                    disable g;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.wdata != write_buffer) begin
                    itf.report_error("Memory Error: write data changed");
                    itf.mcb.error <= 1'b1;
                    disable g;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.write == 1'b0) begin
                    itf.report_error("Memory Error: write terminated prematurely");
                    itf.mcb.error <= 1'b1;
                    disable g;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.read) begin
                    itf.report_error("Memory Error: read asserted during write");
                    itf.mcb.error <= 1'b1;
                    disable g;
                end
            end
        join

        @(itf.mcb) itf.mcb.resp <= 1'b0;
    endtask


    task read;
        faddr = itf.mcb.addr;
        _addr = itf.mcb.addr;
        read_buffer = {mem[_addr+3], mem[_addr+2], mem[_addr+1], mem[_addr]};
        fork : f
            begin

                repeat (DELAY_CYCLE) @(itf.mcb);
                itf.mcb.rdata <= read_buffer;
                itf.mcb.resp <= 1'b1;
                disable f;
            end
            begin

                @(itf.mcb iff itf.mcb.read == 1'b0) begin
                    itf.report_error("Memory Error: read terminated prematurely");
                    itf.mcb.error <= 1'b1;
                    disable f;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.write) begin
                    itf.report_error("Memory Error: write asserted during read");
                    itf.mcb.error <= 1'b1;
                    disable f;
                end
            end
            begin

                @(itf.mcb iff itf.mcb.addr != faddr) begin
                    itf.report_error("Memory Error: read address changed");
                    itf.mcb.error <= 1'b1;
                    disable f;
                end
            end
        join

        @(itf.mcb) itf.mcb.resp <= 1'b0;
    endtask

endmodule