data/full_repos/permissive/130234582/assignment_001/testbench.v
 line:21: before: "("
1: b'%Warning-STMTDLY: data/full_repos/permissive/130234582/assignment_001/testbench.v:23: 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/130234582/assignment_001/testbench.v:33: Unsupported or unknown PLI call: $urandom\n    din = $urandom%8;\n          ^~~~~~~~\n%Warning-STMTDLY: data/full_repos/permissive/130234582/assignment_001/testbench.v:34: Unsupported: Ignoring delay on this delayed statement.\n    #1;\n    ^\n%Error: Exiting due to 1 error(s), 2 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module assignement_001;

reg  [2:0] din;
wire [2:0] dout;


gray dut
(
    .din(din),
    .dout(dout)
);



integer i;
reg result;
initial begin
    din = 0;
    result = 1;
    for(i=0;i<100000;i=i+1) begin
        random_drive();
        check_gray_code();
        #1;
    end
    if(result)
        $display("Tested OK!");
    else
        $display("Tested Fail!"); 
end

task random_drive;
begin
    din = $urandom%8;
    #1;
end
endtask

task check_gray_code;
reg [2:0]   exp_dout;
begin
    case(din)
        0:  exp_dout = 'b000;
        1:  exp_dout = 'b001;
        2:  exp_dout = 'b011;
        3:  exp_dout = 'b010;
        4:  exp_dout = 'b110;
        5:  exp_dout = 'b111;
        6:  exp_dout = 'b101;
        7:  exp_dout = 'b100;
    endcase
    if(exp_dout != dout)
        $display("%0t: ERROR : exp_dout = %b,  real_dout = %b",$time, exp_dout, dout);
    result = result & (exp_dout == dout);
end
endtask
endmodule
module assignement_001;


reg  [2:0] din;
wire [2:0] dout;


gray dut
(
    .din(din),
    .dout(dout)
);



integer i;
reg result;
initial begin
    din = 0;
    result = 1;
    for(i=0;i<100000;i=i+1) begin
        random_drive();
        check_gray_code();
        #1;
    end
    if(result)
        $display("Tested OK!");
    else
        $display("Tested Fail!"); 
end

task random_drive;
begin
    din = $urandom%8;
    #1;
end
endtask

task check_gray_code;
reg [2:0]   exp_dout;
begin
    case(din)
        0:  exp_dout = 'b000;
        1:  exp_dout = 'b001;
        2:  exp_dout = 'b011;
        3:  exp_dout = 'b010;
        4:  exp_dout = 'b110;
        5:  exp_dout = 'b111;
        6:  exp_dout = 'b101;
        7:  exp_dout = 'b100;
    endcase
    if(exp_dout != dout)
        $display("%0t: ERROR : exp_dout = %b,  real_dout = %b",$time, exp_dout, dout);
    result = result & (exp_dout == dout);
end
endtask
endmodule