data/full_repos/permissive/179451217/exp_golomb.v
 line:74: before: "integer"
1: b'%Error: data/full_repos/permissive/179451217/exp_golomb.v:67: Cannot find include file: functions.vh\n`include "functions.vh" \n         ^~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/179451217,data/full_repos/permissive/179451217/functions.vh\n             data/full_repos/permissive/179451217,data/full_repos/permissive/179451217/functions.vh.v\n             data/full_repos/permissive/179451217,data/full_repos/permissive/179451217/functions.vh.sv\n             functions.vh\n             functions.vh.v\n             functions.vh.sv\n             obj_dir/functions.vh\n             obj_dir/functions.vh.v\n             obj_dir/functions.vh.sv\n%Error: Exiting due to 1 error(s)\n'
module exp_golomb #(
    parameter DataWidth = 16,
    parameter K0 = 2,
    parameter K = 2
)(
    input wire clk,
    input wire reset,
    input wire enable,
    input wire code,
    output reg data_valid,
    output reg [DataWidth-1:0] data 
);

`include "functions.vh"

function integer max_n;
    input integer b;
    begin

        b = 1 + (2**b - 1)*(2**K - 1)/(2**K0);

        for(max_n = 0; b > 0; max_n = max_n + 1) b = b >> 1;
        max_n = (max_n-1)/K;
    end
endfunction

localparam MaxN = max_n(DataWidth);
localparam NBits = clog2(MaxN+1);
localparam BBits = clog2(DataWidth)+1;

reg [DataWidth-1:0] base_table [0:MaxN];
integer i;
initial begin
    for(i = 0; i <= MaxN; i = i + 1) begin
        base_table[i] = (2**K0)*(2**(K*i)-1)/(2**K - 1);
    end
end

reg [NBits-1:0] n, n_D;
reg [BBits-1:0] b, b_D;
reg [DataWidth-1:0] data_D, base, base_D, offset, offset_D;
reg data_valid_D;
reg counting, counting_D;

always @* begin
    n_D = n;
    b_D = b;
    data_D = data;
    base_D = base;
    offset_D = offset;
    data_valid_D = 0;
    counting_D = counting;

    if(enable) begin
        if(counting) begin
            if(code == 1'b1) begin
                if(b == 0) begin
                    data_D = 0;
                    data_valid_D = 1'b1;
                end else begin
                    base_D = base_table[n];
                    offset_D = 0;
                    b_D = b - 1;
                    counting_D = 0;
                end
            end else begin
                n_D = n + 1;
                b_D = b + K;
            end
        end else begin
            offset_D = {offset[DataWidth-2:0],code};
            if(b > 0) begin
                b_D = b - 1;    
            end else begin
                data_D = base + offset_D;
                data_valid_D = 1'b1;
                counting_D = 1'b1;
                n_D = 0;
                b_D = K0;
            end
        end
    end
end

always @(posedge clk) begin
    if(reset) begin
        n <= 0;
        b <= K0;
        data <= 0;
        base <= 0;
        offset <= 0;
        data_valid <= 0;
        counting <= 1;
    end else begin
        n <= n_D;
        b <= b_D;
        data <= data_D;
        offset <= offset_D;
        base <= base_D;
        data_valid <= data_valid_D;
        counting <= counting_D;
    end
end

endmodule
module exp_golomb #(
    parameter DataWidth = 16,
    parameter K0 = 2,
    parameter K = 2
)(
    input wire clk,
    input wire reset,
    input wire enable,
    input wire code,
    output reg data_valid,
    output reg [DataWidth-1:0] data 
);


`include "functions.vh"

function integer max_n;
    input integer b;
    begin

        b = 1 + (2**b - 1)*(2**K - 1)/(2**K0);

        for(max_n = 0; b > 0; max_n = max_n + 1) b = b >> 1;
        max_n = (max_n-1)/K;
    end
endfunction

localparam MaxN = max_n(DataWidth);
localparam NBits = clog2(MaxN+1);
localparam BBits = clog2(DataWidth)+1;

reg [DataWidth-1:0] base_table [0:MaxN];
integer i;
initial begin
    for(i = 0; i <= MaxN; i = i + 1) begin
        base_table[i] = (2**K0)*(2**(K*i)-1)/(2**K - 1);
    end
end

reg [NBits-1:0] n, n_D;
reg [BBits-1:0] b, b_D;
reg [DataWidth-1:0] data_D, base, base_D, offset, offset_D;
reg data_valid_D;
reg counting, counting_D;

always @* begin
    n_D = n;
    b_D = b;
    data_D = data;
    base_D = base;
    offset_D = offset;
    data_valid_D = 0;
    counting_D = counting;

    if(enable) begin
        if(counting) begin
            if(code == 1'b1) begin
                if(b == 0) begin
                    data_D = 0;
                    data_valid_D = 1'b1;
                end else begin
                    base_D = base_table[n];
                    offset_D = 0;
                    b_D = b - 1;
                    counting_D = 0;
                end
            end else begin
                n_D = n + 1;
                b_D = b + K;
            end
        end else begin
            offset_D = {offset[DataWidth-2:0],code};
            if(b > 0) begin
                b_D = b - 1;    
            end else begin
                data_D = base + offset_D;
                data_valid_D = 1'b1;
                counting_D = 1'b1;
                n_D = 0;
                b_D = K0;
            end
        end
    end
end

always @(posedge clk) begin
    if(reset) begin
        n <= 0;
        b <= K0;
        data <= 0;
        base <= 0;
        offset <= 0;
        data_valid <= 0;
        counting <= 1;
    end else begin
        n <= n_D;
        b <= b_D;
        data <= data_D;
        offset <= offset_D;
        base <= base_D;
        data_valid <= data_valid_D;
        counting <= counting_D;
    end
end

endmodule