data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v
 line:219: before: "strip"
1: b'%Error: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:14: Cannot find include file: ../lib/assertion.v\n`include "../lib/assertion.v" \n         ^~~~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/200314387/verilog/gamepadAdapter,data/full_repos/permissive/200314387/../lib/assertion.v\n             data/full_repos/permissive/200314387/verilog/gamepadAdapter,data/full_repos/permissive/200314387/../lib/assertion.v.v\n             data/full_repos/permissive/200314387/verilog/gamepadAdapter,data/full_repos/permissive/200314387/../lib/assertion.v.sv\n             ../lib/assertion.v\n             ../lib/assertion.v.v\n             ../lib/assertion.v.sv\n             obj_dir/../lib/assertion.v\n             obj_dir/../lib/assertion.v.v\n             obj_dir/../lib/assertion.v.sv\n%Warning-STMTDLY: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:58: Unsupported: Ignoring delay on this delayed statement.\n        #1\n        ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Error: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:72: Define or directive not defined: \'`FINISH_AND_RETURN\'\n                `FINISH_AND_RETURN(1);\n                ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:72: syntax error, unexpected \';\'\n                `FINISH_AND_RETURN(1);\n                                     ^\n%Error: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:91: Unsupported or unknown PLI call: $ferror\n                        errno = $ferror(fControl, errStr);\n                                ^~~~~~~\n%Error: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:104: Unsupported or unknown PLI call: $ferror\n                        errno = $ferror(fControl, errStr);\n                                ^~~~~~~\n%Error: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:133: Unsupported or unknown PLI call: $ferror\n                        errno = $ferror(fControl, errStr);\n                                ^~~~~~~\n%Error: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:151: Unsupported or unknown PLI call: $ferror\n                        errno = $ferror(fControl, errStr);\n                                ^~~~~~~\n%Warning-STMTDLY: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:157: Unsupported: Ignoring delay on this delayed statement.\n                    #tDelta \n                    ^\n%Warning-STMTDLY: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:165: Unsupported: Ignoring delay on this delayed statement.\n              #1000000\n              ^\n%Warning-STMTDLY: data/full_repos/permissive/200314387/verilog/gamepadAdapter/gamepadAdapter.v:82: Unsupported: Ignoring delay on this delayed statement.\n            #10  \n            ^\n%Error: Exiting due to 7 error(s), 4 warning(s)\n'
module gamepadAdapter #(parameter CONTROL_FILE="gamepad.control") (
    input  _OErandom, 
    input  _OEpad1, 
    input  _OEpad2, 
    output [7:0] Q
);

    function string strip;
        input string str;
    begin
        if (str.len() > 0) begin
            while (str[str.len()-1] == `NL || str[str.len()-1] == `CR) begin
                str = str.substr(0, str.len()-2); 
            end
        end
        strip = str;
    end
    endfunction


    int fControl;
    int c, r;
    int tDelta;
    string strInput = "";
    string controlFile;
    reg [1024:0] errStr;
    integer errno;
    integer iController;
    integer iControllerValue;
    reg [7:0] iController1Value;
    reg [7:0] iController2Value;
    reg [7:0] iRandomValue;
    reg randomValueSet=1'b0;
    localparam MAX_LINE_LENGTH=4096;
    reg [8*MAX_LINE_LENGTH:0] line;


    initial 
    begin : file_block 

        #1

        if (! $value$plusargs("gamepad_control_file=%s", controlFile)) begin
            controlFile = CONTROL_FILE;
        end

        $display("%9t GAMEPAD ", $time, " opening file %s", controlFile);
        `ifndef verilator
                fControl = $fopenr(controlFile); 
        `endif

        if (fControl == `NULL)
        begin
                $error("%9t ERROR ", $time, " failed opening file %s", controlFile);
                `FINISH_AND_RETURN(1);
                disable file_block;
        end
        $display("%9t GAMEPAD ", $time, " file open");

        while (fControl != `NULL)  
        begin

            c = $fgetc(fControl); 

            #10

            if (c != `EOF) 
            begin 
                if (c == "/")
                begin 
                    line="";
                    r = $fgets(line, fControl); 
                    if (r == 0) begin
                        errno = $ferror(fControl, errStr);
                        $display("%9t ", $time, "GAMECONTROLLER: CANT READ LINE: $s", errStr);
                    end
                    $display("%9t ", $time, "GAMECONTROLLER: LINE: // %-s", line);
                
                    strInput = strip(line);
                    $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: // %-s", strInput);
                end
                else if (c == "c")
                begin 
                    line="";
                    r = $fgets(line, fControl); 
                    if (r == 0) begin
                        errno = $ferror(fControl, errStr);
                        $display("%9t ", $time, "GAMECONTROLLER: CANT READ LINE: $s", errStr);
                    end
                    strInput = strip(line);

                    r = $sscanf(strInput, "%1d=%02x", iController, iControllerValue);
                    if (r == 0) begin
                        $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: '%s' can't convert", strInput);
                    end

                    if (iController==1) begin
                        iController1Value = iControllerValue;
                        $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: 'c%s' :  controller 1 = %8b", strInput, iController1Value);
                    end
                    else if (iController==2) begin
                        iController2Value = iControllerValue;
                        $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: 'c%s' :  controller 2 = %8b", strInput, iController2Value);
                    end
                    else $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: 'c%s' :  %d is not a controller id", strInput, iController);


                end

                else if (c == "r")
                begin 

                    line="";
                    r = $fgets(line, fControl); 
                    if (r == 0) begin
                        errno = $ferror(fControl, errStr);
                        $display("%9t ", $time, "GAMECONTROLLER: CANT READ LINE: $s", errStr);
                    end
                    strInput = strip(line);

                    r = $sscanf(strInput, "=%02x", iRandomValue);
                    if (r == 0) begin
                        $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: '%s' can't convert", strInput);
                    end

                    randomValueSet = 1;
                end
                else if (c == "#")
                begin
                    tDelta=0;
                    line="";
                    r = $fgets(line, fControl);
                    if (r == 0) begin
                        errno = $ferror(fControl, errStr);
                        $display("%9t ", $time, "GAMECONTROLLER: CANT READ LINE: $s", errStr);
                    end
                    strInput = strip(line);

                    r = $sscanf(line,"%d\n", tDelta); 
                    #tDelta 
                    $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: '#%s' :  slept for %d", strInput, tDelta);
                    
                end
            end
            else
            begin

              #1000000
              $display("%9t ", $time, "GAMECONTROLLER: NO INPUT - slept");
            end
        end
    end

    assign Q = _OEpad1 ? (_OEpad2 ? (_OErandom ? 8'bz: (randomValueSet ? iRandomValue: $random)): iController2Value) : iController1Value;


endmodule
module gamepadAdapter #(parameter CONTROL_FILE="gamepad.control") (
    input  _OErandom, 
    input  _OEpad1, 
    input  _OEpad2, 
    output [7:0] Q
);


    function string strip;
        input string str;
    begin
        if (str.len() > 0) begin
            while (str[str.len()-1] == `NL || str[str.len()-1] == `CR) begin
                str = str.substr(0, str.len()-2); 
            end
        end
        strip = str;
    end
    endfunction


    int fControl;
    int c, r;
    int tDelta;
    string strInput = "";
    string controlFile;
    reg [1024:0] errStr;
    integer errno;
    integer iController;
    integer iControllerValue;
    reg [7:0] iController1Value;
    reg [7:0] iController2Value;
    reg [7:0] iRandomValue;
    reg randomValueSet=1'b0;
    localparam MAX_LINE_LENGTH=4096;
    reg [8*MAX_LINE_LENGTH:0] line;


    initial 
    begin : file_block 

        #1

        if (! $value$plusargs("gamepad_control_file=%s", controlFile)) begin
            controlFile = CONTROL_FILE;
        end

        $display("%9t GAMEPAD ", $time, " opening file %s", controlFile);
        `ifndef verilator
                fControl = $fopenr(controlFile); 
        `endif

        if (fControl == `NULL)
        begin
                $error("%9t ERROR ", $time, " failed opening file %s", controlFile);
                `FINISH_AND_RETURN(1);
                disable file_block;
        end
        $display("%9t GAMEPAD ", $time, " file open");

        while (fControl != `NULL)  
        begin

            c = $fgetc(fControl); 

            #10

            if (c != `EOF) 
            begin 
                if (c == "/")
                begin 
                    line="";
                    r = $fgets(line, fControl); 
                    if (r == 0) begin
                        errno = $ferror(fControl, errStr);
                        $display("%9t ", $time, "GAMECONTROLLER: CANT READ LINE: $s", errStr);
                    end
                    $display("%9t ", $time, "GAMECONTROLLER: LINE: // %-s", line);
                
                    strInput = strip(line);
                    $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: // %-s", strInput);
                end
                else if (c == "c")
                begin 
                    line="";
                    r = $fgets(line, fControl); 
                    if (r == 0) begin
                        errno = $ferror(fControl, errStr);
                        $display("%9t ", $time, "GAMECONTROLLER: CANT READ LINE: $s", errStr);
                    end
                    strInput = strip(line);

                    r = $sscanf(strInput, "%1d=%02x", iController, iControllerValue);
                    if (r == 0) begin
                        $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: '%s' can't convert", strInput);
                    end

                    if (iController==1) begin
                        iController1Value = iControllerValue;
                        $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: 'c%s' :  controller 1 = %8b", strInput, iController1Value);
                    end
                    else if (iController==2) begin
                        iController2Value = iControllerValue;
                        $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: 'c%s' :  controller 2 = %8b", strInput, iController2Value);
                    end
                    else $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: 'c%s' :  %d is not a controller id", strInput, iController);


                end

                else if (c == "r")
                begin 

                    line="";
                    r = $fgets(line, fControl); 
                    if (r == 0) begin
                        errno = $ferror(fControl, errStr);
                        $display("%9t ", $time, "GAMECONTROLLER: CANT READ LINE: $s", errStr);
                    end
                    strInput = strip(line);

                    r = $sscanf(strInput, "=%02x", iRandomValue);
                    if (r == 0) begin
                        $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: '%s' can't convert", strInput);
                    end

                    randomValueSet = 1;
                end
                else if (c == "#")
                begin
                    tDelta=0;
                    line="";
                    r = $fgets(line, fControl);
                    if (r == 0) begin
                        errno = $ferror(fControl, errStr);
                        $display("%9t ", $time, "GAMECONTROLLER: CANT READ LINE: $s", errStr);
                    end
                    strInput = strip(line);

                    r = $sscanf(line,"%d\n", tDelta); 
                    #tDelta 
                    $display("%9t ", $time, "GAMECONTROLLER: CONTROL RX: '#%s' :  slept for %d", strInput, tDelta);
                    
                end
            end
            else
            begin

              #1000000
              $display("%9t ", $time, "GAMECONTROLLER: NO INPUT - slept");
            end
        end
    end

    assign Q = _OEpad1 ? (_OEpad2 ? (_OErandom ? 8'bz: (randomValueSet ? iRandomValue: $random)): iController2Value) : iController1Value;


endmodule