Hi,
Im looking to randomize a subset of a ‘typdef enum’ data type so that I choose one item of a subset of a number of items. How hsould I do it?
For eg:
`include "ovm.svh"
import ovm_pkg::*;
typedef enum {NO_ERR, ERR1, ERR2, ERR3, ERR4} err_kind;
class item extends ovm_object;
rand bit [7:0] addr;
rand bit [7:0] data;
err_kind err_item;
`ovm_object_utils_begin(item)
`ovm_field_enum (err_kind, err_item, OVM_ALL_ON)
`ovm_field_int (addr, OVM_ALL_ON)
`ovm_field_int (data, OVM_ALL_ON)
`ovm_object_utils_end
function new (string name = "");
super.new(name);
endfunction : new
endclass: item
//****************
module top;
item packet = new();
initial begin
for(int i = 1; i<=(50); i++) begin
void'(packet.randomize(err_item));// with {err_kind [NO_ERR,ERR3]});
$display(" error = %s",packet.err_item.name());
end
$finish;
end
endmodule
In this test case the err_item printed will be one of the all error types. But if I have to choose between only NO_ERR and ERR3, how shoud I do it?
Thank you,
Kaushik