data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v
Syntax Error
1: b'%Warning-STMTDLY: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:221: Unsupported: Ignoring delay on this delayed statement.\n    initial #0\n            ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:158: Operator ASSIGN expects 1 bits on the Assign RHS, but Assign RHS\'s ADD generates 32 or 8 bits.\n                                                                              : ... In instance lpm_counter\n            ivalue = ivalue * 10 + digit;\n                   ^\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:191: Operator NEQ expects 56 bits on the LHS, but LHS\'s VARREF \'lpm_direction\' generates 48 bits.\n                                                                              : ... In instance lpm_counter\n        if ((lpm_direction != "UNUSED") && (lpm_direction != "DEFAULT") &&\n                                                          ^~\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:202: Operator TASKREF \'string_to_reg\' expects 320 bits on the Function Argument, but Function Argument\'s VARREF \'lpm_avalue\' generates 48 bits.\n                                                                              : ... In instance lpm_counter\n            string_to_reg(lpm_avalue, avalue);\n            ^~~~~~~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:207: Operator TASKREF \'string_to_reg\' expects 320 bits on the Function Argument, but Function Argument\'s VARREF \'lpm_svalue\' generates 48 bits.\n                                                                              : ... In instance lpm_counter\n            string_to_reg(lpm_svalue, svalue);\n            ^~~~~~~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:212: Operator TASKREF \'string_to_reg\' expects 320 bits on the Function Argument, but Function Argument\'s VARREF \'lpm_pvalue\' generates 48 bits.\n                                                                              : ... In instance lpm_counter\n            string_to_reg(lpm_pvalue, pvalue);\n            ^~~~~~~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:224: Operator NEQ expects 56 bits on the LHS, but LHS\'s VARREF \'lpm_direction\' generates 48 bits.\n                                                                              : ... In instance lpm_counter\n        if ((lpm_direction != "UNUSED") && (lpm_direction != "DEFAULT") && (updown !== 1\'b0  ) &&\n                                                          ^~\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:253: Operator EQ expects 32 or 2 bits on the LHS, but LHS\'s VARREF \'final_count\' generates 1 bits.\n                                                                              : ... In instance lpm_counter\n                        tmp_count <= (final_count == tmp_modulus-1) ? 0\n                                                  ^~\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:256: Operator ASSIGNDLY expects 1 bits on the Assign RHS, but Assign RHS\'s COND generates 32 or 2 bits.\n                                                                              : ... In instance lpm_counter\n                        tmp_count <= (final_count == 0) ? tmp_modulus-1\n                                  ^~\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:283: Operator EQ expects 32 or 2 bits on the LHS, but LHS\'s VARREF \'final_count\' generates 1 bits.\n                                                                              : ... In instance lpm_counter\n                            ((w_updown==1) && ((final_count==tmp_modulus-1) ||\n                                                           ^~\n%Warning-WIDTH: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:289: Operator EQ expects 56 bits on the LHS, but LHS\'s VARREF \'lpm_direction\' generates 48 bits.\n                                                                              : ... In instance lpm_counter\n                        ((((lpm_direction == "UNUSED") || (lpm_direction == "DEFAULT")) && (i_updown == 1)) ||\n                                                                         ^~\n%Warning-UNSIGNED: data/full_repos/permissive/175100691/gpu/lpm/lpm_counter.v:185: Comparison is constant due to unsigned arithmetic\n                                                                                 : ... In instance lpm_counter\n        if (lpm_modulus > max_modulus)\n                        ^\n%Error: Exiting due to 12 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module lpm_counter (
    clock,
    clk_en,
    cnt_en,

    updown,

    aclr,
    aset,
    aload,

    sclr,

    sset,
    sload,

    data,
    cin,
    q,
    cout,
    eq

);


    parameter lpm_width = 1;

    parameter lpm_direction = "UNUSED";
    parameter lpm_modulus = 0;
    parameter lpm_avalue = "UNUSED";
    parameter lpm_svalue = "UNUSED";

    parameter lpm_pvalue = "UNUSED";
    parameter lpm_port_updown = "PORT_CONNECTIVITY";
    parameter lpm_type = "lpm_counter";
    parameter lpm_hint = "UNUSED";


    input  clock;
    input  clk_en;
    input  cnt_en;
    input  updown;
    input  aclr;
    input  aset;
    input  aload;
    input  sclr;
    input  sset;
    input  sload;
    input  [lpm_width-1:0] data;
    input  cin;


    output [lpm_width-1:0] q;
    output cout;
    output [15:0] eq;


    reg  [lpm_width-1:0] tmp_count;
    reg  [lpm_width-1:0] adata;

    reg  use_adata;
    reg  tmp_updown;
    reg  [lpm_width:0] tmp_modulus;
    reg  [lpm_width:0] max_modulus;
    reg  [lpm_width-1:0] svalue;
    reg  [lpm_width-1:0] avalue;
    reg  [lpm_width-1:0] pvalue;


    wire w_updown;
    wire [lpm_width-1:0] final_count;


    integer i;



    logic clk_en;
    logic cnt_en;
    logic aclr;
    logic aset;
    logic aload;
    logic sclr;
    logic sset;
    logic sload;
    logic cin;
    logic updown_z;

    wire i_clk_en;
    wire i_cnt_en;
    wire i_aclr;
    wire i_aset;
    wire i_aload;
    wire i_sclr;
    wire i_sset;
    wire i_sload;
    wire i_cin;
    wire i_updown;
    assign i_clk_en = clk_en;
    assign i_cnt_en = cnt_en;
    assign i_aclr = aclr;
    assign i_aset = aset;
    assign i_aload = aload;
    assign i_sclr = sclr;
    assign i_sset = sset;
    assign i_sload = sload;
    assign i_cin = cin;
    assign i_updown = updown_z;


    task string_to_reg;
    input  [8*40:1] string_value;
    output [lpm_width-1:0] value;

    reg [8*40:1] reg_s;
    reg [8:1] digit;
    reg [8:1] tmp;
    reg [lpm_width-1:0] ivalue;

    integer m;

    begin
        ivalue = {lpm_width{1'b0}};
        reg_s = string_value;
        for (m=1; m<=40; m=m+1)
        begin
            tmp = reg_s[320:313];
            digit = tmp & 8'b00001111;
            reg_s = reg_s << 8;
            ivalue = ivalue * 10 + digit;
        end
        value = ivalue;
    end
    endtask


    initial
    begin
        max_modulus = 1 << lpm_width;


        if (lpm_width <= 0)
        begin
            $display("Error!  LPM_WIDTH must be greater than 0.\n");
            $display("Time: %0t  Instance: %m", $time);
            $finish;
        end


        if (lpm_modulus < 0)
        begin
            $display("Error!  LPM_MODULUS must be greater or equal to 0.\n");
            $display("Time: %0t  Instance: %m", $time);
            $finish;
        end

        if (lpm_modulus > max_modulus)
        begin
            $display("Warning!  LPM_MODULUS should be within 1 to 2^LPM_WIDTH. Assuming no modulus input.\n");
            $display ("Time: %0t  Instance: %m", $time);
        end

        if ((lpm_direction != "UNUSED") && (lpm_direction != "DEFAULT") &&
            (lpm_direction != "UP") && (lpm_direction != "DOWN"))
        begin
            $display("Error!  LPM_DIRECTION must be \"UP\" or \"DOWN\" if used.\n");
            $display("Time: %0t  Instance: %m", $time);
            $finish;
        end

        if (lpm_avalue == "UNUSED")
            avalue =  {lpm_width{1'b1}};
        else
            string_to_reg(lpm_avalue, avalue);

        if (lpm_svalue == "UNUSED")
            svalue =  {lpm_width{1'b1}};
        else
            string_to_reg(lpm_svalue, svalue);

        if (lpm_pvalue == "UNUSED")
            pvalue =  {lpm_width{1'b0}};
        else
            string_to_reg(lpm_pvalue, pvalue);

        tmp_modulus = ((lpm_modulus == 0) || (lpm_modulus > max_modulus))
                        ? max_modulus : lpm_modulus;
        tmp_count = pvalue;
        use_adata = 1'b0;
    end


    initial #0
    begin

        if ((lpm_direction != "UNUSED") && (lpm_direction != "DEFAULT") && (updown !== 1'b0) &&
            (lpm_port_updown == "PORT_CONNECTIVITY"))
        begin
            $display("Error!  LPM_DIRECTION and UPDOWN cannot be used at the same time.\n");
            $display("Time: %0t  Instance: %m", $time);
            $finish;
        end
    end


    always @(posedge i_aclr or posedge i_aset or posedge i_aload or posedge clock)
    begin
        if (i_aclr || i_aset || i_aload)
            use_adata <= 1'b1;
        else if ($time > 0)
        begin
            if (i_clk_en)
            begin
                use_adata <= 1'b0;

                if (i_sclr)
                    tmp_count <= 0;
                else if (i_sset)
                    tmp_count <= svalue;
                else if (i_sload)
                    tmp_count <= data;
                else if (i_cnt_en && i_cin)
                begin
                    if (w_updown)
                        tmp_count <= (final_count == tmp_modulus-1) ? 0
                                                    : final_count+1;
                    else
                        tmp_count <= (final_count == 0) ? tmp_modulus-1
                                                    : final_count-1;
                end
                else
                    tmp_count <= final_count;
            end
        end
    end

    always @(i_aclr or i_aset or i_aload or data or avalue)
    begin
        if (i_aclr)
        begin
            adata <= 0;
        end
        else if (i_aset)
        begin
            adata <= avalue;
        end
        else if (i_aload)
            adata <= data;
    end


    assign q = final_count;
    assign final_count = (use_adata == 1'b1) ? adata : tmp_count;
    assign cout = (i_cin && (((w_updown==0) && (final_count==0)) ||
                            ((w_updown==1) && ((final_count==tmp_modulus-1) ||
                                                (final_count=={lpm_width{1'b1}}))) ))
                    ? 1'b1 : 1'b0;
    assign updown_z = updown;
    assign w_updown =   (lpm_port_updown == "PORT_USED") ? i_updown :
                        (lpm_port_updown == "PORT_UNUSED") ? ((lpm_direction == "DOWN") ? 1'b0 : 1'b1) :
                        ((((lpm_direction == "UNUSED") || (lpm_direction == "DEFAULT")) && (i_updown == 1)) ||
                        (lpm_direction == "UP"))
                        ? 1'b1 : 1'b0;
    assign eq = {16{1'b0}};

endmodule
module lpm_counter (
    clock,
    clk_en,
    cnt_en,

    updown,

    aclr,
    aset,
    aload,

    sclr,

    sset,
    sload,

    data,
    cin,
    q,
    cout,
    eq

);



    parameter lpm_width = 1;

    parameter lpm_direction = "UNUSED";
    parameter lpm_modulus = 0;
    parameter lpm_avalue = "UNUSED";
    parameter lpm_svalue = "UNUSED";

    parameter lpm_pvalue = "UNUSED";
    parameter lpm_port_updown = "PORT_CONNECTIVITY";
    parameter lpm_type = "lpm_counter";
    parameter lpm_hint = "UNUSED";


    input  clock;
    input  clk_en;
    input  cnt_en;
    input  updown;
    input  aclr;
    input  aset;
    input  aload;
    input  sclr;
    input  sset;
    input  sload;
    input  [lpm_width-1:0] data;
    input  cin;


    output [lpm_width-1:0] q;
    output cout;
    output [15:0] eq;


    reg  [lpm_width-1:0] tmp_count;
    reg  [lpm_width-1:0] adata;

    reg  use_adata;
    reg  tmp_updown;
    reg  [lpm_width:0] tmp_modulus;
    reg  [lpm_width:0] max_modulus;
    reg  [lpm_width-1:0] svalue;
    reg  [lpm_width-1:0] avalue;
    reg  [lpm_width-1:0] pvalue;


    wire w_updown;
    wire [lpm_width-1:0] final_count;


    integer i;



    logic clk_en;
    logic cnt_en;
    logic aclr;
    logic aset;
    logic aload;
    logic sclr;
    logic sset;
    logic sload;
    logic cin;
    logic updown_z;

    wire i_clk_en;
    wire i_cnt_en;
    wire i_aclr;
    wire i_aset;
    wire i_aload;
    wire i_sclr;
    wire i_sset;
    wire i_sload;
    wire i_cin;
    wire i_updown;
    assign i_clk_en = clk_en;
    assign i_cnt_en = cnt_en;
    assign i_aclr = aclr;
    assign i_aset = aset;
    assign i_aload = aload;
    assign i_sclr = sclr;
    assign i_sset = sset;
    assign i_sload = sload;
    assign i_cin = cin;
    assign i_updown = updown_z;


    task string_to_reg;
    input  [8*40:1] string_value;
    output [lpm_width-1:0] value;

    reg [8*40:1] reg_s;
    reg [8:1] digit;
    reg [8:1] tmp;
    reg [lpm_width-1:0] ivalue;

    integer m;

    begin
        ivalue = {lpm_width{1'b0}};
        reg_s = string_value;
        for (m=1; m<=40; m=m+1)
        begin
            tmp = reg_s[320:313];
            digit = tmp & 8'b00001111;
            reg_s = reg_s << 8;
            ivalue = ivalue * 10 + digit;
        end
        value = ivalue;
    end
    endtask


    initial
    begin
        max_modulus = 1 << lpm_width;


        if (lpm_width <= 0)
        begin
            $display("Error!  LPM_WIDTH must be greater than 0.\n");
            $display("Time: %0t  Instance: %m", $time);
            $finish;
        end


        if (lpm_modulus < 0)
        begin
            $display("Error!  LPM_MODULUS must be greater or equal to 0.\n");
            $display("Time: %0t  Instance: %m", $time);
            $finish;
        end

        if (lpm_modulus > max_modulus)
        begin
            $display("Warning!  LPM_MODULUS should be within 1 to 2^LPM_WIDTH. Assuming no modulus input.\n");
            $display ("Time: %0t  Instance: %m", $time);
        end

        if ((lpm_direction != "UNUSED") && (lpm_direction != "DEFAULT") &&
            (lpm_direction != "UP") && (lpm_direction != "DOWN"))
        begin
            $display("Error!  LPM_DIRECTION must be \"UP\" or \"DOWN\" if used.\n");
            $display("Time: %0t  Instance: %m", $time);
            $finish;
        end

        if (lpm_avalue == "UNUSED")
            avalue =  {lpm_width{1'b1}};
        else
            string_to_reg(lpm_avalue, avalue);

        if (lpm_svalue == "UNUSED")
            svalue =  {lpm_width{1'b1}};
        else
            string_to_reg(lpm_svalue, svalue);

        if (lpm_pvalue == "UNUSED")
            pvalue =  {lpm_width{1'b0}};
        else
            string_to_reg(lpm_pvalue, pvalue);

        tmp_modulus = ((lpm_modulus == 0) || (lpm_modulus > max_modulus))
                        ? max_modulus : lpm_modulus;
        tmp_count = pvalue;
        use_adata = 1'b0;
    end


    initial #0
    begin

        if ((lpm_direction != "UNUSED") && (lpm_direction != "DEFAULT") && (updown !== 1'b0) &&
            (lpm_port_updown == "PORT_CONNECTIVITY"))
        begin
            $display("Error!  LPM_DIRECTION and UPDOWN cannot be used at the same time.\n");
            $display("Time: %0t  Instance: %m", $time);
            $finish;
        end
    end


    always @(posedge i_aclr or posedge i_aset or posedge i_aload or posedge clock)
    begin
        if (i_aclr || i_aset || i_aload)
            use_adata <= 1'b1;
        else if ($time > 0)
        begin
            if (i_clk_en)
            begin
                use_adata <= 1'b0;

                if (i_sclr)
                    tmp_count <= 0;
                else if (i_sset)
                    tmp_count <= svalue;
                else if (i_sload)
                    tmp_count <= data;
                else if (i_cnt_en && i_cin)
                begin
                    if (w_updown)
                        tmp_count <= (final_count == tmp_modulus-1) ? 0
                                                    : final_count+1;
                    else
                        tmp_count <= (final_count == 0) ? tmp_modulus-1
                                                    : final_count-1;
                end
                else
                    tmp_count <= final_count;
            end
        end
    end

    always @(i_aclr or i_aset or i_aload or data or avalue)
    begin
        if (i_aclr)
        begin
            adata <= 0;
        end
        else if (i_aset)
        begin
            adata <= avalue;
        end
        else if (i_aload)
            adata <= data;
    end


    assign q = final_count;
    assign final_count = (use_adata == 1'b1) ? adata : tmp_count;
    assign cout = (i_cin && (((w_updown==0) && (final_count==0)) ||
                            ((w_updown==1) && ((final_count==tmp_modulus-1) ||
                                                (final_count=={lpm_width{1'b1}}))) ))
                    ? 1'b1 : 1'b0;
    assign updown_z = updown;
    assign w_updown =   (lpm_port_updown == "PORT_USED") ? i_updown :
                        (lpm_port_updown == "PORT_UNUSED") ? ((lpm_direction == "DOWN") ? 1'b0 : 1'b1) :
                        ((((lpm_direction == "UNUSED") || (lpm_direction == "DEFAULT")) && (i_updown == 1)) ||
                        (lpm_direction == "UP"))
                        ? 1'b1 : 1'b0;
    assign eq = {16{1'b0}};

endmodule