data/full_repos/permissive/197806087/matrix_multiplication/rtl/top.v
1: b"%Error: data/full_repos/permissive/197806087/matrix_multiplication/rtl/top.v:20: Cannot find file containing module: 'counter'\ncounter #(.MAX_COUNT(K)) k_cnt (\n^~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/197806087/matrix_multiplication/rtl,data/full_repos/permissive/197806087/counter\n             data/full_repos/permissive/197806087/matrix_multiplication/rtl,data/full_repos/permissive/197806087/counter.v\n             data/full_repos/permissive/197806087/matrix_multiplication/rtl,data/full_repos/permissive/197806087/counter.sv\n             counter\n             counter.v\n             counter.sv\n             obj_dir/counter\n             obj_dir/counter.v\n             obj_dir/counter.sv\n%Error: data/full_repos/permissive/197806087/matrix_multiplication/rtl/top.v:43: Cannot find file containing module: 'thread'\n        thread #(DATA_WIDTH) mat_thread (\n        ^~~~~~\n%Error: Exiting due to 2 error(s)\n"
module top #(
    parameter K = 3,
    parameter N = 3,
    parameter M = 3,
    parameter DATA_WIDTH = 8,
    parameter NUM_THREADS = N * M
) (
    input wire clk,
    input wire rst
);


reg [DATA_WIDTH-1:0] A [0:M][0:K];
reg [DATA_WIDTH-1:0] B [0:K][0:N];


wire [$clog2(K+1)-1:0] k;
wire done;

counter #(.MAX_COUNT(K)) k_cnt (
        .clk(clk),
        .rst(rst),
        .count(k),
        .done(done)
);



reg done_pipe;
always @(posedge clk) begin
    done_pipe <= done;
end




wire [DATA_WIDTH * M * N - 1:0] thread_outputs;
genvar m, n;

generate
for(m = 0; m < M; m = m + 1) begin
    for(n = 0; n < N; n = n + 1) begin
        thread #(DATA_WIDTH) mat_thread (
            .clk(clk),
            .rst(rst),
            .a(A[m][k]),
            .b(B[k][n]),
            .res(thread_outputs[(m * N + n) * DATA_WIDTH +: DATA_WIDTH])
        );
    end
end
endgenerate



reg  [DATA_WIDTH * M * N - 1:0] final_res;

always @(posedge clk) begin
    if (done) begin
        $display("Done!");
        final_res <= thread_outputs;
    end
end

endmodule
module top #(
    parameter K = 3,
    parameter N = 3,
    parameter M = 3,
    parameter DATA_WIDTH = 8,
    parameter NUM_THREADS = N * M
) (
    input wire clk,
    input wire rst
);



reg [DATA_WIDTH-1:0] A [0:M][0:K];
reg [DATA_WIDTH-1:0] B [0:K][0:N];


wire [$clog2(K+1)-1:0] k;
wire done;

counter #(.MAX_COUNT(K)) k_cnt (
        .clk(clk),
        .rst(rst),
        .count(k),
        .done(done)
);



reg done_pipe;
always @(posedge clk) begin
    done_pipe <= done;
end




wire [DATA_WIDTH * M * N - 1:0] thread_outputs;
genvar m, n;

generate
for(m = 0; m < M; m = m + 1) begin
    for(n = 0; n < N; n = n + 1) begin
        thread #(DATA_WIDTH) mat_thread (
            .clk(clk),
            .rst(rst),
            .a(A[m][k]),
            .b(B[k][n]),
            .res(thread_outputs[(m * N + n) * DATA_WIDTH +: DATA_WIDTH])
        );
    end
end
endgenerate



reg  [DATA_WIDTH * M * N - 1:0] final_res;

always @(posedge clk) begin
    if (done) begin
        $display("Done!");
        final_res <= thread_outputs;
    end
end

endmodule