I am trying to write a task as shown below. the variable count is decreased each time in the while loop but when we jump out this loop, the variable count is not zero, May I know how to handle it ?
task read_check(logic [19:0] addr, output logic [31:0] rd_data, input logic [31:0] expect_data, uint32 count);
while(count--) begin
register_read_addr(addr, rd_data);
if(rd_data != expect_data) begin
`uvm_info(get_type_name(), "not matched now", UVM_LOW);
wait_cycles(10);
end
else begin
`uvm_info(get_type_name(), "matched!", UVM_LOW);
break;
end
end
if(count == 0) begin // <== I thought it should be zero but it isn't...
`uvm_error(get_type_name(), "finally NOT MATCHED");
end
endtask :read_check